import{b as P,r,o as I,y as E,q as c,P as u,x as p,v as q,p as t,c as A,F as U,A as H,cr as O,S as v,E as j,i as x,cp as W,cq as G,cv as J,l as K,bv as Q,D as X}from"./index.8d733f79.js";import{h as S}from"./deviceRunTime.517fd825.js";import{B as T}from"./deviceTree.170dfbd9.js";const Y={class:"dialog-footer"},oe={__name:"deviceModal",emits:["backDeviceIds"],setup(Z,{expose:$,emit:ee}){const{t:D}=P(),{proxy:f}=X(),d=r(!1),l=r({deviceId:"",factoryId:"",pageNo:1,pageSize:10}),m=r([]),g=r(0),o=r([]),C=r([]);function k(e){m.value=[],g.value=0,l.value={deviceId:e.deviceId,factoryId:"",pageNo:1,pageSize:10},d.value=!0,y(1,"init"),w()}function N(){f.$refs.myTableRef.clearSelection(),o.value=[],y(1)}async function w(){const e=await O();C.value=e.data}async function y(e,a){e&&(l.value.pageNo=1);const n=await T({...l.value});g.value=n.data.totalElements,m.value=n.data.content,a==="init"&&o.value&&o.value.length&&o.value.forEach(h=>{f.$refs.myTableRef.toggleRowSelection(h,void 0)})}function V(e){l.value.pageNo=e,y()}function z(e){o.value=e}function B(){if(!o.value.length){v.error(D("selectOneDevice"));return}const e=[];o.value.forEach(a=>{e.push(a.id)}),S({deviceId:l.value.deviceId,otherDeviceIds:e}).then(a=>{v.success(a.msg),b()})}async function M(){const e=await T({pageNo:1,pageSize:1e4,deviceId:l.value.deviceId});if(e.data.totalElements>0){const a=[];e.data.content.forEach(n=>{a.push(n.id)}),S({deviceId:l.value.deviceId,otherDeviceIds:a}).then(n=>{v.success(n.msg),b()})}else v.error(D("noDevice"))}function b(){f.$refs.myTableRef.clearSelection(),o.value=[],setTimeout(()=>{d.value=!1},0)}return $({showModal:k}),(e,a)=>{const n=j,h=x,i=W,L=G,R=J,_=K,F=Q;return I(),E(F,{modelValue:d.value,"onUpdate:modelValue":a[2]||(a[2]=s=>d.value=s),width:"640","align-center":""},{header:c(()=>[u(p(e.$t("applySameTypeDevice")),1)]),footer:c(()=>[q("span",Y,[t(_,{onClick:b},{default:c(()=>[u(p(e.$t("cancel")),1)]),_:1}),t(_,{type:"primary",onClick:B},{default:c(()=>[u(p(e.$t("confirm")),1)]),_:1}),t(_,{type:"primary",onClick:a[1]||(a[1]=s=>M("all")),style:{"margin-left":"24px"}},{default:c(()=>[u(p(e.$t("allDevice")),1)]),_:1})])]),default:c(()=>[t(h,{modelValue:l.value.factoryId,"onUpdate:modelValue":a[0]||(a[0]=s=>l.value.factoryId=s),placeholder:e.$t("factoryP"),style:{"margin-bottom":"12px"},clearable:"",onChange:N,teleported:!1},{default:c(()=>[(I(!0),A(U,null,H(C.value,s=>(I(),E(n,{key:s.id,label:s.name,value:s.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"]),t(L,{ref:"myTableRef",data:m.value,border:!0,onSelectionChange:z,onHeaderDragend:e.changeWidth,"row-key":"id"},{default:c(()=>[t(i,{type:"selection",width:"55","reserve-selection":!0}),t(i,{prop:"name",label:e.$t("deviceName")},null,8,["label"]),t(i,{prop:"code",label:e.$t("deviceCode")},null,8,["label"]),t(i,{prop:"factoryName",label:e.$t("belongTofactory")},null,8,["label"]),t(i,{prop:"deviceTypeName",label:e.$t("deviceType")},null,8,["label"])]),_:1},8,["data","onHeaderDragend"]),t(R,{class:"cardPager",style:{float:"right","margin-top":"16px"},background:"","page-size":l.value.pageSize,layout:"prev, pager, next, jumper",total:g.value,onCurrentChange:V},null,8,["page-size","total"])]),_:1},8,["modelValue"])}}};export{oe as default};
