import{a as P,r as n,w as V,t as S,aj as s,J as q,o as M,K as u,b as R,S as t,a7 as T,P as b}from"./vue.YrNK8sx4.js";import{G as U}from"./api.BT1AK3Px.js";import{G as j}from"./api.Dv806c7F.js";const E={style:{"margin-bottom":"12px"}},A=P({__name:"index",props:{visible:{type:Boolean},deviceIds:{}},emits:["update:visible","confirm"],setup(k,{emit:I}){const r=k,v=I,p=n(r.visible);V(()=>r.visible,a=>p.value=a);const f=n(""),c=n(1),g=n(10),_=n(0),y=n([]),h=n([]),w=n({}),x=n(null);function $(){j().then(a=>{const e={};a.data.forEach(i=>{e[i.id]=i.name}),w.value=e})}async function m(a=!1){a&&(c.value=1),await $(),U({page:c.value,limit:g.value,code:f.value,status:1}).then(e=>{let i=e.data.map(o=>({...o,warehouse:`${w.value[o.warehouse]||`ID:${o.warehouse}`} (${o.available_quantity})`}));r.deviceIds&&r.deviceIds.length>0&&(i=i.filter(o=>{var l;return(l=r.deviceIds)==null?void 0:l.includes(o.id)})),y.value=i,_.value=e.total})}function B(a){h.value=a}function G(a){c.value=a,m()}function z(){v("confirm",h.value),v("update:visible",!1)}function C(){v("update:visible",!1)}return V([p],async a=>{p.value&&(await m(),S(()=>{var e;(e=x.value)==null||e.focus()}))}),(a,e)=>{const i=s("el-input"),o=s("el-button"),l=s("el-table-column"),D=s("el-table"),K=s("el-pagination"),N=s("el-dialog");return M(),q(N,{modelValue:p.value,"onUpdate:modelValue":e[3]||(e[3]=d=>p.value=d),title:"选择设备",width:"800px","close-on-click-modal":!1,onClose:C},{footer:u(()=>[t(o,{onClick:C},{default:u(()=>e[5]||(e[5]=[b("取消")])),_:1}),t(o,{type:"primary",onClick:z},{default:u(()=>e[6]||(e[6]=[b("确定")])),_:1})]),default:u(()=>[R("div",E,[t(i,{ref_key:"searchInput",ref:x,modelValue:f.value,"onUpdate:modelValue":e[0]||(e[0]=d=>f.value=d),placeholder:"输入关键字搜索",style:{width:"240px","margin-right":"8px"},onKeyup:e[1]||(e[1]=T(d=>m(!0),["enter"]))},null,8,["modelValue"]),t(o,{type:"primary",onClick:e[2]||(e[2]=d=>m(!0))},{default:u(()=>e[4]||(e[4]=[b("搜索")])),_:1})]),t(D,{data:y.value,border:"",style:{width:"100%"},onSelectionChange:B,ref:"tableRef"},{default:u(()=>[t(l,{type:"selection",width:"50"}),t(l,{type:"index",label:"序号",width:"60"}),t(l,{prop:"name",label:"设备名称"}),t(l,{prop:"inventory.available_quantity",label:"可用数量"}),t(l,{prop:"category_name",label:"设备分类"}),t(l,{prop:"warehouse",label:"存放仓库"})]),_:1},8,["data"]),t(K,{style:{"margin-top":"12px","text-align":"right"},"current-page":c.value,"page-size":g.value,total:_.value,onCurrentChange:G},null,8,["current-page","page-size","total"])]),_:1},8,["modelValue"])}}});export{A as _};
