import{b as N,r as s,o as Y,y as H,q as n,P as d,x as u,v as V,p as l,n as D,ai as I,S as z,cp as B,cq as R,cv as q,l as P,bv as j,D as x}from"./index.8d733f79.js";import{y as L}from"./diagnosticReport.fd129147.js";const A={class:"dialog-footer"},W={__name:"chooseDeviceModal",emits:["backDeviceIds"],setup(F,{expose:T,emit:w}){const{t:C}=N(),{proxy:g}=x(),r=s(!1),c=s({endTime:"",factoryId:"",pageNo:1,pageSize:10}),v=s([]),f=s(0),o=s([]);function S(e){h(e.orgDeviceDetail),v.value=[],f.value=0,c.value={startTime:e.startTime,endTime:e.endTime,factoryId:e.factoryId,pageNo:1,pageSize:10},r.value=!0,_(1,"init")}function h(e){for(let a=0;a<e.length;a++)(e[a].deviceId||e[a].deviceInfo&&e[a].deviceInfo.id)&&o.value.push({deviceId:e[a].deviceId||e[a].deviceInfo.id}),e[a].devices&&e[a].devices.length&&h(e[a].devices)}async function _(e,a){e&&(c.value.pageNo=1);const t=await L({...c.value});f.value=t.data.totalElements,v.value=t.data.content,a==="init"&&o.value&&o.value.length&&o.value.forEach(m=>{g.$refs.myTableRef.toggleRowSelection(m,void 0)})}function k(e){c.value.pageNo=e,_()}function E(e){o.value=e}function y(e){if(e!=="all"&&!o.value.length){z.error(C("selectOneDevice"));return}const a=[];e!=="all"&&o.value.forEach(t=>{a.push(t.deviceId)}),w("backDeviceIds",a),b()}function b(){g.$refs.myTableRef.clearSelection(),o.value=[],setTimeout(()=>{r.value=!1},0)}return T({showModal:S}),(e,a)=>{const t=B,m=R,M=q,p=P,$=j;return Y(),H($,{modelValue:r.value,"onUpdate:modelValue":a[1]||(a[1]=i=>r.value=i),width:"640","align-center":""},{header:n(()=>[d(u(e.$t("selectDevice")),1)]),footer:n(()=>[V("span",A,[l(p,{onClick:b},{default:n(()=>[d(u(e.$t("cancel")),1)]),_:1}),l(p,{type:"primary",onClick:y},{default:n(()=>[d(u(e.$t("confirm")),1)]),_:1}),l(p,{type:"primary",onClick:a[0]||(a[0]=i=>y("all")),style:{"margin-left":"24px"}},{default:n(()=>[d(u(e.$t("allDevice")),1)]),_:1})])]),default:n(()=>[l(m,{ref:"myTableRef",data:v.value,border:!0,onSelectionChange:E,onHeaderDragend:e.changeWidth,"row-key":"deviceId"},{default:n(()=>[l(t,{type:"selection",width:"55","reserve-selection":!0}),l(t,{prop:"deviceName",label:e.$t("deviceName")},null,8,["label"]),l(t,{prop:"deviceCode",label:e.$t("deviceCode")},null,8,["label"]),l(t,{prop:"watchStartTime",label:e.$t("watchTime")},{default:n(i=>[d(u(i.row.watchStartTime?D(I)(i.row.watchStartTime).format("YYYY-MM-DD HH:mm:ss")+" - "+D(I)(i.row.watchEndTime).format("YYYY-MM-DD HH:mm:ss"):"-"),1)]),_:1},8,["label"])]),_:1},8,["data","onHeaderDragend"]),l(M,{class:"cardPager",style:{float:"right","margin-top":"16px"},background:"","page-size":c.value.pageSize,layout:"prev, pager, next, jumper",total:f.value,onCurrentChange:k},null,8,["page-size","total"])]),_:1},8,["modelValue"])}}};export{W as default};
