import{a as A,r as n,w as I,t as C,aj as f,J as F,o as J,K as p,b as L,S as i,a7 as W,P as x}from"./vue.D1BjjNmv.js";import{G as q}from"./api._lNgVYz0.js";import{G as H}from"./api.DmW_DFI3.js";const O={style:{"margin-bottom":"12px"}},Z=A({__name:"index",props:{visible:{type:Boolean},disabledIds:{}},emits:["update:visible","confirm"],setup(B,{emit:G}){const l=B,g=G,r=n(l.visible);I(()=>l.visible,e=>r.value=e);const _=n(""),m=n(1),S=n(10),E=n(0),d=n([]),R=n([]),z=n({}),o=n(new Map),s=n(new Map),c=n(),w=n(!1);function D(){H().then(e=>{const a={};e.data.forEach(t=>{a[t.id]=t.name}),z.value=a})}async function h(e=!1){e&&(m.value=1),await D(),q({page:m.value,limit:S.value,code:_.value,status:1}).then(a=>{const t=a.data;d.value=t,E.value=a.total,C(()=>{P(),V()})})}function K(e){return!s.value.has(e.id)}function V(){c.value&&(w.value=!0,d.value.forEach(e=>{c.value.toggleRowSelection(e,!1)}),d.value.forEach(e=>{o.value.has(e.id)&&c.value.toggleRowSelection(e,!0)}),w.value=!1,k())}function k(){R.value=d.value.filter(e=>o.value.has(e.id))}function N(e){if(w.value)return;new Set(d.value.map(t=>t.id)).forEach(t=>{const v=e.some(u=>u.id===t);!v&&!s.value.has(t)?o.value.delete(t):!v&&s.value.has(t)&&C(()=>{const u=d.value.find(y=>y.id===t);u&&c.value&&c.value.toggleRowSelection(u,!0)})}),e.forEach(t=>{o.value.has(t.id),o.value.set(t.id,t)}),k()}function T(e){m.value=e,h()}function U(){const e=Array.from(o.value.values()).filter(a=>{var t;return!((t=l.disabledIds)!=null&&t.includes(a.id))});if(e.length===0){g("update:visible",!1);return}g("confirm",e),g("update:visible",!1)}function M(){o.value.forEach((e,a)=>{s.value.has(a)||o.value.delete(a)}),R.value=[],g("update:visible",!1)}function P(){!l.disabledIds||l.disabledIds.length===0||d.value.forEach(e=>{var a;(a=l.disabledIds)!=null&&a.includes(e.id)&&(s.value.set(e.id,e),o.value.set(e.id,e))})}return I([r,m],e=>{r.value?(s.value.clear(),l.disabledIds&&l.disabledIds.length>0&&l.disabledIds.forEach(a=>{s.value.set(a,{id:a})}),h()):s.value.clear()}),I(()=>l.disabledIds,()=>{r.value&&(s.value.clear(),l.disabledIds&&l.disabledIds.length>0&&l.disabledIds.forEach(e=>{s.value.set(e,{id:e})}),P(),C(()=>{V()}))},{deep:!0}),(e,a)=>{const t=f("el-input"),v=f("el-button"),u=f("el-table-column"),y=f("el-table"),$=f("el-pagination"),j=f("el-dialog");return J(),F(j,{modelValue:r.value,"onUpdate:modelValue":a[3]||(a[3]=b=>r.value=b),title:"选择设备分类",width:"800px","close-on-click-modal":!1,onClose:M},{footer:p(()=>[i(v,{onClick:M},{default:p(()=>a[5]||(a[5]=[x("取消")])),_:1}),i(v,{type:"primary",onClick:U},{default:p(()=>a[6]||(a[6]=[x("确定")])),_:1})]),default:p(()=>[L("div",O,[i(t,{modelValue:_.value,"onUpdate:modelValue":a[0]||(a[0]=b=>_.value=b),placeholder:"输入关键字搜索",style:{width:"240px","margin-right":"8px"},onKeyup:a[1]||(a[1]=W(b=>h(!0),["enter"]))},null,8,["modelValue"]),i(v,{type:"primary",onClick:a[2]||(a[2]=b=>h(!0))},{default:p(()=>a[4]||(a[4]=[x("搜索")])),_:1})]),i(y,{data:d.value,border:"",style:{width:"100%"},onSelectionChange:N,ref_key:"tableRef",ref:c,"row-key":"id"},{default:p(()=>[i(u,{type:"selection",width:"50","reserve-selection":!0,selectable:K}),i(u,{type:"index",label:"序号",width:"60"}),i(u,{prop:"name",label:"设备分类"}),i(u,{prop:"description",label:"描述","min-width":"160"})]),_:1},8,["data"]),i($,{style:{"margin-top":"12px","text-align":"right"},"current-page":m.value,"page-size":S.value,total:E.value,onCurrentChange:T},null,8,["current-page","page-size","total"])]),_:1},8,["modelValue"])}}});export{Z as _};
