import{d as V,r as l,a as x,o as b,g as r,c as D,k as B,e as o,w as c,b as _,t as M,l as N,C as P,D as R,E as T,_ as $}from"./index-CUnFTKV2.js";import q from"./CouponSearchForm-C0AL57TN.js";import A from"./CouponTable-DspZG1V7.js";import{_ as F}from"./CouponFormDialog.vue_vue_type_script_setup_true_lang-ChJWLABB.js";import{g as I,d as L}from"./coupon-C54tWHNa.js";const U={class:"page-container"},j={class:"card-header"},G=V({__name:"list",setup(H){const u=l(!1),p=l([]),g=l(0),a=x({page:1,pageSize:20}),s=l(!1),d=l(!1),i=l(null),t=async()=>{u.value=!0;try{const e=await I(a);p.value=e.data.list,g.value=e.data.total}finally{u.value=!1}},m=e=>{a.keyword=e.keyword,a.type=e.type,a.page=1,t()},f=()=>{a.keyword=void 0,a.type=void 0,a.page=1,t()},v=e=>{a.page=e,t()},h=e=>{a.pageSize=e,a.page=1,t()},y=()=>{d.value=!1,i.value=null,s.value=!0},C=e=>{d.value=!0,i.value={...e},s.value=!0},S=async e=>{try{await R.confirm(`确定要删除优惠券 "${e.title}" 吗？删除后不可恢复！`,"删除确认",{type:"warning"}),await L(e.id),T.success("删除成功"),t()}catch{}};return b(()=>{t()}),(e,n)=>{const w=r("el-icon"),k=r("el-button"),z=r("el-card");return B(),D("div",U,[o(z,null,{header:c(()=>[_("div",j,[n[2]||(n[2]=_("span",null,"优惠券管理",-1)),o(k,{type:"primary",onClick:y},{default:c(()=>[o(w,null,{default:c(()=>[o(N(P))]),_:1}),n[1]||(n[1]=M("添加优惠券 ",-1))]),_:1})])]),default:c(()=>[o(q,{onSearch:m,onReset:f}),o(A,{data:p.value,loading:u.value,total:g.value,page:a.page,"page-size":a.pageSize,onPageChange:v,onSizeChange:h,onEdit:C,onDelete:S},null,8,["data","loading","total","page","page-size"])]),_:1}),o(F,{modelValue:s.value,"onUpdate:modelValue":n[0]||(n[0]=E=>s.value=E),coupon:i.value,"is-edit":d.value,onSuccess:t},null,8,["modelValue","coupon","is-edit"])])}}}),X=$(G,[["__scopeId","data-v-ec864300"]]);export{X as default};
