import{a as w,b as F,r as C,ah as h,o as I,y as U,q as s,v as q,p as t,P as b,x as g,n as o,s as E,S as R,j as k,k as x,m as B,l as N,bv as S,D as A}from"./index.8d733f79.js";import{n as z,o as G}from"./systemLink.0379a9eb.js";const H={class:"dialog-footer"},O={__name:"addCode",emits:["refesh"],setup(J,{expose:V,emit:D}){const{proxy:c}=A(),T=w(),{t:i}=F(),u=C(!1),d=h({factoryId:T.query.factoryId||"",deviceCode:"",deviceCodeThird:"",modelCode:"",subDeviceCodeThird:"",subModelCode:""}),v=C(""),$=h({deviceCodeThird:[{required:!0,message:i("deviceCode3P"),trigger:"blur"}],deviceCode:[{required:!0,message:i("deviceCode1P"),trigger:"blur"}],modelCode:[{required:!0,message:i("modelCodeP"),trigger:"blur"}],subDeviceCodeThird:[{required:!0,message:i("subDeviceCode3P"),trigger:"blur"}]}),m=C();function y(e){u.value=!0,v.value=e.id?i("edit"):i("add"),e&&(m.value=e.id,d.deviceCode=e.deviceCode,d.deviceCodeThird=e.deviceCodeThird,d.modelCode=e.modelCode,d.subDeviceCodeThird=e.subDeviceCodeThird,d.subModelCode=e.subModelCode),setTimeout(()=>{c.$refs.setFormRef.clearValidate()},30)}function M(){!c.$refs.setFormRef||c.$refs.setFormRef.validate(e=>{if(e){const l=m.value?z:G;m.value&&(d.id=m.value),l(d).then(r=>{R.success(r.msg),D("refesh"),p()})}else console.log("error submit!")})}function p(){u.value=!1}return V({showModal:y}),(e,l)=>{const r=k,n=x,P=B,f=N,_=S;return I(),U(_,{title:o(v),modelValue:o(u),"onUpdate:modelValue":l[5]||(l[5]=a=>E(u)?u.value=a:null),width:"500px","align-center":!0,onClose:p},{footer:s(()=>[q("div",H,[t(f,{onClick:p},{default:s(()=>[b(g(e.$t("cancel")),1)]),_:1}),t(f,{type:"primary",onClick:M},{default:s(()=>[b(g(e.$t("confirm")),1)]),_:1})])]),default:s(()=>[t(P,{ref:"setFormRef",model:o(d),rules:o($),"label-width":"165"},{default:s(()=>[t(n,{label:e.$t("deviceCode3"),prop:"deviceCodeThird"},{default:s(()=>[t(r,{modelValue:o(d).deviceCodeThird,"onUpdate:modelValue":l[0]||(l[0]=a=>o(d).deviceCodeThird=a),placeholder:e.$t("deviceCode3P"),style:{width:"236px"},maxlength:"50"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),t(n,{label:e.$t("deviceCode1"),prop:"deviceCode"},{default:s(()=>[t(r,{modelValue:o(d).deviceCode,"onUpdate:modelValue":l[1]||(l[1]=a=>o(d).deviceCode=a),placeholder:e.$t("deviceCode1P"),style:{width:"236px"},maxlength:"50"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),t(n,{label:e.$t("modelCode"),prop:"modelCode"},{default:s(()=>[t(r,{modelValue:o(d).modelCode,"onUpdate:modelValue":l[2]||(l[2]=a=>o(d).modelCode=a),placeholder:e.$t("modelCodeP"),style:{width:"236px"},maxlength:"50"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),t(n,{label:e.$t("subDeviceCode3"),prop:"subDeviceCodeThird"},{default:s(()=>[t(r,{modelValue:o(d).subDeviceCodeThird,"onUpdate:modelValue":l[3]||(l[3]=a=>o(d).subDeviceCodeThird=a),placeholder:e.$t("subDeviceCode3P"),style:{width:"236px"},maxlength:"50"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),t(n,{label:e.$t("subDeviceCode"),prop:"subModelCode"},{default:s(()=>[t(r,{modelValue:o(d).subModelCode,"onUpdate:modelValue":l[4]||(l[4]=a=>o(d).subModelCode=a),placeholder:e.$t("subDeviceCodeP"),style:{width:"236px"},maxlength:"50"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])}}};export{O as default};
