import{a as q,b as N,r as f,ah as b,J as R,o as g,y as V,q as r,v as B,p as s,P,x as y,n as t,c as S,F as x,A,s as M,S as J,j as L,k as O,E as z,i as G,m as H,l as K,bv as Q,D as W}from"./index.8d733f79.js";import{l as X,m as Y}from"./systemLink.0379a9eb.js";const Z={class:"dialog-footer"},te={__name:"addParams",emits:["refesh"],setup(j,{expose:$,emit:C}){const{proxy:i}=W(),F=q(),{t:u,locale:ee}=N(),m=f(!1),l=b({factoryId:F.query.factoryId||"",dataFrom:"",name:"",params:"",purpose:"",subDeviceCodeThird:"",unit:""}),h=f(""),_=b({name:[{required:!0,message:u("nameP"),trigger:"blur"}],purpose:[{required:!0,message:u("dataPurposeP"),trigger:"change"}],subDeviceCodeThird:[{required:!0,message:u("subModelCodeP"),trigger:"blur"}],params:[{required:!0,message:u("apiParamsP"),trigger:"blur"}]}),p=f(),D=R.session.getJSON("enums").purpose;function w(e){m.value=!0,h.value=e.id?u("edit"):u("add"),e&&(p.value=e.id,l.dataFrom=e.dataFrom,l.name=e.name,l.params=e.params,l.purpose=e.purpose,l.subDeviceCodeThird=e.subDeviceCodeThird,l.unit=e.unit),setTimeout(()=>{i.$refs.setFormRef.clearValidate()},30)}function E(){!i.$refs.setFormRef||i.$refs.setFormRef.validate(e=>{if(e){const o=p.value?X:Y;p.value&&(l.id=p.value),o(l).then(d=>{J.success(d.msg),C("refesh"),c()})}else console.log("error submit!")})}function c(){m.value=!1}return $({showModal:w}),(e,o)=>{const d=L,n=O,k=z,T=G,U=H,v=K,I=Q;return g(),V(I,{title:t(h),modelValue:t(m),"onUpdate:modelValue":o[6]||(o[6]=a=>M(m)?m.value=a:null),width:"500px","align-center":!0,onClose:c},{footer:r(()=>[B("div",Z,[s(v,{onClick:c},{default:r(()=>[P(y(e.$t("cancel")),1)]),_:1}),s(v,{type:"primary",onClick:E},{default:r(()=>[P(y(e.$t("confirm")),1)]),_:1})])]),default:r(()=>[s(U,{ref:"setFormRef",model:t(l),rules:t(_),"label-width":"165"},{default:r(()=>[s(n,{label:e.$t("name"),prop:"name"},{default:r(()=>[s(d,{modelValue:t(l).name,"onUpdate:modelValue":o[0]||(o[0]=a=>t(l).name=a),placeholder:e.$t("nameP"),style:{width:"236px"},maxlength:"20"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(n,{label:e.$t("unit"),prop:"unit"},{default:r(()=>[s(d,{modelValue:t(l).unit,"onUpdate:modelValue":o[1]||(o[1]=a=>t(l).unit=a),placeholder:e.$t("unitP"),style:{width:"236px"},maxlength:"10"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(n,{label:e.$t("systemName"),prop:"dataFrom"},{default:r(()=>[s(d,{modelValue:t(l).dataFrom,"onUpdate:modelValue":o[2]||(o[2]=a=>t(l).dataFrom=a),placeholder:e.$t("systemNameP"),style:{width:"236px"},maxlength:"20"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(n,{label:e.$t("dataPurpose"),prop:"purpose"},{default:r(()=>[s(T,{modelValue:t(l).purpose,"onUpdate:modelValue":o[3]||(o[3]=a=>t(l).purpose=a),placeholder:e.$t("dataPurposeP"),style:{width:"236px"},teleported:!1},{default:r(()=>[(g(!0),S(x,null,A(t(D),a=>(g(),V(k,{key:a.key,label:a.desc,value:a.key},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),s(n,{label:e.$t("subDeviceCode3"),prop:"subDeviceCodeThird"},{default:r(()=>[s(d,{modelValue:t(l).subDeviceCodeThird,"onUpdate:modelValue":o[4]||(o[4]=a=>t(l).subDeviceCodeThird=a),placeholder:e.$t("subDeviceCode3P"),style:{width:"236px"},maxlength:"50"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(n,{label:e.$t("apiParams"),prop:"params"},{default:r(()=>[s(d,{modelValue:t(l).params,"onUpdate:modelValue":o[5]||(o[5]=a=>t(l).params=a),placeholder:e.$t("apiParamsP"),style:{width:"236px"},maxlength:"200"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])}}};export{te as default};
