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