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