UNPKG

zb-admin-packages

Version:

内部G6封装,需要在Element安装使用后使用

2 lines (1 loc) 45.1 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@antv/g6"),require("lodash/uniqueId"),require("vue")):"function"==typeof define&&define.amd?define(["@antv/g6","lodash/uniqueId","vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).zbAdminPackages=t(e.G6,e.uniqueId,e.Vue)}(this,(function(G6,uniqueId,Vue){"use strict";function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var G6__default=_interopDefaultLegacy(G6),uniqueId__default=_interopDefaultLegacy(uniqueId),Vue__default=_interopDefaultLegacy(Vue);const trim=function(e){return e.replace(/(^\s*)|(\s*$)/g,"")},isEmpty=function(e){return null==e||void 0===e||"string"==typeof e&&(""===trim(e)||"null"===trim(e))},checkParentKey=function(e,t){if(isEmpty(e))return!0;let o;const n=t=>{const{parent:i,model:s}=t._cfg;isEmpty(i)?o=!1:s.condition.key!=e?n(i):o=!0};return n(t),o},deepCopy=e=>JSON.parse(JSON.stringify(e)),deepClone=function(e,t=new WeakMap){if(null==e)return e;if(e instanceof RegExp)return new RegExp(e);if(e instanceof Date)return new Date(e);if("object"!=typeof e)return e;if(t.has(e))return t.get(e);const o=new e.constructor;t.set(e,o);for(const n in e)e.hasOwnProperty(n)&&(o[n]=deepClone(e[n],t));return o},uniqueTimeId=function(){return uniqueId__default.default(`nodeId${(new Date).getTime()}`)},uniqueProcessKey=function(){return uniqueId__default.default(`processKey${(new Date).getTime()}`)},injectId=function(e){return e.id=uniqueTimeId(),e},uniqueConditionKey=function(){return uniqueId__default.default(`conditionKey${(new Date).getTime()}`)},deepCopyCondition=function(e){const t=function(e){e.id=uniqueTimeId(),e.conditionKey=uniqueConditionKey(),e.children&&e.children.length>0&&e.children.forEach((e=>{t(e)}))};return t(e),e},getRangeLable=function(e){let t="";return e.max?(e.min&&(t+=e.min,t+="<="===e.left?"≤":"<"),t+="值",t+="<="===e.right?"≤":"<",t+=e.max,t+=e.unit):e.min&&(t+="值",t+="<="===e.left?"≥":">",t+=e.min,t+=e.unit),`[ ${t} ]`},getOptionLable=function(e){if(e&&e.option&&e.option.length>0){return e.option.map((e=>`[ ${e} ]`)).join("、")}return""};function decimalRegular(e=7,t=2,o){return"-"==o?`/^-?(0|[1-9]\\d{0,${e-1}})(\\.\\d{1,${t}})?$/`:`/^(0|[1-9]\\d{0,${e-1}})(\\.\\d{1,${t}})?$/`}function numberRegular(e=3){return`/^(0|[1-9]\\d{0,${e-1}})$/`}const symbolCompare=(e,t,o,n)=>"<="==e&&"<="==t?n-o>=0:"<"==e&&"<"==t||"<"==e&&"<="==t?n-o>0:"<="!=e||"<"!=t||n-o>0,calcRsult=function(wrapper){let{min:min,max:max,maxReg:maxReg,minReg:minReg,keepDecimal:keepDecimal,left:left,right:right,maxlength:maxlength}=wrapper;const reg=isEmpty(keepDecimal)||0==keepDecimal?eval(numberRegular(1*maxlength)):eval(decimalRegular(Number(maxlength),Number(keepDecimal)));if(!isEmpty(min)&&!reg.test(min))return!1;if(!isEmpty(max)&&!reg.test(max))return!1;let str="1";if(!isEmpty(keepDecimal)){for(let e=0;e<keepDecimal;e+=1)str+="0";str=Number(str)}if(min=isEmpty(min)?min:min*str,max=isEmpty(max)?max:max*str,maxReg=isEmpty(maxReg)?maxReg:maxReg*str,minReg=isEmpty(minReg)?minReg:minReg*str,isEmpty(minReg)&&isEmpty(maxReg)){if(isEmpty(min)&&isEmpty(max))return!0;if(isEmpty(min)&&!isEmpty(max))return!0;if(!isEmpty(min)&&isEmpty(max))return!0;if(!isEmpty(min)&&!isEmpty(max))return max-min>=0&&symbolCompare(left,right,min,max)}if(!isEmpty(minReg)&&!isEmpty(maxReg)){if(isEmpty(min)&&!isEmpty(max))return max-minReg>=0&&maxReg-max>=0;if(isEmpty(min)&&isEmpty(max))return!0;if(!isEmpty(min)&&!isEmpty(max))return min-minReg>=0&&max-min>=0&&maxReg-max>=0&&symbolCompare(left,right,min,max);if(!isEmpty(min)&&isEmpty(max))return min-minReg>=0&&maxReg-min>=0}if(!isEmpty(minReg)&&isEmpty(maxReg)){if(isEmpty(min)&&isEmpty(max))return!0;if(isEmpty(min)&&!isEmpty(max))return max-minReg>=0;if(!isEmpty(min)&&!isEmpty(max))return min-minReg>=0&&max-min>=0&&symbolCompare(left,right,min,max);if(!isEmpty(min)&&isEmpty(max))return min-minReg>=0}if(isEmpty(minReg)&&!isEmpty(maxReg)){if(isEmpty(min)&&isEmpty(max))return!0;if(isEmpty(min)&&!isEmpty(max))return maxReg-max>=0;if(!isEmpty(min)&&!isEmpty(max))return max-min>=0&&maxReg-max>=0&&symbolCompare(left,right,min,max);if(!isEmpty(min)&&isEmpty(max))return maxReg-min>=0}return!0},checkRegular=function(e){const{min:t,max:o}=e;return!(o&&o>Number.MAX_SAFE_INTEGER)&&(!(t&&t>Number.MAX_SAFE_INTEGER)&&calcRsult(e))},checkConditionRange=function(e){const t=`校验不通过。最小值(${e.minReg})-最大值(${e.maxReg})-小数点(${e.keepDecimal})`;return isEmpty(e.min)&&isEmpty(e.max)?t:(isEmpty(e.max)||checkRegular(e,e.max))&&(isEmpty(e.min)||checkRegular(e,e.min))?"":t},keyInObj=(e,t)=>e.hasOwnProperty(t),forEachObj=function(e,t){Object.keys(e).forEach(((o,n)=>{t(o,e[o],n)}))},iconDenySvg="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmVyc2lvbj0iMS4xIj4KCiA8Zz4KICA8dGl0bGU+YmFja2dyb3VuZDwvdGl0bGU+CiAgPHJlY3QgZmlsbD0ibm9uZSIgaWQ9ImNhbnZhc19iYWNrZ3JvdW5kIiBoZWlnaHQ9Ijc5MSIgd2lkdGg9IjE2NjIiIHk9Ii0xIiB4PSItMSIvPgogPC9nPgogPGc+CiAgPHRpdGxlPkxheWVyIDE8L3RpdGxlPgogIDxjaXJjbGUgaWQ9InN2Z18xIiBmaWxsPSIjRjU2QzZDIiBzdHJva2Utd2lkdGg9IjAiIHN0cm9rZT0iYmxhY2siIHI9IjEwIiBjeT0iMTAiIGN4PSIxMCIvPgogIDx0ZXh0IGlkPSJzdmdfMiIgZm9udC1zaXplPSIxMiIgZmlsbD0id2hpdGUiIHk9IjE1IiB4PSI0Ij7lkKY8L3RleHQ+CiA8L2c+Cjwvc3ZnPg==",nodeTypeEnum$1={START_NODE:"startNode",CONDITION_NODE:"conditionNode",BRANCH_NODE:"branchNode",PROCESS_NODE:"processNode"},startNodeStyle={type:"rect",label:"开始",labelCfg:{style:{fill:"#FFFFFF",fontSize:14},position:"center"},size:[80,32],style:{fill:"#3F9EFF",stroke:"#3F9EFF",lineWidth:0,radius:16},anchorPoints:[[0,.5],[1,.5]]},conditonNodeStyle={type:"modelRect",preRect:{show:!1},stateIcon:{show:!1,img:iconDenySvg},logoIcon:{show:!1},descriptionCfg:{style:{fill:"#f00"}},size:[80,32],labelCfg:{style:{fill:"rgba(0,0,0,0.8)",fontSize:14},position:"center"},style:{fill:"#F9F9F9",stroke:"#AEAEAE",lineWidth:1,radius:4},anchorPoints:[[0,.5],[1,.5]]},processNodeStyle={type:"modelRect",preRect:{show:!0,width:8,fill:"#AEAEAE",radius:4},stateIcon:{show:!1},logoIcon:{show:!1},size:[160,32],labelCfg:{style:{fill:"rgba(0,0,0,0.8)",fontSize:14},position:"center"},style:{fill:"#F9F9F9",stroke:"#AEAEAE",lineWidth:1,radius:4},anchorPoints:[[0,.5],[1,.5]]},branchNodeStyle={type:"rect",labelCfg:{style:{fill:"#FFFFFF",fontSize:12},position:"center"},size:[66,24],style:{fill:"#3F9EFF",stroke:"#3F9EFF",lineWidth:0,radius:2},anchorPoints:[[0,.5],[1,.5]]},getLabelWidth=(e,t)=>{let o=0;const n=new RegExp("[一-龥]+");return e.split("").forEach((e=>{n.test(e)?o+=t:o+=G6__default.default.Util.getLetterWidth(e,t)})),parseInt(o)},getMaxLable=(e,t,o)=>{const n=G6__default.default.Util.getTextSize("...",t)[0];let i=0,s=e;const a=new RegExp("[一-龥]+");return e.split("").forEach(((r,l)=>{i>o-n||(a.test(r)?i+=t:i+=G6__default.default.Util.getLetterWidth(r,t),i>o-n&&(s=`${e.substr(0,l)}...`))})),s};function getInitStyle(e){let t;switch(e.nodeType){case nodeTypeEnum$1.START_NODE:t=deepClone(startNodeStyle);break;case nodeTypeEnum$1.PROCESS_NODE:t=deepClone(processNodeStyle);break;case nodeTypeEnum$1.CONDITION_NODE:t=deepClone(conditonNodeStyle),e.isMust?(t.style.stroke="#AEAEAE",t.style.radius=4):(t.style.stroke="#FF955E",t.style.radius=16),e.isAccept?t.stateIcon.show=!1:t.stateIcon.show=!0;break;case nodeTypeEnum$1.BRANCH_NODE:t=deepClone(branchNodeStyle),e.isSure?(t.label="确定分支",t.style.fill="#3F9EFF",t.style.stroke="#3F9EFF"):(t.label="待定分支",t.style.fill="#FF955E",t.style.stroke="#FF955E")}return t}function injectNodeStyle(e){const t=getInitStyle(e);if(Object.keys(t).forEach((o=>{e[o]=t[o]})),e.nodeType===nodeTypeEnum$1.CONDITION_NODE){const{condition:t}=e;"1"===t.type?e.name=`${t.name} :${getOptionLable(t)}`:"2"===t.type&&(e.name=`${t.name} :${getRangeLable(t)}`),1==t.isCalc&&(e.description="(计算公式)",e.size[1]=50)}if(e.name){const t=getMaxLable(e.name,14,200),o=getLabelWidth(t,14);e.label=t,e.labelWidth=o+60,e.size[0]=o+60}return e}class Command$1{constructor(e,t){this.graph=e,this.$bus=t,this.onCommand()}onCommand(){this.$bus.$off("graphComman"),this.$bus.$on("graphComman",(e=>{this.executeCommand(e.direct,e.item,e.form)}))}executeCommand(e,t,o){const n=t.getModel(),i=t.getID();switch(e){case"add-process":{const{processName:e,process:t}=o,n=uniqueProcessKey(),s={name:e,processName:e,nodeType:"processNode",processKey:n,id:uniqueTimeId()};t&&(t.processKey=n,t.isMain=!1),this.$bus.$emit("mock-add-process",{processKey:n,processName:e,process:t}),this.graph.addChild(injectNodeStyle(s),i)}break;case"edit-process":{const{processName:e}=o;n.name=e,n.processName=e,this.updateProcessNode(t,n)}break;case"set-no-accept":n.isAccept=!1,n.condition.isAccept="0",this.updateConditionNode(t,n);break;case"set-accept":n.isAccept=!0,n.condition.isAccept="1",this.updateConditionNode(t,n);break;case"set-no-must":n.isMust=!1,n.condition.isMust="0",this.updateConditionNode(t,n);break;case"set-must":n.isMust=!0,n.condition.isMust="1",this.updateConditionNode(t,n);break;case"set-no-sure":n.isSure=!1,this.updateConditionNode(t,n);break;case"set-sure":n.isSure=!0,this.updateConditionNode(t,n);break;case"edit-condition":case"edit-formula":n.condition=o.condition,this.updateConditionNode(t,n);break;case"add-branch-tag":{const e=o.isBranchSure,t={nodeType:"branchNode",id:uniqueTimeId(),isSure:e};this.graph.addChild(injectNodeStyle(t),i)}break;case"delete-condition":case"delete-process":{const e=[];G6__default.default.Util.traverseTree(n,(t=>{"processNode"===t.nodeType&&e.push(t.processKey||t.key)})),this.graph.removeChild(i),this.$bus.$emit("mock-delete-process",{processKey:e})}break;case"cancle-branch-tag":this.graph.removeChild(i);break;case"add-condition":{const{condition:e}=o,t={nodeType:"conditionNode",condition:e,isMust:!0,isAccept:!0,id:uniqueTimeId(),conditionKey:uniqueConditionKey()};this.graph.addChild(injectNodeStyle(t),i),this.selectNode(t.id)}break;case"add-branch-condition":{o.parent=t;const e=deepCopyCondition(o.condition),n=this.graph.findDataById(t.getID());n.children||(n.children=[]),n.children.push(e),setTimeout((()=>{this.graph.layout(),this.graph.clearItemStates(t)}),600)}}}selectNode(e){this.graph.findAllByState("node","select").forEach((e=>{this.graph.clearItemStates(e,"select")})),this.graph.setItemState(this.graph.findById(e),"select",!0)}updateConditionNode(e,t){const{processKey:o}=this.graph.save(),n=e.getID();e.update(injectNodeStyle(t)),this.$bus.$emit("mock-update-condition",{processKey:o,id:n,item:t}),setTimeout((()=>{this.graph.layout()}),10)}updateProcessNode(e,t){const{processKey:o}=this.graph.save(),n=e.getID();e.update(injectNodeStyle(t)),this.$bus.$emit("mock-edit-process",{processKey:o,id:n,item:t}),setTimeout((()=>{this.graph.layout()}),10)}}const addProcessMenu={key:"add-process",name:"添加子流程"},editProcessMenu={key:"edit-process",name:"编辑"},editConditionMenu={key:"edit-condition",name:"编辑要求"},editFormulaMenu={key:"edit-formula",name:"编辑计算公式"},deleteProcessMenu={key:"delete-process",name:"删除"},deleteConditionMenu={key:"delete-condition",name:"删除"},addBranchTagMenu={key:"add-branch-tag",name:"标记分支状态"},setNoSureMenu={key:"set-no-sure",name:"标记为待定分支"},setSureMenu={key:"set-sure",name:"标记为确定分支"},cancleBranchTagMenu={key:"cancle-branch-tag",name:"取消标记"},setNoAcceptMenu={key:"set-no-accept",name:"标记为否决型"},setAcceptMenu={key:"set-accept",name:"标记为接受型"},setNoMustMenu={key:"set-no-must",name:"标记为软性"},setMustMenu={key:"set-must",name:"标记为硬性"},copyConditionMenu={key:"copy-condition",name:"复制"},copyBranchMenu={key:"copy-branch-menu",name:"复制分支"},isLastChild=e=>!(e.children&&e.children.length>0);function ingetNodeMenus(e){const{nodeType:t}=e,o=isLastChild(e),n=e.isAccept?setNoAcceptMenu:setAcceptMenu,i=e.isMust?setNoMustMenu:setMustMenu,s=e.isSure?setNoSureMenu:setSureMenu;let a;switch(t){case nodeTypeEnum$1.START_NODE:a=[addProcessMenu];break;case nodeTypeEnum$1.PROCESS_NODE:a=o?[editProcessMenu,addProcessMenu,addBranchTagMenu,deleteProcessMenu]:[editProcessMenu,addProcessMenu,deleteProcessMenu];break;case nodeTypeEnum$1.CONDITION_NODE:a=o?[editConditionMenu,copyConditionMenu,addProcessMenu,i,n,addBranchTagMenu,deleteConditionMenu]:[editConditionMenu,copyConditionMenu,copyBranchMenu,addProcessMenu,i,n,deleteConditionMenu],1==e.condition.isCalc&&a.splice(1,0,editFormulaMenu);break;case nodeTypeEnum$1.BRANCH_NODE:a=[s,cancleBranchTagMenu]}return a}function getChildFlowNodeMenus(e){return ingetNodeMenus(e).filter((e=>"add-process"!==e.key&&"add-branch-tag"!==e.key))}function getNodeMenus(e){const t=ingetNodeMenus(e);if(e.children&&e.children.length>0){if(e.children.find((e=>e.nodeType===nodeTypeEnum$1.BRANCH_NODE)))return t.filter((e=>"add-process"!==e.key&&"add-branch-tag"!==e.key))}return t}var nodeMenus={getNodeMenus:getNodeMenus,getChildFlowNodeMenus:getChildFlowNodeMenus};class Listener{constructor(e,t){this.graph=e,this.$bus=t,this.isMainFlow=!0,this.onNodeClick(),this.onNodeDoubleClick(),this.onNodeContextmenu(),this.onNodeDrag(),this.onCanvasClick(),this.onCanvasContextmenu(),this.onNodeMouse()}clearState(e){this.graph.findAllByState("node",e).forEach((t=>{this.graph.clearItemStates(t,e)}))}onNodeClick(){this.graph.on("node:click",(e=>{this.clearState("select");const{item:t}=e;this.graph.setItemState(t,"select",!0)}))}onNodeMouse(){let e=!1;this.graph.on("node:mouseenter",(t=>{e=!0;const o=t.item.getBBox(),n=o.x,i=o.y+o.height,{x:s,y:a}=this.graph.getClientByPoint(n,i);t.item.getModel().name&&setTimeout((()=>{if(e&&t.item&&t.item.getModel()){const{condition:e,name:o}=t.item.getModel();if(e&&1==e.isCalc){let t="计算公式:";e.formulaData&&e.formulaData.desc&&(t+=e.formulaData.desc,e.formulaData.formulaReplaceValue.forEach((e=>{t=t.replace(`{${e.key}}`,`${e.value}${e.unit}`)}))),this.$bus.$emit("showTooltip",{x:s,y:a,message:`${o}\n${t}`})}else this.$bus.$emit("showTooltip",{x:s,y:a,message:`${o}`})}}),600)})),this.graph.on("node:mousedown",(()=>{e=!1,this.$bus.$emit("hideTooltip")})),this.graph.on("node:mouseleave",(()=>{e=!1,this.$bus.$emit("hideTooltip")}))}onNodeDoubleClick(){this.graph.on("node:dblclick",(e=>{const t=e.item.getModel();"processNode"===t.nodeType&&this.$bus.$emit("change-process",{processKey:t.processKey})}))}onFlowChange({isMainFlow:e}){this.isMainFlow=e}onNodeContextmenu(){this.graph.on("node:contextmenu",(e=>{e.preventDefault(),this.$bus.$emit("hideTooltip"),this.clearState("select");const{item:t}=e;this.graph.setItemState(t,"select",!0);const o=this.isMainFlow?nodeMenus.getNodeMenus(t.getModel()):nodeMenus.getChildFlowNodeMenus(t.getModel());this.$bus.$emit("nodeContextmenu",{menus:o,x:e.clientX,y:e.clientY,item:t})}))}onCanvasClick(){this.graph.on("canvas:click",(e=>{console.log("canvas event",e),this.clearState("select"),this.graph.layout()}))}onNodeDrag(){let e;this.graph.on("node:dragstart",(()=>{e=void 0})),this.graph.on("node:drag",(t=>{e=void 0;const{item:o}=t;this.graph.getNodes().forEach((n=>{if(this.graph.setItemState(n,"closest",!1),n.getModel().id===o.getModel().id)return;const i=n.getBBox().x,s=n.getBBox().y,a=n.getBBox().x+n.getBBox().width,r=n.getBBox().y+n.getBBox().height;t.x>=i&&t.x<=a&&t.y>=s&&t.y<=r&&(e=n)})),e&&this.graph.setItemState(e,"closest",!0)})),this.graph.on("node:dragend",(t=>{if(!e)return void this.graph.layout();if("branchNode"===e.getModel().nodeType)return void this.graph.layout();if(e.getModel().children&&e.getModel().children.find((e=>"branchNode"===e.nodeType)))return void this.graph.layout();const{item:o}=t;if("branchNode"===o.getModel().nodeType)return void this.graph.layout();const n=o.getModel().condition;if(n){const{parentKey:t,parentName:o}=n;if(!checkParentKey(t,e))return this.graph.layout(),this.clearState("closest"),void this.$bus.$emit("parentKeyFind",{type:"error",content:`拖动的节点在目标节点及其父级节点上未找到对应的父级KEY【${o||t}】,请确认目标节点上有父级节点后再进行移动`})}const i=this.graph.findDataById(o.getID());let s=!1;if(G6__default.default.Util.traverseTree(i,(t=>{t.id===e.getID()&&(s=!0)})),s)return void this.graph.layout();this.graph.removeChild(o.getID());const a=this.graph.findDataById(e.getID());a.children||(a.children=[]),a.children.push(i),setTimeout((()=>{this.graph.layout(),this.clearState("closest")}),600)}))}onCanvasContextmenu(){this.graph.on("canvas:contextmenu",(e=>{e.preventDefault(),this.clearState("select")}))}}const defaultNode={},defaultEdge={type:"cubic-horizontal",style:{radius:20,offset:0,lineWidth:2,stroke:"#CDCFD6"},sourceAnchor:1,targetAnchor:0},nodeStateStyles={select:{stroke:"#d3adf7",lineWidth:2},closest:{stroke:"#d3adf7",lineWidth:6,opacity:.8}},modes={default:["drag-canvas","zoom-canvas",{type:"drag-node",enableDelegate:!0}],edit:["drag-canvas","zoom-canvas"]};function getChildMaxLableWidth(e){let t=0;return e&&e.forEach((e=>{const o=e.labelWidth?e.labelWidth:66;o>t&&(t=o)})),t}const layout={type:"compactBox",direction:"LR",getId:e=>e.id,getHeight:e=>40,getWidth(e){let t=80;if(e.labelWidth&&(t=e.labelWidth),e.children){return(t+getChildMaxLableWidth(e.children))/2}return"startNode"===e.nodeType?t:1e3},getVGap:e=>20,getHGap:()=>30};var graphConfig={modes:modes,defaultNode:defaultNode,defaultEdge:defaultEdge,layout:layout,nodeStateStyles:nodeStateStyles,animate:!0},script$6={name:"G6Brain",components:{},props:{},data:()=>({graph:null,command:null,listener:null,selectNode:null}),created(){},mounted(){this.$bus.$on("parentKeyFind",(e=>{this.$message[e.type](e.content,2,(()=>{}))}))},destroyed(){this.$bus.$off("parentKeyFind")},methods:{initGraph({width:e,height:t}){this.graph=new G6__default.default.TreeGraph({container:"mountNode",width:e,height:t,fitView:!1,...graphConfig}),this.graph.node((e=>injectNodeStyle(e))),this.command=new Command$1(this.graph,this.$bus),this.listener=new Listener(this.graph,this.$bus)},renderGraph(e){this.graph.read(e),this.graph.fitCenter(),this.moveStartNode(),this.graph.setItemState(this.getStartNode(),"select",!0),this.listener.onFlowChange({isMainFlow:!0===e.isMain})},changeGraph(e){this.graph.changeData(e),this.graph.fitCenter(),this.moveStartNode(),this.graph.setItemState(this.getStartNode(),"select",!0),this.listener.onFlowChange({isMainFlow:!0===e.isMain})},moveStartNode(){this.graph.moveTo(this.graph.getWidth()/10,this.graph.getHeight()/3)},getStartNode(){const e=this.graph.save().id;return this.graph.findById(e)},getSelectNode(){const e=this.graph.findAllByState("node","select");return e&&e.length>0?e[0]:null}}};const _hoisted_1$5={id:"mountNode"};function render$5(e,t,o,n,i,s){return Vue.openBlock(),Vue.createElementBlock("div",_hoisted_1$5)}script$6.render=render$5,script$6.__file="components/G6Brain/g6Brain.vue";var script$5={name:"WaitUseRegion",props:{conditions:{type:Array,default:()=>[]}},data:()=>({isExpand:!0}),computed:{formulaDataText:()=>function(e){if(e&&e.desc){let t=e.desc;return e.formulaReplaceValue.forEach((e=>{t=t.replace(`{${e.key}}`,`${e.value}${e.unit}`)})),t}return""}},methods:{getRangeLable:getRangeLable,getOptionLable:getOptionLable,conditionContextmenu(e,t,o){let n=[{key:"edit-condition-from-list",name:"编辑要求"},{key:"copy-condition-from-list",name:"复制"},{key:"delete-condition-from-list",name:"删除"}];1==e.isCalc&&(n=[{key:"edit-condition-from-list",name:"编辑要求"},{key:"edit-formula-from-list",name:"编辑计算公式"},{key:"copy-condition-from-list",name:"复制"},{key:"delete-condition-from-list",name:"删除"}]),this.$bus.$emit("conditionContextmenu",{menus:n,x:o.pageX,y:o.pageY,item:{data:e,index:t}}),o.preventDefault()},conditionClick(e,t){if("1"!==e.type||e.enums&&e.enums.length>0){if("2"===e.type){const t=checkConditionRange(e);if(t)return void this.$message.error(t)}1!=e.isCalc||e.formulaData&&e.formulaData.desc?this.$emit("conditionClick",{condition:e,index:t}):this.$message.error("请先完善计算公式")}else this.$message.error("请先完善值域范围")}}};const _withScopeId$2=e=>(Vue.pushScopeId("data-v-cc4a641c"),e=e(),Vue.popScopeId(),e),_hoisted_1$4={class:"region"},_hoisted_2$4=_withScopeId$2((()=>Vue.createElementVNode("span",{class:"title"},"待使用区域",-1))),_hoisted_3$3=_withScopeId$2((()=>Vue.createElementVNode("i",{class:"el-icon-arrow-down"},null,-1))),_hoisted_4$2=_withScopeId$2((()=>Vue.createElementVNode("i",{class:"el-icon-arrow-up"},null,-1))),_hoisted_5$2=["title","onContextmenu","onClick"],_hoisted_6$1={class:"flex"},_hoisted_7$1={class:"index-num"},_hoisted_8={class:"name"},_hoisted_9={key:0,class:"option-wrapper"},_hoisted_10={key:1,class:"option-wrapper"},_hoisted_11={key:2,class:"option-branch"},_hoisted_12={key:0,class:"flex"},_hoisted_13=_withScopeId$2((()=>Vue.createElementVNode("span",{class:"formula-title"},"计算公式:",-1))),_hoisted_14={class:"option-wrapper formula-data-text"};function render$4(e,t,o,n,i,s){return Vue.openBlock(),Vue.createElementBlock("section",_hoisted_1$4,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["head",i.isExpand?"expand-head":""])},[_hoisted_2$4,i.isExpand?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"collapse-expand",onClick:t[0]||(t[0]=e=>i.isExpand=!1)},[Vue.createTextVNode("收起 "),_hoisted_3$3])):(Vue.openBlock(),Vue.createElementBlock("div",{key:1,class:"collapse-expand",onClick:t[1]||(t[1]=e=>i.isExpand=!0)},[Vue.createTextVNode("展开 "),_hoisted_4$2]))],2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["content",i.isExpand?"expand-content":""])},[Vue.createCommentVNode("可选项 type === 1"),(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(o.conditions,((e,t)=>(Vue.openBlock(),Vue.createElementBlock("div",{key:t,class:"condition-item",title:e.option,onContextmenu:o=>s.conditionContextmenu(e,t,o),onClick:o=>s.conditionClick(e,t,o)},[Vue.createElementVNode("div",_hoisted_6$1,[Vue.createElementVNode("span",_hoisted_7$1,Vue.toDisplayString(t+1)+". ",1),Vue.createElementVNode("span",_hoisted_8,Vue.toDisplayString(e.name)+":",1),"1"===e.type?(Vue.openBlock(),Vue.createElementBlock("span",_hoisted_9,Vue.toDisplayString(s.getOptionLable(e)),1)):Vue.createCommentVNode("v-if",!0),"2"===e.type?(Vue.openBlock(),Vue.createElementBlock("span",_hoisted_10,Vue.toDisplayString(s.getRangeLable(e)),1)):Vue.createCommentVNode("v-if",!0),"copy-branch-menu"===e.nodeTypeMenu?(Vue.openBlock(),Vue.createElementBlock("span",_hoisted_11,"分支复制📢")):Vue.createCommentVNode("v-if",!0)]),1==e.isCalc?(Vue.openBlock(),Vue.createElementBlock("div",_hoisted_12,[_hoisted_13,Vue.createCommentVNode("<span class=\"option-wrapper\">[{{item.formulaData?item.formulaData.desc:''}}]</span>"),Vue.createElementVNode("span",_hoisted_14,Vue.toDisplayString(s.formulaDataText(e.formulaData)),1)])):Vue.createCommentVNode("v-if",!0)],40,_hoisted_5$2)))),128))],2)])}script$5.render=render$4,script$5.__scopeId="data-v-cc4a641c",script$5.__file="components/WaitUseRegion/waitUseRegion.vue";var script$4={data:()=>({menus:[],event:null}),created(){},mounted(){this.onShowContextmenu(),this.onShowNodeContextmenu(),this.onHideContextmenu()},destroyed(){this.$bus.$off("showContextmenu"),this.$bus.$off("showNodeContextmenu"),this.$bus.$off("hideContextmenu")},methods:{init(){},onShowContextmenu(){this.$bus.$on("showContextmenu",(({menus:e,x:t,y:o,...n})=>{console.log("onShowContextmenu"),this.menus=e,this.event=n;const i=this.$refs.contextMenu;i.style.left=`${t}px`,i.style.top=`${o}px`,i.style.display="block"}))},onShowNodeContextmenu(){this.$bus.$on("showNodeContextmenu",(({x:e,y:t,menus:o,event:n})=>{this.menus=o,this.event=n;const i=this.$refs.contextMenu;i.style.left=`${e}px`,i.style.top=`${t}px`,i.style.display="block"}))},onHideContextmenu(){this.$bus.$on("hideContextmenu",(()=>{this.$refs.contextMenu.style.display="none"}))},showContextmenu(e,t,o){if(this.menus=e,e&&e.length>0){const e=this.$refs.contextMenu;e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.display="block"}this.event=o},hideContextmenu(){this.$refs.contextMenu.style.display="none"},handleMenuItemClick(e){this.$bus.$emit("menuItemClick",{menu:e,event:this.event,item:e}),this.$emit("menuItemClick",{menu:e,item:e,event:this.event}),this.hideContextmenu()}}};const _hoisted_1$3={style:{"user-select":"none"}},_hoisted_2$3={ref:"contextMenu",class:"el-scrollbar__view el-select-dropdown__list context-menu"},_hoisted_3$2=["onClick"];function render$3(e,t,o,n,i,s){return Vue.openBlock(),Vue.createElementBlock("div",_hoisted_1$3,[Vue.createElementVNode("ul",_hoisted_2$3,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(i.menus,(e=>(Vue.openBlock(),Vue.createElementBlock("li",{key:e.key,class:"el-select-dropdown__item",onClick:t=>s.handleMenuItemClick(e)},Vue.toDisplayString(e.name),9,_hoisted_3$2)))),128))],512)])}script$4.render=render$3,script$4.__scopeId="data-v-6a1ac2fc",script$4.__file="components/Contextmenu/contextmenu.vue";var script$3={data:()=>({message:""}),computed:{messageBr(){return this.message.replace(/\n/g,"<br>")}},created(){},mounted(){this.onShowTooltip(),this.onHideTooltip()},methods:{init(){},onShowTooltip(){this.$bus.$off("showTooltip"),this.$bus.$on("showTooltip",(({x:e,y:t,message:o})=>{this.message=o;const n=this.$refs.tooltip;n.style.left=`${e}px`,n.style.top=`${t}px`,n.style.display="block"}))},onHideTooltip(){this.$bus.$off("hideTooltip"),this.$bus.$on("hideTooltip",(()=>{this.$refs.tooltip.style.display="none"}))}}};const _hoisted_1$2={class:"tooltip-wrapper",style:{"user-select":"none"}},_hoisted_2$2=["innerHTML"];function render$2(e,t,o,n,i,s){return Vue.openBlock(),Vue.createElementBlock("div",_hoisted_1$2,[Vue.createElementVNode("span",{ref:"tooltip",class:"tooltip row",innerHTML:s.messageBr},null,8,_hoisted_2$2)])}script$3.render=render$2,script$3.__scopeId="data-v-5e15fc28",script$3.__file="components/Tooltip/tooltip.vue";var script$2={name:"ElRender",props:{html:{type:String,default:""},form:{type:Object,default:()=>({})}},data:()=>({}),render(e,t){return e(Vue__default.default.extend({template:this.html,props:{form:{type:Object,default:()=>({})}},methods:{handleInputChange(e,t){},handleBlur(e,t){}}}),{props:{form:this.form}})},__scopeId:"data-v-57f1547a",__file:"components/FormulaModal/elRender.vue"};const reg=/\{(.+?)\}/g,decReg=/(?!^0\.0?0$)^(0|([1-9]\d{0,4}))(\.\d{1,2})?$/,descToDescEl=function(e,t){const o=Object.create(null),n=Object.create(null),i=e.desc.replace(reg,(function(){const n=arguments[1],i=e.formulaReplaceValue.find((e=>e.key==n));o[n]=i.value,e.descElModel=o,keyInObj(i,"unit")||(i.unit="");return`<el-input :maxLength="5" style="width:${i.unit?"110":"95"}px;margin:0 6px;" placeholder="请输入" :disabled="form.disabled" v-model="form.descElModel.${n}" @blur="handleBlur($event,'${t}')" @change="handleInputChange($event,'${t}')"><template slot="append">${i.unit}</template></el-input>`}));return e.descEl=`<div class='formula-content'>${i}</div>`,n.validateStatus="success",n.errorMsg=null,e.textWrap=n,keyInObj(e,"disabled")||(e.disabled=!0),e},filterSubmitFormula=function(e,t){return forEachObj(e,((t,o)=>{o?(o.formulaReplaceValue.forEach((e=>{keyInObj(o.descElModel,e.key)&&(e.value=o.descElModel[e.key])})),delete o.descElModel,delete o.descEl,delete o.textWrap,delete o.disabled):delete e[t]})),e},generatingOtionList=e=>{const{formulaReplaceValue:t,desc:o,formula:n,formulaId:i,unit:s}=e,a={};return a.defaultData=t,a.desc=o,a.formula=n,a.formulaId=i,a.unit=s,a},generatingFormluaList=e=>{const{name:t,scale:o,...n}=e,i={};return i.name=t,i.scale=o,i.option=[generatingOtionList(n)],i};var script$1={name:"FormulaModal",components:{elRender:script$2},data:()=>({radioStyle:{display:"flex",alignItems:"center",minHeight:"30px",width:"100%",padding:"10px 0"},radioGroupStyle:{width:"100%"},showFormulaModal:!1,curFormulaKey:"",curFormulaKeyData:{},allFormulaListObj:{},curFormulaInfo:{name:"公式模板",option:[],key:null,scale:0},modalValue:null,formulaList:null,formulaListChoice:""}),computed:{formulaClass:()=>function(e){return e==this.modalValue?"formula-selected":""}},created(){this.getAllFormulaList()},methods:{showModal({formula:e,handleComfirm:t,formulaList:o}){this.showFormulaModal=!0,o&&o.length>0?(this.curFormulaKey="",this.curFormulaKeyData={key:""},this.formulaListChoice="",this.curFormulaInfo={name:"公式模板",option:[],key:null,scale:0}):(this.curFormulaKey=e.key,this.curFormulaKeyData=e),this.handleComfirm=t,this.formulaList=o,this.getCurFormulaShowList(this.curFormulaKey)},changeFormula(e){this.curFormulaKey=e,this.modalValue=null,this.curFormulaKeyData={key:e},this.getCurFormulaShowList(this.curFormulaKey)},getAllFormulaList(){},getCurFormulaShowList(e){const{formulaId:t,formulaReplaceValue:o}=this.curFormulaKeyData;let n=this.allFormulaListObj[e];isEmpty(n)&&!isEmpty(t)&&(n=generatingFormluaList(this.curFormulaKeyData));const i=n&&deepCopy(n);if(!(isEmpty(i)||i.option.length<=0)){if(!isEmpty(t)&&-1==i.option.findIndex((e=>e.formulaId==t))){const e=generatingOtionList(this.curFormulaKeyData);i.option.unshift(e)}i.option.forEach(((n,i)=>{n.formulaReplaceValue=deepCopy(n.defaultData),delete n.defaultData,isEmpty(t)||n.formulaId!=t||(n.formulaReplaceValue=o,n.disabled=!1,this.modalValue=i),descToDescEl(n,e)})),this.curFormulaInfo=i,console.log("当前公式数据",this.curFormulaInfo)}},handleSure(){const{option:e,key:t=this.curFormulaKey,name:o,scale:n}=this.curFormulaInfo,i=this.modalValue;if(e.length<=0)return void(this.showFormulaModal=!1);if(isEmpty(i))return;let s=!0,a=!0;const{descElModel:r,textWrap:l,unit:d}=e[i];if(forEachObj(r,((e,t)=>{if(isEmpty(t))return l.errorMsg="输入框为必填项",void(a=!1);decReg.test(t)||(l.errorMsg="输入格式不正确",a=!1),a||(s=!1)})),!s||!a)return void this.$modal.msgError("存在格式错误,或者未填写字段");const c=deepCopy(e[i]);c.name=o,c.unit=d,c.scale=n;const u=filterSubmitFormula({[t]:c}),m=this.handleComfirm({...u[t],key:t});m?this.$modal.msgError(m.message):this.$nextTick((()=>{this.showFormulaModal=!1}))},handleCancel(){this.showFormulaModal=!1},onChangeModal(e){const t=e;this.curFormulaInfo.option.forEach(((e,o)=>{o==t?e.disabled=!1:(e.disabled=!0,e.textWrap.errorMsg=null)}))},afterCloseFn(){this.modalValue=null}}};const _withScopeId$1=e=>(Vue.pushScopeId("data-v-611ffcc4"),e=e(),Vue.popScopeId(),e),_hoisted_1$1={class:"title-area"},_hoisted_2$1=_withScopeId$1((()=>Vue.createElementVNode("span",{class:"tips-area"},"*温馨提示:选中之后当前公式,输入框可以修改",-1))),_hoisted_3$1={key:0,class:"flex",style:{"align-items":"center","margin-bottom":"20px"}},_hoisted_4$1=_withScopeId$1((()=>Vue.createElementVNode("span",{style:{"margin-left":"20px"}},"选择属性:",-1))),_hoisted_5$1={slot:"footer",class:"dialog-footer"};function render$1(e,t,o,n,i,s){const a=Vue.resolveComponent("el-row"),r=Vue.resolveComponent("el-option"),l=Vue.resolveComponent("el-select"),d=Vue.resolveComponent("elRender"),c=Vue.resolveComponent("el-radio"),u=Vue.resolveComponent("el-form-item"),m=Vue.resolveComponent("el-radio-group"),h=Vue.resolveComponent("el-form"),p=Vue.resolveComponent("el-button"),g=Vue.resolveComponent("el-dialog");return Vue.openBlock(),Vue.createBlock(g,{visible:i.showFormulaModal,"append-to-body":"","destroy-on-close":"","close-on-click-modal":!1,"show-close":!1,width:"720px"},{default:Vue.withCtx((()=>[Vue.createCommentVNode(" 标题slot "),Vue.createVNode(a,{slot:"title",type:"flex",align:"middle"},{default:Vue.withCtx((()=>[Vue.createElementVNode("span",_hoisted_1$1,Vue.toDisplayString(i.curFormulaInfo.name+"【公式模板】"),1),_hoisted_2$1])),_:1}),Vue.createCommentVNode(" 加上a-form用于input校验提示 "),i.formulaList&&i.formulaList.length>0?(Vue.openBlock(),Vue.createElementBlock("div",_hoisted_3$1,[_hoisted_4$1,Vue.createVNode(l,{modelValue:i.formulaListChoice,"onUpdate:modelValue":t[0]||(t[0]=e=>i.formulaListChoice=e),style:{width:"400px"},onChange:s.changeFormula},{default:Vue.withCtx((()=>[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(i.formulaList,(e=>(Vue.openBlock(),Vue.createBlock(r,{key:e.name,label:e.name,value:e.key},null,8,["label","value"])))),128))])),_:1},8,["modelValue","onChange"])])):Vue.createCommentVNode("v-if",!0),i.curFormulaInfo.option.length>0?(Vue.openBlock(),Vue.createBlock(h,{key:1,layout:"horizontal","label-align":"left"},{default:Vue.withCtx((()=>[Vue.createVNode(m,{modelValue:i.modalValue,"onUpdate:modelValue":t[1]||(t[1]=e=>i.modalValue=e),style:Vue.normalizeStyle(i.radioGroupStyle),onInput:s.onChangeModal},{default:Vue.withCtx((()=>[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(i.curFormulaInfo.option,((e,t)=>(Vue.openBlock(),Vue.createBlock(u,{key:t,class:Vue.normalizeClass(["formula-list",s.formulaClass(t)]),error:e.textWrap.errorMsg},{default:Vue.withCtx((()=>[Vue.createVNode(c,{style:Vue.normalizeStyle(i.radioStyle),label:t},{default:Vue.withCtx((()=>[Vue.createVNode(d,{html:e.descEl,form:e},null,8,["html","form"])])),_:2},1032,["style","label"])])),_:2},1032,["class","error"])))),128))])),_:1},8,["modelValue","style","onInput"]),i.curFormulaInfo.key&&0===i.curFormulaInfo.option.length?(Vue.openBlock(),Vue.createBlock(a,{key:0},{default:Vue.withCtx((()=>[Vue.createTextVNode(" 当前属性还未在后台配置公式数据,请尽快联系管理员处理,谢谢。 ")])),_:1})):Vue.createCommentVNode("v-if",!0)])),_:1})):Vue.createCommentVNode("v-if",!0),Vue.createElementVNode("div",_hoisted_5$1,[Vue.createVNode(p,{onClick:s.handleCancel},{default:Vue.withCtx((()=>[Vue.createTextVNode("取 消")])),_:1},8,["onClick"]),Vue.createVNode(p,{type:"primary",onClick:s.handleSure},{default:Vue.withCtx((()=>[Vue.createTextVNode("确 定")])),_:1},8,["onClick"])])])),_:1},8,["visible"])}script$1.render=render$1,script$1.__scopeId="data-v-611ffcc4",script$1.__file="components/FormulaModal/formulaModal.vue";class Command{constructor(e,t){this.context=e,this.$bus=t,this.executeCommand={showContextmenu:(e,t)=>{const{menus:o,x:n,y:i,item:s}=e;this.context.$refs.contextmenu.showContextmenu(o,{x:n,y:i},{item:s,type:t})},changeProcess:e=>{e&&(this.context.currentTree=e)},addProcess:(e,t,o)=>{o?this.context.processDataManage.addPublicProcess(o):this.context.processDataManage.addProcess(e,t)},deleteProcess:e=>{this.context.processDataManage.deleteProcess(e)},updateProcess:(e,t,o)=>{this.context.processDataManage.updateProcess(o.processKey,o.processName),this.context.processDataManage.updateNodeData(e,t,o)},updateCondition:(e,t,o)=>{this.context.processDataManage.updateNodeData(e,t,o)}},this.offEvent(),this.onContextmenu(),this.onChangeProcess(),this.onAddProcess(),this.onDeleteProcess(),this.onUpdateProcess(),this.onUpdateCondition()}offEvent(){this.$bus.$off("nodeContextmenu"),this.$bus.$off("conditionContextmenu"),this.$bus.$off("mock-add-process"),this.$bus.$off("change-process"),this.$bus.$off("mock-edit-process"),this.$bus.$off("mock-update-condition"),this.$bus.$off("mock-delete-process")}onContextmenu(){this.$bus.$on("nodeContextmenu",(e=>{this.executeCommand.showContextmenu(e,"graph")})),this.$bus.$on("conditionContextmenu",(e=>{this.executeCommand.showContextmenu(e,"conditionList")}))}onAddProcess(){this.$bus.$on("mock-add-process",(({processKey:e,processName:t,process:o})=>{this.executeCommand.addProcess(e,t,o)}))}onChangeProcess(){this.$bus.$on("change-process",(({processKey:e})=>{this.executeCommand.changeProcess(e)}))}onUpdateProcess(){this.$bus.$on("mock-edit-process",(({processKey:e,id:t,item:o})=>{this.executeCommand.updateProcess(e,t,o)}))}onUpdateCondition(){this.$bus.$on("mock-update-condition",(({processKey:e,id:t,item:o})=>{this.executeCommand.updateCondition(e,t,o)}))}onDeleteProcess(){this.$bus.$on("mock-delete-process",(({processKey:e})=>{e.forEach((e=>{this.executeCommand.deleteProcess(e)}))}))}}const nodeTypeEnum={START_NODE:"startNode",CONDITION_NODE:"conditionNode",BRANCH_NODE:"branchNode",PROCESS_NODE:"processNode"};class ProcessDataManage{constructor(e){this.processArray=Array.isArray(e)?e:[]}addProcess(e,t,o){const n=injectId({processKey:e,processName:t,nodeType:nodeTypeEnum.START_NODE,isMain:o});this.processArray.push(n)}addPublicProcess(e){this.processArray.push(e)}getProcessArray(){return this.processArray}getProcess(e){return this.processArray.find((t=>t.processKey===e))}getMainProcess(){return this.processArray.find((e=>!0===e.isMain))}getFirstProcess(){return this.processArray[0]}updateProcess(e,t){this.getProcess(e).processName=t}deleteProcess(e){const t=this.processArray.findIndex((t=>t.processKey===e));t>=0&&this.processArray.splice(t,1)}updateNodeData(e,t,o){const n=this.getProcess(e);G6__default.default.Util.traverseTree(n,(e=>{e.id===t&&Object.keys(o).forEach((t=>{e[t]=o[t]}))}))}}var script={name:"ConditionTreeEditor",components:{g6Brain:script$6,waitUseRegion:script$5,contextmenu:script$4,tooltip:script$3,formulaModal:script$1},props:{id:{type:[String,Number]},tempCode:{type:[String,Number],default:"T000001"},height:{type:[Number,String],default:0},showSaveDraftBtn:{type:Boolean,default:!1}},data:()=>({submitLoading:!1,conditions:[],currentTree:"",processDataManage:null,command:null,graphHeight:0}),watch:{currentTree(e){e&&this.$refs.g6Brain.changeGraph(this.processDataManage.getProcess(e))}},created(){console.log("npm包",this,this.$bus),this.command=new Command(this,this.$bus)},mounted(){const e=document.getElementById("graph-container").clientWidth,t=document.getElementById("graph-container").clientHeight-15;this.$refs.g6Brain.initGraph({width:e,height:t}),this.graphHeight=t},methods:{setInitConditions(e){this.conditions=e||[]},initGraphJson(e){this.processDataManage=new ProcessDataManage(e),this.currentTree=e[0].processKey},initProcessData(e,t,o){this.processDataManage=new ProcessDataManage,this.processDataManage.addProcess(e,t,o),this.currentTree=e},commandGraph(e){this.$bus.$emit("graphComman",e)},showModal(e){console.log("打开了弹框",e)},getG6BrainSelectNode(){return this.$refs.g6Brain.getSelectNode()},handleConditionClick({condition:e,index:t}){const o=this.getG6BrainSelectNode();if(!o)return void this.$message.error("请先选中节点");const n=o.getModel();if("branchNode"!==n.nodeType){if(n.children&&n.children.length>0){if(n.children.find((e=>"branchNode"===e.nodeType)))return void this.$message.error("该节点已经标记分支状态")}checkParentKey(e.parentKey,o)?(this.conditions.splice(t,1),"copy-branch-menu"!==e.nodeTypeMenu?this.commandGraph({direct:"add-condition",item:o,form:{condition:e}}):this.commandGraph({direct:"add-branch-condition",item:o,form:{condition:e}})):this.$message.error(`该属性在此条分支中未找到对应的父级KEY:【${e.parentName||e.parentKey}】,请先添加父级属性`)}else this.$message.error("该节点不能添加属性")},handleGraphMenuItemClick({item:e,event:t}){const{condition:o}=t.item.getModel();let n,i;switch(e.key){case"delete-process":case"delete-condition":case"cancle-branch-tag":case"add-branch-tag":case"edit-process":case"edit-condition":this.showModal({item:e,event:t});break;case"edit-formula":n=o.formulaData?o.formulaData:{},n=Object.assign({key:o.key},n),this.$refs.formulaModal.showModal({formula:n,handleComfirm:n=>{o.formulaData=n,this.commandGraph({direct:e.key,item:t.item,form:{condition:o}})}});break;case"add-process":this.showModal({item:e,tempCode:this.tempCode,event:t});break;case"copy-condition":this.showModal({item:e,event:t,handleComfirm:e=>{1==e.condition.isCalc&&delete e.condition.formulaData,this.conditions.push(e.condition)}});break;case"set-no-accept":case"set-accept":case"set-no-must":case"set-must":case"set-no-sure":case"set-sure":this.commandGraph({direct:e.key,item:t.item});break;case"copy-branch-menu":i=this.$refs.g6Brain.graph.findDataById(t.item.getID()),i.nodeTypeMenu=e.key,this.conditions.push(deepCopy(i))}},handleConditionListMenuItemClick({item:e,event:t}){const o=t.item.data;let n;switch(e.key){case"edit-condition-from-list":this.showModal({item:e,event:t,type:"conditionList",handleComfirm:e=>{this.conditions.splice(t.item.index,1,e.condition)}});break;case"edit-formula-from-list":n=o.formulaData?o.formulaData:{},n=Object.assign({key:o.key},n),this.$refs.formulaModal.showModal({formula:n,handleComfirm:e=>{o.formulaData=e,console.log("handleComfirm",e),this.conditions.splice(t.item.index,1,o)}});break;case"delete-condition-from-list":this.conditions.splice(t.item.index,1);break;case"copy-condition-from-list":this.showModal({item:e,event:t,handleComfirm:e=>{1==e.condition.isCalc&&delete e.condition.formulaData,this.conditions.splice(t.item.index+1,0,e.condition)}})}},handleMenuItemClick({item:e,event:t}){"graph"===t.type?this.handleGraphMenuItemClick({item:e,event:t}):"conditionList"===t.type&&this.handleConditionListMenuItemClick({item:e,event:t})},addMoreCondition(){console.log("添加更多属性")},submitData(e){this.submitLoading=!0;const t=this.processDataManage.getProcessArray(),o=this.processDataManage.getProcess("main");this.$emit("submitData",{id:this.id,isDraft:e,processArray:t,mainProcess:o,waitingUseField:this.conditions});const n=setTimeout((()=>{clearTimeout(n),this.submitLoading=!1}),800)}}};const _withScopeId=e=>(Vue.pushScopeId("data-v-086b7172"),e=e(),Vue.popScopeId(),e),_hoisted_1={class:"head"},_hoisted_2={class:"title"},_hoisted_3={class:"process-name"},_hoisted_4=_withScopeId((()=>Vue.createElementVNode("div",{class:"line-1-px"},null,-1))),_hoisted_5={id:"graph-container",style:{flex:"1",display:"flex","flex-direction":"column"}},_hoisted_6=_withScopeId((()=>Vue.createElementVNode("div",{class:"line-1-px"},null,-1))),_hoisted_7={class:"save-area",style:{height:"30px"}};function render(e,t,o,n,i,s){const a=Vue.resolveComponent("el-radio-button"),r=Vue.resolveComponent("el-radio-group"),l=Vue.resolveComponent("el-button"),d=Vue.resolveComponent("waitUseRegion"),c=Vue.resolveComponent("g6Brain"),u=Vue.resolveComponent("contextmenu"),m=Vue.resolveComponent("tooltip"),h=Vue.resolveComponent("formula-modal");return Vue.openBlock(),Vue.createElementBlock("section",{class:"container",style:Vue.normalizeStyle("height:"+o.height+"px"),onClick:t[3]||(t[3]=t=>e.$refs.contextmenu.hideContextmenu())},[Vue.createCommentVNode(" 头部菜单切换区域 "),Vue.createElementVNode("div",_hoisted_1,[Vue.createElementVNode("div",_hoisted_2,[i.processDataManage&&i.processDataManage.getProcessArray?(Vue.openBlock(),Vue.createBlock(r,{key:0,modelValue:i.currentTree,"onUpdate:modelValue":t[0]||(t[0]=e=>i.currentTree=e),size:"small"},{default:Vue.withCtx((()=>[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(i.processDataManage.getProcessArray(),((e,t)=>(Vue.openBlock(),Vue.createBlock(a,{key:t,label:e.processKey},{default:Vue.withCtx((()=>[Vue.createElementVNode("span",_hoisted_3,Vue.toDisplayString(e.processName),1)])),_:2},1032,["label"])))),128))])),_:1},8,["modelValue"])):Vue.createCommentVNode("v-if",!0)]),Vue.createVNode(l,{type:"primary",size:"small",icon:"el-icon-plus",style:{margin:"0 40px 0 10px",height:"32px"},onClick:s.addMoreCondition},{default:Vue.withCtx((()=>[Vue.createTextVNode("添加更多属性")])),_:1},8,["onClick"])]),Vue.createCommentVNode(" 分割线 "),_hoisted_4,Vue.createCommentVNode(" G6区域 "),Vue.createElementVNode("div",_hoisted_5,[Vue.createCommentVNode(" G6等待区域 "),Vue.createElementVNode("div",{class:"waitUseRegion",style:Vue.normalizeStyle("max-height:"+(i.graphHeight-20)+"px")},[Vue.createVNode(d,{conditions:i.conditions,onConditionClick:s.handleConditionClick},null,8,["conditions","onConditionClick"])],4),Vue.createCommentVNode(" G6工作区域"),Vue.createVNode(c,{ref:"g6Brain",mode:"default"},null,512)]),Vue.createCommentVNode(" 分割线 "),_hoisted_6,Vue.createCommentVNode(" 底部按钮 "),Vue.createElementVNode("div",_hoisted_7,[o.showSaveDraftBtn?(Vue.openBlock(),Vue.createBlock(l,{key:0,style:{width:"200px",height:"30px"},loading:i.submitLoading,onClick:t[1]||(t[1]=e=>s.submitData(1))},{default:Vue.withCtx((()=>[Vue.createTextVNode("存为草稿")])),_:1},8,["loading"])):Vue.createCommentVNode("v-if",!0),Vue.createVNode(l,{type:"primary",style:{width:"200px",height:"30px","margin-left":"16px"},loading:i.submitLoading,onClick:t[2]||(t[2]=e=>s.submitData(0))},{default:Vue.withCtx((()=>[Vue.createTextVNode("保 存")])),_:1},8,["loading"])]),Vue.createCommentVNode(" 右键按钮组件 "),Vue.createVNode(u,{ref:"contextmenu",key:"conditionTree",onMenuItemClick:s.handleMenuItemClick},null,8,["onMenuItemClick"]),Vue.createCommentVNode(" 提示组件 "),Vue.createVNode(m),Vue.createCommentVNode(" 计算弹框组件 "),Vue.createVNode(h,{ref:"formulaModal"},null,512)],4)}script.render=render,script.__scopeId="data-v-086b7172",script.__file="CondtionTreeEditor/index.vue";const components=[script],install=function(e,t={}){components.forEach((t=>{e.component(t.name,t)}))};"undefined"!=typeof window&&window.Vue&&install(window.Vue);var index={install:install};return index}));