import{V as de,K as ie,a0 as re,Y as le,a9 as pe,a5 as ue,r as ce,L as me,Z as _e,aK as fe,a8 as ve,F as Ie,aB as ye,aA as ge,a as he}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.170379627897339.js";import"./index.170379627897316.js";import"./index.1703796278973305.js";import"./index.170379627897315.js";import"./index.1703796278973301.js";import"./index.1703796278973302.js";import"./index.170379627897332.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 Se}from"./instance.17037962789732.js";import{H as be,J as z,F as ke,D as F}from"./instance.1703796278973.js";import{_ as K}from"./MSelect.vue_vue_type_script_setup_true_lang.17037962789732.js";import Ce from"./PatchMapping.17037962789732.js";import{o as A}from"./comm.1703796278973.js";import{u as xe}from"./permission.1703796278973.js";import{d as we,k,l as je,v as Ve,p as Le,r as Pe,u as d,o as l,c as _,a,b as i,t as V,x as L,F as P,B as h,h as Ue,A as Be,z as Je,M as H,a5 as Ne}from"./vue.1703796278973.js";import{_ as Oe}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"./system.1703796278973.js";import"./default.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";import"./index.170379627897337.js";import"./index.1703796278973321.js";const Ae={class:"pagination"},Ee=we({__name:"index",setup(Me){var D;const Q=[{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%"}],b=xe().hasPermission("device/Instance:update"),C=k(0),U=k(10),p=Se(),B=JSON.parse(((D=p.current)==null?void 0:D.metadata)||"{}"),S=k(!1),E=k([]),J=je(()=>{const t=C.value>=1?C.value:1;return B.properties.slice((t-1)*10,t*10)}),m=Ve({dataSource:[]}),M=k(),w=k(!1),Y=async()=>{var t,e,s;if((t=p.current)!=null&&t.parentId){const u=await be(p.current.parentId);u.status===200&&(E.value=(s=(e=u.result)==null?void 0:e[0])==null?void 0:s.map(o=>({label:o.name,value:o.id,provider:o.provider})))}},N=async t=>{var s,u;S.value=!0;const e=t.map(o=>({metadataId:o.id,metadataName:`${o.name}(${o.id})`,metadataType:"property",name:o.name}));if(e&&e.length){const o=await z(((s=p.current)==null?void 0:s.parentId)||"",{deviceId:p.current.id,query:{}}).catch(()=>{m.dataSource=e,S.value=!1});if(o.status===200){const f=(u=o.result)==null?void 0:u[0].reduce((g,I)=>{const y=e.find(v=>v.metadataId===I.metadataId);return y?Object.assign(y,I):g.push(I),g},e);m.dataSource=f}}S.value=!1},Z=async t=>{var s;const e=p.current.id;t&&e&&(await ke(((s=p.current)==null?void 0:s.parentId)||"",{deviceId:e,idList:[t]})).status===200&&(A("操作成功!","success"),N(J.value))},G=()=>{w.value=!1,O()},$=(t,e)=>{e==="channel"&&(m.dataSource[t].collectorId=void 0),m.dataSource[t].pointId=void 0};Le(()=>{Y(),N(J.value)});const W=()=>{N(J.value)},X=()=>{M.value.validate().then(async t=>{var s;const e=Ne(m).dataSource.filter(u=>u.channelId);if(e&&e.length!==0){const u={deviceId:p.current.id,provider:(s=e[0])==null?void 0:s.provider,requestList:e};(await F(p.current.parentId||"",u)).status===200&&(A("操作成功!","success"),O())}}).catch(t=>{console.log("error",t)})},ee=async t=>{var I,y;const e=(I=m.dataSource||[])==null?void 0:I.filter(v=>v.channelId),u={...e.find(v=>v.id===(t==null?void 0:t.id)),state:(t==null?void 0:t.state.value)==="enabled"?"disabled":"enabled"},o=e.filter(v=>v.id!==(t==null?void 0:t.id)),f={deviceId:p.current.id,provider:(y=e[0])==null?void 0:y.provider,requestList:[...o,u]};(await F(p.current.parentId||"",f)).status===200&&(A("操作成功!","success"),O())},O=async()=>{var t,e;if(S.value=!0,m.dataSource&&m.dataSource.length){const s=await z(((t=p.current)==null?void 0:t.parentId)||"",{deviceId:p.current.id,query:{}}).catch(()=>{S.value=!1});if(s.status===200){const u=de(m.dataSource),o=(e=s.result)==null?void 0:e[0].map(f=>{const g=u.find(I=>I.metadataId===f.metadataId);return g?{...g,...f}:f});m.dataSource=o}}S.value=!1};return(t,e)=>{const s=ie,u=re,o=Pe("AIcon"),f=le,g=pe,I=ue,y=ce,v=me,R=_e,te=fe,ae=ve,ne=Ie,q=ye,oe=ge,se=he;return d(B).properties.length?(l(),_(oe,{key:0,spinning:d(S)},{default:a(()=>[i(q,{bordered:!1,style:{padding:"0"}},{extra:a(()=>[i(u,null,{default:a(()=>[i(s,{onClick:e[0]||(e[0]=j=>w.value=!0)},{default:a(()=>[V("批量映射")]),_:1}),i(s,{type:"primary",onClick:X},{default:a(()=>[V("保存")]),_:1})]),_:1})]),default:a(()=>[i(ne,{ref_key:"formRef",ref:M,model:d(m)},{default:a(()=>{var j,T;return[i(te,{dataSource:d(m).dataSource,columns:Q,pagination:!1},{headerCell:a(({column:r})=>[r.key==="collectorId"?(l(),L(P,{key:0},[V(" 采集器 "),i(f,{title:"边缘网关代理的真实物理设备"},{default:a(()=>[i(o,{type:"QuestionCircleOutlined"})]),_:1})],64)):h("",!0)]),bodyCell:a(({column:r,record:n,index:x})=>[r.dataIndex==="channelId"?(l(),_(y,{key:0,name:["dataSource",x,"channelId"]},{default:a(()=>[i(I,{style:{width:"100%"},value:n[r.dataIndex],"onUpdate:value":c=>n[r.dataIndex]=c,placeholder:"请选择",allowClear:"",onChange:()=>$(x,"channel")},{default:a(()=>[(l(!0),L(P,null,Ue(d(E),c=>(l(),_(g,{key:c.value,value:c.value,label:c.label},{default:a(()=>[V(Be(c.label),1)]),_:2},1032,["value","label"]))),128))]),_:2},1032,["value","onUpdate:value","onChange"])]),_:2},1032,["name"])):h("",!0),r.dataIndex==="collectorId"?(l(),_(y,{key:1,name:["dataSource",x,"collectorId"],rules:[{required:!!n.channelId,message:"请选择采集器"}]},{default:a(()=>[i(K,{modelValue:n[r.dataIndex],"onUpdate:modelValue":c=>n[r.dataIndex]=c,id:n.channelId,type:"COLLECTOR",edgeId:d(p).current.parentId,provider:n.provider,"onUpdate:provider":c=>n.provider=c,onChange:c=>$(x,"collector")},null,8,["modelValue","onUpdate:modelValue","id","edgeId","provider","onUpdate:provider","onChange"])]),_:2},1032,["name","rules"])):h("",!0),r.dataIndex==="pointId"?(l(),_(y,{key:2,name:["dataSource",x,"pointId"],rules:[{required:!!n.channelId,message:"请选择点位"}]},{default:a(()=>[i(K,{modelValue:n[r.dataIndex],"onUpdate:modelValue":c=>n[r.dataIndex]=c,id:n.collectorId,type:"POINT",edgeId:d(p).current.parentId},null,8,["modelValue","onUpdate:modelValue","id","edgeId"])]),_:2},1032,["name","rules"])):h("",!0),r.dataIndex==="id"?(l(),L(P,{key:3},[n[r.dataIndex]?(l(),L(P,{key:0},[n.state.value==="enabled"?(l(),_(v,{key:0,status:"success",text:"在线"})):(l(),_(v,{key:1,status:"warning",text:"离线"}))],64)):(l(),_(v,{key:1,status:"error",text:"未绑定"}))],64)):h("",!0),r.key==="action"?(l(),_(u,{key:4},{default:a(()=>[i(f,{title:d(b)?"解绑":"暂无权限,请联系管理员"},{default:a(()=>[i(R,{title:"确认解绑?",disabled:!n.id||!d(b),onConfirm:c=>Z(n.id)},{default:a(()=>[i(s,{type:"link",disabled:!n.id||!d(b),style:{padding:"0 5px"}},{default:a(()=>[i(o,{type:"icon-jiebang"})]),_:2},1032,["disabled"])]),_:2},1032,["disabled","onConfirm"])]),_:2},1032,["title"]),n.id?(l(),_(f,{key:0,title:d(b)?n.state.value==="enabled"?"禁用":"启用":"暂无权限,请联系管理员"},{default:a(()=>[i(R,{title:n.state.value==="enabled"?"确认禁用?":"确认启用?",disabled:!d(b),onConfirm:c=>ee(n)},{default:a(()=>[i(s,{type:"link",style:{padding:"0 5px"},disabled:!d(b)},{default:a(()=>[n.state.value==="enabled"?(l(),_(o,{key:0,type:"StopOutlined"})):(l(),_(o,{key:1,type:"PlayCircleOutlined"}))]),_:2},1032,["disabled"])]),_:2},1032,["title","disabled","onConfirm"])]),_:2},1032,["title"])):h("",!0)]),_:2},1024)):h("",!0)]),_:1},8,["dataSource"]),Je("div",Ae,[i(ae,{pageSize:d(U),"onUpdate:pageSize":e[1]||(e[1]=r=>H(U)?U.value=r:null),current:d(C),"onUpdate:current":e[2]||(e[2]=r=>H(C)?C.value=r:null),total:((T=(j=d(B))==null?void 0:j.properties)==null?void 0:T.length)||0,onChange:W},null,8,["pageSize","current","total"])])]}),_:1},8,["model"])]),_:1}),d(w)?(l(),_(Ce,{key:0,deviceId:d(p).current.id,onClose:e[3]||(e[3]=j=>w.value=!1),onSave:G,metaData:d(m).dataSource,edgeId:d(p).current.parentId},null,8,["deviceId","metaData","edgeId"])):h("",!0)]),_:1},8,["spinning"])):(l(),_(q,{key:1,bordered:!1,style:{padding:"0"}},{default:a(()=>[i(se,{description:"暂无数据,请配置物模型",style:{margin:"10% 0"}})]),_:1}))}}});const jt=Oe(Ee,[["__scopeId","data-v-42a0ced6"]]);export{jt as default};