var webUser = new WebUser(); if (typeof FrmSubFlowSta == "undefined") { var FrmSubFlowSta = {} // 不可用 FrmSubFlowSta.Disable = 0, // 可用 FrmSubFlowSta.Enable = 1, // 只读 FrmSubFlowSta.Readonly = 2 } if (typeof SFShowCtrl == "undefined") { var SFShowCtrl = {} // 所有的子线程都可以看到 SFShowCtrl.All = 0, // 仅仅查看我自己的 SFShowCtrl.MySelf = 1 } //传一个节点对象. function SubFlow_Init(node) { var workID = GetQueryString("WorkID"); if (workID == null || workID == undefined) workID = 0; var flowNo = GetQueryString("FK_Flow"); var nodeID = node.NodeID; // GetQueryString("FK_Node"); var currNodeID = GetQueryString("FK_Node"); var pworkID = GetQueryString("WorkID"); if (pworkID == null || pworkID == undefined) pworkID = 0; var _Html = ""; var subFlows = new Entities("BP.WF.Template.SFlow.SubFlowHands"); subFlows.Retrieve("FK_Node", nodeID, "SubFlowType", 0, "Idx"); //处理累加表单问题,如果当前节点与,绑定子流程的节点不一致,就把他设置为只读. if (currNodeID != nodeID) { for (var i = 0; i < subFlows.length; i++) { var en = subFlows[i]; en.SubFlowSta = 2; } } //查询出来所有子流程的数据. var fsf = new Entity("BP.WF.Template.SFlow.FrmSubFlow", nodeID); var subFlowGuids = $.grep(subFlows, function (subFlow) { return subFlow.SubFlowStartModel !=0; }); //表示存在批量发起子流程 if (subFlowGuids.length != 0) { return ShowBtnListSubFlow(subFlows, fsf, node, workID, pworkID, flowNo, nodeID); } return ShowTableSubFlow(subFlows, fsf, node, workID, pworkID, flowNo, nodeID); } //自定义展示子流程 function ShowBtnListSubFlow(subFlows, fsf, node, workID, pworkID, flowNo, nodeID) { var _Html = ""; var basePath = "./"; var currUrl = GetHrefUrl(); if (currUrl.indexOf("Admin/FoolFormDesigner/Designer.htm") != -1) basePath = "../../"; for (var i = 0; i < subFlows.length; i++) { var subFlow = subFlows[i]; //如果子流程为启动模式 /*if (fsf.SFSta == FrmSubFlowSta.Enable && GetQueryString("DoType") != "View") { //增加启动按钮 if (subFlow.SubFlowModel == 0 || subFlow.SubFlowModel == null) { //下级子流程. _Html += "
"; } if (subFlow.SubFlowModel == 1) { //平级子流程. if (gwf == null) gwf = new Entity("BP.WF.GenerWorkFlow", workID); //如果当前的流程不是子流程,就不处理. if (gwf.PWorkID == 0) { _Html += "
 " + subFlow.SubFlowName + "
为子流程的时候才能启动(" + subFlow.SubFlowName + ")]
"; } else { pworkID = gwf.PWorkID; //传递启动该子流程的流程的信息 IsSameLevel = 1;SLWorkID=workId _Html += "
"; } } }*/ //} else { // _Html += "
" + subFlow.SubFlowName + "
"; //} _Html += "
" + subFlow.SubFlowName + "
"; var gwfs = new Entities("BP.WF.GenerWorkFlows"); if (fsf.SFShowCtrl == SFShowCtrl.All) gwfs.Retrieve("PWorkID", pworkID, "FK_Flow", subFlow.SubFlowNo, "WFState"); //流程. else gwfs.Retrieve("PWorkID", pworkID, "FK_Flow", subFlow.SubFlowNo, "Starter", webUser.No, "WFState"); //流程. _Html += "
"; for (var j = 0; j < gwfs.length; j++) { var item = gwfs[j]; if (item.WFState == 1) { //只显示标题 _Html += "
" + GetPara(item.AtPara, "SubFlowGuideEnNameFiled") + "
"; continue; } var url = basePath+"MyView.htm?WorkID=" + item.WorkID + "&FK_Flow=" + item.FK_Flow + "&IsCheckGuide=1&Frms=" + item.Paras_Frms + "&FK_Node=" + item.FK_Node + "&PNodeID=" + item.PNodeID + "&PWorkID=" + item.PWorkID; _Html += "
" + item.Title + "
"; } _Html += "
"; } return _Html; } function GetState(wfState) { switch (parseInt(wfState)) { case 1: return "草稿"; case 2: return "运行中"; break; case 3: //已完成. return "已完成"; break; case 4: return "挂起"; case 5: return "退回"; case 6: return "转发"; case 7: return "删除"; case 8: return "加签"; case 11: return "加签回复"; default: return "其它"; } } //表格模式展示子流程 function ShowTableSubFlow(subFlows, sf, node, workID, pworkID, flowNo, nodeID) { var _Html = ""; _Html += ""; _Html += ""; _Html += ""; _Html += ""; _Html += ""; _Html += ""; _Html += ""; _Html += ""; _Html += ""; _Html += ""; //要兼容旧版本. if (subFlows.length == 0 && sf.SFDefInfo != "") { var strs = sf.SFDefInfo.split(','); for (var idx = 0; idx < strs.length; idx++) { var flowNo = strs[idx]; if (flowNo == null || flowNo == "") continue; var en = new Entity("BP.WF.Template.SFlow.SubFlowHand"); en.FK_Node = nodeID; en.SubFlowNo = flowNo; en.SetPKVal(flowNo + "_" + nodeID + "_0"); en.Insert(); } } var tdHtml = ""; var imgbasePath = "./"; var currUrl = GetHrefUrl(); if (currUrl.indexOf("Admin/FoolFormDesigner/Designer.htm") != -1) imgbasePath = "../../"; if (currUrl.indexOf("FrmGener.htm") != -1) imgbasePath = "../"; for (var i = 0; i < subFlows.length; i++) { var subFlow = subFlows[i]; if (subFlow.SubFlowSta == 0) continue; //如果是禁用. @0=禁用@1=启用@2=只读 if (sf.SFSta == FrmSubFlowSta.Enable && subFlow.SubFlowSta == 1 && GetQueryString("DoType") != "View") { if (subFlow.SubFlowModel == 0 || subFlow.SubFlowModel == null) { //下级子流程. tdHtml = "
 " + subFlow.SubFlowName + "
