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

2 lines
6.2KB

  1. import{d as Q,D as W,r as F,L as X,c as p,e as n,I as c,i as t,h as u,j as U,f as _,F as V,J as C,g as I,u as f,k as N,t as Y}from"./index.b4f1c826.js";const Z={class:"orBox"},k={class:"flexbetween"},x=["onClick"],ee={key:0,class:"mx-48 my-17 bg-warning text-white rounded-full w-24 h-24 flex items-center justify-center"},le=Q({name:"conditionDialog"}),ae=Object.assign(le,{props:{visible:{type:Boolean,default:!1,required:!0},data:Object},emits:["close","update:data"],setup(T,{emit:R}){const{filedConditionsOptions:d}=W.dictStore.globalDicts||{},D=T,h=R,B=F(),l=F({groups:[]}),z={name:[{required:!0,message:"\u8BF7\u8F93\u5165\u4F01\u4E1A\u540D\u79F0",trigger:"blur"}]},L=async i=>{if(!i){h("close",!0);return}await i.validate(async s=>{if(s){const r=[];l.value.groups.length&&l.value.groups.forEach((w,y)=>{const j=w.conditions.map(m=>({id:m.id,title:d.find(g=>g.value===m.id).label,compare:m.compare,value:Array.of(m.value),valueType:d.find(g=>g.value===m.id).valueType}));r.push({groupType:"AND",conditions:j,cids:j.map(m=>m.id)})});const v={id:D.data.id,name:D.data.name,type:"CONDITION",props:{groups:r,groupsType:"OR"}};h("update:data",v),h("close",!0)}})},P=i=>{l.value.groups[i].conditions.push({})},S=(i,s)=>{l.value.groups[i].conditions.splice(s,1)},E=()=>{l.value.groups.push({conditions:[]})},J=i=>{l.value.groups.splice(i,1)},G=(i,s)=>{l.value.groups[i].conditions[s].compare=void 0,l.value.groups[i].conditions[s].value=void 0};return X(()=>D.visible,async i=>{i?l.value={groups:D.data.props.groups.map(s=>({conditions:s.conditions.map(r=>({...r,value:d.find(v=>v.value===r.id).type==="bool_condition"?r.value.join()*1:r.value.join()}))}))}:B.value.resetFields()}),(i,s)=>{const r=p("el-option"),v=p("el-select"),w=p("el-form-item"),y=p("el-col"),j=p("el-input"),m=p("Delete"),g=p("el-icon"),H=p("el-row"),q=p("Plus"),O=p("el-button"),K=p("el-form"),M=p("el-dialog");return n(),c(M,{"model-value":T.visible,title:"\u7B5B\u9009\u6570\u636E",width:"840px","destroy-on-close":"",onClose:s[2]||(s[2]=$=>h("close"))},{footer:t(()=>[u(O,{type:"primary",onClick:s[0]||(s[0]=$=>L(B.value))},{default:t(()=>[U(" \u63D0\u4EA4 ")]),_:1}),u(O,{onClick:s[1]||(s[1]=$=>h("close"))},{default:t(()=>[U(" \u5173\u95ED ")]),_:1})]),default:t(()=>[u(K,{ref_key:"formRef",ref:B,model:l.value,rules:z,"label-suffix":":",class:"form"},{default:t(()=>[(n(!0),_(V,null,C(l.value.groups,($,o)=>(n(),_("div",{key:o},[I("div",Z,[(n(!0),_(V,null,C($.conditions,(A,a)=>(n(),c(H,{key:a,gutter:8,class:"mb-8"},{default:t(()=>[u(y,{span:8},{default:t(()=>[u(w,{prop:`groups[${o}][conditions][${a}].id`,rules:{required:!0,message:"\u8BF7\u9009\u62E9\u9879\u76EE\u5B57\u6BB5"}},{default:t(()=>[u(v,{modelValue:l.value.groups[o].conditions[a].id,"onUpdate:modelValue":e=>l.value.groups[o].conditions[a].id=e,class:"w-full",onChange:e=>G(o,a)},{default:t(()=>[(n(!0),_(V,null,C(f(d),e=>(n(),c(r,{key:e.value,label:e.label,value:e.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["prop"])]),_:2},1024),u(y,{span:6},{default:t(()=>[u(w,{prop:`groups[${o}][conditions][${a}].compare`,rules:{required:!0,message:"\u8BF7\u9009\u62E9\u5224\u65AD\u7B26"}},{default:t(()=>[u(v,{modelValue:l.value.groups[o].conditions[a].compare,"onUpdate:modelValue":e=>l.value.groups[o].conditions[a].compare=e},{default:t(()=>[l.value.groups[o].conditions[a].id?(n(!0),_(V,{key:0},C(f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).judges,(e,b)=>(n(),c(r,{key:b,label:e,value:b},null,8,["label","value"]))),128)):N("",!0)]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["prop"])]),_:2},1024),u(y,{span:9},{default:t(()=>[u(w,{prop:`groups[${o}][conditions][${a}].value`,rules:{required:!0,message:"\u8BF7\u9009\u62E9\u6216\u8F93\u5165"}},{default:t(()=>[l.value.groups[o].conditions[a].id?f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).type==="bool_condition"?(n(),c(v,{key:1,modelValue:l.value.groups[o].conditions[a].value,"onUpdate:modelValue":e=>l.value.groups[o].conditions[a].value=e,class:"w-full"},{default:t(()=>[u(r,{label:"\u662F",value:1}),u(r,{label:"\u5426",value:0})]),_:2},1032,["modelValue","onUpdate:modelValue"])):f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).type==="value_condition"?(n(),c(v,{key:2,modelValue:l.value.groups[o].conditions[a].value,"onUpdate:modelValue":e=>l.value.groups[o].conditions[a].value=e,class:"w-full"},{default:t(()=>[(n(!0),_(V,null,C(f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).options,(e,b)=>(n(),c(r,{key:b,label:e,value:b},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).type==="single_condition"?(n(),c(v,{key:3,modelValue:l.value.groups[o].conditions[a].value,"onUpdate:modelValue":e=>l.value.groups[o].conditions[a].value=e,class:"w-full"},{default:t(()=>[(n(!0),_(V,null,C(f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).options,(e,b)=>(n(),c(r,{key:b,label:e,value:b},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).type==="range_condition"?(n(),c(j,{key:4,modelValue:l.value.groups[o].conditions[a].value,"onUpdate:modelValue":e=>l.value.groups[o].conditions[a].value=e},{append:t(()=>[U(Y(f(d).find(e=>e.value===l.value.groups[o].conditions[a].id).unit),1)]),_:2},1032,["modelValue","onUpdate:modelValue"])):N("",!0):(n(),c(v,{key:0,class:"w-full"}))]),_:2},1032,["prop"])]),_:2},1024),u(y,{span:1,class:"flex items-center text-danger delCol justify-end"},{default:t(()=>[u(g,{class:"cursor-pointer",onClick:e=>S(o,a)},{default:t(()=>[u(m)]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1024))),128)),I("div",k,[u(O,{size:"small",onClick:A=>P(o)},{default:t(()=>[u(g,{class:"mr-4"},{default:t(()=>[u(q)]),_:1}),U("\u4E14\u6761\u4EF6 ")]),_:2},1032,["onClick"]),$.length?N("",!0):(n(),_("span",{key:0,class:"text-danger cursor-pointer",onClick:A=>J(o)},[u(g,null,{default:t(()=>[u(m)]),_:1})],8,x))])]),o<l.value.groups.length-1?(n(),_("p",ee,"\u6216")):N("",!0)]))),128)),u(O,{size:"small",type:"primary",plain:"",class:"mt-16",onClick:E},{default:t(()=>[u(g,{class:"mr-4"},{default:t(()=>[u(q)]),_:1}),U("\u6216\u6761\u4EF6 ")]),_:1})]),_:1},8,["model"])]),_:1},8,["model-value"])}}});export{ae as default};