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.

359 lines
14 KiB
Plaintext

11 months ago
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>选择接受人</title>
<!--
1, 退回界面。
2需要 FK_Flow, FK_Node,WorkID, FID.
3, 调用方法 ReturnWork.htm?FK_Flow=001&FK_Node=103&WorkID=232&FID=23
-->
<link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
<link href="../Scripts/bootstrap/css/components-rounded.css" rel="stylesheet" />
<link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
<link href="../Scripts/bootstrap/css/themes/default/style.min.css" rel="stylesheet" />
<link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../Scripts/commonYangYH.js"></script>
<script src="../Scripts/QueryString.js" type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/bootstrap/js/jquery.cokie.min.js"></script>
<script type="text/javascript" src="../Scripts/bootstrap/js/jstree.js"></script>
<script type="text/javascript" src="../Scripts/bootstrap/js/jsTree.ddl.js"></script>
<!-- 导入配置文件. -->
<script type="text/javascript" src="../Scripts/config.js"></script>
<script type="text/javascript" src="../Comm/Gener.js"></script>
<link href="../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
<style type="text/css">
#TB_Doc {
height: 132px;
width: 433px;
}
</style>
<script type="text/javascript">
$(function () {
InitTreeData();
bindTest();
});
//确定 人员选择
function SelectEmps() {
GetSelectedEmpsReturnVal();
//No 是返回到别的页面的值
if (returnVal.No == undefined || returnVal.No == '') {
alert("未选择人员");
} else {
window.parent.selectEmpsWindowClose("确定");
}
}
//取消人员选择
function Close() {
if (window.parent != null && window.parent.selectEmpsWindowClose != null) {
window.parent.selectEmpsWindowClose("取消");
}
}
var pageData = {
IsSelectMore: GetQueryString('IsSelectMore') != undefined && GetQueryString('IsSelectMore') == "1" ? true : false,
FK_Dept: GetQueryString('FK_Dept') || '',
ParentDept: '',
selectedEmps: GetQueryString("SelectedEmps") || ""
};
var returnVal = {};
var isFirst = true;
//初始化树 接收人
function InitTreeData() {
$('#OrgJSTree').css('display', 'block');
var url = '';
//初始化Tree
var plugins = [];
if (pageData.IsSelectMore == true) { //多选
plugins = [
"checkbox",
"state",
"conditionalselect"
];
}
//返回节点数组
var initNodeData = function (data, fk_dept2) {
data = cceval('(' + data + ')');
var fk_dept = fk_dept2; //pageData.FK_Dept;
var parentNo = undefined;
var fkDeptObj = $.grep(data.Depts, function (value) {
return value.No == fk_dept;
});
if (fkDeptObj != undefined && fkDeptObj.length == 1) {
parentNo = fkDeptObj[0].ParentNo;
}
pageData.FK_Dept = parentNo;
//本节点
var instance = $('#OrgJSTree').jstree(true);
var depts = $.grep(data.Depts, function (value) {
return value.ParentNo == parentNo;
})
//if (instance.)
//子部门
var childDepts = $.grep(data.Depts, function (value) {
return value.ParentNo == fk_dept;
})
//人员
var emps = data.Emps;
var itemArr = [];
$.each(depts, function (i, dept) {
var deptNode = {
"text": dept.Name,
"id": dept.No,
"state": { "opened": true },
"children": true,
"data": dept
};
if (dept.No == fk_dept) { //是本部门时加载子部门和人员
var children = [];
if (childDepts.length > 0) {
$.each(childDepts, function (i, childDept) {
var childDeptNode = {
"text": childDept.Name,
"id": childDept.No,
//"state": {disabled:true},
"children": true,
"data": childDept
};
children.push(childDeptNode);
});
}
if (emps.length > 0) {
$.each(emps, function (i, emp) {
var empNo = emp.No.replace("Emp_", "");
var empNode = {
"text": emp.Name,
"id": emp.No,
"state": { selected: pageData.selectedEmps.indexOf(empNo+",")!=-1?true:false},
"children": false,
"data": emp,
"icon": "jstree-file"
};
children.push(empNode);
});
}
deptNode.data.childrenData = children;
}
itemArr.push(deptNode);
});
if (instance == false || instance.get_node(fk_dept) == false) {
pageData.ParentDept = parentNo;
}
else {
itemArr = itemArr[0].data.childrenData;
}
return itemArr;
};
$('#OrgJSTree').jstree({
'core': {
'data': function (node, cb) {
//初始化根节点
if (node.id == "#") {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
handler.AddPara("FK_Node", GetQueryString("FK_Node"));
if (pageData.FK_Dept != undefined)
handler.AddPara("FK_Dept", pageData.FK_Dept);
var data = handler.DoMethodReturnString("SelectEmps_Init");
if (data.indexOf('err@') == 0) {
alert(data);
return;
}
var fk_dept2 = pageData.FK_Dept;
cb(initNodeData(data, fk_dept2));
}
else {
if (node.data != undefined && node.data.childrenData != undefined && node.data.childrenData.length > 0) {
var fk_dept2 = node.id;
cb(node.data.childrenData, fk_dept2);
}
else {
pageData.FK_Dept = node.id;
var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
handler.AddPara("FK_Node", GetQueryString("FK_Node"));
handler.AddPara("FK_Dept", node.id);
var data = handler.DoMethodReturnString("SelectEmps_Init");
if (data.indexOf('err@') == 0) {
alert(data);
return;
}
var fk_dept2 = node.id;
cb(initNodeData(data, fk_dept2));
}
}
}
},
"plugins": plugins,
"checkbox": {
"keep_selected_style": false,//是否默认选中
"three_state": true,//父子级别级联选择
"tie_selection": true
},
}).on('changed.jstree', function (node, cb) {
GetSelectedEmpsReturnVal();
}).bind("loaded.jstree", function (event, data) {
data.instance.open_node();
}).bind("select_node.jstree", function (e, data) { //点击事件
//触发toggle_node 事件 就行了
//if (isFirst == true)
// isFirst = false;
//else
$('#OrgJSTree').jstree("toggle_node", data.node);
}).on("loaded.jstree", function (event, data) {
if (typeof data.instance.clear_state === "function")
data.instance.clear_state(); // <<< 这句清除jstree保存的选中状态
});
}
//弹出树
function bindTest() {
$('#test').bind('click', function () {
if ($('#OrgJSTree').css('display') == "none") {
$('#OrgJSTree').css('display', 'block');
var instance = $('#OrgJSTree').jstree(true);
if ($('#orgTxt').val() != undefined && $('#orgTxt').val() != '') {
instance.select_node($('#orgTxt').val());
}
}
else {
$('#OrgJSTree').css('display', 'none');
}
});
$('#toPrevDept').bind('click', function () {
if (pageData.ParentDept == 'null' || pageData.ParentDept == 0) {
alert("已到第一级机构");
return;
}
var webUser = new WebUser();
// SAAS模式下限制只可以看到OrgNo级别
if (webUser.CCBPMRunModel != 0 && pageData.ParentDept == 100) {
alert("已到第一级机构");
return;
}
//判断最高级别.
//var user = new WebUser();
//if (user.CustomerNo == 'TianYe') {
// if (user.FK_Dept.indexOf('18099') == 0) {
// if (pageData.ParentDept.indexOf('18099') != 0) {
// alert('已经是最高级别了.');
// return;
// }
// }
//}
pageData.FK_Dept = pageData.ParentDept;
$('#OrgJSTree').jstree(true).refresh();
});
}
//获取树选中的值
function GetSelectedEmpsReturnVal() {
var instance = $('#OrgJSTree').jstree(true);
var selectedIdArr = instance.get_selected();
var selectedNodes = [];
var nameArrs = [];
var noArr = [];
var nameArr = [];
$.each(selectedIdArr, function (i, selectedId) {
selectedNodes.push(instance.get_node(selectedId));
});
$.each(selectedNodes, function (i, selectedNode) {
if (selectedNodes[i].icon != true) {
nameArrs.push(selectedNode.data);
}
});
if (nameArrs.length > 0) {
for (var property in nameArrs[0]) {
returnVal[property] = [];
}
}
$.each(nameArrs, function (i, selected) {
for (var property in returnVal) {
var val = selected[property];
if (property == "No")
val = val.replace("Emp_", "");
returnVal[property].push(val);
}
});
for (var property in nameArrs[0]) {
returnVal[property] = returnVal[property].join(",");
}
}
function Search() {
var keyVal = $("#TB_Key").val();
if (keyVal == "")
return;
//根据输入的部门编号或者名称获取部门信息
var ens = new Entities("BP.Port.Depts");
ens.RetrieveCond("No,Name", "like", '%' + keyVal + '%');
//查询到的部门节点就展开
var $jstree = $('#OrgJSTree').jstree(true);
for (var i = 0; i < ens.length; i++) {
$jstree.open_node($jstree.get_node(ens[i].No));
}
}
</script>
</head>
<body>
<div id="OrgJSTree" class="tree-demo jstree jstree-1 jstree-default" style="position:absolute;bottom:60px;left:0;right:0;top:0; overflow-y:auto;"></div>
<div style="position: fixed; bottom: 0; right: 0;">
<button type="button" id="toPrevDept" class="layui-btn">
<!--<img src="../Img/Btn/JumpWay.png" />--> 上一级
</button>
<button type="button" onclick="Close()" class="layui-btn layui-btn-primary">
<!--<img src="../Img/Btn/Return.png" />--> 取消
</button>
<button type="button" onclick="SelectEmps()" class="layui-btn layui-btn-normal">
<!--<img src="../Img/Btn/Confirm.png" />--> 确定
</button>
<!--<input type="button" value="上一级" id="toPrevDept" />
<input type="button" onclick="Close()" value="取消" />
<input type="button" onclick="SelectEmps()" value="确定" />-->
</div>
<!--<input type="button" onclick="Close()" value="取消" /><input type="button" onclick="SelectEmps()"
value="确定" />-->
</body>
</html>