import{$ as e,H as t,L as n,P as r,V as i,Vt as a,Wt as o,_ as s,d as c,et as l,f as u,i as d,lt as f,p,st as m,u as h,v as g,z as _}from"./runtime-core.esm-bundler-DbRZbT7v.js";import{s as v}from"./index-Mgun2LFs.js";import"./request-DG5cMCYw.js";import{c as y,i as b,n as x}from"./inventory-DpS3CSeB.js";var S={class:`p-6 space-y-4`},C={class:`bg-white rounded-2xl border border-gray-100 shadow-sm p-4 flex items-center flex-wrap gap-3`},w={class:`bg-white rounded-2xl border border-gray-100 shadow-sm`},T={class:`flex items-center gap-3 px-5 py-4 border-b border-gray-50`},E={class:`text-sm text-gray-400 ml-1`},D={class:`px-2`},O={class:`px-5 py-3 border-t border-gray-50`},k={__name:`index`,setup(k){let A=f([]),j=f(0),M=f(!1),N=f([]),P=f([]),F=m({warehouse_id:``,material_id:``,low_stock:``}),I=m({page:1,per_page:20});async function L(){M.value=!0;try{let e=await b.getList({...F,...I});A.value=e.data?.list||e.data?.data||[],j.value=e.data?.total||0}catch{v.error(`获取库存列表失败`)}finally{M.value=!1}}async function R(){try{let[e,t]=await Promise.all([y.getList({per_page:500}),x.getList({per_page:500})]);N.value=e.data?.list||e.data?.data||[],P.value=t.data?.list||t.data?.data||[]}catch{}}function z(){I.page=1,L()}function B(){Object.assign(F,{warehouse_id:``,material_id:``,low_stock:``}),z()}function V(e){I.page=e,L()}function H(e){I.per_page=e,I.page=1,L()}function U(e){return e.min_quantity!=null&&Number(e.quantity)<Number(e.min_quantity)}function W(){v.info(`导出功能待实现`)}return r(()=>{L(),R()}),(r,f)=>{let m=i(`el-option`),v=i(`el-select`),y=i(`el-button`),b=i(`el-alert`),x=i(`el-table-column`),k=i(`el-tag`),L=i(`el-table`),R=i(`el-pagination`),G=t(`loading`);return n(),p(`div`,S,[h(`div`,C,[g(v,{modelValue:F.warehouse_id,"onUpdate:modelValue":f[0]||=e=>F.warehouse_id=e,placeholder:`选择仓库`,clearable:``,filterable:``,style:{width:`160px`}},{default:e(()=>[(n(!0),p(d,null,_(N.value,e=>(n(),c(m,{key:e.id,label:e.name,value:e.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`]),g(v,{modelValue:F.material_id,"onUpdate:modelValue":f[1]||=e=>F.material_id=e,placeholder:`选择物料`,clearable:``,filterable:``,style:{width:`180px`}},{default:e(()=>[(n(!0),p(d,null,_(P.value,e=>(n(),c(m,{key:e.id,label:`${e.name}(${e.code||`-`})`,value:e.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`]),g(v,{modelValue:F.low_stock,"onUpdate:modelValue":f[2]||=e=>F.low_stock=e,placeholder:`库存状态`,clearable:``,style:{width:`130px`}},{default:e(()=>[g(m,{label:`全部`,value:``}),g(m,{label:`低库存预警`,value:`1`})]),_:1},8,[`modelValue`]),g(y,{type:`primary`,onClick:z},{default:e(()=>[...f[5]||=[s(`查询`,-1)]]),_:1}),g(y,{onClick:B},{default:e(()=>[...f[6]||=[s(`重置`,-1)]]),_:1}),g(y,{class:`ml-auto`,onClick:W},{default:e(()=>[...f[7]||=[s(`导出`,-1)]]),_:1})]),g(b,{title:`红色行表示当前库存低于最低库存量，请及时补货`,type:`warning`,"show-icon":``,closable:!1}),h(`div`,w,[h(`div`,T,[f[8]||=h(`span`,{class:`w-1 h-5 bg-rose-500 rounded-full inline-block`},null,-1),f[9]||=h(`span`,{class:`font-medium text-gray-700`},`库存查询`,-1),h(`span`,E,`共 `+o(j.value)+` 条`,1)]),h(`div`,D,[l((n(),c(L,{data:A.value,style:{width:`100%`},"row-class-name":({row:e})=>U(e)?`low-stock-row`:``},{default:e(()=>[g(x,{prop:`warehouse_name`,label:`仓库`,"min-width":`110`}),g(x,{prop:`material_code`,label:`物料编码`,width:`120`}),g(x,{prop:`material_name`,label:`物料名称`,"min-width":`140`}),g(x,{prop:`category`,label:`分类`,width:`100`,align:`center`}),g(x,{prop:`unit`,label:`单位`,width:`70`,align:`center`}),g(x,{label:`当前库存`,width:`110`,align:`right`},{default:e(({row:t})=>[h(`span`,{class:a(U(t)?`text-red-500 font-bold`:`text-gray-700`)},o(t.quantity),3),U(t)?(n(),c(k,{key:0,type:`danger`,size:`small`,class:`ml-1`},{default:e(()=>[...f[10]||=[s(`偏低`,-1)]]),_:1})):u(``,!0)]),_:1}),g(x,{prop:`min_quantity`,label:`最低库存`,width:`100`,align:`right`}),g(x,{prop:`max_quantity`,label:`最高库存`,width:`100`,align:`right`}),g(x,{prop:`updated_at`,label:`更新时间`,"min-width":`160`})]),_:1},8,[`data`,`row-class-name`])),[[G,M.value]])]),h(`div`,O,[g(R,{"current-page":I.page,"onUpdate:currentPage":f[3]||=e=>I.page=e,"page-size":I.per_page,"onUpdate:pageSize":f[4]||=e=>I.per_page=e,total:j.value,"page-sizes":[10,20,50],layout:`total,sizes,prev,pager,next,jumper`,background:``,onCurrentChange:V,onSizeChange:H},null,8,[`current-page`,`page-size`,`total`])])])])}}};export{k as default};