(function () { z.workflow = z.workflow || {}; //转件弹出框配置 var transferModalConfig = { rotatePartsDto: {}, treeData: [], batchSelectData: [], mark_logic: '', mark_logic_tip: '', iSameLevel: false, sysOpList: [], userOpList: [], position: -1, sysOpinionGrid: null, userOpinionGrid: null, iTransferConfirmTip: 1, reloadModal: function (transferData, iSameLevel) { transferModalConfig.modalBindEvents(); transferModalConfig.rotatePartsDto = transferData.rotatePartsDto || {}; transferModalConfig.treeData = transferData.zTreeData || []; transferModalConfig.mark_logic = transferData.rotatePartsDto.mutexLogic; transferModalConfig.mark_logic_tip = transferData.rotatePartsDto.mutexLogicTip; transferModalConfig.position = transferData.position; transferModalConfig.sysOpList = transferData.sysOpList; transferModalConfig.userOpList = transferData.userOpList; if (!transferModalConfig.mark_logic_tip) { transferModalConfig.mark_logic_tip = "触发互斥条件,无法选择!"; } transferModalConfig.iSameLevel = iSameLevel; transferModalConfig.iTransferConfirmTip = transferData.rotatePartsDto.iTransferConfirmTip; transferModalConfig.buildConfig(); //初始化插件 transferModalConfig.initOpinions(); $(".transfer-tab-li").eq(0).click(); //默认选中第一个tab页 }, //计算弹出框的,布局宽高 initOpinions: function () { //系统意见 var sysOpinionObj = $("[name=transfer_sys_opinion]"); if (sysOpinionObj && sysOpinionObj.length > 0) { transferModalConfig.sysOpinionGrid = z.ui.jqgrid("[name=transfer_sys_opinion]").init({ minheight: 100, rowNum: null, rownumbers: false, data: transferModalConfig.sysOpList, height: $("[name=transfer_sys_opinion]").height() - 38, pagination: false, colModel: [ {name: "id", hidden: true}, {name: 'content',label: '系统可选意见(双击)',whitespace: "normal",align: "center"}, { label: '当前环节专属', name: "iDedicatedOpinion", fixed: true, width: 70, align: "center", switchs: [{ onClick: function (rowObject, rowindex, link, event) { transferModalConfig.updateIDedicatedOpinion(rowObject, link); } }] } ], ondblClickRow: function (rowid, iRow, iCol, e) { var rowData = z.ui.jqgrid("[name=transfer_sys_opinion]").getRowData(rowid); transferModalConfig.updateOpinionContent(rowData.content); } }) } var userOpinionObj = $("[name=transfer_user_opinion]"); if (userOpinionObj && userOpinionObj.length > 0) { //个人常用意见 transferModalConfig.userOpinionGrid = z.ui.jqgrid("[name=transfer_user_opinion]").init({ pagination: false, rowNum: null, rownumbers: false, height: $("[name=transfer_user_opinion]").height() - 38, minheight: 100, colModel: [ {name: "id", hidden: true}, {name: 'content',label: '个人常用意见(双击)',whitespace: "normal",align: "center"}, { label: '当前环节专属', name: "iDedicatedOpinion", fixed: true, width: 70, align: "center", switchs: [{ onClick: function (rowObject, rowindex, link, event) { transferModalConfig.updateIDedicatedOpinion(rowObject, link); } }] }, { name: 'action', label: '操作', width: 70, fixed: true, align: "center", buttons: [{ label: " 移除", className: "btn btn-danger", onClick: function (rowObject, rowindex) { z.ui.ajax({ url: workflowHost + "/TFlowOpPersonal/delByID", data: { ID: rowObject.id, }, success: function (res) { transferModalConfig.userOpinionGrid.delRowData(rowObject.id); } }); } }] } ], data: transferModalConfig.userOpList, ondblClickRow: function (rowid, iRow, iCol, e) { var rowData = z.ui.jqgrid("[name=transfer_user_opinion]").getRowData(rowid); transferModalConfig.updateOpinionContent(rowData.content); } }) } }, updateIDedicatedOpinion: function (rowObject, link) { link.disabled();//禁用 var iDedicatedOpinion = link.getValue() == 0 ? 1 : 0; z.ui.ajax({ url: workflowHost + "/TFlowOpPersonal/isThisActivity", data: { id: rowObject.id, activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), iDedicatedOpinion: iDedicatedOpinion }, success: function (res) { if (!res.msg) { var status = link.getValue();//取状态 link.setValue(status == 0 ? 1 : 0);//赋状态 } else { z.ui.alertError(res.msg); } link.enable();//启用 } }); }, initGridsConfig: function (tempId) { var thatEle = "[name=" + tempId + "_grid]"; z.ui.jqgrid(thatEle).init({ height: $(thatEle).height() - 35, colModel: [ {name: 'id', label: 'id', hidden: true}, {name: 'name', label: '人员', width: 120, align: "center"}, {name: 'department', label: '部门', width: 200, align: "center"}, { label: "操作", name: 'action', width: 80, fixed: true, align: "center", buttons: [{ label: " 移除", className: "btn btn-danger", onClick: function (rowObject, rowindex) { transferModalConfig.delRow(z.ui.jqgrid(thatEle), rowObject.id, tempId); } }] } ], data: [] }); $(thatEle).addClass("transfer-display"); }, //初始化grid initTreesConfig: function (thatData, acTmpId, iSelectParticipant) { var thatEle = "[name=" + acTmpId + "_tree]"; var treeObj = z.ui.ztree(thatEle).init({ callback: { onClick: function (event, treeId, treeNode) { treeObj.checkNode(treeNode, !treeNode.checked, false, true); }, onCheck: function (event, treeId, treeNode) { if (transferModalConfig.isMutex(acTmpId)) { treeObj.checkNode(treeNode, false, false, false); z.ui.alertWarning(transferModalConfig.mark_logic_tip); return; } transferModalConfig.treeNodeEvent(treeObj, treeNode, acTmpId); }, onLoadSuccess: function (event, treeId, treeNode) { //判断是否默认全选所有人员 if (iSelectParticipant == 1 && !transferModalConfig.isMutex(acTmpId)) { var treeObjNew = z.ui.ztree(thatEle); treeObjNew.checkAllNodes(true); transferModalConfig.defaultCheckEvent(treeObjNew, acTmpId); } } }, view: { height: $(thatEle).height(), iconCls: function (val) { //icon样式 if (val.type == 1) { return "z-tree-icon-dep"; } else if (val.type == 2) { return "z-tree-icon-person"; } else if (val.type == 3) { return "z-tree-icon-worker"; } }, formatter: function (node) { return node.name; }, defaultOpen: true //是否默认展开所有父级,默认false }, search: { enable: true //是否带有搜索功能,默认false }, check: { //配置的选择框对象 enable: true //是否使用选择框 }, treedata: thatData }); }, //初始化tree treeNodeEvent: function (treeObj, treeNode, acTempId) { var nodes = treeObj.transformToArray(treeNode); //当前选中节点 var thatGrid = z.ui.jqgrid("[name=" + acTempId + "_grid]"); for (var i = 0; i < nodes.length; i++) { var thatNode = nodes[i]; if (thatNode.type == 3) { transferModalConfig.gridAddOrDelRow(thatNode, thatGrid, acTempId, treeObj); } } }, //树节点事件 defaultCheckEvent: function (treeObj, acTempId) { var nodes = treeObj.transformToArray(treeObj.getNodes()); //所有节点 var thatGrid = z.ui.jqgrid("[name=" + acTempId + "_grid]"); for (var i = 0; i < nodes.length; i++) { var thatNode = nodes[i]; if (thatNode.type == 3) { thatNode.checked = true; transferModalConfig.gridAddOrDelRow(thatNode, thatGrid, acTempId, treeObj); } } }, //默认全选树节点事件 gridAddOrDelRow: function (treeNode, gridObj, acTempId, treeObj) { if (treeNode.checked) { transferModalConfig.addRow(gridObj, { id: treeNode.id, name: treeNode.name, department: treeNode.getParentNode().name, type: 1, isMsg: "开启" }, acTempId, treeObj, treeNode) } else { transferModalConfig.delRow(gridObj, treeNode.id, acTempId) } }, //grid操作 addRow: function (gridObj, rowData, acTempId, treeObj, treeNode) { var gridIds = gridObj.getDataIDs() || []; if ($.inArray(rowData.id, gridIds) < 0) { //已存在不添加 if (treeObj && treeNode) { var cNodes = []; var grepNodes; $.each(treeObj.getCheckedNodes(true), function (index, item) { if (item.type == 3) { grepNodes = $.grep(cNodes, function(n, i) { return n.id == item.id; }); if (grepNodes.length == 0) { cNodes.push(item); } } }); var cIndex = $.inArray(treeNode, cNodes); if (cIndex == 0) { gridObj.addRowData(rowData.id, rowData, "first"); } else { gridObj.addRowData(rowData.id, rowData, "after", cNodes[cIndex-1].id); } } else { gridObj.addRowData(rowData.id, rowData); } } if (gridObj.getDataIDs().length > 0) { $("[name=checkbox_" + acTempId + "]").find(".z-checkbox-item").addClass("checked"); } }, //添加grid 行 delRow: function (gridObj, id, acTempId) { //移除grid 行数据 gridObj.delRowData(id); // var thatChk = $("checkbox_" + acTempId + " .z-checkbox-item"); //tab 复选框 var thatChk = $("[name=checkbox_" + acTempId + "]").find(".z-checkbox-item");//tab 复选框 var required = $("[z-tabindex=" + acTempId + "]").attr("z-required"); //是否必选 var gridIds = gridObj.getDataIDs() || []; //设置tab页的勾选状态 if (gridIds.length == 0 && required == "0") { thatChk.removeClass("checked"); } //移除左侧人员架构树的勾选状态 var treeObj = z.ui.ztree("[name=" + acTempId + "_tree]"); var nodes = treeObj.getCheckedNodes(); for (var i = 0; i < nodes.length; i++) { var node = nodes[i]; if (node.id == id) { treeObj.checkNode(node, false, true); } } }, //删除grid行 buildConfig: function () { var rotatePartsData = transferModalConfig.rotatePartsDto.rotatePartsData || []; for (var i = 0; i < rotatePartsData.length; i++) { var thatData = rotatePartsData[i]; var nodeId = thatData.activityTemplateId || thatData.archiveTemplateId || thatData.gatewayTemplateId; transferModalConfig.initGridsConfig(nodeId);//初始化表格 for (var j = 0; j < transferModalConfig.treeData.length; j++) { var thatTree = transferModalConfig.treeData[j]; if (thatTree.activityTemplateId == nodeId) { transferModalConfig.initTreesConfig(thatTree.orgTree, nodeId, thatTree.iSelectParticipant); break; } } } }, //初始化treegrid配置 transferActByDialog: function (ele) { z.ui.lock(ele, function () { var rData = transferModalConfig.rotatePartsDto || {}; if (!rData.activityInstanceId) { z.ui.alertWarning("缺少活动实例ID"); z.ui.unLock(ele); return; } var postData = { rotatePartsDto: { rotatePartsData: [], activityInstanceId: rData.activityInstanceId } }; var transferArr = $(".transfer-tab-li") || []; var tabUserArr = [], tabValid = [], unselectedNode = []; var isNoMust = {flag: true, users: 0}; for (var i = 0; i < transferArr.length; i++) { var thatTab = transferArr[i], userNames = []; var templateId = $(thatTab).attr("z-tabindex"), tabName = $(thatTab).attr("lang"), //节点名称 isChecked = z.ui.checkbox("[name=checkbox_" + templateId + "]").getValue(), //是否选中(必选) userIds = z.ui.jqgrid("[name=" + templateId + "_grid]").getDataIDs() || []; //选中下一步参与人 var rotateItem = null; for (var j = 0; j < rData.rotatePartsData.length; j++) { var thatData = rData.rotatePartsData[j]; var nodeId = thatData.activityTemplateId || thatData.archiveTemplateId || thatData.gatewayTemplateId; if (templateId === nodeId) { if (userIds.length > 0) {//非必填节点且未选择参与人不做转件操作 rotateItem = thatData; } else {//未选择人员的节点,需判断是否满足互斥,并给予确认提示 if (!transferModalConfig.isMutex(templateId)) { unselectedNode.push(tabName); } } break; } } if (rotateItem) { var iExistUser; for (var j = 0; j < userIds.length; j++) { var rowData = z.ui.jqgrid("[name=" + templateId + "_grid]").getRowData(userIds[j]); //校验是否重复添加 if (rowData) { iExistUser = false; $.each(rotateItem.participants, function (index, item) { if (item.id == userIds[j]) { iExistUser = true; return false; } }); userNames.push(rowData.name); if (!iExistUser) { rotateItem.participants.push({id: userIds[j]}); } } } tabUserArr.push({name: tabName, users: userNames.join(",")}); postData.rotatePartsDto.rotatePartsData.push(rotateItem); } // 1,节点checkbox是否选中 (验证必选参与人) // 2,isNoMust记录是否全部非必选和选择的人员总数量 isNoMust.users += userIds.length; if (isChecked == "1") { isNoMust.flag = false; if (userIds.length == 0) { tabValid.push({label: tabName}); } } } //如果全部非必选并且选择人员的总数量为0,提示至少选择一位参与人 if (isNoMust.flag == true && isNoMust.users == 0) { z.ui.alertWarning("至少选择一位参与人!"); z.ui.unLock(ele); return; } //检查每个节点是否选中参与人 if (tabValid.length > 0) { var tipMsg = []; for (var i = 0; i < tabValid.length; i++) { tipMsg.push(tabValid[i].label + ":至少选择一位参与人!"); } z.ui.alertWarning(tipMsg.join("
")); z.ui.unLock(ele); return; } //执行转件 if (transferModalConfig.iTransferConfirmTip == 1 && unselectedNode.length > 0) {//未选节点给予确认提示信息 z.ui.confirm("transferConfirmTip").init({ content: "[" + unselectedNode.join("、") + "]未选择办理人,将无法流转至相应环节,是否确认继续转件?", onConfirm: function () { transferModalConfig.executeTransfer(ele, postData, tabUserArr); }, onCancel: function () { z.ui.unLock(ele); } }); } else { transferModalConfig.executeTransfer(ele, postData, tabUserArr); } }); },//转件保存事件 batchSelect: function (ele) { z.ui.lock(ele, function () { z.ui.modal("batchSelect").init({ url: workflowHost + "/Transfer/batchSelect", title: "批量选择待办件", width: $(".transfer-form").width(), height: "60%", onAfterClose: function(data) { if(data && data.selectList) { transferModalConfig.batchSelectData = data.selectList; } } }); z.ui.unLock(ele); }); },//批量选择待办件 executeTransfer: function (ele, postData, tabUserArr) { var transferFun = function (all) { var postUrl = workflowHost + "/Transfer/save"; postData.rotatePartsDto.participantId = z.ui.comm.getUrlParam("participant"); postData.rotatePartsDto.handleType = 0;//PC端转件 postData["flowOpinion"] = JSON.stringify(z.workflow.getEditOpinion()); if (transferModalConfig.iSameLevel) { postUrl = workflowHost + "/Transfer/sameLevelSave"; postData["position"] = transferModalConfig.position; } //判断是否批量选择待办件 if (transferModalConfig.batchSelectData.length > 0) { postData.rotatePartsDto.batchTransferData = transferModalConfig.batchSelectData; } z.ui.ajax({ url: postUrl, data: z.ui.form.childStringify(postData), complete: function () { z.ui.unLock(ele); }, success: function (res) { all(res); } }); } z.ui.asynAll({ methods: [transferFun], all: function (transferRes) { if (transferRes && transferRes != null) { if (transferRes.index != 2 && (!transferRes.tip || !transferRes.tip[0] || !transferRes.tip[0].users)) { flowFun.transferSuccessTip(transferRes.tip, 1000); z.ui.unLock(ele); return; } } flowFun.transferSuccess(tabUserArr); z.ui.unLock(ele); } }); },//执行转件 isMutex: function (acTmpId) { if (!transferModalConfig.mark_logic) { return false; } var liObj = transferModalConfig.findTabToIndex(acTmpId); if (!liObj) return false; //按 || 拆分互斥条件 var markArr = transferModalConfig.mark_logic.replace(/{/gm, "").replace(/}/gm, "").split("||"); //按活动id找到此活动li的jq对象 for (var i = 0; i < markArr.length; i++) { var that = markArr[i]; //按 && 拆分活动节点 {ptjd} && {ldsp} var itemArr = that.replace("(", "").replace(")", "").split("&&"); // 是否包含此活动 未包含则跳过 if ($.grep(itemArr, function (item) { return item == liObj.attr("mark"); }).length == 0) { continue; } //按多个活动标识查找jq对象 var lis = transferModalConfig.findTabToMarts(itemArr); //包括自己且除自己以外的tab被选中-》触发互斥 for (var j = 0; j < lis.length; j++) { var itemLi = lis[j]; if (itemLi.attr("mark") !== liObj.attr("mark") && itemLi.find(".z-checkbox-item").hasClass("checked")) { return true; } } } return false; }, //互斥验证 findTabToMarts: function (markArr) { var rtnArr = []; var tabLi = $("[name=transfer-form]").find("li"); for (var i = 0; i < tabLi.length; i++) { var that = $(tabLi[i]); for (var j = 0; j < markArr.length; j++) { var thatItem = markArr[j]; if (thatItem == that.attr("mark")) { rtnArr.push(that); } } } return rtnArr; }, findTabToIndex: function (tabIndex) { var tabLi = $("[name=transfer-form]").find("li"); //mark var arr = $.grep(tabLi, function (item) { return $(item).attr("z-tabindex") === tabIndex; }) if (arr.length > 0) return $(arr[0]); return null; }, modalBindEvents: function () { //tab页点击事件 $(".transfer-tab-li").click(function () { $(".transfer-tab-li").removeClass("on"); $(".transfer-tree").removeClass("transfer-active"); $(".transfer-grid").removeClass("transfer-active"); $(this).addClass("on"); var tabId = $(this).attr("z-tabindex"); $("[name=" + tabId + "_tree]").addClass("transfer-active"); $("[name=" + tabId + "_grid]").addClass("transfer-active"); }); //关闭按钮 $(".close-transfer-btn").click(function () { z.ui.modal("transferModal").close(); }); //个人常用意见 删除 $("[name=user_op_del]").on("click", function (event) { transferModalConfig.delOpersonals($(this)); event.stopPropagation(); // 阻止事件冒泡 }); //设置常用意见 $("[name=opinion_add]").on("click", function () { z.ui.lock($(this), function () { z.ui.ajax({ url: workflowHost + "/TFlowOpPersonal/setContent", data: { activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), content: $("[name^=tab_opContent_]").children("textarea:eq(0)").val() }, complete: function () { z.ui.unLock($(this)); }, success: function (res) { z.ui.alertSuccess("常用意见设置成功!", function () { transferModalConfig.userOpinionGrid.addRowData(res.id, res, "first"); }); } }) }) }); //批量选择待办件按钮事件 if ($(".batch-transfer-btn").length > 0) { $(".batch-transfer-btn").click(function () { transferModalConfig.batchSelect($(this)); }); } //保存按钮事件 $(".add-transfer-btn").click(function () { transferModalConfig.transferActByDialog($(this)); }); //审批意见 改变事件 $("textarea.transfer-opinion-text").on("input propertychange", function () { var editOpinion = $("[name='flowReviewContain']").find(".opinionEdit"); if (editOpinion.length > 0) { $(editOpinion[0]).find("[name='yjnr']").val($(this).val()); } }); },//弹出层绑定事件 updateOpinionContent: function (opinionContent) { $("[name^=tab_opContent_]").children("textarea:eq(0)").val(opinionContent); var editOpinion = $("[name='flowReviewContain']").find(".opinionEdit"); if (editOpinion.length > 0) { $(editOpinion[0]).find("[name='yjnr']").val(opinionContent); } }//更新审批意见框内容 }; //抄送弹出层配置 var ccModalConfig = { treeObj: {}, //zTree 对象 gridObj: {}, //grid 对象 treeData: [], //tree 数据 modalHeight: $(window).height(), reloadModal: function (participants, modalHeight) { ccModalConfig.treeData = participants; ccModalConfig.initTree(); ccModalConfig.initGrid(); ccModalConfig.bindEvents(); }, initTree: function () { ccModalConfig.treeObj = z.ui.ztree("[name=carbonCopyTree]").init({ callback: { onCheck: function (event, treeId, treeNode) { ccModalConfig.treeCheckEvent(treeNode); }, onClick: function (event, treeId, treeNode) { ccModalConfig.treeObj.checkNode(treeNode, !treeNode.checked, true); ccModalConfig.treeCheckEvent(treeNode); }, }, view: { height: ccModalConfig.modalHeight - 85, iconCls: function (val) { //icon样式 if (val.type == 1) { return "z-tree-icon-dep"; } else if (val.type == 2) { return "z-tree-icon-person"; } else if (val.type == 3) { return "z-tree-icon-worker"; } }, formatter: function (node) { return node.name; // +'[领导人数:'+ node.id +']'; }, defaultOpen: true //是否默认展开所有父级,默认false }, search: { enable: true //是否带有搜索功能,默认false }, check: { //配置的选择框对象 enable: true //是否使用选择框 }, treedata: ccModalConfig.treeData }) }, initGrid: function () { ccModalConfig.gridObj = z.ui.jqgrid("[name=carbonCopyGrid]").init({ height: ccModalConfig.modalHeight - 85 - 38, colModel: [ {name: 'id', label: 'id', hidden: true}, {name: 'name', label: '人员', width: 120, fixed: true, align: "center"}, {name: 'department', label: '部门', width: 200, fixed: true, align: "center"}, { label: "操作", name: 'action', width: 80, align: "center", buttons: [{ label: " 移除", className: "btn btn-danger", onClick: function (rowObject, rowindex) { ccModalConfig.gridObj.delRowData(rowObject.id); } }] } ], data: [] }); }, treeCheckEvent: function (node) { var nodes = ccModalConfig.treeObj.transformToArray(node); //选中节点 for (var i = 0; i < nodes.length; i++) { var thatNode = nodes[i]; if (thatNode.type == 3) { ccModalConfig.gridRowAddOrDel(thatNode) } } }, gridRowAddOrDel: function (node) { if (node.checked) { var gridIds = ccModalConfig.gridObj.getDataIDs() || []; if ($.inArray(node.id, gridIds) < 0) { //已存在不添加 ccModalConfig.gridObj.addRowData(node.id, { id: node.id, name: node.name, department: node.getParentNode().name, type: 1, isMsg: "开启" }); } } else { ccModalConfig.gridObj.delRowData(node.id); } }, bindEvents: function () { // 弹出框 关闭 $(".close-carbon-copy-btn").bind("click", function () { z.ui.modal("carbonCopyDialog").close(); }); //弹出框 保存 $(".add-carbon-copy-btn").bind("click", function () { var idArray = ccModalConfig.gridObj.getDataIDs(); if (!idArray || idArray.length == 0) { z.ui.alertWarning("请选择抄送人"); return; } z.ui.ajax({ "url": workflowHost + "/ICarbonCopyInstance/save", data: { "activityInstanceId": z.ui.comm.getUrlParam("activityInstanceId"), "participants": JSON.stringify(idArray) }, success: function () { z.ui.alertSuccess("抄送成功", function () { var sourcewindowid = z.ui.comm.getUrlParam("sourcewindowid");//获取到A页面注册用的窗体id if (sourcewindowid != undefined) { var msgData = { "type": "reload", "status": 210 // 抄送 }; z.webcontainer.sendMessageById(sourcewindowid, msgData); } z.ui.modal("carbonCopyDialog").close(); }); } }); }); } }; //流程方法 var flowFun = { save: function (ele, funs) { var methods = []; z.ui.lock(ele, function () { // 1,执行业务的所有表单方法 $.each(funs, function (i, v) { methods.push(function (all) { v.fun(all, false) // 这里工作流可以自己做处理 }); }); //保存审批意见 var opinionFun = function (all) { z.ui.ajax({ url: workflowHost + "/IFlowOpinion/save", data: z.ui.form.childStringify({IFlowOpinion: JSON.stringify(z.workflow.getEditOpinion())}), success: function (res) { all(); }, error: function () { all({success: false, errorMsg: "审批意见保存失败!"}) } }); } methods.push(opinionFun); z.ui.asynAll({ methods: methods, all: function () { var error = false; var errorMsg = ["保存失败!"]; for (var i = 0; i < arguments.length; i++) { var that = arguments[i]; if (that && that.success === false) { if (!error) error = true; if (that.errorMsg) errorMsg.push(that.errorMsg); } } if (!error) { z.ui.alertSuccess("保存成功!"); } else { z.ui.alertWarning(errorMsg.join("
")); } z.ui.unLock(ele); } }); }) },//保存 transfer: function (ele, funs) { var methods = []; z.ui.lock(ele, function () { $.each(funs, function (i, v) { methods.push(function (all) { v.fun(all, true); //参数1,事件队列执行结束后统一执行的方法,在保存事件必须调用 //参数2(可选),传递一个参数给页面 }) }); //无执行方法时,直接执行转件操作 xf 2020/6/21 if (methods.length == 0) { flowFun.getNextActivity();//转件 z.ui.unLock(ele); return; } z.ui.asynAll({ methods: methods, all: function () { //arguments 类数组 var error = false; var errorMsg = ["保存失败!"]; for (var i = 0; i < arguments.length; i++) { var that = arguments[i]; if (that && that.success === false) { if (!error) error = true; if (that.errorMsg) errorMsg.push(that.errorMsg); } } if (!error) { flowFun.getNextActivity(function () { z.ui.unLock(ele); });//转件 } else { z.ui.alertWarning(errorMsg.join("
")); z.ui.unLock(ele); } } }); }) },//转件 sameLevelTransfer: function (ele, funs) { var methods = []; z.ui.lock(ele, function () { $.each(funs, function (i, v) { methods.push(function (all) { v.fun(all, false); //参数1,事件队列执行结束后统一执行的方法,在保存事件必须调用 //参数2(可选),传递一个参数给页面 }) }); }) //无执行方法时,直接执行转件操作 xf 2020/6/21 if (methods.length == 0) { flowFun.getSameLevelActivity(ele.attr("btn-num"), function () { z.ui.unLock(ele); });//转件 return; } z.ui.asynAll({ methods: methods, all: function () { //arguments 类数组 var error = false; var errorMsg = ["保存失败!"]; for (var i = 0; i < arguments.length; i++) { var that = arguments[i]; if (that && that.success === false) { if (!error) error = true; if (that.errorMsg) errorMsg.push(that.errorMsg); } } if (!error) { flowFun.getSameLevelActivity(ele.attr("btn-num"), function () { z.ui.unLock(ele); });//转件 } else { z.ui.alertWarning(errorMsg.join("
")); z.ui.unLock(ele); } } }); },//同级转件 sameLevelReturn: function (ele) { var activityInstanceId = z.ui.comm.getUrlParam("activityInstanceId"); flowFun.isMeetTheReturnCondition(activityInstanceId, function () { flowFun.openCallbackWindow({ title: "同级退回", url: "/HandlerCaseCenter/getSameLevelReturnActivity", data: { "activityInstanceId": activityInstanceId, "flowInsId": z.ui.comm.getUrlParam("flowInstanceId"), "position": ele.attr("btn-num") } }); }); },//同级退件 callback: function (ele) { var activityInstanceId = z.ui.comm.getUrlParam("activityInstanceId"); flowFun.isMeetTheReturnCondition(activityInstanceId, function () { flowFun.openCallbackWindow({ title: "退回", url: "/HandlerCaseCenter/getCalBackActivity", data: { "activityInstanceId": activityInstanceId, "flowInsId": z.ui.comm.getUrlParam("flowInstanceId") } }); }); },//退件 isMeetTheReturnCondition: function (activityInstanceId, method) { z.ui.ajax({ url: workflowHost + "/HandlerCaseCenter/isMeetTheReturnCondition", data: {"activityInstanceId": activityInstanceId}, success: function (result) { if (!result.msg) { if (method instanceof Function) { method(); } } else { z.ui.alertError(result.msg); } } }); },//是否满足退件条件 openCallbackWindow: function (obj) { z.ui.modal("returnModal").init({ modalId: "callbackActivity", url: workflowHost + obj.url, data: obj.data, title: obj.title, width: 760, height: 274, showHead: true, showCloseBtn: true, showMask: true }); },//打开退件窗体 close: function () { z.webcontainer.closeTabById(z.ui.comm.getUrlParam("webContainerTabId")); },//关闭 暂无关闭业务逻辑 focus: function (ele) { //左侧节点注册点击事件 z.ui.lock(ele, function () { z.ui.ajax({ url: workflowHost + "/IAttentionInstance/save", data: { flowInstanceId: z.ui.comm.getUrlParam("flowInstanceId"), activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), }, complete: function () { z.ui.unLock(ele); }, success: function (res) { z.ui.alertSuccess(ele.text() + "成功!", 1000, function () { //$("[name='closeBtn']").click(); // 关闭当前TAB }); } }); }); },//关注 unfocus: function (ele) { z.ui.lock(ele, function () { z.ui.ajax({ url: workflowHost + "/IAttentionInstance/cancelFocus", data: { flowInstanceId: z.ui.comm.getUrlParam("flowInstanceId"), activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), }, complete: function () { z.ui.unlock(ele); }, success: function (res) { z.ui.alertSuccess(ele.text() + "成功", 1000, function () { //$("[name='closeBtn']").click(); // 关闭当前TAB }); } }); }); },//取消关注 cc: function (ele) { z.ui.ajax({ "url": workflowHost + "/ICarbonCopyInstance/index", data: { "activityInstanceId": z.ui.comm.getUrlParam("activityInstanceId") }, success: function (result) { var participantArr = result.participants; var dialogHtml = result.dialogHtml; flowFun.openCCModal(participantArr, dialogHtml); } }) }, //抄送 hangup: function (ele) { z.ui.lock(ele, function () { z.ui.ajax({ url: workflowHost + "/Transfer/isHangUp", data: { activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId") }, complete: function () { z.ui.unLock(ele); }, success: function (res) { if (res == "ok") { z.ui.modal("hangUp_local").init({ url: workflowHost + "/IHangUp/add", dateType: "jsonp", title: "申请挂起", height: 410, width: 800, data: { activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), isRecover: 0, participantId: z.ui.comm.getUrlParam("participant") } }); } } }) }) },// 挂起 hangupcancel: function (ele) { var _this = flowFun; z.ui.confirm("hangupcancel").init({ content: "取消挂起后,挂起流程无法恢复,是否确认取消?", onConfirm: function () { z.ui.lock(ele, function () { z.ui.ajax({ url: workflowHost + "/IHangUp/cancel", data: {flowInsId: z.ui.comm.getUrlParam("flowInstanceId")}, complete: function () { z.ui.unLock(ele); }, success: function (res) { _this.close(); } }) }) } }) }, //取消挂起 nullapply: function (ele) { z.ui.lock(ele, function () { z.ui.ajax({ url: workflowHost + "/Transfer/isVoid", data: {flowInstanceId: z.ui.comm.getUrlParam("flowInstanceId")}, complete: function () { z.ui.unLock(ele); }, success: function (res) { if (res == "ok") { z.ui.modal("nullyApply_local").init({ url: workflowHost + "/INullyApply/add", dateType: "jsonp", title: "申请作废", height: 400, width: 800, data: { voidFlowInstanceId: z.ui.comm.getUrlParam("flowInstanceId"), activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId") } }); } } }) }); },//作废 nullapplycancel: function (ele) { var _this = flowFun; z.ui.confirm("nullapplycancel").init({ content: "取消作废后,作废流程无法恢复,是否确认取消?", onConfirm: function () { z.ui.lock(ele, function () { z.ui.ajax({ url: workflowHost + "/INullyApply/cancel", data: {flowInstanceId: z.ui.comm.getUrlParam("flowInstanceId")}, complete: function () { z.ui.unLock(ele); }, success: function (res) { _this.close(); } }) }) } }) }, //取消作废 reportprint: function (ele) { var thatUrl = getUrl(); var url = [workflowHost, "/Transfer/printReport?flowInstanceId=", z.ui.comm.getStrUrlParam(thatUrl, "flowInstanceId"), "&activityInstanceId=", z.ui.comm.getStrUrlParam(thatUrl, "activityInstanceId"), "&fromId=", z.ui.comm.getStrUrlParam(thatUrl, "_fm")].join(""); z.webcontainer.openTab({ id: z.ui.comm.getStrUrlParam(thatUrl, "flowInstanceId") + '_flow_reports_page', title: "报表打印", url: url, iconclass: 'fa fa-file' }); function getUrl() { var menuItem = $(".workflow-left").find(".menu"); for (var i = 0; i < menuItem.length; i++) { var that = $(menuItem[i]); if (that.hasClass("active")) { return that.attr("addr"); } } } },//打印 historyOpinion: function (ele) { var editFlowOpinion = $("[name='flowReviewContain']").find(".opinionEdit"); z.ui.modal("viewHistoryOpinion").init({ url: workflowHost + "/IFlowOpinion/historyOpinion", dateType: "jsonp", title: "历史意见", width: "90%", height: "92%", data: { flowInstanceId: z.ui.comm.getUrlParam("flowInstanceId"), activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), iEditOpinion: editFlowOpinion.length > 0 ? true : false }, onAfterClose: function(data) { if (data && data.opinionContent && editFlowOpinion.length > 0) { $(editFlowOpinion[0]).find("[name='yjnr']").val(data.opinionContent); } } }); },//历史意见 flowlog: function (ele) { z.webcontainer.openTab({ id: 'workflowMain_History_' + z.ui.comm.getUrlParam("flowInstanceId"), title: "流程日志", // tip: window.userConfig.tn, url: workflowHost + "/IFlowRecord/index?flowInstanceId=" + z.ui.comm.getUrlParam("flowInstanceId"), iconclass: 'fa fa-file' }); },//流程日志 showparent: function (ele) { z.ui.lock(ele, function () { z.ui.ajax({ url: workflowHost + "/Transfer/showParent", data: {flowInstanceId: z.ui.comm.getUrlParam("flowInstanceId")}, complete: function () { z.ui.unLock(ele); }, success: function (res) { z.webcontainer.openTab({ id: 'workflowMain_Log_' + z.ui.comm.getUrlParam("flowInstanceId"), title: res.name, url: res.url, iconclass: 'fa fa-file' }); } }) }) }, leftCfg: function (postData, fun) { z.ui.ajax({ url: workflowHost + "/Transfer/flowPageConfig", data: postData, success: function (res) { if (fun instanceof Function) { fun(); } } }) },//左侧设置 cyyj: function (ele) { var yjnrObj = ele.parent().parent().find("[name=yjnr]") z.ui.modal("cyyj_modal").init({ url: workflowHost + '/TFlowOpPersonal/show', data: {activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), yjnr: yjnrObj.html()}, title: '常用意见', width: 850, height: 430, showHead: true, showCloseBtn: true, showMask: true, onLoadSuccess: function (res, modal) { modal.find("[name=user_opinion_text]").val(yjnrObj.val()); }, }) z.ui.modal("cyyj_modal").custom.refeash = function (res) { yjnrObj.val(res); //ReviewRight->ReviewLine opinionEdit->意见内容 }; },//常用意见 getNextActivity: function (fun) { z.ui.ajax({ url: workflowHost + "/Transfer/getNextActivity", data: { activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), participantId: z.ui.comm.getUrlParam("participant"), flowOpinion: JSON.stringify(z.workflow.getEditOpinion()), height: $(window).height(), width: $(window).width() }, complete: function () { if (fun instanceof Function) { fun(); } }, success: function (result) { if (result.isTransfer == 1 && result.iBatchTransfer == 0) {//直接转件 var transferTip = result.transferTip; if (transferTip && transferTip != null) { if (transferTip.index != 2 && (!result.tip || !result.tip[0] || !result.tip[0].users)) { flowFun.transferSuccessTip(transferTip.tip, 1000); return; } } flowFun.transferSuccess(result.tip); } else {//弹窗选中参与人后转件 var rotatePartsDto = result.rotatePartsDto; if (!rotatePartsDto || rotatePartsDto.rotatePartsData.length == 0) { z.ui.alertWarning("数据错误请联系管理员", 1000); return; } flowFun.transferProcess(result); } } }); },//获取下一步活动(普通转件) getSameLevelActivity: function (position, fun) { z.ui.ajax({ url: workflowHost + "/Transfer/getSameLevelNextActivity", data: { activityInstanceId: z.ui.comm.getUrlParam("activityInstanceId"), participantId: z.ui.comm.getUrlParam("participant"), position: position, flowOpinion: JSON.stringify(z.workflow.getEditOpinion()), height: $(window).height(), width: $(window).width() }, complete: function () { if (fun instanceof Function) { fun(); } }, success: function (result) { if (result.isTransfer == 1 && result.iBatchTransfer == 0) {//直接转件 var transferTip = result.transferTip; if (transferTip && transferTip != null) { if (transferTip.index != 2 && (!result.tip || !result.tip[0] || !result.tip[0].users)) { flowFun.transferSuccessTip(transferTip.tip, 1000); return; } } flowFun.transferSuccess(result.tip); } else {//弹窗选中参与人后转件 var rotatePartsDto = result.rotatePartsDto; if (!rotatePartsDto || rotatePartsDto.rotatePartsData.length == 0) { z.ui.alertWarning("数据错误请联系管理员", 1000); return; } result["position"] = position; flowFun.transferProcess(result, true); } } }); },//获取下一步活动(同级转件) transferProcess: function (transferData, iSameLevel) { z.ui.modal("transferModal").init({ title: iSameLevel ? "同级转件" : '转件',//头文字 content: transferData.transferHtml, //页面html模板,与url互斥 // width: 900, // height: transferModalConfig.modalHeight, showHead: true,//显示头 showCloseBtn: true,//显示关闭按钮 showMask: true,//显示背景遮罩 onLoadSuccess: function (res, modal) { z.ui.comp.init("[name=transfer-form]"); //清空批量选择待办件 transferModalConfig.batchSelectData = []; transferModalConfig.reloadModal(transferData, iSameLevel); } }); },//弹窗转件 transferSuccess: function (tabUserArr) { var resMsg = []; var msgLen = 5;//已成功转至 for (var i = 0; i < tabUserArr.length; i++) { var tabUser = tabUserArr[i]; if (tabUser.users) { msgLen += tabUser.users.length; var users = tabUser.users.length > 30 ? tabUser.users.substr(0, 30) + "..." : tabUser.users; resMsg.push("已成功转至[" + tabUser.name + "]-[" + users + "]"); } else if (tabUser.split) {//拆件 resMsg.push("转件成功"); } else {//归档节点无参与人 resMsg.push("已成功归档"); } } if (resMsg.length == 0) { resMsg.push("转件成功"); } //弹出提示消息两秒后关闭窗口 10字/秒阅读速度 msgLen = msgLen.length < 10 ? 10 : msgLen.length; flowFun.transferSuccessTip(resMsg.join("
"), ((msgLen / 10.0).toFixed(3)) * 1000); },//转件结束事件 transferSuccessTip: function (successTip, displayTime) { z.ui.alertSuccess(successTip, displayTime, function () { z.ui.modal("transferModal").close(); $("[name='closeBtn']").click();//关闭当前TAB z.webcontainer.closeCurrentTab(); }); },//转件成功提示信息 openCCModal: function (participants, dialogHtml) { z.ui.modal("carbonCopyDialog").init({ title: '流程抄送',//头文字 content: dialogHtml, //页面html模板,与url互斥 width: 900, height: ccModalConfig.modalHeight, showHead: true,//显示头 showCloseBtn: true,//显示关闭按钮 showMask: true,//显示背景遮罩 onLoadSuccess: function (modal, res) { ccModalConfig.reloadModal(participants); },//加载完成事件 onBeforeShow: function (modal) { },//显示前事件,返回false阻止显示 onAfterShow: function (modal) { },//显示后事件 onBeforeClose: function (modal) { },//点击关闭按钮前事件,返回false阻止关闭 onAfterClose: function (modal) { },//点击关闭按钮后事件 onLoadError: function (xhr, ts, err) {//加载失败 } }); }, leftMenuClick: function (url, type, fun) { if (!url) { z.ui.alertWarning("错误的表单地址"); return; } reloadBtnHtml(url, fun); var thatId = z.ui.comm.getUrlParam("activityInstanceId") + "_" + z.ui.comm.getUrlParam("_fm"); var thisRight = $("[name=right_" + thatId + "]"); if (z.workflow.canFormEdit === true) { var ifm = thisRight.children("iframe"); if (ifm.length > 0) { z.webcontainer.messager.send({ targetwindow: ifm[0].contentWindow, msgreceiveevent: "onBeforeSelectNode", data: {}, callback: function (result, msg, e) { selectNode(); } }); } else { selectNode(); } } else { selectNode() } function reloadBtnHtml(url, fun) { var flowInstanceId = z.ui.comm.getStrUrlParam(url, "flowInstanceId"); var activityInstanceId = z.ui.comm.getStrUrlParam(url, "activityInstanceId"); var v = z.ui.comm.getStrUrlParam(url, "_o"); var f = z.ui.comm.getStrUrlParam(url, "first"); var fid = z.ui.comm.getStrUrlParam(url, "_fm"); var uId = z.ui.comm.getStrUrlParam(url, "userId"); z.ui.ajax({ url: workflowHost + "/Transfer/getBtnHtml", data: { flowInstanceId: flowInstanceId, activityInstanceId: activityInstanceId, v: v, f: f, fid: fid, uId: uId }, success: function (result) { $("[name=workflow-top-btns]").html(result); if (fun instanceof Function) { fun(); } } }) } function selectNode() { z.workflow.canFormEdit = z.ui.comm.getStrUrlParam(url, "_o") === "v"; var modalDiv = $(".workflow-right"); //父容器 // thisRight.hide(); //隐藏当前活动节点的内容 modalDiv.children("[name^='right']").hide(); //隐藏全部right节点iframe var selid = z.ui.comm.getStrUrlParam(url, "activityInstanceId") + "_" + z.ui.comm.getStrUrlParam(url, "_fm"); if (selid == thatId) {//当前活动节点 thisRight.show(); if (z.workflowMaterials.treeObj) { z.workflowMaterials.treeObj.setBack(thisRight); } } else { //显示选中节点iframe var frameDiv = $("[name=right_" + selid + "]"); if (!frameDiv || frameDiv.length == 0) { frameDiv = $("
").attr("name", "right_" + selid).css({ "width": "100%", "height": "100%" }) frameDiv.append($("