You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 lines
6.5 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var $=(c,m,d)=>new Promise((w,M)=>{var h=g=>{try{p(d.next(g))}catch(v){M(v)}},_=g=>{try{p(d.throw(g))}catch(v){M(v)}},p=g=>g.done?w(g.value):Promise.resolve(g.value).then(h,_);p((d=d.apply(c,m)).next())});import{_ as K,aC as I}from"./entry/index-CT2bBVPU-1724922878694.js";import{V as D,Z as P,M as q}from"./index-DeqOXDrL.js";import{a as U}from"./index-C7hAoacN.js";import{a6 as E,T as R,a5 as X}from"./antd-BY-1PcYE.js";import{d as Z,f as k,o as j,aa as H,_ as G,$ as L,a0 as b,k as u,a9 as f,G as T,u as y,ac as A,a3 as F,a4 as J}from"./vue-aEZWZQSa.js";const B=c=>(F("data-v-80250bc1"),c=c(),J(),c),O={class:"bpmn-viewer w-full h-full"},Q={id:"toolbar",class:"flex flex-row justify-between items-center mb-24px"},W={key:0},Y=B(()=>b("span",null,"适应屏幕(居中)",-1)),ee=B(()=>b("span",null,"缩小视图",-1)),te=B(()=>b("span",null,"放大视图",-1)),ie=Z({__name:"index",props:{type:{type:String,default:"businessKey"},xml:{type:String,required:!1},businessKey:{type:String,required:!1}},setup(c){const m=c,d=k(),w=k(),M=k(""),h=k([]),_=k([]),p=k(1);j(()=>$(this,null,function*(){switch(d.value&&d.value.destroy(),d.value=new D({container:w.value,additionalModules:[{zoomScroll:["value",""]},P,q]}),m.type){case"businessKey":if(!m.businessKey)return;const a=yield U(m.businessKey);M.value=a.xml,h.value=a.taskList,_.value=a.historyList,yield g(a.xml);break;case"xml":if(!m.xml)return;yield g(m.xml);break}}));function g(a){return $(this,null,function*(){var e;try{yield(e=d.value)==null?void 0:e.importXML(a),S(),N(),v()}catch(l){}})}function v(){var l,t;const a=(l=d.value)==null?void 0:l.get("eventBus"),e=(t=d.value)==null?void 0:t.get("overlays");!a||!e||(a.on("element.hover",r=>{let i=_.value.find(o=>o.taskDefinitionKey===r.element.id);r.element.type==="bpmn:UserTask"&&i&&setTimeout(()=>{z(r,e,i)},10)}),a.on("element.out",()=>{e.clear()}))}function z(a,e,l){e.add(a.element.id,{position:{top:a.element.height,left:0},html:`<div class="verlays">
<p>审批人员: ${l.nickName||""}<p/>
<p>节点状态:${l.status||""}</p>
<p>开始时间:${l.startTime||""}</p>
<p>结束时间:${l.endTime||""}</p>
<p>审批耗时:${l.runDuration||""}</p>
<p>流程版本V${l.version||""}.0</p>
</div>`})}function S(){var t,r,i,o;p.value=((t=d.value)==null?void 0:t.get("canvas").zoom("fit-viewport"))||1;const a=(r=document.querySelector(".bpmn-viewer .viewport"))==null?void 0:r.getBBox(),e=(i=d.value)==null?void 0:i.get("canvas").viewbox();if(!a||!e)return;const l={x:a.x+a.width/2-65,y:a.y+a.height/2};(o=d.value)==null||o.get("canvas").viewbox({x:l.x-e.width/2,y:l.y-e.height/2,width:e.width,height:e.height}),p.value=a.width/e.width*1.8}function V(a=!0){var e,l;p.value=((e=d.value)==null?void 0:e.get("canvas").zoom())||1,p.value+=a?.1:-.1,(l=d.value)==null||l.get("canvas").zoom(p.value)}function N(){var l;const a=(l=d.value)==null?void 0:l.get("canvas"),e=d.value._definitions.rootElements[0].flowElements;a&&C(e,a)}function C(a,e){const l=h.value.findLast(t=>t.completed===!1);if(l){const t=[];for(let r of a){if(r.id===l.key){t.push(r);break}t.push(r)}a=t}a.forEach(t=>{var r;if(t.$type==="bpmn:UserTask"){const i=h.value.find(o=>o.key===t.id);i&&(e.addMarker(t.id,i.completed?"highlight":"highlight-todo"),(r=t.outgoing)==null||r.forEach(o=>{const n=h.value.find(s=>s.key===o.targetRef.id);n?e.addMarker(o.id,n.completed?"highlight":"highlight-todo"):o.targetRef.$type==="bpmn:ExclusiveGateway"?(e.addMarker(o.id,i.completed?"highlight":"highlight-todo"),e.addMarker(o.targetRef.id,i.completed?"highlight":"highlight-todo"),o.targetRef.outgoing.forEach(s=>{x(s.id,s.targetRef.$type,s.targetRef.id,e,i.completed)})):o.targetRef.$type==="bpmn:ParallelGateway"?(e.addMarker(o.id,i.completed?"highlight":"highlight-todo"),e.addMarker(o.targetRef.id,i.completed?"highlight":"highlight-todo"),o.targetRef.outgoing.forEach(s=>{x(s.id,s.targetRef.$type,s.targetRef.id,e,i.completed)})):o.targetRef.$type==="bpmn:InclusiveGateway"&&(e.addMarker(o.id,i.completed?"highlight":"highlight-todo"),e.addMarker(o.targetRef.id,i.completed?"highlight":"highlight-todo"),o.targetRef.outgoing.forEach(s=>{x(s.id,s.targetRef.$type,s.targetRef.id,e,i.completed)}))}))}else if(t.$type==="bpmn:ExclusiveGateway")t.outgoing.forEach(i=>{const o=h.value.find(n=>n.key===i.targetRef.id);o&&e.addMarker(i.id,o.completed?"highlight":"highlight-todo")});else if(t.$type==="bpmn:ParallelGateway")t.outgoing.forEach(i=>{const o=h.value.find(n=>n.key===i.targetRef.id);o&&e.addMarker(i.id,o.completed?"highlight":"highlight-todo")});else if(t.$type==="bpmn:InclusiveGateway")t.outgoing.forEach(i=>{const o=h.value.find(n=>n.key===i.targetRef.id);o&&e.addMarker(i.id,o.completed?"highlight":"highlight-todo")});else if(t.$type==="bpmn:SubProcess"){const i=h.value.find(o=>o.key===t.id);i&&e.addMarker(t.id,i.completed?"highlight":"highlight-todo"),C(t.flowElements,e)}else if(t.$type==="bpmn:StartEvent")e.addMarker(t.id,"startEvent"),t.outgoing&&t.outgoing.forEach(i=>{h.value.find(n=>n.key===i.targetRef.id)&&(e.addMarker(i.id,"highlight"),e.addMarker(t.id,"highlight"))});else if(t.$type==="bpmn:EndEvent"){e.addMarker(t.id,"endEvent");const i=h.value.find(o=>o.key===t.id);if(i){e.addMarker(i.key,"highlight"),e.addMarker(t.id,"highlight");return}}})}function x(a,e,l,t,r){e==="bpmn:ExclusiveGateway"&&(t.addMarker(a,r?"highlight":"highlight-todo"),t.addMarker(l,r?"highlight":"highlight-todo")),e==="bpmn:ParallelGateway"&&(t.addMarker(a,r?"highlight":"highlight-todo"),t.addMarker(l,r?"highlight":"highlight-todo")),e==="bpmn:InclusiveGateway"&&(t.addMarker(a,r?"highlight":"highlight-todo"),t.addMarker(l,r?"highlight":"highlight-todo"))}return(a,e)=>{const l=H("a-button");return G(),L("div",O,[b("div",Q,[c.type==="businessKey"?(G(),L("div",W,[u(y(E),{color:"gray"},{default:f(()=>[T("未完成")]),_:1}),u(y(E),{color:"warning"},{default:f(()=>[T("进行中")]),_:1}),u(y(E),{color:"green"},{default:f(()=>[T("已完成")]),_:1})])):A("",!0),u(y(X),null,{default:f(()=>[u(y(R),{placement:"bottom"},{title:f(()=>[Y]),default:f(()=>[u(l,{"pre-icon":"material-symbols:center-focus-strong-outline",onClick:S})]),_:1}),u(y(R),{placement:"bottom"},{title:f(()=>[ee]),default:f(()=>[u(l,{"pre-icon":"ooui:zoom-out",onClick:e[0]||(e[0]=t=>V(!1))})]),_:1}),u(y(R),{placement:"bottom"},{title:f(()=>[te]),default:f(()=>[u(l,{"pre-icon":"ooui:zoom-in",onClick:e[1]||(e[1]=t=>V(!0))})]),_:1})]),_:1})]),b("div",{ref_key:"containerRef",ref:w,class:"w-full h-full"},null,512)])}}}),oe=K(ie,[["__scopeId","data-v-80250bc1"]]),ge=I(oe);export{ge as B};