var copyrightid = sp.getUrlName("copyrightid"); var directionid = sp.getUrlName("directionid"); var userid = sp.getUrlName("userid"); var routeid = sp.getUrlName("routeid"); var routeinfoid = sp.getUrlName("routeinfoid"); var get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); var bpmnModeler = new BpmnJS({ container: '#canvas', //additionalModules: [customTranslateModule], keyboard: { bindTo: window }, additionalModules: [{ // 禁用左侧默认工具栏 paletteProvider: ['value', ''], // 去不干净,还是默认生成空白 dom // // 禁用滚轮滚动 // // 禁止拖动线 bendpoints: ['value', ''], // // 禁止点击节点出现contextPad contextPadProvider: ['value', ''], // // 禁止双击节点出现label编辑框 labelEditingProvider: ['value', ''] }] }); var diagramXML = ""; var doneArray = []; var processArray = []; var waitArray = []; var doneLineArray = []; function importXML(xml) { // import diagram bpmnModeler.importXML(xml, function(err) { if (err) { return console.error('could not import BPMN 2.0 diagram', err); } var canvas = bpmnModeler.get('canvas'); // zoom to fit full viewport canvas.zoom('fit-viewport'); // canvas.addMarker('fifthTask_ANONYMOUS', 'highlight'); //const successIds = highLightData.highLine.concat(highLightData.highPoint) //const procesingIds = highLightData.waitingToDo; setNodeColor(doneArray, bpmnModeler, 'nodeSuccess'); setNodeColor(processArray, bpmnModeler, 'nodeProcing'); setNodeColor(waitArray, bpmnModeler, 'nodeWaiting'); setNodeColor(doneLineArray, bpmnModeler, 'nodeLineSuccess'); }); } function getXML() { $.ajax({ type: "post", url: apiurljs.login + "workflow/getWorkFlowData", data: { "copyrightid": s4.encryptData_CBC(copyrightid) }, dataType: "text", success: function(obj) { var response = strToJson(s4.decryptData_CBC(JSON.parse(obj).data)) let domParser = new DOMParser(); let xmlDom = domParser.parseFromString(response, 'text/xml') let xmlTaskDom = xmlDom.getElementsByTagName('task') let infoArray_ = angular.element(document.body).scope().ctl.infoArray for (let i = 0; i < xmlTaskDom.length; i++) { let task = xmlTaskDom[i] let names = [] infoArray_.forEach((item => { let ENDNODEID = item.ENDNODEID let USERNAMEFROM = item.USERNAMEFROM if (ENDNODEID == task.id) { if(names.indexOf(item.USERNAME) == -1){ names.push(item.USERNAME) } // names.push(USERNAMEFROM) } })) if (names.length > 0) { let name = task.getAttribute('name') task.setAttribute("name", name + `\n(${names.join(',')})`) } } var sXML = new XMLSerializer() diagramXML = sXML.serializeToString(xmlDom); if (diagramXML == "") { //美观版,带边框的 //diagramXML = " sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138 sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26 sid-E433566C-2289-4BEB-A19C-1697048900D2 sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A \r\n\r\n"; //最简版,不带边框 diagramXML = " SequenceFlow_0gqlk33 SequenceFlow_0gqlk33 SequenceFlow_02bni32 SequenceFlow_02bni32 "; } importXML(diagramXML); }, error: function(response) { diagramXML = " SequenceFlow_0gqlk33 SequenceFlow_0gqlk33 SequenceFlow_02bni32 SequenceFlow_02bni32 "; } }); } function getRouteList() { var postData = { directionid: directionid, userid: userid, routeid: routeid, routeinfoid: routeinfoid, } $.ajax({ type: "post", url: apiurljs.login + "g2app/abase/queryDataRouteList", headers: { Authorization: "Bearer " + get_AccessToken, }, data: JSON.stringify({ data: s4.encryptData_CBC(JSON.stringify(postData)) }), dataType: "json", contentType: "application/json", success: function(obj) { var response = strToJson(s4.decryptData_CBC(obj.data)); angular.element(document.body).scope().ctl.infoArray = response.data; response.data.forEach(function(item, index) { if (item.DIRECTIONID) { item.DIRECTIONID = item.DIRECTIONID.replace("_" + copyrightid, ""); } if (item.STARTNODEID) { item.STARTNODEID = item.STARTNODEID.replace("_" + copyrightid, ""); } if (item.ENDNODEID) { item.ENDNODEID = item.ENDNODEID.replace("_" + copyrightid, ""); } }) //流转记录长读等于1 表示 if (response.data.length == 1) { doneArray.push(response.data[0].STARTNODEID); doneLineArray.push(response.data[0].DIRECTIONID); if (response.data[0].STATUS == "1") { waitArray.push(item.ENDNODEID); } else if (response.data[0].STATUS == "2" || response.data[0].STATUS == "0") { processArray.push(response.data[0].ENDNODEID); } } else { response.data.forEach(function(item, index) { doneLineArray.push(item.DIRECTIONID); if (index != response.data.length - 1) { doneArray.push(item.STARTNODEID); doneArray.push(item.ENDNODEID); } else { var myDeal = false; var myInfo = ""; var isEnd = false; if (item.USERID == "STOP") { isEnd = true; } if (item.USERID == userid) { myDeal = true; myInfo = item; } if (isEnd) { doneArray.push(item.ENDNODEID); } else { if (myDeal) { if (myInfo.STATUS == "1") { waitArray.push(item.ENDNODEID); } else if (myInfo.STATUS == "2") { processArray.push(item.ENDNODEID); } } else { if (item.STATUS == "1") { waitArray.push(item.ENDNODEID); } else if (item.STATUS == "2") { processArray.push(item.ENDNODEID); } } } } }) } getXML() }, error: function(response) { console.log(response); } }); } function setNodeColor(ids, newBpmn, colorClass) { var elementRegistry = newBpmn.get('elementRegistry'); //流程图过长解析需要时间 setTimeout(function () { ids.forEach(function (item) { if (elementRegistry._elements[item]) { var element = elementRegistry._elements[item].gfx element.classList.add(colorClass) } }) }, 100) } var app = angular.module('app', []); //定义一个全局的截图插件变量 var cropper; app.controller("formeditCtrl", ["$scope", "$http", "$timeout", "$sce", function($scope, $http, $timeout, $sce) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.tabOpen = false; //右侧是否打开 self.infoArray = []; self.loadXML1 = function() { getRouteList(); } self.loadXML2 = function() { getXML(); } self.changeInfoTab = function() { self.tabOpen = !self.tabOpen; self.loadXML2(); } self.loadXML1(); self.getItemNode = function(obj) { self.tabOpen = true; //右侧是否打开 self.loadXML2(); $scope.$apply(); var indexNum = -1; self.infoArray.forEach(function(item, index) { if (obj.id == item.ENDNODEID) { indexNum = index; } }) if (indexNum > -1) { setTimeout(function() { $(".right-show-content").scrollTop($(".item-flow-info").eq(indexNum).offset() .top); }, 100) } else { setTimeout(function() { $(".right-show-content").scrollTop(0); }, 100) } } }])