import{b as F,a as _,c as I,f as $}from"./coupon-C54tWHNa.js";import{d as j,r as f,G as v,g as s,J as q,c as A,k as C,K as G,e as a,z as J,w as o,b as h,x as c,t as d,E as y,_ as K}from"./index-CUnFTKV2.js";const M={class:"coupon-table"},R={class:"money"},H={class:"discount"},O=j({__name:"CouponTable",props:{data:{},loading:{type:Boolean},total:{},page:{},pageSize:{}},emits:["page-change","size-change","edit","delete"],setup(r,{emit:z}){const p=r,u=z,g=f(p.page),m=f(p.pageSize);v(()=>p.page,t=>{g.value=t}),v(()=>p.pageSize,t=>{m.value=t});const w=t=>F[t]||"未知类型",x=t=>{switch(t){case _.NewUser:return"success";case _.Equity:return"warning";case _.FullReduction:return"";default:return"info"}},k=t=>I[t]||"不限制",S=t=>{u("page-change",t)},T=t=>{u("size-change",t)},N=t=>{u("edit",t)},U=t=>{u("delete",t)},V=async(t,n)=>{try{await $(t.id,n),y.success(n===0?"已启用":"已禁用")}catch(l){t.status=n===0?1:0,y.error(l.message||"状态更新失败")}};return(t,n)=>{const l=s("el-table-column"),D=s("el-tag"),L=s("el-switch"),b=s("el-button"),P=s("el-table"),B=s("el-pagination"),E=q("loading");return C(),A("div",M,[G((C(),J(P,{data:r.data,border:"",stripe:""},{default:o(()=>[a(l,{prop:"id",label:"ID",width:"80",align:"center"}),a(l,{prop:"title",label:"优惠券名称","min-width":"150"}),a(l,{label:"满减门槛",width:"100",align:"right"},{default:o(({row:e})=>{var i;return[h("span",R,"¥"+c(((i=e.minPrice)==null?void 0:i.toFixed(2))||"0.00"),1)]}),_:1}),a(l,{label:"优惠金额",width:"100",align:"right"},{default:o(({row:e})=>{var i;return[h("span",H,"¥"+c(((i=e.discountPrice)==null?void 0:i.toFixed(2))||"0.00"),1)]}),_:1}),a(l,{label:"有效期",width:"100",align:"center"},{default:o(({row:e})=>[d(c(e.validDays)+"天 ",1)]),_:1}),a(l,{label:"类型",width:"120",align:"center"},{default:o(({row:e})=>[a(D,{type:x(e.type),size:"small"},{default:o(()=>[d(c(e.typeName||w(e.type)),1)]),_:2},1032,["type"])]),_:1}),a(l,{label:"使用限制",width:"100",align:"center"},{default:o(({row:e})=>[h("span",null,c(e.useLimitName||k(e.useLimit)),1)]),_:1}),a(l,{label:"状态",width:"100",align:"center"},{default:o(({row:e})=>[a(L,{modelValue:e.status,"onUpdate:modelValue":i=>e.status=i,"active-value":0,"inactive-value":1,"active-text":"启用","inactive-text":"禁用","inline-prompt":"",onChange:i=>V(e,i)},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:1}),a(l,{label:"创建时间",width:"160",align:"center"},{default:o(({row:e})=>[d(c(e.createdAt||"-"),1)]),_:1}),a(l,{label:"操作",width:"150",align:"center",fixed:"right"},{default:o(({row:e})=>[a(b,{type:"primary",link:"",size:"small",onClick:i=>N(e)},{default:o(()=>[...n[2]||(n[2]=[d(" 编辑 ",-1)])]),_:1},8,["onClick"]),a(b,{type:"danger",link:"",size:"small",onClick:i=>U(e)},{default:o(()=>[...n[3]||(n[3]=[d(" 删除 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[E,r.loading]]),a(B,{"current-page":g.value,"onUpdate:currentPage":n[0]||(n[0]=e=>g.value=e),"page-size":m.value,"onUpdate:pageSize":n[1]||(n[1]=e=>m.value=e),"page-sizes":[10,20,50,100],total:r.total,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:T,onCurrentChange:S,class:"pagination"},null,8,["current-page","page-size","total"])])}}}),X=K(O,[["__scopeId","data-v-c8a27013"]]);export{X as default};
