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