var subFlows = []; function InitPage() { var isMobile = GetQueryString('IsMobile'); if (isMobile == null || isMobile == undefined || isMobile == "") isMobile = 0; var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork"); handler.AddUrlData(); var data = handler.DoMethodReturnString("TimeBase_Init"); if (data.indexOf('err@') == 0) { alert(data); return; } if (data == "[]") return; data = cceval('(' + data + ')'); //日志列表. var tracks = data["Track"]; //工作列表. var timeDay = ""; var checkStr = ""; var dotColor = -1; var idx = 1; //获得流程引擎注册表信息. var gwf = data["WF_GenerWorkFlow"][0]; //审核组件信息. var fwc = data["FrmWorkCheck"][0]; //获得工作人员列表. var gwls = data["WF_GenerWorkerList"]; //该流程启动的子流程数据 subFlows = data["WF_SubFlow"]; //前进的 track. 用于获取当前节点的上一个节点的track. var trackDotOfForward = null; var webUser = new WebUser(); //是否有审核组件? var isHaveCheck = false; for (var i = 0; i < tracks.length; i++) { var track = tracks[i]; // 记录审核节点。 if (track.ActionType == ActionType.WorkCheck) { isHaveCheck = true; break; } } //输出列表. zhoupeng 2017-12-19 修改算法,所有的审核动作都依靠发送来显示. var isHaveThread = false; //是否有子线程 var firstTrack; var isHaveSubFlow = false; //是否有子流程 var threadTrMyPK = ""; for (var i = 0; i < tracks.length; i++) { var track = tracks[i]; if (track.FID != 0) { if (isHaveThread == false) firstTrack = track; isHaveThread = true; if (track.ActionType != ActionType.WorkCheck) threadTrMyPK += track.MyPK + ","; continue; } var at = track.ActionType; if (at == ActionType.ForwardFL && track.NDFrom!=parseInt(GetQueryString("FK_Flow"))+"01") continue; //增加一个子线程的节点 if (isHaveThread == true) { var newRow = ""; firstTrack.EmpFrom = ""; firstTrack.EmpFromT = ""; newRow = ""; newRow += "" + GenerLeftIcon(firstTrack) + ""; newRow += ""; newRow += "子线程前进子线程前进

查看子线程时间轴

"; newRow += ""; $("#Table1 tr:last").after(newRow); } isHaveThread = false; threadTrMyPK = ""; if (track.ActionType == ActionType.FlowBBS) continue; if (track.ActionType == ActionType.WorkCheck) continue; //时间轴. var timeBase = ""; var img = ActionTypeStr(track.ActionType); img = "" + track.ActionTypeText + ""; //是否显示审批意见? var isShowCheckMsg = true; if (fwc.FWCMsgShow == "1" && track.NDFrom == GetQueryString("FK_Node") && webUser.No != track.EmpTo) { continue; //isShowCheckMsg = false; } //内容. var doc = ""; doc += img + track.NDFromT + " - " + track.ActionTypeText; if (at == ActionType.Return) { doc += "

退回到:" + track.NDToT + "退回给:" + track.EmpToT + "

"; doc += "

退回意见如下

"; } var isHaveCheck = false; var nodeSubFlows = $.grep(subFlows, function (subFlow) { return subFlow.FK_Node == track.NDFrom && subFlow.SubFlowSta==1; }); if (at == ActionType.Forward || at == ActionType.FlowOver) { doc += "

到达节点:" + track.NDToT + "到达人员:" + track.EmpToT + "

"; //判断是否隐藏 if (Hide_IsOpenFrm == true) { doc += "

查看表单

"; } if (nodeSubFlows.length!=0) doc += "

查看子流程

"; //说明审核组件采用的是2019版本 if (track.Msg != null && track.Msg != undefined && track.Msg.indexOf("WorkCheck@") != -1) { var val = track.Msg.split("WorkCheck@"); if (val.length == 2) { track.Msg = val[1]; isHaveCheck = true; doc += "

审批意见:" + track.Msg + "

"; } } else { //查找关联的审核意见 //找到该节点,该人员的审核track, 如果没有,就输出Msg, 可能是焦点字段。 for (var myIdx = 0; myIdx < tracks.length; myIdx++) { var checkTrack = tracks[myIdx]; if (checkTrack.NDFrom == track.NDFrom && checkTrack.ActionType == ActionType.WorkCheck && checkTrack.EmpFrom == track.EmpFrom) { isHaveCheck = true; doc += "

审批意见:" + checkTrack.Msg + "

"; break; } } } } //协作发送. if (at == ActionType.TeampUp) { for (var myIdx = 0; myIdx < tracks.length; myIdx++) { var checkTrack = tracks[myIdx]; if (checkTrack.NDFrom == track.NDFrom && checkTrack.ActionType == ActionType.WorkCheck && checkTrack.EmpFrom == track.EmpFrom) { var val = track.Msg.replace('null', '').split("WorkCheck@"); if (val.length == 2) track.Msg = val[1]; doc += "

会签意见:" + track.Msg.replace('null', '') + "

"; } } } //输出备注信息. var tag = track.Tag; if (tag != null) tag = tag.replace("~", "'"); var msg = track.Msg; if (msg.indexOf("WorkCheck@") != -1) { var val = track.Msg.replace('null', '').split("WorkCheck@"); if (val.length == 2) msg = val[1]; } if (msg == "0") msg = ""; if (msg != "" && isHaveCheck == false) { while (msg.indexOf('\t\n') >= 0) { msg = msg.replace('\t\n', '
'); } msg = msg.replace('null', ''); if (msg == "" || msg == undefined) msg = "无"; doc += "

"; doc += "" + msg + ""; doc += "

"; } //输出row var newRow = ""; newRow = ""; newRow += "" + GenerLeftIcon(track) + ""; newRow += ""; newRow += "" + doc + ""; newRow += ""; $("#Table1 tr:last").after(newRow); idx++; } //增加等待审核的人员, 在所有的人员循环以后. if (gwls) { var isHaveNoChecker = false; var gwl = null; for (var i = 0; i < gwls.length; i++) { var gwl = gwls[i]; if (gwl.IsPass == 1) continue; isHaveNoChecker = true; } //如果有尚未审核的人员,就输出. if (isHaveNoChecker == true) { var rowDay = ""; rowDay += "等待审批" + gwf.NodeName + ""; rowDay += ""; $("#Table1 tr:last").after(rowDay); for (var i = 0; i < gwls.length; i++) { var html = ""; var gwl = gwls[i]; if (gwl.IsPass == 1) continue; if (gwl.IsPass == 3 || gwl.IsPass < 0) continue; var doc = ""; if (Hide_IsRead == true) { doc += "
"; if (gwl.IsRead == "1") doc += "已阅
"; else doc += "未阅"; } doc += "

审批人:"; doc += gwl.FK_EmpText; doc += "

"; //判断是否隐藏 doc += "

"; doc += "应完成日期:"; doc += gwl.SDT +''; doc += "工作到达日期:"; doc += gwl.RDT; doc += "

"; //到达时间. var toTime = gwl.RDT; var toTimeDot = toTime.replace(/\-/g, "/"); toTimeDot = new Date(Date.parse(toTimeDot.replace(/-/g, "/"))); //当前发生日期. timeDot = new Date(); doc += "

"; doc += "已经耗时:"; doc += GetSpanTime(toTimeDot, timeDot) +''; //应该完成日期. toTime = gwl.SDT; toTimeDot = toTime.replace(/\-/g, "/"); toTimeDot = new Date(Date.parse(toTimeDot.replace(/-/g, "/"))); //当前发生日期. timeDot = new Date(); var timeLeft = GetSpanTime(timeDot, toTimeDot); if (timeLeft != 'NaN秒') { if (timeLeft.startsWith('-')) { doc += "已超时:"; doc += timeLeft.substring(1, timeLeft.length) + '' } else { doc += "还剩余:"; doc += timeLeft + '' }; } doc += "

"; var nodeSubFlows = $.grep(subFlows, function (subFlow) { return subFlow.FK_Node == gwl.FK_Node && subFlow.SubFlowSta == 1; }); if (nodeSubFlows.length != 0) doc += "

查看子流程

"; var left = "
"; left += "
"; left += "" + gwl.FK_EmpText; left += "
"; var newRow = ""; newRow = ""; newRow += "" + left + ""; newRow += ""; newRow += "" + doc + ""; newRow += ""; $("#Table1 tr:last").after(newRow); } } } //调整大小. if (window.screen) { var w = screen.availWidth; var h = screen.availHeight; window.moveTo(0, 0); window.resizeTo(w, h); } } //子线程,子流程的时间轴轨迹 function OpenSubThreadTime(workID, mypks) { OpenBootStrapModal("./TimeSubThread.htm?MyPKs=" + mypks + "&FK_Flow=" + GetQueryString("FK_Flow") + "&FK_Node=" + GetQueryString("FK_Node"), "SubThread", "子线程", 500, 600); } /** * 父流程启动的子流程 * @param {any} workID */ function OpenSubFlowTable(obj,workid,fk_node) { var nodeSubFlows = $.grep(subFlows, function (subFlow) { return subFlow.FK_Node == fk_node && subFlow.SubFlowSta == 1; }); //显示一个table,包含启动的子流程名称和启动的子流程实例 var _html = ""; var gwfs = new Entities("BP.WF.GenerWorkFlows"); if (workid == null || workid == undefined) workid = 0; gwfs.Retrieve("PWorkID", workid, "PNodeID", fk_node); nodeSubFlows.forEach(function (subFlow) { _html += subFlow.SubFlowName + "
"; _html += "
" $.each(gwfs, function (i, gwf) { if (gwf.FK_Flow == subFlow.SubFlowNo) { _html +=""+gwf.Title + "
"; } }) }); var p = $(obj).offset(); $('#subFlowDiv').html(_html); $('#subFlowinfo').offset({ top: p.top + 20 - 2, left: p.left+30 }); $('#subFlowinfo').show(); } /* 打开子流程表单. */ function OpenSubFlow(workid, flowNo, nodeID, pworkid) { var url = "../../MyView.htm?WorkID=" + workid + "&FK_Flow=" + flowNo + "&FK_Node=" + nodeID+ "&PWorkID=" + pworkid+"&IsReadonly=1"; window.open(url); //window.location.url = url; return; } //生成左边的icon. function GenerLeftIcon(track) { //左边的日期点. var left = "
"; days = track.RDT.substring(5, 16); days = days.replace('-', '月'); days = days.replace(' ', '日'); days = days.replace(':', '时'); left += "
"; left += track.EmpFromT; left += "" + days + "分"; left += "
"; return left; } function GetSpanTime(date1, date2) { ///计算date2-date1的时间差,返回使用“x天x小时x分x秒”形式的字符串表示 var date3 = date2.getTime() - date1.getTime(); //时间差秒 if (date1.getTime() > date2.getTime()) date3 = date1.getTime() - date2.getTime(); var str = ''; //计算出相差天数 var days = Math.floor(date3 / (24 * 3600 * 1000)); if (days > 0) { str += days + '天'; } //计算出小时数 var leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数 var hours = Math.floor(leave1 / (3600 * 1000)); if (hours > 0) { str += hours + '小时'; } //计算相差分钟数 var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数 var minutes = Math.floor(leave2 / (60 * 1000)); if (minutes > 0) { str += minutes + '分'; } var leave3 = leave2 % (60 * 1000); var seconds = Math.floor(leave3 / 1000); if (seconds > 0) str += seconds + '秒'; if (date1.getTime() > date2.getTime()) return "-" + str; return str; if (seconds == NaN) return date1 + "," + date2; return str; return str; } /**Begin - Form Controls ***************/ var ActionType = { /// /// 发起 /// Start: 0, /// /// 前进(发送) /// Forward: 1, /// /// 退回 /// Return: 2, /// /// 退回并原路返回. /// ReturnAndBackWay: 201, /// /// 移交 /// Shift: 3, /// /// 撤消移交 /// UnShift: 4, /// /// 撤消发送 /// UnSend: 5, /// /// 分流前进 /// ForwardFL: 6, /// /// 合流前进 /// ForwardHL: 7, /// /// 流程正常结束 /// FlowOver: 8, /// /// 调用起子流程 /// CallChildenFlow: 9, /// /// 启动子流程 /// StartChildenFlow: 10, /// /// 子线程前进 /// SubFlowForward: 11, /// /// 取回 /// Tackback: 12, /// /// 恢复已完成的流程 /// RebackOverFlow: 13, /// /// 强制终止流程 For lijian:2012-10-24. /// FlowOverByCoercion: 14, /// /// 挂起 /// Hungup: 15, /// /// 取消挂起 /// UnHungup: 16, /// /// 强制移交 /// ShiftByCoercion: 17, /// /// 催办 /// Press: 18, /// /// 逻辑删除流程(撤销流程) /// DeleteFlowByFlag: 19, /// /// 恢复删除流程(撤销流程) /// UnDeleteFlowByFlag: 20, /// /// 抄送 /// CC: 21, /// /// 工作审核(日志) /// WorkCheck: 22, /// /// 删除子线程 /// DeleteSubThread: 23, /// /// 请求加签 /// AskforHelp: 24, /// /// 加签向下发送 /// ForwardAskfor: 25, /// /// 自动条转的方式向下发送 /// Skip: 26, /// /// 队列发送 /// Order: 27, /// /// 协作发送 /// TeampUp: 28, /// /// 流程评论 /// FlowBBS: 29, /// /// 信息 /// Info: 100 }; function ActionTypeStr(at) { switch (at) { case ActionType.Start: return "../../Img/Action/Start.png"; case ActionType.Forward: return "../../Img/Action/Forward.png"; case ActionType.Return: return "../../Img/Action/Return.png"; case ActionType.ReturnAndBackWay: return "../../Img/Action/ReturnAndBackWay.png"; case ActionType.Shift: return "../../Img/Action/Shift.png"; case ActionType.UnShift: return "../../Img/Action/UnShift.png"; case ActionType.UnSend: return "../../Img/Action/UnSend.png"; case ActionType.ForwardFL: return "../../Img/Action/ForwardFL.png"; case ActionType.ForwardHL: return "../../Img/Action/ForwardHL.png"; case ActionType.CallChildenFlow: return "../../Img/Action/CallChildenFlow.png"; case ActionType.StartChildenFlow: return "../../Img/Action/StartChildenFlow.png"; case ActionType.SubFlowForward: return "../../Img/Action/SubFlowForward.png"; case ActionType.RebackOverFlow: return "../../Img/Action/RebackOverFlow.png"; case ActionType.FlowOverByCoercion: return "../../Img/Action/FlowOverByCoercion.png"; case ActionType.Hungup: return "../../Img/Action/Hungup.png"; case ActionType.UnHungup: return "../../Img/Action/UnHungup.png"; case ActionType.ShiftByCoercion: return "../../Img/Action/ShiftByCoercion.png"; case ActionType.Press: return "../../Img/Action/Press.png"; case ActionType.DeleteFlowByFlag: return "../../Img/Action/DeleteFlowByFlag.png"; case ActionType.UnDeleteFlowByFlag: return "../../Img/Action/UnDeleteFlowByFlag.png"; case ActionType.CC: return "../../Img/Action/CC.png"; case ActionType.WorkCheck: return "../../Img/Action/WorkCheck.png"; case ActionType.AskforHelp: return "../../Img/Action/AskforHelp.png"; case ActionType.Skip: return "../../Img/Action/Skip.png"; case ActionType.Order: return "../../Img/Action/Order.png"; case ActionType.TeampUp: return "../../Img/Action/TeampUp.png"; case ActionType.FlowBBS: return "../../Img/Action/FlowBBS.png"; case ActionType.Info: return "../../Img/Action/Info.png"; default: return "../../Img/dot.png"; } }