import J from"./childFlow.9a21add8.js";import{p as R}from"./playCircle.1a554fd4.js";import T from"./approvalDialog.51823266.js";import{g as P,h as L}from"./flowConfiguration.796f9d5a.js";import{_ as V,d as q,y as B,x as M,b as F,r as _,o as U,al as g,c as u,e as z,f as G,h as a,i,g as d,t as H,u as O,j as c,F as K,L as Q,q as W}from"./index.149277cd.js";import{p as X}from"./flowPathConfiguration.6bf93928.js";import"./index.c31c2933.js";import"./unitManage.e6941394.js";const Y={class:"flex justify-between items-center"},Z={class:"overflow-x-auto flex"},ee={class:"node flex flex-1 flex-col items-center justify-center"},te={class:"start_box node_box text-white flex items-center justify-center"},ne=["src"],se={class:"flex flex-col"},oe=q({name:"configEdit"}),le=Object.assign(oe,{setup(re){const{proxy:w}=W(),S=B(),v=M(),f=({key:t,type:e,item:n})=>{let s={};s={name:e==="APPROVAL"?"\u5BA1\u6279":e==="CONSTRCTION"?"\u5EFA\u8BBE\u7533\u62A5\u5BA1\u6279":e==="CC"?"\u6284\u9001":e==="SEAL"?"\u76D6\u7AE0":"",type:e,props:void 0,id:""},t===-1?m.value.splice(0,0,s):n.splice(t+1,0,s)},k=async(t,e,n,s)=>{e.splice(t,1)},p=F({visible:!1,data:{name:void 0}}),A=({key:t,item:e})=>{p.visible=!0,p.data=e[t],p.orgCode=v.query.orgCode||""},I=t=>{p.visible=!1},j=t=>{Q(()=>{Object.entries(t).forEach(e=>{p.data[e[0]]=e[1]})})},y=_(),x=_(),m=_([]),C=_({}),$=async()=>{const t=await X({processDefId:v.query.processDefId});y.value=t.data.processDefId,x.value=t.data.processDefName,C.value=t.data;const e={children:JSON.parse(t.data.process)};m.value=b([],e,!0)},b=(t,e,n)=>{if(e.branchs){const s=[];e.branchs.forEach(o=>{let r={};if(r={name:o.name,type:o.type,props:o.props,id:n?o.id:void 0},o.children&&JSON.stringify(o.children)!=="{}"){const l=[];o.children.branchs||l.push({name:o.children.name,type:o.children.type,props:o.children.props,id:n?o.children.id:void 0}),b(l,o.children,n),r.children=l}else r.children=[];s.push(r)}),t.push({type:"CONDITIONS",props:{},branchs:s})}return e.children&&JSON.stringify(e.children)!=="{}"&&(e.children.branchs||t.push({name:e.children.name,type:e.children.type,props:e.children.props,id:n?e.children.id:void 0}),b(t,e.children,n)),t},D=()=>{const t=[],e="0123456789abcdef";for(let s=0;s<36;s++)t[s]=e.substr(Math.floor(Math.random()*16),1);return t[14]="4",t[19]=e.substr(t[19]&3|8,1),t[8]=t[13]=t[18]=t[23]="-",t.join("")},N=(t,e)=>(t=t.reverse(),t.reduce((n,s,o)=>{const r=s.id||D();return e&&o===t.length-1&&(s.parent=e.id),s.branchs?(s.branchs.forEach(l=>{l.parentId=r||null,l.id=l.id||D(),l.children&&l.children.length?l.children=N(l.children,l):l.children&&!l.children.length&&delete l.children}),o?(n.parentId=r||null,{type:"route",id:r,children:n}):(s.id=r,s)):o?(n.parentId=r||null,s.id=r,s.children=n,s):(s.id=r,s)},null)),E=async()=>{let t={};const e=JSON.parse(JSON.stringify(m.value));t=t.children=JSON.parse(JSON.stringify(N(e)));const n={...C.value,process:t};delete n.created,delete n.sort,delete n.updated,delete n.version,await P(n),await L(n),w.$message.success("\u53D1\u5E03\u6210\u529F")};return U(()=>{$(),y.value=v.query.processDefId}),g("showApprovalDialog",A),g("addNode",f),g("removeNode",k),(t,e)=>{const n=u("el-button"),s=u("Plus"),o=u("el-icon"),r=u("el-popover"),l=u("el-card");return z(),G(K,null,[a(l,{shadow:"never"},{header:i(()=>[d("div",Y,[d("span",null,H(x.value),1),d("div",null,[a(n,{onClick:e[0]||(e[0]=h=>O(S).go(-1))},{default:i(()=>e[5]||(e[5]=[c("\u8FD4\u56DE")])),_:1}),a(n,{type:"primary",onClick:E},{default:i(()=>e[6]||(e[6]=[c("\u53D1\u5E03")])),_:1})])])]),default:i(()=>[d("div",Z,[d("div",ee,[d("div",te,[e[7]||(e[7]=c(" \u5F00\u59CB ")),d("img",{src:O(R)},null,8,ne)]),a(r,{placement:"right",width:100,trigger:"hover"},{reference:i(()=>[a(o,{class:"add_icon mt-20 mb-20 cursor-pointer"},{default:i(()=>[a(s)]),_:1})]),default:i(()=>[d("div",se,[d("p",null,[a(n,{class:"mb-8 w-full",onClick:e[1]||(e[1]=h=>f({key:-1,type:"APPROVAL"}))},{default:i(()=>e[8]||(e[8]=[c(" \u5BA1\u6279\u4EBA ")])),_:1})]),d("p",null,[a(n,{class:"ml-1 mb-8 w-full",onClick:e[2]||(e[2]=h=>f({key:-1,type:"SEAL"}))},{default:i(()=>e[9]||(e[9]=[c(" \u76D6\u7AE0\u4EBA ")])),_:1})]),d("p",null,[a(n,{class:"ml-1 mb-8 w-full",onClick:e[3]||(e[3]=h=>f({key:-1,type:"CC"}))},{default:i(()=>e[10]||(e[10]=[c(" \u6284\u9001\u4EBA ")])),_:1})]),d("p",null,[a(n,{class:"mb-8 w-full",onClick:e[4]||(e[4]=h=>f({key:-1,type:"CONSTRCTION"}))},{default:i(()=>e[11]||(e[11]=[c(" \u5EFA\u8BBE\u5BA1\u6279\u4EBA ")])),_:1})])])]),_:1}),a(J,{"node-data":m.value},null,8,["node-data"]),e[12]||(e[12]=d("div",{class:"end_box node_box text-white flex items-center justify-center"}," \u6D41\u7A0B\u7ED3\u675F ",-1))])])]),_:1}),a(T,{visible:p.visible,data:p.data,"org-code":p.orgCode,onClose:I,"onUpdate:data":j},null,8,["visible","data","org-code"])],64)}}}),he=V(le,[["__scopeId","data-v-76f7f8eb"]]);export{he as default};