import{M as g,aL as J,aB as K,K as N,Z as T,cH as O,cI as V,aA as z,W as E}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.1703796278973303.js";import"./index.1703796278973321.js";import"./index.170379627897317.js";import"./index.170379627897339.js";import"./index.170379627897316.js";import"./index.170379627897319.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./index.1703796278973308.js";import"./index.170379627897334.js";import"./index.170379627897327.js";import"./index.1703796278973304.js";import{aa as H,a6 as G}from"./instance.1703796278973.js";import{d as R,k as i,w as U,r as W,o as Z,c as $,a as s,z as u,b as n,u as r,t as b,A as q,G as F,H as Q}from"./vue.1703796278973.js";import{_ as X}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.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"./index.170379627897332.js";import"./index.170379627897333.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";const Y=p=>(F("data-v-16362b10"),p=p(),Q(),p),tt={class:"map-tree"},et=Y(()=>u("div",{class:"map-tree-top"}," 采集器的点位名称与属性名称一致时将自动映射绑定;有多个采集器点位名称与属性名称一致时以第1个采集器的点位数据进行绑定 ",-1)),ot={class:"map-tree-content"},at={style:{width:"100px"}},st=R({__name:"PatchMapping",props:{type:{type:String,default:"MODBUS_TCP"},metaData:{type:Array,default:()=>[]},deviceId:{type:String,default:""}},emits:["close","save"],setup(p,{emit:I}){const c=p,h=i([]),d=i([]),a=i([]),k=i([]),f=i(!1),v=(e,o)=>(e.forEach(t=>{t.key=t.id,t.title=t.name,t.checkable=o==="collectors",t.collectors&&Array.isArray(t.collectors)&&t.collectors.length&&(t.children=v(t.collectors,"collectors")),t.points&&Array.isArray(t.points)&&t.points.length&&(t.children=v(t.points,"points"))}),e),x=async()=>{f.value=!0;const e=await H({terms:[{column:"provider",value:c.type}]});f.value=!1,e.status===200&&(k.value=v(e.result,"channel"))},w=(e,o)=>{h.value=[...e],d.value=(o==null?void 0:o.checkedNodes)||[]},A=()=>{a.value=d.value},M=e=>{const o=a.value.findIndex(t=>t.key===e);a.value.splice(o,1),h.value=a.value.map(t=>t.key),d.value=a.value},S=async()=>{if(!a.value.length)g.warning("请选择采集器");else{const e=[];a.value.map(t=>{const _=(t.children||[]).map(l=>{var m;return{channelId:t.parentId,collectorId:l.collectorId,pointId:l.id,metadataType:"property",metadataId:(m=c.metaData.find(y=>y.name===l.name))==null?void 0:m.metadataId,provider:c.type}});e.push(..._)});const o=e.filter(t=>!!t.metadataId);o&&o.length!==0?(await G(c.deviceId,c.type,o)).status===200&&(g.success("操作成功"),I("save")):g.error("暂无对应属性的映射")}},j=()=>{I("close")};return U(()=>{c.type&&x()}),(e,o)=>{const t=J,_=K,l=N,m=W("AIcon"),y=T,L=O,B=V,D=z,P=E;return Z(),$(P,{width:"900px",title:"批量映射",visible:"",onOk:S,onCancel:j},{default:s(()=>[u("div",tt,[et,n(D,{spinning:r(f)},{default:s(()=>[u("div",ot,[n(_,{class:"map-tree-content-card",title:"源数据"},{default:s(()=>[n(t,{checkable:"",height:300,"tree-data":r(k),checkedKeys:r(h),onCheck:w},null,8,["tree-data","checkedKeys"])]),_:1}),u("div",at,[n(l,{disabled:r(a).length>=r(d).length,onClick:A},{default:s(()=>[b("加入右侧")]),_:1},8,["disabled"])]),n(_,{class:"map-tree-content-card",title:"采集器"},{default:s(()=>[n(B,{size:"small","data-source":r(a),class:"map-tree-content-card-list"},{renderItem:s(({item:C})=>[n(L,null,{actions:s(()=>[n(y,{title:"确定删除?",onConfirm:nt=>M(C.key)},{default:s(()=>[n(m,{type:"DeleteOutlined"})]),_:2},1032,["onConfirm"])]),default:s(()=>[b(q(C.title)+" ",1)]),_:2},1024)]),_:1},8,["data-source"])]),_:1})])]),_:1},8,["spinning"])])]),_:1})}}});const Ot=X(st,[["__scopeId","data-v-16362b10"]]);export{Ot as default};