import{b as Z,Z as A,J as R,ah as V,r as b,w as F,cE as G,o as d,c as Q,v as c,p as h,n,s as W,aH as $,y as u,q as m,P as x,x as g,t as f,N as X,C as E,aj as S,ay as Y,j as ee,l as te,br as ae,D as ne}from"./index.8d733f79.js";import{E as se}from"./el-text.54dc8292.js";import{f as le,q as oe,j as ie,k as re,m as de,n as ce,o as pe,p as ue,r as me}from"./components.b31a8293.js";import fe from"./addNodeDialog.82695024.js";const _e={class:"components-tab"},ye={class:"tree-content"},ve={class:"df",style:{"margin-bottom":"16px","justify-content":"space-between"}},be={class:"custom-tree-node df"},he=["title"],ge={style:{flex:"1"}},$e={__name:"componentsTab",setup(ke){const{t:L}=Z(),l=A(()=>R.session.getJSON("userInfo")),M=R.session.getJSON("enums").dataType,k=V({tableData:[],columns:[{prop:"name",label:"paramsName"},{prop:"identifier",label:"identifier"},{prop:"dataType",label:"dataType",formatter:e=>{var t;return(t=M.find(a=>+a.key===e.dataType))==null?void 0:t.desc}},{prop:"unit",label:"unit"},{prop:"defaultValue",label:"defaultValue"}]}),D=V({tableData:[],columns:[{prop:"propertyName",label:"metricName"},{prop:"identifier",label:"identifier"},{prop:"unit",label:"unit"}]}),{proxy:i}=ne(),_=b(),y=b([]),C=b(0),j={children:"pointDetailDTOList",label:"name"},p=b("");F(p,e=>{_.value.filter(e)});const B=(e,t,a)=>{if(!e)return!0;const s=[];P(a,s,e);let o=!1;return s.forEach(T=>{o=o||T}),o},P=(e,t,a)=>{const s=e.data&&e.data.name&&e.data.name.toUpperCase().includes(a.toUpperCase());s&&t.push(s),!s&&e.level!==1&&e.parent&&P(e.parent,t,a)},v=()=>{le().then(e=>{y.value=e.data,I(y.value[0].id),Y(()=>{_.value.filter(p.value),_.value.setCurrentKey(y.value[0].globalId)})})};v();const I=e=>{oe({componentId:e}).then(t=>{k.tableData=t.data})},q=e=>{de({id:e}).then(t=>{D.tableData=t.data})},O=()=>{i.$refs.addDialogRef.showModal("add")},U=(e,t,a)=>{let s;t===0?s=a==="add"?ce:pe:s=a==="add"?ue:me,s(e).then(o=>{o.code===200&&(i.$modal.msgSuccess(o.msg),v(),i.$refs.addDialogRef.closeModal())})},J=(e,t)=>{let a;t.level===0?a={dataType:t.level,id:t.id,identifier:t.identifier}:a={dataType:t.level,id:t.id,name:t.name,identifier:t.identifier,componentId:e.parent.data.name,componentIdentifier:e.parent.data.identifier},i.$refs.addDialogRef.showModal("edit",a)},K=(e,t)=>{i.$modal.confirm(L("confirmDelete")).then(()=>{if(t.level===0){const a={id:t.id,identifier:t.identifier};ie(a).then(s=>{i.$modal.msgSuccess(s.msg),v()})}else{const a={pointId:t.id,pointIdentifier:t.identifier,componentIdentifier:e.parent.data.identifier};re(a).then(s=>{i.$modal.msgSuccess(s.msg),v()})}}).catch(()=>{})},z=e=>{C.value=e.level,console.log("\u70B9\u51FB\u8282\u70B9",e),e.level===0&&I(e.id),e.level===1&&q(e.id)};return(e,t)=>{const a=ee,s=te,o=se,T=ae,N=G("hasPermi");return d(),Q("div",_e,[c("div",ye,[c("div",ve,[h(a,{modelValue:n(p),"onUpdate:modelValue":t[0]||(t[0]=r=>W(p)?p.value=r:null),placeholder:e.$t("inputP"),style:{flex:"1"},clearable:"","suffix-icon":"Search"},null,8,["modelValue","placeholder"]),n(l).userLevel===0&&n(l).superType===1?$((d(),u(s,{key:0,type:"primary",onClick:t[1]||(t[1]=r=>O()),style:{"margin-left":"10px"}},{default:m(()=>[x(g(e.$t("add")),1)]),_:1})),[[N,["device_components_add"]]]):f("",!0)]),h(T,null,{default:m(()=>[h(o,{style:{width:"100%"},ref_key:"treeRef",ref:_,class:"filter-tree","node-key":"globalId",data:n(y),props:j,"default-expand-all":"","highlight-current":"","filter-node-method":B,"expand-on-click-node":!1,onNodeClick:z},{default:m(({node:r,data:w})=>[c("div",be,[c("span",{class:X(["node-text",{"txt-omit":n(l).userLevel===0&&n(l).superType===1}]),title:r.label},g(r.label),11,he),c("span",null,[n(l).userLevel===0&&n(l).superType===1?$((d(),u(s,{key:0,link:"",type:"primary",onClick:E(H=>J(r,w),["stop"])},{default:m(()=>[x(g(e.$t("edit")),1)]),_:2},1032,["onClick"])),[[N,["device_components_edit"]]]):f("",!0),n(l).userLevel===0&&n(l).superType===1?$((d(),u(s,{key:1,link:"",type:"danger",onClick:E(H=>K(r,w),["stop"])},{default:m(()=>[x(g(e.$t("delete")),1)]),_:2},1032,["onClick"])),[[N,["device_components_delete"]]]):f("",!0)])])]),_:1},8,["data"])]),_:1})]),c("div",ge,[n(C)===0?(d(),u(n(S),{key:0,columns:n(k).columns,tableData:n(k).tableData,pagination:!1,style:{height:"100%"}},null,8,["columns","tableData"])):f("",!0),n(C)===1?(d(),u(n(S),{key:1,columns:n(D).columns,tableData:n(D).tableData,pagination:!1,style:{height:"100%"}},null,8,["columns","tableData"])):f("",!0)]),h(n(fe),{ref:"addDialogRef",onConfirm:U},null,512)])}}};export{$e as default};
