import{d as e,r as t,o as s,b as a,e as r,f as l,N as o,g as n,b2 as i,i as c,I as p,J as d,T as u,q as v,v as x,w as m,j as h}from"./index-BoIUJTA2.js";/* empty css *//* empty css */import{_ as g}from"./index.vue_vue_type_script_setup_true_lang-DUbflfBQ.js";import{h as f}from"./operations-Cr4YfoRu.js";import{E as y}from"./index-ZsMdSUVI.js";import{E as b}from"./index-ClDjAOOe.js";import{_}from"./_plugin-vue_export-helper-BCo6x5W8.js";import"./iconify-DFoKediz.js";const k={class:"art-card h-full p-6 relative overflow-hidden group"},w={class:"art-card-header mb-6"},j={class:"title"},q={class:"flex-c mb-1"},E={class:"space-y-4"},I={class:"flex-1 min-w-0"},M={class:"flex justify-between items-start mb-1"},P={class:"font-bold text-g-700 truncate mr-2"},S={class:"flex justify-between text-xs text-g-400"},z={class:"text-orange-600 font-bold"},C={key:0,class:"text-center py-8 text-g-300"},D=_(e({__name:"inventory-alert",setup(e){const _=t(!1),D=t([]),J=e=>({physical:"ri:box-3-line",virtual:"ri:ticket-2-line",coupon:"ri:coupon-line"}[e]||"ri:question-line");return s(()=>{return e=this,t=null,s=function*(){_.value=!0;try{D.value=yield f()}catch(e){u.error("获取库存预警失败")}finally{_.value=!1}},new Promise((a,r)=>{var l=e=>{try{n(s.next(e))}catch(t){r(t)}},o=e=>{try{n(s.throw(e))}catch(t){r(t)}},n=e=>e.done?a(e.value):Promise.resolve(e.value).then(l,o);n((s=s.apply(e,t)).next())});var e,t,s}),(e,t)=>{const s=g,u=y,f=b,N=i;return r(),a("div",k,[l("div",w,[l("div",j,[l("div",q,[n(s,{icon:"ri:stock-line",class:"text-warning mr-2 text-xl"}),t[0]||(t[0]=l("h4",{class:"text-xl font-black text-g-900 tracking-tight"},"库存预警监控",-1))]),t[1]||(t[1]=l("p",{class:"text-sm text-g-500"},"实时监控商品/奖品存量,防止卖空断货",-1))])]),o((r(),a("div",null,[l("div",E,[(r(!0),a(p,null,d(D.value,e=>{return r(),a("div",{key:e.id,class:v(["flex items-center p-3 rounded-lg border border-g-100 hover:shadow-sm transition-all",e.stock<=e.threshold/2?"bg-red-50/30":""])},[l("div",{class:v(["w-10 h-10 rounded-full flex-cc mr-4",(o=e.type,{physical:"bg-blue-100 text-blue-600",virtual:"bg-purple-100 text-purple-600",coupon:"bg-orange-100 text-orange-600"}[o]||"bg-gray-100 text-gray-600")])},[n(s,{icon:J(e.type)},null,8,["icon"])],2),l("div",I,[l("div",M,[l("span",P,x(e.name),1),n(u,{type:e.stock<=e.threshold/2?"danger":"warning",size:"small"},{default:m(()=>[h(" 库存: "+x(e.stock),1)]),_:2},1032,["type"])]),l("div",S,[l("span",null,"消耗速度: "+x(e.salesSpeed)+" / 天",1),l("span",null,[t[2]||(t[2]=h("预估耗尽: ",-1)),l("span",z,x(Math.round(e.stock/(e.salesSpeed||1)))+"天",1)])]),n(f,{percentage:Math.min(e.stock/e.threshold*100,100),"show-text":!1,"stroke-width":4,class:"mt-2",color:e.stock<=e.threshold/2?"#ef4444":"#f59e0b"},null,8,["percentage","color"])])],2);var o}),128))]),D.value.length?c("",!0):(r(),a("div",C," 暂无低库存预警 "))])),[[N,_.value]])])}}}),[["__scopeId","data-v-8f87a4f8"]]);export{D as default};