var step = 0; var gwf; $(function () { var workid = GetQueryString("WorkID"); var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork"); handler.AddPara("WorkID", workid); var ds = handler.DoMethodReturnJSON("JobSchedule_Init"); gwf= ds["WF_GenerWorkFlow"][0]; //工作记录. var tempNodes = ds["WF_Node"]; //节点. var tempDirs = ds["WF_Direction"]; //连接线. var tracks = ds["Track"]; //历史记录. var transf = ds["WF_TransferCustom"];//游离态的节点 var nodes = {}; for (var i = 0; i < tempNodes.length; i++) { var nodeID = tempNodes[i].NodeID; if (!$.isArray(nodes[nodeID])) { nodes[nodeID] = []; } nodes[nodeID].push(tempNodes[i]); } var dirs = {}; //每个节点的连线 for (var i = 0; i < tempNodes.length; i++) { var nodeDir = []; var nodeID = tempNodes[i].NodeID; for (var k = 0; k < tempDirs.length; k++) { if (tempDirs[k].Node == nodeID) nodeDir.push({ ToNodeID: tempDirs[k].ToNode }); else continue; } if (nodeDir.length == 0) continue; if (!$.isArray(dirs[nodeID])) { dirs[nodeID] = []; } dirs[nodeID].push(nodeDir); } var step = 0; //获取走过的节点, 生成唯一的节点连续字符串比如 101,102,103 var nds = ""; for (var i = 0; i < tracks.length; i++) { var tk = tracks[i]; if (nds.indexOf(tk.FK_Node) != -1) continue; nds += "," + tk.FK_Node; } //把节点转化为数组. var nds = nds.split(","); for (var i = 0; i < nds.length; i++) { var nodeID = nds[i]; if (nodeID == "") continue; var currTrack = getTracksByNodeID(tracks,nodeID); if (currTrack.length != 0) {//$(".DashbCon") $("#JobSchedule").append('
'+ (currTrack[0].NodeName?currTrack[0].NodeName:'') +'

'+ (currTrack[0].EmpName == null?'':currTrack[0].EmpName == 0?'':currTrack[0].EmpName)+'

'+ (currTrack[0].SDT == null?'':currTrack[0].SDT == 0?'':currTrack[0].SDT) +'

') } } //流程未完成的状态, 输出没有经过的节点。 if (gwf.WFState != 3) { //当前停留的节点. var currNodeID = gwf.FK_Node;// $(".DashbCon") $("#JobSchedule").append('
' + nodes[currNodeID][0].Name + '
'); //递归获取未运行到的节点 ShowNextNode_DiGui(currNodeID, dirs, transf, nodes, gwf); } return; }); //根据tracks、nodeID获取当前节点的运行信息 function getTracksByNodeID(tracks,nodeID){ var curTrack=[]; for(var i =0;i
'+ node.Name +'
'); currNodeID = nextNodes[0]; }else { haveMsNode += ","+nextNodes[0]; $(".DashbCon").append('
'); for (var idx = 0; idx < nextNodes.length; idx++) { var node = nodes[nextNodes[idx]][0]; $(".multiple").append('
'+ node.Name +'
'); //ShowNextNode_DiGui(nextNodes[idx],dirs,nodes); } } } } //游离态节点的递归 function ShowNextYouLiTai_DiGui(currNodeID, transf, dirs, nodes) { for (var i = 0; i < 100; i++) { var currNode = nodes[currNodeID][0]; var nextNodes = ""; if(currNode.AtPara.indexOf("IsYouLiTai")!=-1) nextNodes = GetNextYouLiTaiNodeID(currNodeID, transf, dirs, nodes); else nextNodes = GetNextNodeID() if (nextNodes.length == 0) //最后一个节点 break; //拼接其余节点 if (nextNodes.length == 1) { haveMsNode += "," + nextNodes[0]; var node = GetNodeByNodeID(nodes, nextNodes[0]); if (node != undefined) $(".DashbCon").append('
' + node.Name + '
'); currNodeID = nextNodes[0]; } else { haveMsNode += "," + nextNodes[0]; $(".DashbCon").append('
'); for (var idx = 0; idx < nextNodes.length; idx++) { var node = GetNodeByNodeID(nodes, nextNodes[idx]); $(".multiple").append('
' + node.Name + '
'); //ShowNextNode_DiGui(nextNodes[idx],dirs,nodes); } } } } function GetNextNodeIDExpSpecNode_del(nodeID, specToNode, dirs) { for (var i = 0; i < dirs.length; i++) { var dir = dirs[i]; if (dir.Node == currNode) { if (dir.ToNode == specToNode) return 0; } } return 0; }