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.

220 lines
7.6 KiB
Plaintext

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>本组织部门</title>
<link href="../../../Comm/Style/CommStyle.css" rel="stylesheet" type="text/css" />
<link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
<link href="../../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<script src="../../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="../../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
<script type="text/javascript" src="../../../Scripts/config.js"></script>
<script type="text/javascript" src="../../../Comm/Gener.js"></script>
<script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
<!-- 自己的系统风格统一. -->
<link href="../../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
<link href="../../../Style/skin/css/Default.css" rel="stylesheet" />
<!-- 自己的系统风格统一end -->
<base target="_self" />
<script type="text/javascript">
//页面启动函数.
$(function () {
$("#Msg").html("<img src=../../../Img/loading.gif />&nbsp;正在加载,请稍后......");
//求出来已经设置的延续子流程.
var nodeID = GetQueryString("FK_Node");
var orgNo = GetQueryString("OrgNo");
//global
var global = window;
global.selectedNodes = [];
global.selectedRows = [];
//跟节点编号.
var rootNo = "0";
var webUser = new WebUser();
rootNo = webUser.OrgNo;
//多对多实体.
var nodeDepts = new Entities("BP.WF.Template.NodeDepts");
nodeDepts.Retrieve("FK_Node", nodeID);
var nodeDept = new Entity("BP.WF.Template.NodeDept");
$.each(nodeDepts, function (i, o) {
var enDot = new Entity(nodeDept, o);
var no = enDot.FK_Dept;
var name = enDot.FK_DeptText;
global.selectedNodes.push({
"No": no,
"Name": name
});
});
loadTree(rootNo, global, orgNo, nodeID);
$("#Msg").html("");
});
function loadTree(rootNo, global, orgNo, nodeID) {
var ens = new Entities("BP.Port.Depts");
if (orgNo != null && orgNo != "undefined" && orgNo != "")
ens.Retrieve("OrgNo", orgNo);
else
ens.RetrieveAll();
var jsonTree = createJsonToTree(ens, rootNo);
//查询出来数据.
$('#tree').tree({
data: jsonTree, // 数据源
checkbox: true, //是否显示复选框
highlightSelected: false, //是否高亮选中
animate: true,
onSelected: function (node) {
var tree = $('#tree');
if (node.state.open) {
//处于展开状态则折叠
tree.tree('collapseNode', node.nodeId);
} else {
//展开
tree.tree('expandNode', node.nodeId);
}
}
});
}
//树形结构转换
var treeJson = [];
function createJsonToTree(jsonArray, parentNo) {
if (parentNo != "0") {
//增加当前用户所在的部门
var en = new Entity("BP.Port.Dept", parentNo);
var checked = false;
var selectedNodes = window.selectedNodes;
var sel = $.grep(selectedNodes, function (obj) {
return en.No == obj.No;
});
if (sel.length > 0) {
checked = true;
}
treeJson.push({
"id": en.No,
"text": en.Name,
"children": creatTreeChildern(jsonArray, en.No),
"checked": checked,
"state": 'closed'
});
}
for (var i = 0; i < jsonArray.length; i++) {
var data = jsonArray[i];
if (data.ParentNo == parentNo) {
var checked = false;
var selectedNodes = window.selectedNodes;
var sel = $.grep(selectedNodes, function (obj) {
return data.No == obj.No;
});
if (sel.length > 0) {
checked = true;
}
treeJson.push({
"id": data.No,
"text": data.Name,
"children": creatTreeChildern(jsonArray, data.No),
"checked": checked,
"state": 'closed'
});
}
}
function _(treeArray) {
$.each(treeArray, function (i, o) {
if ($.isArray(o.nodes)) {
if (o.nodes.length == 0) {
o.nodes = undefined;
} else {
_(o.nodes);
}
}
});
}
_(treeJson);
return treeJson;
}
function creatTreeChildern(jsonArray, parentNo) {
var childList = []
for (var i = 0; i < jsonArray.length; i++) {
var data = jsonArray[i];
if (data.ParentNo == parentNo) {
var checked = false;
var selectedNodes = window.selectedNodes;
var sel = $.grep(selectedNodes, function (obj) {
return data.No == obj.No;
});
if (sel.length > 0) {
checked = true;
}
childList.push({
"id": data.No,
"text": data.Name,
"children": creatTreeChildern(jsonArray, data.No),
"checked": checked,
"state": 'closed'
});
}
}
return childList;
}
//保存.
function Save() {
var nodeID = GetQueryString("FK_Node");
var orgNo = GetQueryString("OrgNo");
//删除,该组织下已经保存的岗位.
//var sql = "DELETE FROM WF_NodeDept WHERE FK_Node=" + nodeID;
//DBAccess.RunSQL(sql);
var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode");
handler.AddPara("nodeID", nodeID);
handler.DoMethodReturnString("NodeDept_Dele");
//获取复选框选中的节点
var nodes = $('#tree').tree('getChecked');
var s = '';
for (var i = 0; i < nodes.length; i++) {
var en = new Entity("BP.WF.Template.NodeDept");
en.FK_Node = nodeID;
en.FK_Dept = nodes[i].id;
en.Insert();
}
window.close();
}
</script>
</head>
<body>
<input type="button" value='保存' onclick='Save();' id='save' />
<div id="tree"></div>
<div id="Msg"></div>
</body>
</html>