import{K as z,a0 as G,Y as H,a9 as W,a5 as X,r as ee,L as te,Z as ae,aK as oe,F as ne,aB as de,aA as re,a as se}from"./index.17037962789732.js";import"./index.170379627897317.js";import"./index.1703796278973303.js";import"./index.1703796278973308.js";import"./index.170379627897334.js";import"./index.170379627897319.js";import"./index.170379627897327.js";import"./index.170379627897318.js";import"./index.1703796278973305.js";import"./index.170379627897315.js";import"./index.1703796278973301.js";import"./index.1703796278973302.js";import"./index.170379627897332.js";import"./index.170379627897339.js";import"./index.170379627897316.js";import"./index.170379627897314.js";import"./index.1703796278973304.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./index.170379627897333.js";import"./index.170379627897336.js";import{u as le}from"./instance.17037962789732.js";import{a4 as ie,a5 as pe,a6 as ce,a7 as me}from"./instance.1703796278973.js";import{_ as U}from"./MSelect.vue_vue_type_script_setup_true_lang.17037962789733.js";import ue from"./PatchMapping.17037962789733.js";import{d as _e,k as g,v as fe,p as ye,r as Ie,u as p,o as r,c as l,a,b as n,t as h,x as C,F as w,B as c,h as ve,A as ge,a5 as he}from"./vue.1703796278973.js";import{aN as M}from"./index.17037962789733.js";import{_ as ke}from"./_plugin-vue_export-helper.1703796278973.js";import"./dayjs.min.1703796278973.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./comm.1703796278973.js";import"./system.1703796278973.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";import"./index.170379627897337.js";import"./index.1703796278973321.js";const be=_e({__name:"index",props:{provider:{type:String,default:"MODBUS_TCP"}},setup(j){var B;const V=j,P=[{title:"名称",dataIndex:"metadataName",key:"metadataName",width:"20%"},{title:"通道",dataIndex:"channelId",key:"channelId",width:"20%"},{title:"采集器",dataIndex:"collectorId",key:"collectorId",width:"20%"},{title:"点位",key:"pointId",dataIndex:"pointId",width:"20%"},{title:"状态",key:"id",dataIndex:"id",width:"10%"},{title:"操作",key:"action",width:"10%"}],$=(t,e)=>e.label.toLowerCase().indexOf(t.toLowerCase())>=0,u=le(),L=JSON.parse(((B=u.current)==null?void 0:B.metadata)||"{}"),k=g(!1),N=g([]),_=fe({dataSource:[]}),O=g(),y=g(!1),E=async()=>{var e;const t=await me({paging:!1,terms:[{terms:[{column:"provider",value:V.provider}]}]});t.status===200&&(N.value=(e=t.result)==null?void 0:e.map(i=>({label:i.name,value:i.id,provider:i.provider})))},I=async()=>{k.value=!0,E();const t=L.properties.map(e=>({metadataId:e.id,metadataName:`${e.name}(${e.id})`,metadataType:"property",name:e.name}));if(t&&t.length){const e=await ie("device",u.current.id);if(e.status===200){const i=e.result.reduce((v,m)=>{const f=t.find(b=>b.metadataId===m.metadataId);return f?Object.assign(f,m):v.push(m),v},t);_.dataSource=i}}k.value=!1},R=async t=>{t&&(await pe("device",u.current.id,[t])).status===200&&(M.success("操作成功!"),I())},q=()=>{y.value=!1,I()};ye(()=>{I()});const A=()=>{O.value.validate().then(async()=>{const t=he(_).dataSource.filter(e=>e.channelId);t&&t.length!==0&&(await ce(u.current.id,V.provider,t)).status===200&&(M.success("操作成功!"),I())}).catch(t=>{console.log("error",t)})};return(t,e)=>{const i=z,v=G,m=Ie("AIcon"),f=H,b=W,D=X,x=ee,T=te,F=ae,K=oe,Q=ne,J=de,Y=re,Z=se;return p(L).properties.length?(r(),l(Y,{key:0,spinning:p(k)},{default:a(()=>[n(J,{bordered:!1,borderStyle:"padding: 0"},{extra:a(()=>[n(v,null,{default:a(()=>[n(i,{onClick:e[0]||(e[0]=o=>y.value=!0)},{default:a(()=>[h("批量映射")]),_:1}),n(i,{type:"primary",onClick:A},{default:a(()=>[h("保存")]),_:1})]),_:1})]),default:a(()=>[n(Q,{ref_key:"formRef",ref:O,model:p(_)},{default:a(()=>[n(K,{dataSource:p(_).dataSource,columns:P},{headerCell:a(({column:o})=>[o.key==="collectorId"?(r(),C(w,{key:0},[h(" 采集器 "),n(f,{title:"数据采集中配置的真实物理设备"},{default:a(()=>[n(m,{type:"QuestionCircleOutlined"})]),_:1})],64)):c("",!0)]),bodyCell:a(({column:o,record:d,index:S})=>[o.dataIndex==="channelId"?(r(),l(x,{key:0,name:["dataSource",S,"channelId"]},{default:a(()=>[n(D,{style:{width:"100%"},value:d[o.dataIndex],"onUpdate:value":s=>d[o.dataIndex]=s,placeholder:"请选择",allowClear:"","filter-option":$},{default:a(()=>[(r(!0),C(w,null,ve(p(N),s=>(r(),l(b,{key:s.value,value:s.value,label:s.label},{default:a(()=>[h(ge(s.label),1)]),_:2},1032,["value","label"]))),128))]),_:2},1032,["value","onUpdate:value"])]),_:2},1032,["name"])):c("",!0),o.dataIndex==="collectorId"?(r(),l(x,{key:1,name:["dataSource",S,"collectorId"],rules:[{required:!!d.channelId,message:"请选择采集器"}]},{default:a(()=>[n(U,{modelValue:d[o.dataIndex],"onUpdate:modelValue":s=>d[o.dataIndex]=s,id:d.channelId,type:"COLLECTOR"},null,8,["modelValue","onUpdate:modelValue","id"])]),_:2},1032,["name","rules"])):c("",!0),o.dataIndex==="pointId"?(r(),l(x,{key:2,name:["dataSource",S,"pointId"],rules:[{required:!!d.channelId,message:"请选择点位"}]},{default:a(()=>[n(U,{modelValue:d[o.dataIndex],"onUpdate:modelValue":s=>d[o.dataIndex]=s,id:d.collectorId,type:"POINT"},null,8,["modelValue","onUpdate:modelValue","id"])]),_:2},1032,["name","rules"])):c("",!0),o.dataIndex==="id"?(r(),C(w,{key:3},[d[o.dataIndex]?(r(),l(T,{key:0,status:"success",text:"已绑定"})):(r(),l(T,{key:1,status:"error",text:"未绑定"}))],64)):c("",!0),o.key==="action"?(r(),l(f,{key:4,title:"解绑"},{default:a(()=>[n(F,{title:"确认解绑",disabled:!d.id,onConfirm:s=>R(d.id)},{default:a(()=>[n(i,{type:"link",disabled:!d.id},{default:a(()=>[n(m,{type:"icon-jiebang"})]),_:2},1032,["disabled"])]),_:2},1032,["disabled","onConfirm"])]),_:2},1024)):c("",!0)]),_:1},8,["dataSource"])]),_:1},8,["model"])]),_:1}),p(y)?(r(),l(ue,{key:0,deviceId:p(u).current.id,onClose:e[1]||(e[1]=o=>y.value=!1),onSave:q,type:j.provider,metaData:p(_).dataSource},null,8,["deviceId","type","metaData"])):c("",!0)]),_:1},8,["spinning"])):(r(),l(J,{key:1,bordered:!1,borderStyle:"padding: 0"},{default:a(()=>[n(Z,{description:"暂无数据,请配置物模型",style:{margin:"10% 0"}})]),_:1}))}}});const pt=ke(be,[["__scopeId","data-v-53b60633"]]);export{pt as default};