/** 流程中转移负责人 **/ layui.define(['layer','table','form','tree','element'],function(exports){ var Assign = function(){ this.MODULENAME = "flowable/vciFlowableAssign"; this.id = "vciFlowableAssign"; this.moduleKey = "vciFlowableAssign"; this.backPath = configData.compatibility ? path : configData.processServicePath ; this.taskOid = "";//任务的主键 this.processTaskTitle = "";//任务的标题 this.config = {}; this.url = { treeDept:'departmentQueryController/refTree', dataGridMyDept:'userQueryController/refDataGridByCurrentDepartment', dataGridAllUser:'userQueryController/refDataGrid',//全部的用户 dataGridThisTaskInTemplate:'workflowDefineController/listProcessUserByTask',//流程模板中定义的候选人 dataGridSystemVar:'',//系统变量中的用户 setAssign:'workflowCommandController/transferPrincipal'//转派 }; }; Assign.prototype.getContent = function(){ //兼容的方法,实际无内容 return ""; }; Assign.prototype.init = function(id,options){ //初始化 var that = this; $webUtil.copyConfig(that,that.moduleKey); that.config[id] = options; if($webUtil.isNull(options.taskOid)){ $webUtil.showErrorMsg("没有流程待办任务的主键"); return false; } if($webUtil.isNull(options.processTaskTitle)){ $webUtil.showErrorMsg("没有流程待办任务的名称"); return false; } var tabId = "tab_user_for_task_" + id; options.tabId = tabId; var table = layui.table; var tree = layui.tree; var startAssign = layer.open({ type:1, title:'为【' + options.processTaskTitle + '】任务设置处理人', btn:['确定','取消'], //skin:'layui-layer-lan', content:'
'+ '' + '
' + '
' + '
' + '
'+ '
' + '
' + '
' + '' + '
      ' + '
' + '
' + '
' + '
'+ '
' + '
' + '
' + '
      '+ '
' + //目前暂时不添加系统变量,后续平台完善后,应该加上同岗位,同职务,同职级,直属领导,我的下属这些系统变量 // '
' + // '
' + // '' + // '
      ' + // '
' + // '
' + // '
' + // '
' + // '
' + // '
' + '
' + '
', area:[$webUtil.getDialogScreenWidth({width:900}) + 'px',$webUtil.getDialogScreenHeight({fullScreen:true}) + 'px'], closeBtn:1, shade:true, shadeClose:true, yes:function(index,layero){ var userId = that.getSelectUser(id); if(!userId){ return false; } $webUtil.post(that.url.setAssign,{taskOid:options.taskOid,userId:userId},function(result){ if(result.success){ $webUtil.showMsgFromResult(result,"转派成功"); layer.close(startAssign); if(that.okCallback){ that.okCallback(); } }else{ $webUtil.showErrorMsg(result.msg); } },function(xhr,err){ $webUtil.showErrorMsg("设置转移负责人出现了错误,您可以稍后再试"); },that.backPath); }, cancel:function(index,layero){ layer.close(startAssign); }, success:function(layero) { //1.初始化选项卡 //同部门的用户 that.initSameDeptUser(id); //全部用户 that.initAllUser(id); //模板中定义的候选人 that.initTemplatUser(id); //系统变量的暂时不调用 //监控选项卡点击,默认就是第一个选项卡 options.selectTabIndex = 0; layui.element.on('tab(' + options.tabId + ')', function(data){ options.selectTabIndex = data.index; }); } }); }; Assign.prototype.initSameDeptUser = function(id){ var that = this; var options = that.config[id]; //相同部门的用户 var table = layui.table; table.render({ elem:'#samedept_table_' + options.tabId, id:'samedept_table_' + options.tabId, url:configData.frameworkPath + that.url.dataGridMyDept, page:{ limit:30, page:1 }, cols:[that.getUserColumns()] }); $webUtil.createSearchHtml({ name:'姓名', id:'用户账号(用户名)' },$('[layui-filter="samedept_toolbar_' + options.tabId + '"]'),'samedept_table_' + options.tabId); }; Assign.prototype.initAllUser = function(id){ var that = this; var options = that.config[id]; var table = layui.table; var tree = layui.tree; //初始化全部用户的列表,使用部门展示 var deptTreeUI = $('[layui-filter="alluser_tree_' + options.tabId + '"]'); tree.init("alluser_tree_" + options.tabId , deptTreeUI,{ showSearch:true, url:that.url.treeDept, backPath:configData.frameworkPath, extraParams: { showAllDept:true }, click: function (item, elem, options) { that.showUsersForDept(id,item.oid); } }); //列表并行初始化,是因为第一个节点默认的就是全部用户 table.render({ elem:'#alluser_table_' + options.tabId, id:'alluser_table_' + options.tabId, url:configData.frameworkPath + that.url.dataGridAllUser, page:{ limit:30, page:1 }, cols:[that.getUserColumns()] }); $webUtil.createSearchHtml({ name:'姓名', id:'用户账号(用户名)' },$('[layui-filter="alluser_toolbar_' + options.tabId + '"]'),'alluser_table_' + options.tabId); }; Assign.prototype.showUsersForDept = function(id,deptOid){ //根据部门显示用户 var that = this; var table = layui.table; if(deptOid == "#ALLDEPT#"){ deptOid = ""; } var options = that.config[id]; table.reload('alluser_table_' + options.tabId ,{ where:{ "conditionMap['pkDepartment']":deptOid } }); }; Assign.prototype.initTemplatUser = function(id){ var that = this; var options = that.config[id]; var tree = layui.tree; //初始化流程模板中定义的用户 $webUtil.get(that.url.dataGridThisTaskInTemplate,{taskOid:options.taskOid},function(result){ if(result.success){ var thisNodeUsers = result.obj.departments; if(thisNodeUsers){ layui.each(thisNodeUsers,function(_userIndex,_userItem){ if(_userItem.type == "role"){ _userItem.name = _userItem.name + "(角色)"; } else if(_userItem.type == "dept"){ _userItem.name = _userItem.name + "(部门)"; } if(_userItem.secret && _userItem.secret*1>0 && _userItem.secretText){ _userItem.name += "[" + _userItem.secretText + "]"; } if(!$webUtil.isNull(_userItem.id)){ _userItem.name = _userItem.id+' '+_userItem.name; } if(_userItem.children && _userItem.children.length > 0){ layui.each(_userItem.children,function(_childrenUserIndex,_childrenUserItem){ if(_childrenUserItem.secret && _childrenUserItem.secret*1>0 && _childrenUserItem.secretText){ _childrenUserItem.name += "[" + _childrenUserItem.secretText + "]"; } if(!$webUtil.isNull(_childrenUserItem.id)){ _childrenUserItem.name = _childrenUserItem.id+' '+_childrenUserItem.name; } }); } }); } var treeUL = $('[layui-filter="intemplate_' +options.tabId + '"]'); tree.init("tree_" + that.tabId, treeUL, { nodes:thisNodeUsers, showSearch:true, onlyLeaf:false,//只能选择叶子节点 onlyLeafText:'请选择用户,不要选择角色和部门(树上的叶子节点才是用户类型)', click: function (item, elem, options) { that.config[id].selectTreeItem = item; } }); }else{ $('[layui-filter="intemplate_' +options.tabId + '"]').html("获取流程模板中设置的候选人出错,但是您仍然可以使用其他方式选择用户"); } },function(xhr,error){ $('[layui-filter="intemplate_' +options.tabId + '"]').html("获取流程模板中设置的候选人出错,但是您仍然可以使用其他方式选择用户"); },that.backPath,false); }; Assign.prototype.initSystemVarUser = function(){ var that = this; var table = layui.table; var tree = layui.tree; //系统变量--还未完成 var systemTreeUI = $('[layui-filter="systemvar_tree_' + that.tabId + '"]'); tree.init("systemvar_tree_" + that.tabId, systemTreeUI, { nodes:[{ oid:'CURRENT', text:'相同部门下的用户', leaf:true },{ oid:'CURREN', text:'相同角色下的用户', leaf:true },{ oid:'CURREeNT', text:'我的主管领导', leaf:true }], click: function (item, elem, options) { that.showUsersForSystem(item.id); } }); table.render({ elem:'#systemvar_table_' + that.tabId, id:'systemvar_table_' + that.tabId, url:that.backPath + that.url.dataGridSystemVar, page:{ limit:30, page:1 }, cols:[that.getUserColumns()] }); $webUtil.createSearchHtml({ name:'姓名', id:'用户账号(用户名)' },$('[layui-filter="systemvar_toolbar_' + that.tabId + '"]'),'systemvar_table_' + that.tabId); }; Assign.prototype.getUserColumns = function(){ //用户的展示列表 var table = layui.table; return [table.getIndexColumn(),table.getCheckColumn(),{ field:'id', title:'用户账号(用户名)', sort:true, width:170 },{ field:'name', title:'姓名', sort: true, width:150 },{ field:'secretGradeText', title:'密级', width:100, hidden:!configData.controllerSecret }]; }; Assign.prototype.getSelectUser = function(id){ var that = this; var options = that.config[id]; if(options.selectTabIndex == 0){ //说明是第一个 var userId = $webUtil.getOidFromGrid("samedept_table_" + options.tabId,true,true,'id'); if(!userId){ return false; } return userId; }else if(options.selectTabIndex == 1){ var userId = $webUtil.getOidFromGrid("alluser_table_" + options.tabId,true,true,'id'); if(!userId){ return false; } return userId; }else{ if(!options.selectTreeItem){ //选择树的节点 $webUtil.showErrorMsg("没有选择用户"); return false; } if(!options.selectTreeItem.leaf && options.selectTreeItem.children && options.selectTreeItem.children.length>0){ $webUtil.showErrorMsg("在【本任务的流程模板中定义的候选人】选项卡中只能选择用户"); return false; } return options.selectTreeItem.id; } }; var sp = new Assign(); exports(sp.MODULENAME,sp); });