import{d as q,O as rt,k as h,l as Q,m as U,r as K,o as n,x as u,z,b as d,u as a,M as dt,a as m,t as y,c as A,B as c,A as _,F as g,h as pt}from"./vue.1703796278973.js";import{aP as lt,aQ as mt,a0 as ct,aK as ut}from"./index.17037962789732.js";import"./index.1703796278973305.js";import"./index.170379627897315.js";import"./index.170379627897317.js";import"./index.1703796278973301.js";import"./index.1703796278973302.js";import"./index.170379627897332.js";import"./index.1703796278973303.js";import"./index.170379627897339.js";import"./index.170379627897316.js";import"./index.170379627897314.js";import"./index.1703796278973304.js";import"./index.170379627897336.js";import"./index.170379627897323.js";import{u as yt}from"./instance.17037962789732.js";import{u as _t}from"./product.17037962789738.js";import{u as ft}from"./metadata.1703796278973.js";import{_ as j}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import{E as vt,r as xt,a as ht}from"./index.1703796278973159.js";import{aN as T}from"./index.17037962789733.js";import{_ as gt}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"./instance.1703796278973.js";import"./comm.1703796278973.js";import"./system.1703796278973.js";import"./index.170379627897333.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";import"./product.17037962789737.js";import"./encodeQuery.1703796278973.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./index.1703796278973318.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./BaseForm.17037962789732.js";import"./ExpandsForm.vue_vue_type_script_setup_true_name_ExpandsForm_lang.17037962789732.js";import"./data.17037962789732.js";import"./utils.1703796278973.js";import"./moment.1703796278973.js";import"./index.1703796278973319.js";import"./index.170379627897325.js";import"./index.1703796278973312.js";import"./index.170379627897338.js";import"./index.170379627897337.js";import"./index.1703796278973310.js";import"./index.1703796278973320.js";import"./index.170379627897322.js";import"./index.1703796278973158.js";import"./index.1703796278973313.js";import"./index.170379627897327.js";const $=[{title:"标识",dataIndex:"id",width:100},{title:"名称",dataIndex:"name",width:200},{title:"说明",dataIndex:"description",width:200}],It=$.concat([{title:"事件级别",dataIndex:"level"}]),kt=$.concat([{title:"是否异步",dataIndex:"async"}]),wt=$.concat([{title:"数据类型",dataIndex:"valueType"},{title:"属性来源",dataIndex:"source"},{title:"读写类型",dataIndex:"type"}]),Mt=$.concat([{title:"数据类型",dataIndex:"valueType"},{title:"读写类型",dataIndex:"type"}]),w=new Map;w.set("properties",wt);w.set("events",It);w.set("tags",Mt);w.set("functions",kt);const Ct=w,St={class:"table-header"},Nt={key:0,style:{width:"100px"}},Tt={key:1,style:{width:"200px"}},$t={key:2,style:{width:"200px"}},Bt=q({name:"BaseMetadata"}),Et=q({...Bt,props:{type:null,target:null,permission:null},setup(M){const B=M,D=rt(),f=yt(),C=_t(),E=h(!1),S=h([]),{type:s,target:v="product"}=B,G=h({ordinary:"普通",warn:"警告",urgent:"紧急"}),H=h({device:"设备",manual:"手动",rule:"规则"}),W=h({read:"读",write:"写",report:"上报"}),X=[{title:"操作",align:"left",width:80,dataIndex:"action"}],Y={showTotal:(t,e)=>`第 ${e[0]} - ${e[1]} 条/总共 ${t} 条`,showSizeChanger:!0,showQuickJumper:!1,defaultPageSize:10,size:"small"},Z=Q(()=>Ct.get(s).concat(X)),J=Q(()=>{var t;return JSON.parse((v==="product"?(t=C.current)==null?void 0:t.metadata:f.current.metadata)||"{}")}),b=h(),tt=t=>{if(t){const e=J.value[s].filter(i=>i.name.indexOf(t)>-1).sort((i,p)=>(p==null?void 0:p.sortsIndex)-(i==null?void 0:i.sortsIndex));S.value=e}else S.value=J.value[s]},O=()=>{var i,p;E.value=!0;const t=v==="product"?(i=C.current)==null?void 0:i.metadata:f.current.metadata,e=JSON.parse(t||"{}");S.value=(p=e[s])==null?void 0:p.sort((x,k)=>(k==null?void 0:k.sortsIndex)-(x==null?void 0:x.sortsIndex)),E.value=!1};U([D.params.id,s],O,{immediate:!0});const o=ft();U(()=>o.model.importMetadata,t=>{t&&(O(),o.set("importMetadata",!1))});const et=()=>{var t;o.set("edit",!0),o.set("item",void 0),o.set("type",s),o.set("action","add"),B.target==="device"&&!((t=f.detail)!=null&&t.independentMetadata)&&T.warning("修改物模型后会脱离产品物模型")},I=new Map;I.set("events-add","eventNotInsertable"),I.set("events-updata","eventNotModifiable"),I.set("properties-add","propertyNotInsertable"),I.set("properties-updata","propertyNotModifiable");const N=(t,e)=>v==="device"&&(f.detail.features||[]).find(i=>i.id===I.get(`${e}-${t}`)),at=t=>{var e;o.model.edit=!0,o.model.item=t,o.model.type=s,o.model.action="edit",B.target==="device"&&!((e=f.detail)!=null&&e.independentMetadata)&&T.warning("修改物模型后会脱离产品物模型")},ot=async()=>{const{id:t}=D.params;v==="device"?await f.refresh(t):await C.getDetail(t),o.set("importMetadata",!0)},st=async t=>{const e=xt(s,[t],v==="device"?f.current:C.detail);(await ht(v,e)).status===200?(T.success("操作成功!"),o.model.edit=!1,o.model.item={},ot()):T.error("操作失败!")};return(t,e)=>{const i=lt,p=K("AIcon"),x=K("Ellipsis"),k=mt,it=ct,nt=ut;return n(),u(g,null,[z("div",St,[z("div",null,[d(i,{value:a(b),"onUpdate:value":e[0]||(e[0]=r=>dt(b)?b.value=r:null),placeholder:"请输入名称",onSearch:tt,allowClear:""},null,8,["value"])]),z("div",null,[d(j,{type:"primary",hasPermission:`${M.permission}:update`,key:"add",onClick:et,disabled:N("add",a(s)),tooltip:{title:N("add",a(s))?"当前的存储方式不支持新增":"新增"}},{icon:m(()=>[d(p,{type:"PlusOutlined"})]),default:m(()=>[y(" 新增 ")]),_:1},8,["hasPermission","disabled","tooltip"]),a(o).model.edit?(n(),A(vt,{key:0,type:a(v),tabs:a(s),onRefresh:O},null,8,["type","tabs"])):c("",!0)])]),d(nt,{loading:a(E),"data-source":a(S),columns:a(Z),"row-key":"id",model:"TABLE",size:"small",pagination:a(Y)},{bodyCell:m(({column:r,record:l})=>{var V,F,L,R;return[r.dataIndex==="id"?(n(),u("div",Nt,[d(x,null,{default:m(()=>[y(_(l.id||"-"),1)]),_:2},1024)])):c("",!0),r.dataIndex==="name"?(n(),u("div",Tt,[d(x,null,{default:m(()=>[y(_(l.name||"-"),1)]),_:2},1024)])):c("",!0),r.dataIndex==="description"?(n(),u("div",$t,[d(x,null,{default:m(()=>[y(_(l.description||"-"),1)]),_:2},1024)])):c("",!0),r.dataIndex==="level"?(n(),u(g,{key:3},[y(_(a(G)[(V=l.expands)==null?void 0:V.level]||"-"),1)],64)):c("",!0),r.dataIndex==="async"?(n(),u(g,{key:4},[y(_(l.async?"是":"否"),1)],64)):c("",!0),r.dataIndex==="valueType"?(n(),u(g,{key:5},[y(_((F=l.valueType)==null?void 0:F.type),1)],64)):c("",!0),r.dataIndex==="source"?(n(),u(g,{key:6},[y(_(a(H)[(L=l.expands)==null?void 0:L.source]),1)],64)):c("",!0),r.dataIndex==="type"?(n(!0),u(g,{key:7},pt(((R=l.expands)==null?void 0:R.type)||[],P=>(n(),A(k,{key:P},{default:m(()=>[y(_(a(W)[P]),1)]),_:2},1024))),128)):c("",!0),r.dataIndex==="action"?(n(),A(it,{key:8},{default:m(()=>[d(j,{"has-permission":`${M.permission}:update`,type:"link",key:"edit",style:{padding:"0"},disabled:N("updata",a(s)),onClick:P=>at(l),tooltip:{title:N("updata",a(s))?"当前的存储方式不支持编辑":"编辑"}},{default:m(()=>[d(p,{type:"EditOutlined"})]),_:2},1032,["has-permission","disabled","onClick","tooltip"]),d(j,{"has-permission":`${M.permission}:delete`,type:"link",key:"delete",style:{padding:"0"},danger:"","pop-confirm":{title:"确认删除?",onConfirm:async()=>{await st(l)}},tooltip:{title:"删除"}},{default:m(()=>[d(p,{type:"DeleteOutlined"})]),_:2},1032,["has-permission","pop-confirm"])]),_:2},1024)):c("",!0)]}),_:1},8,["loading","data-source","columns","pagination"])],64)}}});const je=gt(Et,[["__scopeId","data-v-e9669a2c"]]);export{je as default};