import{d as V,s as Y,K as J,k as r,r as T,u as s,o as l,c as v,x as w,b as n,a as o,t as _,B as D,A as O,F as j,h as F}from"./vue.1703796278973.js";import{a0 as H,L as z,ax as U}from"./index.17037962789732.js";import"./index.1703796278973300.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.1703796278973305.js";import"./index.1703796278973306.js";import"./index.170379627897333.js";import"./index.170379627897336.js";import{_ as G}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import{h as Q}from"./moment.1703796278973.js";import{k as W,K as X,L as Z}from"./instance.1703796278973.js";import{u as ee}from"./instance.17037962789732.js";import"./default.1703796278973.js";import"./index.1703796278973299.js";import{_ as te}from"./index.vue_vue_type_script_setup_true_lang.170379627897316.js";import{u as se}from"./permission.1703796278973.js";import{_ as oe}from"./index.vue_vue_type_script_setup_true_lang.170379627897318.js";import{aN as g}from"./index.17037962789733.js";const ae={key:1},Ne=V({__name:"index",setup(ie){const B=ee(),{detail:p}=Y(B),P=J(),d=r(!1);se();const m=new Map;m.set("online","success"),m.set("offline","error"),m.set("notActive","warning");const u=r({}),x=r({}),c=r([]),h=r(!1),k=r({}),C=[{title:"ID",dataIndex:"id",key:"id",ellipsis:!0,search:{type:"string",defaultTermType:"eq"}},{title:"设备名称",dataIndex:"name",key:"name",ellipsis:!0,search:{type:"string"}},{title:"所属产品",dataIndex:"productName",key:"productName",search:{type:"string"}},{title:"注册时间",dataIndex:"registryTime",key:"registryTime",scopedSlots:!0,search:{type:"date"}},{title:"状态",dataIndex:"state",key:"state",scopedSlots:!0,search:{type:"select",options:[{label:"禁用",value:"notActive"},{label:"离线",value:"offline"},{label:"在线",value:"online"}]}},{title:"说明",dataIndex:"describe",key:"describe",ellipsis:!0,search:{type:"string"}},{title:"操作",key:"action",fixed:"right",width:200,scopedSlots:!0}],A=e=>e?[{key:"view",text:"查看",tooltip:{title:"查看"},icon:"EyeOutlined",onClick:()=>{P.push("/iot/device/instance/detail/"+e.id)}},{key:"action",text:"解绑",tooltip:{title:"解绑"},icon:"DisconnectOutlined",popConfirm:{title:"确认解绑吗？",okText:"确定",cancelText:"取消",onConfirm:async()=>{var f;(await X(p.value.id,e.id,{})).status===200&&((f=u.value)==null||f.reload(),g.success("操作成功！"))}}},{key:"update",text:"编辑",tooltip:{title:"编辑"},icon:"EditOutlined",onClick:()=>{k.value=e,d.value=!0}}]:[],R=e=>{x.value=e},N=e=>{c.value=[...e]},b=()=>{c.value=[]},q=async()=>{var e;c.value.length?(await Z(p.value.id,c.value)).status===200&&(g.success("操作成功！"),b(),(e=u.value)==null||e.reload()):g.warning("请勾选需要解绑的数据")},E=e=>{var a;h.value=!1,e&&((a=u.value)==null||a.reload())},$=()=>{d.value=!1};return(e,a)=>{var I;const f=T("pro-search"),y=G,S=H,K=z,L=T("AIcon"),M=U;return s(d)?(l(),v(oe,{key:0,onCloseChildSave:$,childData:s(k)},null,8,["childData"])):(l(),w("div",ae,[n(f,{columns:C,target:"child-device",onSearch:R,class:"device-child-device-search"}),n(M,{ref_key:"childDeviceRef",ref:u,columns:C,request:s(W),bodyStyle:{padding:0},defaultParams:{terms:[{column:"parentId",value:((I=s(p))==null?void 0:I.id)||"",termType:"eq"}]},rowSelection:{selectedRowKeys:s(c),onChange:N},onCancelSelect:b,params:s(x),model:"TABLE"},{rightExtraRender:o(()=>[n(S,null,{default:o(()=>{var t;return[((t=s(p))==null?void 0:t.accessProvider)==="official-edge-gateway"?(l(),v(y,{key:0,type:"primary",hasPermission:"device/Instance:update",onClick:a[0]||(a[0]=i=>{k.value={},d.value=!0})},{default:o(()=>[_("新增并绑定")]),_:1})):D("",!0),n(y,{type:"primary",onClick:a[1]||(a[1]=i=>h.value=!0),hasPermission:"device/Instance:update"},{default:o(()=>[_(" 绑定")]),_:1}),n(y,{type:"primary",hasPermission:"device/Instance:update",popConfirm:{title:"确定解绑吗？",onConfirm:q}},{default:o(()=>[_("批量解除")]),_:1},8,["popConfirm"])]}),_:1})]),registryTime:o(t=>[_(O(t.registryTime?s(Q)(t.registryTime).format("YYYY-MM-DD HH:mm:ss"):""),1)]),state:o(t=>[n(K,{text:t.state.text,status:s(m).get(t.state.value)},null,8,["text","status"])]),action:o(t=>[n(S,{size:16},{default:o(()=>[(l(!0),w(j,null,F(A(t,"table"),i=>(l(),v(y,{key:i.key,disabled:i.disabled,popConfirm:i.popConfirm,tooltip:{...i.tooltip},onClick:i.onClick,type:"link",style:{padding:"0px"},hasPermission:"device/Instance:"+i.key},{icon:o(()=>[n(L,{type:i.icon},null,8,["type"])]),_:2},1032,["disabled","popConfirm","tooltip","onClick","hasPermission"]))),128))]),_:2},1024)]),_:1},8,["request","defaultParams","rowSelection","params"]),s(h)?(l(),v(te,{key:0,onChange:E})):D("",!0)]))}}});export{Ne as _};
