import{d as B,O as W,k as g,v as $,p as G,m as Q,r as M,o as k,x as X,b as h,a as r,D as Z,u as o,M as ee,c as R,t as te,B as j,z as y,A as x,F as ae}from"./vue.1703796278973.js";import{I as se,a2 as ne,L as oe,ax as le,W as re}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.1703796278973300.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{d as ce,e as ie}from"./firmware.1703796278973.js";import{h as de}from"./moment.1703796278973.js";import{_ as pe}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"./comm.1703796278973.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";const ue=B({name:"SelectDevicesPage"}),me=B({...ue,props:{data:{type:Object,default:()=>{}}},emits:["update:modelValue","change"],setup(w,{emit:b}){const u=w,V=W(),S=g({}),f=g(!1),a=g([]),i=$({indeterminate:!1,checkAll:!1,checkedList:[]});let d=[];const _=new Map,p=g(),I={context:{includeTags:!1,includeBind:!1,includeRelations:!1},terms:[{terms:[{column:"productId",value:V.query.productId}],type:"and"}],sorts:[{name:"createTime",order:"desc"}]},v=new Map;v.set("online","processing"),v.set("offline","error"),v.set("notActive","warning");const A=[{title:"ID",key:"id",dataIndex:"id",fixed:"left",width:200,ellipsis:!0,search:{type:"string"}},{title:"设备名称",key:"name",dataIndex:"name",ellipsis:!0,search:{type:"string"}},{title:"固件版本",dataIndex:"version",key:"version",ellipsis:!0,search:{type:"string"},scopedSlots:!0},{title:"注册时间",key:"registerTime",dataIndex:"registerTime",search:{type:"date",rename:"registryTime"},width:200,scopedSlots:!0},{title:"状态",dataIndex:"state",key:"state",scopedSlots:!0,search:{type:"select",options:[{label:"在线",value:"online"},{label:"离线",value:"offline"},{label:"禁用",value:"notActive"}]},width:150}],O=e=>{Object.assign(i,{checkedList:e.target.checked?d:[],indeterminate:!1}),a.value=i.checkedList},N=(e,t,n)=>{a.value=t?[...D(n)]:a.value.filter(l=>l!==(e==null?void 0:e.id))},q=(e,t,n)=>{const l=C(n);a.value=e?[...D(t)]:a.value.concat(l).filter(c=>!l.includes(c))},C=e=>e.map(t=>t==null?void 0:t.id).filter(t=>!!t),D=e=>new Set([...a.value,...C(e)]),K=e=>{e.length===0&&(a.value=[])},P=()=>{p.value=L(a.value),b("update:modelValue",a.value),f.value=!1},L=e=>{let t=e.map(n=>_.has(n)&&_.get(n)).toString();return t==="false"&&(t=e),t},Y=()=>{!u.data.view&&(f.value=!0)},E=()=>{f.value=!1,a.value=[]};G(()=>{ce({...I,paging:!1}).then(e=>{e.status===200&&(d=e.result.map(t=>(_.set(t.id,t.name),t.id)),u.data.id&&(p.value=L(u.data.deviceId),b("update:modelValue",u.data.deviceId),console.log(111,p.value,u.data.deviceId)))})}),Q(()=>a.value,e=>{Object.assign(i,{checkedList:e,indeterminate:!!e.length&&e.length{var n;const t=(n=e==null?void 0:e.terms)==null?void 0:n.map(l=>(l.terms=l.terms.map(c=>c.column==="version"?{column:"id$dev-firmware",value:[c]}:c),l));S.value={terms:t||[]}};return(e,t)=>{const n=M("AIcon"),l=se,c=M("pro-search"),F=ne,H=oe,J=le,U=re;return k(),X(ae,null,[h(l,{placeholder:"请选择设备",value:o(p),"onUpdate:value":t[0]||(t[0]=s=>ee(p)?p.value=s:null),disabled:!0},{addonAfter:r(()=>[h(n,{class:Z(w.data.view?"disabled":""),type:"EditOutlined",onClick:Y},null,8,["class"])]),_:1},8,["value"]),o(f)?(k(),R(U,{key:0,title:"选择设备","ok-text":"确认","cancel-text":"取消",visible:!0,width:"80%",onCancel:E,onOk:P},{default:r(()=>[h(c,{columns:A,target:"search",onSearch:z,type:"simple"}),h(J,{ref:"tableRef",model:"TABLE",columns:A,request:o(ie),defaultParams:I,rowSelection:{selectedRowKeys:o(a),onSelect:N,onSelectAll:q,onChange:K},params:o(S)},{headerTitle:r(()=>[o(d).length!==0?(k(),R(F,{key:0,checked:o(i).checkAll,"onUpdate:checked":t[1]||(t[1]=s=>o(i).checkAll=s),indeterminate:o(i).indeterminate,onChange:O,style:{"margin-left":"8px"}},{default:r(()=>[te(" 全选 ")]),_:1},8,["checked","indeterminate"])):j("",!0)]),productId:r(s=>[y("span",null,x(s.productName),1)]),state:r(s=>{var m,T;return[h(H,{text:(m=s.state)==null?void 0:m.text,status:o(v).get((T=s.state)==null?void 0:T.value)},null,8,["text","status"])]}),version:r(s=>{var m;return[y("span",null,x(((m=s.firmwareInfo)==null?void 0:m.version)||""),1)]}),registerTime:r(s=>[y("span",null,x(o(de)(s.registerTime).format("YYYY-MM-DD HH:mm:ss")),1)]),_:1},8,["request","rowSelection","params"])]),_:1})):j("",!0)],64)}}});const Ue=pe(me,[["__scopeId","data-v-a5562cd8"]]);export{Ue as default};