2025-06-02 21:34:56 +08:00

2 lines
4.4 KiB
JavaScript

import{g as t,_ as e,c as o,e as i,w as a,j as l,f as r,F as n,H as d,o as s}from"./index-C-c3zR6K.js";import{V as h,Z as c,M as p}from"./vue-treeselect-DOtaeHu9.js";var g,f={exports:{}};function m(t){h.call(this,t)}t((g||(g=1,"function"==typeof Object.create?f.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:f.exports=function(t,e){if(e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}}),f.exports))(m,h),m.prototype._modules=[].concat(h.prototype._modules,[c,p]);const u={class:"containers"},w={class:"canvas",ref:"flowCanvas"};const y=e({name:"BpmnViewer",props:{flowData:{type:Object,default:()=>{},required:!1},procInsId:{type:String,default:""}},data:()=>({bpmnViewer:null,flowDetail:{},loading:!0}),watch:{flowData:{handler(t){Object.keys(t).length>0&&(this.bpmnViewer&&this.bpmnViewer.destroy(),this.bpmnViewer=new m({container:this.$refs.flowCanvas,height:"calc(100vh - 200px)"}),this.loadFlowCanvas(t))}}},created(){},methods:{loadFlowCanvas(t){return e=this,o=null,i=function*(){try{yield this.bpmnViewer.importXML(t.xmlData),yield this.fitViewport(),void 0!==t.nodeData&&t.nodeData.length>0&&this.procInsId&&(yield this.fillColor(t.nodeData))}catch(e){}},new Promise(((t,a)=>{var l=t=>{try{n(i.next(t))}catch(e){a(e)}},r=t=>{try{n(i.throw(t))}catch(e){a(e)}},n=e=>e.done?t(e.value):Promise.resolve(e.value).then(l,r);n((i=i.apply(e,o)).next())}));var e,o,i},fitViewport(){this.zoom=this.bpmnViewer.get("canvas").zoom("fit-viewport","auto"),this.loading=!1},zoomViewport(t=!0){this.zoom=this.bpmnViewer.get("canvas").zoom(),this.zoom+=t?.1:-.1,this.zoom>=.2&&this.bpmnViewer.get("canvas").zoom(this.zoom)},fillColor(t){const e=this.bpmnViewer.get("canvas");this.bpmnViewer.getDefinitions().rootElements[0].flowElements.forEach((o=>{var i,a,l;const r=t.find((t=>t.key===o.id)),n=t.find((t=>!t.completed)),d=t[t.length-1];if("bpmn:UserTask"===o.$type)r&&(e.addMarker(o.id,r.completed?"highlight":"highlight-todo"),null==(i=o.outgoing)||i.forEach((o=>{const i=t.find((t=>t.key===o.targetRef.id));i&&(n&&r.key===n.key&&!n.completed?(e.addMarker(o.id,n.completed?"highlight":"highlight-todo"),e.addMarker(o.targetRef.id,n.completed?"highlight":"highlight-todo")):(e.addMarker(o.id,i.completed?"highlight":"highlight-todo"),e.addMarker(o.targetRef.id,i.completed?"highlight":"highlight-todo")))})));else if("bpmn:ExclusiveGateway"===o.$type)r&&(e.addMarker(o.id,r.completed?"highlight":"highlight-todo"),null==(a=o.outgoing)||a.forEach((o=>{const i=t.find((t=>t.key===o.targetRef.id));i&&(e.addMarker(o.id,i.completed?"highlight":"highlight-todo"),e.addMarker(o.targetRef.id,i.completed?"highlight":"highlight-todo"))})));else if("bpmn:ParallelGateway"===o.$type)r&&(e.addMarker(o.id,r.completed?"highlight":"highlight-todo"),null==(l=o.outgoing)||l.forEach((o=>{const i=t.find((t=>t.key===o.targetRef.id));i&&(e.addMarker(o.id,i.completed?"highlight":"highlight-todo"),e.addMarker(o.targetRef.id,i.completed?"highlight":"highlight-todo"))})));else if("bpmn:StartEvent"===o.$type)o.outgoing.forEach((i=>{if(t.find((t=>t.key===i.targetRef.id)))return e.addMarker(i.id,"highlight"),void e.addMarker(o.id,"highlight")}));else if("bpmn:EndEvent"===o.$type&&d.key===o.id&&d.completed)return void e.addMarker(o.id,"highlight")}))}}},[["render",function(t,e,h,c,p,g){const f=l("el-button"),m=l("el-tooltip"),y=l("el-button-group"),v=l("el-main"),k=l("el-container"),b=d("loading");return s(),o("div",u,[i(k,{style:{"align-items":"stretch"}},{default:a((()=>[i(v,{class:"flow-viewer"},{default:a((()=>[e[2]||(e[2]=r("div",{class:"process-status"},[r("span",{class:"intro"},"状态:"),r("div",{class:"finish"},"已办理"),r("div",{class:"processing"},"处理中"),r("div",{class:"todo"},"未进行")],-1)),n(r("div",w,null,512),[[b,p.loading]]),i(y,{class:"button-group"},{default:a((()=>[i(m,{effect:"dark",content:"适中",placement:"bottom"},{default:a((()=>[i(f,{size:"small",icon:"rank",onClick:g.fitViewport},null,8,["onClick"])])),_:1}),i(m,{effect:"dark",content:"放大",placement:"bottom"},{default:a((()=>[i(f,{size:"small",icon:"zoom-in",onClick:e[0]||(e[0]=t=>g.zoomViewport(!0))})])),_:1}),i(m,{effect:"dark",content:"缩小",placement:"bottom"},{default:a((()=>[i(f,{size:"small",icon:"zoom-out",onClick:e[1]||(e[1]=t=>g.zoomViewport(!1))})])),_:1})])),_:1})])),_:1})])),_:1})])}]]);export{y as B};