You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

788 lines
28 KiB
Plaintext

11 months ago
<html>
<head>
<title>组织结构管理</title>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="../../GPM/themes/default/easyui.css" />
<script type="text/javascript" src="../../WF/Scripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../../WF/Scripts/jquery/jquery.easyui.min.js"></script>
<script src="../../WF/Scripts/jquery/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../WF/Scripts/QueryString.js" type="text/javascript"></script>
<link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
<!-- 引入新版本的类库. -->
<script src="../../WF/Scripts/config.js" type="text/javascript"></script>
<script src="../../WF/Comm/Gener.js" type="text/javascript"></script>
<script src="config.js"></script>
<script src="../../WF/Scripts/bootstrap/bootstrap-treeview/src/js/bootstrap-treeview.js" type="text/javascript"></script>
<link href="../../WF/Scripts/bootstrap/bootstrap-treeview/src/css/bootstrap-treeview.css" rel="stylesheet" type="text/css" />
<script src="../../WF/Scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="../../WF/Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="../../WF/Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" type="text/css" />
<script src="../../WF/Scripts/bootstrap/bootstrap-table/src/bootstrap-table.js" type="text/javascript"></script>
<link href="../../WF/Scripts/bootstrap/bootstrap-table/src/bootstrap-table.css" rel="stylesheet" type="text/css" />
<script src="../../WF/Scripts/bootstrap/bootstrap-table/src/locale/bootstrap-table-zh-CN.js" type="text/javascript"></script>
<script src="../../WF/Scripts/bootstrap/BootstrapUIDialog.js" type="text/javaScript"></script>
<script src="../../App/layuiadmin/layui/layui.js"></script>
<!--引入zTree树. -->
<link href="../../WF/Scripts/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"
type="text/css" />
<script src="../../WF/Scripts/zTree_v3/js/jquery.ztree.all.min.js" type="text/javascript"></script>
<script src="../../WF/Scripts/zTree_v3/js/jquery.ztree.core.js" type="text/javascript"></script>
<script src="../../WF/Scripts/zTree_v3/js/jquery.ztree.excheck.js" type="text/javascript"></script>
<script src="../../WF/Scripts/zTree_v3/js/jquery.ztree.exedit.js" type="text/javascript"></script>
<style type="text/css">
.small-menu {
margin-top: 10px;
position: absolute;
width: 120px;
z-index: 99999;
border: 0px;
background: #FFF;
padding: 0px;
display: none;
box-shadow: 0 0 6px rgba(0,0,0,.2);
}
.small-menu div {
height: 38px !important;
padding-left: 20px;
margin: 0px;
border-bottom: solid 1px #CCC;
cursor: pointer;
line-height: 38px
}
.small-menu div img {
padding-right: 10px;
margin: 0px;
}
.small-menu div:hover {
background-color: #EAF2FF;
}
.small-menu-separator {
padding-bottom: 0;
border-bottom: 1px solid #DDD;
}
.small-menu div.edit A {
background-image: url(images/page_white_edit.png);
}
.small-menu div.cut A {
background-image: url(images/cut.png);
}
.small-menu div.copy A {
background-image: url(images/page_white_copy.png);
}
.small-menu div.paste A {
background-image: url(images/page_white_paste.png);
}
.small-menu div.delete A {
background-image: url(images/page_white_delete.png);
}
.small-menu div.quit A {
background-image: url(images/door.png);
}
</style>
<script type="text/javascript">
var deptNo = "";
var setting = {
view: {
dblClickExpand: false, //双击节点时,是否自动展开父节点的标识
showLine: true, //是否显示节点之间的连线
fontCss: {}, //字体样式函数
selectedMulti: false //设置是否允许同时选中多个节点
},
check: {
chkboxType: { "Y": "ps", "N": "ps" },
chkboxType: { "Y": "", "N": "" },
chkStyle: "checkbox", //复选框类型
enable: false //每个节点上是否显示 CheckBox
},
edit: {
enable: true,
editNameSelectAll: true,
showRemoveBtn: false,
showRenameBtn: false,
removeTitle: "remove",
renameTitle: "rename"
},
data: {
simpleData: {
enable: true,
idKey: "id",
pIdKey: "pid",
rootPId: ""
}
},
callback: {
onClick: function (event, treeId, treeNode) {
deptNo = treeNode.id;
BindEmps();
},
onRightClick: OnRightClick
} //这里是节点点击事件
};
//右键菜单功能实现
(function ($, undefined) {
$.fn.popupSmallMenu = function (options) {
var $currMenu = $(this),
defaultOptions = {
event: null,
onClickItem: null
},
options = $.extend(defaultOptions, options);
var _smallMenu = {
popupSmallMenu: function () {
this._bindItemClick();
this._bindMenuEvent();
this._showMenu();
return $currMenu;
},
_bindMenuEvent: function () {
var thiz = this;
$currMenu.hover(function () {
}, function () {
thiz._unBindItemClick();
$currMenu.hide();
});
$currMenu.click(function () {
thiz._unBindItemClick();
$currMenu.hide();
});
},
_showMenu: function () {
if (!options.event) {
alert('请传入鼠标事件');
}
var height = options.event.clientY;
var height1 = $(document.body).height();
var DValue = height1 - height;
if (DValue < 260) {
height = options.event.clientY - 260;
}
$currMenu.css({
top: height + "px",
left: options.event.clientX + "px",
display: "block"
});
},
_bindItemClick: function () {
$currMenu.find('div').each(function (index, obj) {
var $li = $(obj);
var itemIden = $li.attr('class');
$li.bind('click', function (event) {
event.stopPropagation();
if (options.onClickItem
&& typeof options.onClickItem === 'function') {
options.onClickItem(itemIden);
}
});
});
}
,
_unBindItemClick: function () {
$currMenu.find('div').each(function (index, obj) {
$(obj).unbind();
});
}
};
return _smallMenu.popupSmallMenu();
}
})(jQuery);
//右键点击
function OnRightClick(event, treeId, treeNode) {
zTreeObj.selectNode(treeNode);
if (treeNode) {
//弹出菜单
$("#menu").popupSmallMenu({
event: event,
onClickItem: function (item) {
if (item == "moveUpDept") {
moveUpDept(treeNode, item);
} else if (item == "moveDownDept") {
moveDownDept(treeNode, item);
} else if (item == "edit") {
Edit(treeNode);
} else if (item == "newSameLevel") {
NewSameLevel(treeNode);
} else if (item == "newNextLevel") {
NewNextLevel(treeNode);
} else if (item == "delete") {
Delete(treeNode);
}
}
});
}
}
//上移部门
function moveUpDept(treeNode, item) {
var dept = new Entity("BP.Cloud.Dept", treeNode.id);
var data = dept.DoMethodReturnString("DoUp");
//树节点直接更新
var before = $("#" + treeNode.tId).prev();
if (before.length == 0) {
return;
}
$("#" + treeNode.tId).insertBefore(before);
}
//下移部门
function moveDownDept(treeNode, item) {
var dept = new Entity("BP.Cloud.Dept", treeNode.id);
var data = dept.DoMethodReturnString("DoDown");
//树节点直接更新
var next = $("#" + treeNode.tId).next();
if (next.length == 0) {
return;
}
$("#" + treeNode.tId).insertAfter(next);
}
//增加同级部门
function NewSameLevel(treeNode) {
var val = prompt("请输入部门名称", "");
if (val == null || val == '') {
return false;
}
var dept = new Entity("BP.Cloud.Dept");
dept.Name = val;
dept.ParentNo = treeNode.pid;
dept.OrgNo = webUser.OrgNo;
dept.Insert();
//更新树节点
var treeObj = $.fn.zTree.getZTreeObj("regionZTree");
var parentNode = treeObj.getNodeByTId(treeNode.parentTId);
var newNode = { name: val, id: dept.No};
//把这个新节点添加到当前选中的节点下,作为它的子节点
newNode = treeObj.addNodes(parentNode, newNode);
}
//增加下级部门
function NewNextLevel(treeNode) {
var deptNo = null;
//如果部门编号的模式是自己编写的.
if (NewDeptNoModel == 0) {
deptNo = GenerNewDeptNo(treeNode.id, treeNode.pid);
if (deptNo == null || deptNo == undefined)
return;
}
var val = prompt("请输入部门名称", "");
if (val == null || val == '') {
return false;
}
var dept = new Entity(deptEnName);
if (deptNo != null)
dept.No = deptNo;
dept.Name = val;
dept.ParentNo = treeNode.id;
dept.OrgNo = webUser.OrgNo;
dept.Insert();
//更新树节点
var treeObj = $.fn.zTree.getZTreeObj("regionZTree");
var newNode = { name: val, id: dept.No };
//var newNode = { name: val };
//把这个新节点添加到当前选中的节点下,作为它的子节点
newNode = treeObj.addNodes(treeNode, newNode);
}
function GenerNewDeptNo(no, parentNo) {
var alt = "请输入部门编号";
alt += "\t\n 1.如为空,则系统自动生成.";
alt += "\t\n 2.如输入已经存在的部门编码,系统就会抛出错误.";
alt += "\t\n 3.当前部门的编码为:" + no + ", 父节点的ID为:" + parentNo;
var deptNo = prompt(alt, "");
if (deptNo == null || deptNo == '') {
//需要系统自动生成编号,就直接走insert();
} else {
while (true) {
if (deptNo == null || deptNo == '') {
break;
} else {
var dept = new Entity(deptEnName);
dept.No = deptNo;
if (dept.RetrieveFromDBSources() == 0)
break;
deptNo = prompt('该编号已经存在,请重新输入,(点击取消让系统自动生成编号)', deptNo);
continue;
}
break;
}
}
if (deptNo == '')
deptNo = null;
return deptNo;
}
//编辑部门
function Edit(treeNode) {
var name = $("#" + treeNode.tId + "_span").text();
var val = prompt("请输入部门名称", name);
if (val == null || val == '') {
//alert('必须输入名称.');
return false;
}
var dept = new Entity("BP.Cloud.Dept", treeNode.id);
dept.Name = val;
dept.Update();
//更新树节点
$("#" + treeNode.tId + "_span").text(val);
}
//删除部门
function Delete(treeNode) {
if (confirm("你确定删除该部门吗?") == false)
return;
var dept = new Entity("BP.Cloud.Dept", treeNode.id);
dept.Delete();
if (dept.IsExits() == true)
return;
//树节点删除
var my = document.getElementById(treeNode.tId);
if (my != null)
my.parentNode.removeChild(my);
}
var webUser = new WebUser();
//初始化
$(function () {
$("#pageloading").show();
var org = new Entity("BP.Cloud.Org", webUser.OrgNo);
if (org.RegFrom == 1) {
// SetHref( 'OrganizationWeiXin.htm';
// return;
}
if (org.RegFrom == 2) {
SetHref('OrganizationDingDing.htm');
return;
}
var handler = new HttpHandler("BP.Cloud.HttpHandler.Admin_Org");
var ens = handler.DoMethodReturnJSON("Organization_Init");
var jsonTree = createJsonToTree(ens);
zTreeObj = $.fn.zTree.init($("#regionZTree"), setting, jsonTree);
fillter(zTreeObj); //设置展开前三级
//绑定帮助信息.
var html = "<br><br><h3 style='padding-left:5px'>组织结构管理:<font color=green>" + org.Name + "</font></h3>";
html += "<ul>";
html += "<li>组织结构管理,就是部门、人员、岗位之间的管理。</li>";
html += "<li>合理的划分岗位,分配好岗位权限,是流程正确运行的基础。</li>";
html += "<li>驰骋BPM支持一人多部门在一个部门下多岗位。</li>";
html += "<li>维护部门在节点上点击右键,可以新建,保存,修改。</li>";
html += "<li>相关功能1:<a href=\"javascript:OpenEditEns('BP.Cloud.StationTypes');\">岗位类型维护</a></li>";
html += "<li>相关功能2:<a href=\"javascript:OpenEditEns('BP.Cloud.StationExts');\">岗位维护</a></li>";
html += "<li>相关功能3:<a href=\"javascript:TemplateImp();\">导入组织结构模版文件</a></li>";
html += "</ul>";
$("#Emps").html(html);
$("#pageloading").hide();
//鼠标移开时右键菜单消失
$(document).on('mouseleave ', '.dropdown-menu', function () {
$(".dropdown-menu").hide();
$.learunindex.destroy
});
});
function OpenEditEns(ensName) {
var ens = "/WF/Comm/Ens.htm?EnsName=" + ensName;
WinOpen(ens);
}
function TemplateImp() {
var url = "/App/Org/TemplateImp.htm";
OpenWindowRight(url, '导入组织结构');
}
//已知URL,在右侧打开页面
function OpenWindowRight(url, title) {
if (top.layui.index) {
top.layui.index.openTabsPage(url, title)
} else {
window.open(url)
}
}
//设置展开前三级
function fillter(zTreeObj) {
//获得树形图对象
var nodeList = zTreeObj.getNodes();       //展开第一个根节点
for (var i = 0; i < nodeList.length; i++) { //设置节点展开第二级节点
zTreeObj.expandNode(nodeList[i], true, false, true);
}
}
//转换ztree需要的数据格式
var treeJson = [];
function createJsonToTree(jsonArray) {
for (var i = 0; i < jsonArray.length; i++) {
var data = jsonArray[i];
if (data.No == "" || data.No == undefined)
continue;
treeJson.push({
"id": data.No,
"pid": data.ParentNo,
"name": data.Name,
"idx": data.Idx
});
}
return treeJson;
}
//绑定人员.
function BindEmps() {
var dept = new Entity("BP.Cloud.Dept", deptNo);
var html = "";
html += "<div class='container'>";
html += "<div class='fixed-table-header'>";
html += "<table class='table table-hover table-striped' style='width:90%;' >";
html += "<tr><h5><b><img src='/App/Img/Home.png' style='width:30px;' /> <a href=\"javascript:EditDept('" + dept.No + "')\" >" + dept.Name + " </a></b> - <a href='javascript:NewEmp()'>新建人员</a></h5></tr>";
html += "<thead ><tr> ";
html += "<th style='background-color:#F2F2F2;'>序</th>";
html += "<th style='background-color:#F2F2F2;'>编号</th>";
html += "<th style='background-color:#F2F2F2;'>名称</th>";
html += "<th style='background-color:#F2F2F2;'>主部门</th>";
html += "<th style='background-color:#F2F2F2;'>邮件</th>";
html += "<th style='background-color:#F2F2F2;'>电话</th>";
html += "<th style='background-color:#F2F2F2;'>操作</th>";
html += "<th style='background-color:#F2F2F2;'>位置</th>";
html += "</tr></thead>";
var handler = new HttpHandler("BP.Cloud.HttpHandler.Admin_Org");
handler.AddPara("FK_Dept", dept.No);
var emps = handler.DoMethodReturnJSON("Organization_GenerEmpsByDeptNo");
// var deptEmps = new Entities("BP.Cloud.DeptEmps");
// deptEmps.Retrieve("FK_Dept", dept.No);
var empNos = ",";
html += "<tbody>";
for (var i = 0; i < emps.length; i++) {
var emp = emps[i];
// var deptEmp = deptEmps[i];
//var empNo = orgNo + "_" + deptEmp.FK_Emp;
//var emp = new Entity("BP.Cloud.EmpWeb", empNo);
html += "<tr ondblclick=\"EditEmp('" + emp.No + "')\" >";
html += "<td class='Idx' >" + (i + 1) + "</td>";
html += "<td>" + emp.UserID + "</td>";
if(emp.UseSta == 1)
html += "<td><a href=\"javascript:EditEmp('" + emp.No + "')\">" + emp.Name + "</a></td>";
else
html += "<td>" + emp.Name + "</td>";
if (emp.IsMainDept == 1)
html += "<td><font color=green>主部门</font></td>";
else
html += "<td>非主部门</td>";
if (emp.Email == null || emp.Email == "")
html += "<td>-</td>";
else
html += "<td>" + emp.Email + "</td>";
if (emp.Tel == null || emp.Tel == "")
html += "<td>-</td>";
else
html += "<td>" + emp.Tel + "</td>";
if (emp.IsMainDept == 1) {
html += "<td>";
html += "<a href=\"javascript:Del('" + emp.No + "','" + emp.UserID + "','" + dept.No + "',"+emp.UseSta+")\" ><img src='/WF/Img/Btn/Delete.gif'>删除</a>";
if (emp.UseSta == 1)
html += "<a href=\"javascript:DoUnEnable('" + emp.No + "','" + emp.UserID + "','" + dept.No + "')\" ><img src='/WF/Img/Btn/UnEnable.png'>禁用</a>";
if (emp.UseSta == 0)
html += "<a href=\"javascript:DoEnable('" + emp.No + "','" + emp.UserID + "','" + dept.No + "')\" ><img src='/WF/Img/Btn/Enable.png'>启用</a>";
html += "</td>";
}
else
html += "<td><a href=\"javascript:Remove('" + emp.No + "','" + emp.UserID + "')\" ><img src='/WF/Img/Btn/Delete.gif'>移除本部门</a></td>";
html += "<td><img src='/WF/Img/Btn/Up.GIF' onclick=\"Up('" + emp.No + "')\" alt='上移' />-<img src='/WF/Img/Btn/Down.gif' onclick=\"Down('" + emp.No + "')\" alt='下移' /> </td>";
html += "</tr>";
empNos += emp.No + ',';
}
html += "</tbody>";
html += "</table>";
html += "</div>";
html += "</div>";
$("#Emps").html(html);
}
function Up(no) {
var emp = new Entity("BP.Cloud.Emp", no);
var data = emp.DoMethodReturnString("DoUp");
BindEmps();
}
function Down(no) {
var emp = new Entity("BP.Cloud.Emp", no);
var data = emp.DoMethodReturnString("DoDown");
BindEmps();
}
function EditDept(no) {
var url = '../../WF/Comm/En.htm?EnName=BP.Cloud.Dept&No=' + no;
OpenBootStrapModal(url, "eudlgframe", "编辑", '800', '500', "icon-edit", true, null, null);
}
function NewEmp() {
var pkval = "";
var empNoAlert = "请输入同事的登陆账号.";
//如果需要输入手机号.
if (RegUserIDMode == 0)
empNoAlert = '新同事手机号,用于登录.';
var webUser = new WebUser();
while (true) {
pkval = promptGener(empNoAlert, pkval);
if (pkval == null || pkval == undefined)
return;
if (RegUserIDMode == 0) {
var msg = IsMobileNumber(pkval);
if (msg != true) {
alert(msg)
continue;
}
}
var handler = new HttpHandler("BP.Cloud.HttpHandler.App_Org");
handler.AddPara("FK_Dept", deptNo);
handler.AddPara("No", pkval);
data = handler.DoMethodReturnString("Organization_NewEmp");
if (data.indexOf('info@') != -1) {
alert(data);
break;
}
if (data.indexOf('err@') != -1) {
alert(data);
continue;
}
break;
}
pkval = webUser.OrgNo + "_" + pkval;
EditEmp(pkval);
//BindEmps();
}
function IsMobileNumber(phone) {
var flag = false;
var message = "";
var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(15[0-3]{1})|(15[4-9]{1})|(18[0-9]{1})|(199))+\d{8})$/;
if (phone == '') {
message = "手机号码不能为空!";
} else if (phone.length != 11) {
//console.log("请输入11位手机号码");
message = "请输入11位手机号码";
} else if (!myreg.test(phone)) {
//console.log("请输入有效的手机号码!");
message = "请输入有效的手机号码!";
} else {
flag = true;
}
if (message != "") {
// alert(message);
return message;
}
return flag;
}
function EditEmp(no) {
var url = '/WF/Comm/En.htm?EnName=BP.Cloud.EmpWeb&No=' + no;
OpenBootStrapModal(url, "eudlgframe", "编辑", '800', '500', "icon-edit", true, null, null, function () {
BindEmps();
});
}
function RefEmps() {
var url = "../../WF/Comm/RefFunc/BranchesAndLeaf.htm?EnName=BP.Cloud.Dept&Dot2DotEnsName=BP.Cloud.DeptEmps&Dot2DotEnName=BP.Cloud.DeptEmp&AttrOfOneInMM=FK_Dept&AttrOfMInMM=FK_Emp&EnsOfM=BP.Cloud.Emps&DefaultGroupAttrKey=FK_Dept&No=" + deptNo + "&PKVal=" + deptNo + "&s=0.13113811473063341";
OpenBootStrapModal(url, "eudlgframe", "关联人员", '1000', '500', "icon-edit", true, null, null);
}
function Del(no, empID,empDept,useSta) {
if (confirm('您确定要删除该人员吗?') == false)
return;
var deptEmpPK = empDept + "_" + empID;
alert(deptEmpPK);
//取消人员部门管理关系
var en = new Entity("BP.Port.DeptEmp");
en.SetPKVal(deptEmpPK);
en.Delete();
if (useSta == 1) {
var en = new Entity("BP.Cloud.Emp", no);
en.Delete();
}
if (useSta == 0) {
var en = new Entity("BP.WF.Port.WFEmp", no);
en.Delete();
}
BindEmps();
}
/**
* 禁用用户信息
* @param empNo
*/
function DoUnEnable(empNo) {
//把用户的信息禁用掉存储到WF_Emp表中
var emp = new Entity("BP.Port.Emp", empNo);
var data = emp.DoMethodReturnString("DoUnEnable");
alert(data);
BindEmps();
}
/**
* 启用用户
* @param empNo
*/
function DoEnable(empNo) {
var wfEmp = new Entity("BP.WF.Port.WFEmp", empNo);
wfEmp.UseSta = 1;//启用
wfEmp.Save();
var emp = new Entity("BP.Port.Emp");
emp.CopyJSON(wfEmp);
emp.Save();
BindEmps();
}
function Remove(no, userID) {
if (confirm('您确定要从该部门中移除吗?') == false)
return;
var en = new Entity("BP.Cloud.DeptEmp");
en.SetPKVal(deptNo + "_" + userID);
en.Delete();
BindEmps();
}
</script>
<style type="text/css">
</style>
</head>
<body class="easyui-layout">
<div id="pageloading">
</div>
<div data-options="region:'west',split:true" style="width: 240px; padding: 1px; overflow: hidden;">
<div style="width: 100%; height: 95%; overflow: auto;">
<ul id="regionZTree" class="ztree" data-options="animate:false,dnd:false"></ul>
</div>
<div id="menu" class="small-menu" style="width: 120px;">
<div class="newSameLevel">
<img src="../../WF/Admin/Portal/Img/ico-flow-pic.png">增加同级
</div>
<div class="newNextLevel">
<img src="../../WF/Admin/Portal/Img/ico-flow-import.png">增加子级
</div>
<div class="edit">
<img src="../../WF/Admin/Portal/Img/ico-flow-prototype.png">编辑
</div>
<div class="delete">
<img src="../../WF/Admin/Portal/Img/ico-flow-delete.png">删除
</div>
<div class="moveUpDept">
<img src="../../WF/Admin/Portal/Img/ico-flow-up.png">上移
</div>
<div class="moveDownDept">
<img src="../../WF/Admin/Portal/Img/ico-flow-down.png">下移
</div>
</div>
</div>
<div data-options="region:'center',split:true" style="width:90%;">
<div id="Emps"></div>
</div>
</body>
</html>