import{b as I,r as c,o as p,y as h,q as a,v as P,p as r,P as _,x as v,n,c as B,F,A as L,s as D,j as M,k as R,E as S,i as U,m as q,l as T,bv as x,D as H}from"./index.8d733f79.js";import{a as O}from"./deviceHealth.f8ad4f4a.js";const j={class:"dialog-footer"},K={__name:"customGroup",emits:["confirm"],setup(A,{expose:b,emit:V}){const{proxy:d}=H(),{t:f}=I(),s=c(!1),m=c([]),o=c({deviceHealthGroupId:null,groupType:2,componentIdentifier:"",healthGroupName:"",weight:null,isEnable:!0,healthConfigs:[],metrics:[]}),y={healthGroupName:[{required:!0,message:f("groupNameP"),trigger:"blur"}],metrics:[{required:!0,message:f("monitorMetricP"),trigger:"change"}]},E=l=>{s.value=!0,O({deviceId:l}).then(e=>{m.value=e.data})},N=()=>{d.$refs.formRef.validate(l=>{l?(o.value.healthConfigs=[],o.value.metrics.forEach(e=>{const u=m.value.find(i=>i.metric===e);o.value.healthConfigs.push({configId:null,metric:u.metric,name:u.name,minValue:null,maxValue:null,standardValue:null,calcLowerLimit:null,calcUpperLimit:null,effectivePeriod:null,weight:null,isEnable:null})}),V("confirm",JSON.stringify(o.value)),s.value=!1):console.log("error submit!")})},$=()=>{d.$refs.formRef.resetFields()};return b({showTarget:E}),(l,e)=>{const u=M,i=R,C=S,G=U,w=q,g=T,k=x;return p(),h(k,{title:l.$t("createGroup"),modelValue:n(s),"onUpdate:modelValue":e[3]||(e[3]=t=>D(s)?s.value=t:null),"append-to-body":!0,onClosed:$},{footer:a(()=>[P("div",j,[r(g,{onClick:e[2]||(e[2]=t=>s.value=!1)},{default:a(()=>[_(v(l.$t("cancel")),1)]),_:1}),r(g,{type:"primary",onClick:N},{default:a(()=>[_(v(l.$t("confirm")),1)]),_:1})])]),default:a(()=>[r(w,{ref:"formRef",rules:y,model:n(o)},{default:a(()=>[r(i,{label:l.$t("groupName"),prop:"healthGroupName",style:{"margin-bottom":"22px"}},{default:a(()=>[r(u,{modelValue:n(o).healthGroupName,"onUpdate:modelValue":e[0]||(e[0]=t=>n(o).healthGroupName=t),placeholder:l.$t("groupNameP"),maxlength:"20",style:{width:"calc(70%)"}},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),r(i,{label:l.$t("monitorMetric"),prop:"metrics"},{default:a(()=>[r(G,{modelValue:n(o).metrics,"onUpdate:modelValue":e[1]||(e[1]=t=>n(o).metrics=t),multiple:"","collapse-tags":"",filterable:"",placeholder:l.$t("monitorMetricP"),style:{width:"calc(70%)"}},{default:a(()=>[(p(!0),B(F,null,L(n(m),t=>(p(),h(C,{key:t.metric,label:t.name,value:t.metric},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model"])]),_:1},8,["title","modelValue"])}}};export{K as default};
