import{a as q,b as I,r as m,ah as N,o as c,y as V,q as r,v as O,p as s,P as g,x as h,n as t,c as R,F as x,A as B,t as D,s as M,S as L,j as W,k as T,E as z,i as G,m as H,l as J,bv as K,D as Q}from"./index.8d733f79.js";import{p as X,q as Y}from"./systemLink.0379a9eb.js";const Z={class:"dialog-footer"},te={__name:"addAddress",emits:["refesh"],setup(j,{expose:_,emit:b}){const{proxy:i}=Q(),w=q(),{t:n,locale:ee}=I(),u=m(!1),$=[{key:"1",desc:"OPC UA"},{key:"2",desc:"OPC DA 2.0"}],e=m({opcServer:"",type:"",clsid:"",password:"",username:""}),f=m(""),k=N({opcServer:[{required:!0,message:n("opcAddrP"),trigger:"blur"}],type:[{required:!0,message:n("protocolVerP"),trigger:"change"}]});function E(l){u.value=!0,f.value=n(l?"edit":"add"),l&&(e.value.id=l.id,Object.keys(e.value).forEach(o=>{e.value[o]=l[o]}))}function F(){!i.$refs.setFormRef||i.$refs.setFormRef.validate(l=>{l?(e.value.factoryId=w.query.factoryId||"",(e.value.id?X:Y)(e.value).then(d=>{L.success(d.msg),b("refesh"),y()})):console.log("error submit!")})}function y(){u.value=!1}const P=()=>{e.value={opcServer:"",type:"",clsid:"",password:"",username:""},i.$refs.setFormRef.resetFields()};return _({showModal:E}),(l,o)=>{const d=W,p=T,S=z,U=G,A=H,v=J,C=K;return c(),V(C,{title:t(f),modelValue:t(u),"onUpdate:modelValue":o[5]||(o[5]=a=>M(u)?u.value=a:null),width:"500px","align-center":!0,onClosed:P},{footer:r(()=>[O("div",Z,[s(v,{onClick:y},{default:r(()=>[g(h(l.$t("cancel")),1)]),_:1}),s(v,{type:"primary",onClick:F},{default:r(()=>[g(h(l.$t("confirm")),1)]),_:1})])]),default:r(()=>[s(A,{ref:"setFormRef",model:t(e),rules:t(k),"label-width":"120"},{default:r(()=>[s(p,{label:l.$t("opcAddr"),prop:"opcServer"},{default:r(()=>[s(d,{modelValue:t(e).opcServer,"onUpdate:modelValue":o[0]||(o[0]=a=>t(e).opcServer=a),placeholder:l.$t("opcAddrP"),style:{width:"236px"},maxlength:"100"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(p,{label:l.$t("protocolVer"),prop:"type"},{default:r(()=>[s(U,{modelValue:t(e).type,"onUpdate:modelValue":o[1]||(o[1]=a=>t(e).type=a),teleported:!1,placeholder:l.$t("protocolVerP"),style:{width:"236px"}},{default:r(()=>[(c(),R(x,null,B($,a=>s(S,{key:a.key,label:a.desc,value:a.key},null,8,["label","value"])),64))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),t(e).type==="2"?(c(),V(p,{key:0,label:"clsid",prop:"clsid",rules:[{required:!0,message:t(n)("inputP"),trigger:"blur"}]},{default:r(()=>[s(d,{modelValue:t(e).clsid,"onUpdate:modelValue":o[2]||(o[2]=a=>t(e).clsid=a),placeholder:l.$t("inputP"),style:{width:"236px"},maxlength:"100"},null,8,["modelValue","placeholder"])]),_:1},8,["rules"])):D("",!0),s(p,{label:l.$t("userName"),prop:"username"},{default:r(()=>[s(d,{modelValue:t(e).username,"onUpdate:modelValue":o[3]||(o[3]=a=>t(e).username=a),placeholder:l.$t("userNameP"),style:{width:"236px"},maxlength:"100"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(p,{label:l.$t("passWord"),prop:"password"},{default:r(()=>[s(d,{modelValue:t(e).password,"onUpdate:modelValue":o[4]||(o[4]=a=>t(e).password=a),placeholder:l.$t("passWordP"),style:{width:"236px"},maxlength:"100"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])}}};export{te as default};