[" + sf.SFCaption + "]"; } if (subFlow.SubFlowModel == 1) { //平级子流程. if (gwf == null) gwf = new Entity("BP.WF.GenerWorkFlow", workID); //如果当前的流程不是子流程,就不处理. if (gwf.PWorkID == 0) { tdHtml = "
 " + subFlow.SubFlowName + "
为子流程的时候才能启动(" + subFlow.SubFlowName + ")]"; } else { pworkID = gwf.PWorkID; //传递启动该子流程的流程的信息 IsSameLevel = 1;SLWorkID=workId tdHtml = "
 " + subFlow.SubFlowName + "
[" + sf.SFCaption + "]"; } } } if (sf.SFSta == FrmSubFlowSta.Readonly || subFlow.SubFlowSta == 2 || GetQueryString("DoType") == "View") tdHtml = "
 " + subFlow.SubFlowName + "
"; _Html += "
"; _Html += ""; _Html += ""; //该流程的子流程信息. var gwfs = new Entities("BP.WF.GenerWorkFlows"); if (sf.SFShowCtrl == SFShowCtrl.All) gwfs.Retrieve("PWorkID", pworkID, "FK_Flow", subFlow.SubFlowNo); //流程. else gwfs.Retrieve("PWorkID", pworkID, "FK_Flow", subFlow.SubFlowNo, "Starter", webUser.No); //流程. for (var j = 0; j < gwfs.length; j++) { var item = gwfs[j]; if (item.WFState == 0) continue; //平级子流程,获取平级的workID var slWorkID = GetPara(item.AtPara, "SLWorkID"); if (slWorkID != null && slWorkID != undefined && slWorkID != GetQueryString("WorkID")) continue; _Html += ""; if (item.StarterName == null || item.StarterName == "") _Html += ""; else _Html += ""; if (item.TodoEmps.indexOf( webUser.No + "," + webUser.Name + ";" ) >= 0) { _Html += ""; } else { if (sf.SFOpenType == 0) { _Html += ""; } else { _Html += ""; } } //到达节点名称. if (item.NodeName == null || item.NodeName == "") _Html += ""; else _Html += ""; //流程的状态 _Html += ""; var emps = item.TodoEmps.split(';'); var myemps = ""; for (var idx = 0; idx < emps.length; idx++) { var empstrs = emps[idx]; if (empstrs == null) continue; if (empstrs == '' || empstrs.length == 0 || empstrs == null) continue; empstrs = emps[idx].split(','); myemps += "" + empstrs[1] + ","; } //到达人员. _Html += ""; //日期. if (item.RDT == null || item.RDT == "") _Html += ""; else _Html += ""; //流程备注. //if (item.FlowNote == null) // _Html += ""; //else // _Html += ""; _Html += ""; } } _Html += "
发起人标题停留节点状态处理人处理时间信息
" + tdHtml + "
 " + item.StarterName + ""; _Html += " " + item.Title + ""; _Html += " " + item.Title + ""; _Html += " " + item.Title + " " + item.NodeName + "" + GetState(item.WFState) + "" + myemps + " " + item.RDT + "" + item.FlowNote + "
