import{V as D,I as L,r as N,a5 as $,aH as J,a6 as R,a2 as V,l as F,aG as S,F as T,K as G,W as H}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import{_ as K}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897314.js";import"./index.1703796278973302.js";import"./index.170379627897325.js";import"./index.1703796278973311.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import{a as W,u as q}from"./collector.1703796278973.js";import{O as g}from"./data.1703796278973.js";import{d as z,k as d,m as E,o as Q,c as X,a as l,b as o,t as _,u as t}from"./vue.1703796278973.js";const de=z({__name:"SaveOPCUA",props:{data:{type:Object,default:()=>{}}},emits:["change"],setup(y,{emit:f}){const c=y,m=d(!1),v=d(),p=c.data.id,h=c.data.collectorId,w=c.data.provider,a=d({name:"",configuration:{type:void 0,interval:3e3},accessModes:[],features:[],description:""}),C=async()=>{var u;const r=await((u=v.value)==null?void 0:u.validate()),{interval:e}=a.value.configuration,i={...c.data,...r,provider:w,collectorId:h,interval:e};m.value=!0;const n=p?await q(p,{...c.data,...i}).catch(()=>{}):await W(i).catch(()=>{});f("change",(n==null?void 0:n.status)===200),m.value=!1},b=()=>{f("change",!1)},k=(r,e)=>e.label.toLowerCase().indexOf(r.toLowerCase())>=0;return E(()=>c.data,r=>{var e,i;if(r.id&&r.provider==="OPC_UA"){const n=D(r);a.value=n,(e=n.accessModes[0])!=null&&e.value&&(a.value.accessModes=r.accessModes.map(u=>u.value)),(i=n.features[0])!=null&&i.value&&(a.value.features=r.features.map(u=>u.value))}},{immediate:!0,deep:!0}),(r,e)=>{const i=L,n=N,u=$,x=J,j=R,O=V,U=F,M=S,P=T,I=G,B=K,A=H;return Q(),X(A,{title:"编辑",visible:!0,width:"700px",onCancel:b},{footer:l(()=>[o(I,{key:"back",onClick:b},{default:l(()=>[_("取消")]),_:1}),o(B,{key:"submit",type:"primary",loading:t(m),onClick:C,style:{"margin-left":"8px"},hasPermission:`DataCollect/Collector:${t(p)?"update":"add"}`},{default:l(()=>[_(" 确认 ")]),_:1},8,["loading","hasPermission"])]),default:l(()=>[o(P,{class:"form",layout:"vertical",model:t(a),name:"basic",autocomplete:"off",rules:t(g),ref_key:"formRef",ref:v},{default:l(()=>[o(n,{label:"点位名称",name:"name"},{default:l(()=>[o(i,{placeholder:"请输入点位名称",value:t(a).name,"onUpdate:value":e[0]||(e[0]=s=>t(a).name=s)},null,8,["value"])]),_:1}),o(n,{label:"数据类型",name:["configuration","type"]},{default:l(()=>[o(u,{style:{width:"100%"},value:t(a).configuration.type,"onUpdate:value":e[1]||(e[1]=s=>t(a).configuration.type=s),options:[{value:"Number",label:"数值类型"},{value:"DateTime",label:"时间类型"},{value:"Array",label:"数组类型"},{value:"String",label:"文本类型"},{value:"Boolean",label:"布尔"}],placeholder:"请选择数据类型",allowClear:"","show-search":"","filter-option":k},null,8,["value"])]),_:1}),o(n,{label:"访问类型",name:"accessModes"},{default:l(()=>[o(x,{multiple:"",showImage:!1,value:t(a).accessModes,"onUpdate:value":e[2]||(e[2]=s=>t(a).accessModes=s),options:[{label:"读",value:"read"},{label:"写",value:"write"},{label:"订阅",value:"subscribe"}],column:3},null,8,["value"])]),_:1}),o(n,{label:"采集频率",name:["configuration","interval"],rules:[...t(g).interval]},{default:l(()=>[o(j,{style:{width:"100%"},placeholder:"请输入采集频率",value:t(a).configuration.interval,"onUpdate:value":e[3]||(e[3]=s=>t(a).configuration.interval=s),"addon-after":"ms",max:9999999999999998},null,8,["value"])]),_:1},8,["rules"]),o(n,{label:"",name:["features"]},{default:l(()=>[o(U,{value:t(a).features,"onUpdate:value":e[4]||(e[4]=s=>t(a).features=s)},{default:l(()=>[o(O,{value:"changedOnly",name:"type"},{default:l(()=>[_("只推送变化的数据")]),_:1})]),_:1},8,["value"])]),_:1}),o(n,{label:"说明",name:["description"]},{default:l(()=>[o(M,{placeholder:"请输入说明",value:t(a).description,"onUpdate:value":e[5]||(e[5]=s=>t(a).description=s),maxlength:200,rows:3,showCount:""},null,8,["value"])]),_:1})]),_:1},8,["model","rules"])]),_:1})}}});export{de as _};
