Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

2 rindas
6.3KB

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