"; return _Html; } //删除子流程 function DeleteSubFlowDraf(workid, flowNo) { var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt"); handler.AddPara("WorkID", workid); handler.AddPara("FK_Flow", flowNo); var data = handler.DoMethodReturnString("SubFlowGuid_DeleteSubFlowDraf"); if (data.indexOf("err@") != -1) { alert(data); console.log(data); return; } $("#" + workid).remove(); } function InsertSubFlows(flowNo, fid, workid, layer, html) { //该流程的子流程信息, 并按照流程排序. var gwfs = new Entities("BP.WF.GenerWorkFlows"); gwfs.Retrieve("PWorkID", workid, "FK_Flow"); //流程. if (gwfs.Count == 0) return; var currUrl = GetHrefUrl(); if (currUrl.indexOf("Admin/FoolFormDesigner/Designer.htm") != -1) imgbasePath = "../../"; var myFlowNo = ""; var item = null; for (var i = 0; i < gwfs.length; i++) { item = gwfs[i]; if (item.WFState == 0) continue; if (myFlowNo.indexOf(item.FK_Flow) == -1) { myFlowNo = myFlowNo + "," + item.FK_Flow; //输出流程. var fl = new Entity("BP.WF.Flow", item.FK_Flow); var tdhtml = "
" + GenerSpace(layer * 2) + " " + fl.Name + "
"; html += ""; html += "" + tdhtml + ""; html += ""; } html += ""; html += " "; html += GenerSpace(layer * 2) + " " + item.Title + ""; //到达节点名称. if (item.NodeName == null || item.NodeName == "") html += " "; else html += "" + item.NodeName + ""; if (item.WFState == 3) html += "已完成"; else html += "未完成"; //到达人员. htm += "" + item.TodoEmps + ""; //日期. if (item.RDT == null || item.RDT == "") html += " "; else html += "" + item.RDT + ""; //流程备注. // htm += "" + item.FlowNote + ""; html += ""; //加载他下面的子流程. InsertSubFlows(item.FK_Flow, item.FK_Node, item.WorkID, layer + 1, html); } return html; } function GenerSpace(spaceNum) { if (spaceNum <= 0) return ""; var strs = ""; while (spaceNum != 0) { strs += "  "; spaceNum--; } return strs; } function RSize() { if (document.body.scrollWidth > (window.screen.availWidth - 100)) { window.dialogWidth = (window.screen.availWidth - 100).toString() + "px" } else { window.dialogWidth = (document.body.scrollWidth + 50).toString() + "px" } if (document.body.scrollHeight > (window.screen.availHeight - 70)) { window.dialogHeight = (window.screen.availHeight - 50).toString() + "px" } else { window.dialogHeight = (document.body.scrollHeight + 115).toString() + "px" } window.dialogLeft = ((window.screen.availWidth - document.body.clientWidth) / 2).toString() + "px" window.dialogTop = ((window.screen.availHeight - document.body.clientHeight) / 2).toString() + "px" } function NoSubmit(ev) { if (window.event.srcElement.tagName == "TEXTAREA") return true; if (ev.keyCode == 13) { window.event.keyCode = 9; ev.keyCode = 9; return true; } return true; } function OpenIt(url) { var newWindow = window.open(url, 'card', 'width=700,top=50,left=50,height=500,scrollbars=yes,resizable=yes,toolbar=false,location=false'); newWindow.focus(); var loop = setInterval(function () { if (newWindow.closed) { clearInterval(loop); parent.location.reload(); } }, 1); return; }