import{d as M,r as s,a as N,o as q,g as f,c as A,k as R,e as l,w as r,b,t as j,l as F,C as O,E as d,D as h,_ as H}from"./index-CUnFTKV2.js";import J from"./GoodsSearchForm-DHQFAwXs.js";import K from"./GoodsTable-DEvvbyl-.js";import Q from"./GoodsAddDialog-BqmyYYa6.js";import W from"./GoodsEditDialog-HpA1tMlS.js";import X from"./PrizeListDialog-guJ4nmLf.js";import Y from"./GoodsExtendDialog-Bd9LhmU8.js";import{n as Z,o as ee,s as ae,u as oe,p as te,q as se,r as le}from"./goods-CWDKnOy3.js";import"./typeFieldConfig-uKDdHlaR.js";import"./PrizeAddDialog-Cpn8NCez.js";import"./prizelevel-DnmTpVNC.js";import"./PrizeRewardConfig-BiQQyjsC.js";import"./PrizeEditDialog-Afamj_zb.js";import"./DesignatedPrizeDialog-Cb3w-i3D.js";import"./user-EiTTpYhZ.js";import"./format-C0IiqLeQ.js";const ne={class:"page-container"},de={class:"card-header"},ie=M({__name:"index",setup(ce){const u=s(!1),V=s([]),C=s(0),i=s([]),o=N({page:1,pageSize:20}),c=s(0),_=s(0),p=s(""),g=s(!1),m=s(!1),v=s(!1),y=s(!1),t=async()=>{u.value=!0;try{const e=await Z(o);V.value=e.data.list,C.value=e.data.total}finally{u.value=!1}},G=async()=>{try{const e=await ee();i.value=e.data.list}catch{}},S=e=>{o.title=void 0,o.status=void 0,o.type=void 0,Object.assign(o,e),o.page=1,t()},x=()=>{o.title=void 0,o.status=void 0,o.type=void 0,o.page=1,t()},D=e=>{o.page=e,t()},k=e=>{o.pageSize=e,o.page=1,t()},z=()=>{g.value=!0},T=async(e,a)=>{try{await ae(e.id,a),d.success(a===1?"上架成功":"下架成功"),t()}catch{t()}},w=async(e,a)=>{try{await oe(e.id,{...e,sort:a}),d.success("排序更新成功"),t()}catch{t()}},B=async(e,a)=>{switch(c.value=a.id,_.value=a.type,p.value=a.title,e){case"edit":m.value=!0;break;case"delete":await E(a);break;case"copy":await L(a);break;case"prizes":v.value=!0;break;case"extend":y.value=!0;break;case"clearLottery":await P(a);break}},E=async e=>{try{await h.confirm(`确定要删除盒子 "${e.title}" 吗？删除后不可恢复！`,"删除确认",{type:"warning"}),await te(e.id),d.success("删除成功"),t()}catch{}},L=async e=>{try{await h.confirm(`确定要复制盒子 "${e.title}" 吗？将同时复制所有奖品配置。`,"复制确认",{type:"info"});const a=await se(e.id);d.success(`复制成功，新盒子ID: ${a.data.id}`),t()}catch{}},P=async e=>{try{await h.confirm(`⚠️ 危险操作！确定要清空盒子 "${e.title}" 的所有抽奖记录吗？此操作不可恢复！`,"危险操作确认",{type:"error",confirmButtonText:"确定清空",cancelButtonText:"取消",confirmButtonClass:"el-button--danger"}),await le(e.id),d.success("清空抽奖记录成功"),t()}catch{}};return q(()=>{G(),t()}),(e,a)=>{const U=f("el-icon"),$=f("el-button"),I=f("el-card");return R(),A("div",ne,[l(I,null,{header:r(()=>[b("div",de,[a[5]||(a[5]=b("span",null,"盒子管理",-1)),l($,{type:"primary",onClick:z},{default:r(()=>[l(U,null,{default:r(()=>[l(F(O))]),_:1}),a[4]||(a[4]=j("新增盒子 ",-1))]),_:1})])]),default:r(()=>[l(J,{"goods-types":i.value,onSearch:S,onReset:x},null,8,["goods-types"]),l(K,{data:V.value,loading:u.value,total:C.value,page:o.page,"page-size":o.pageSize,onPageChange:D,onSizeChange:k,onCommand:B,onStatusChange:T,onSortChange:w},null,8,["data","loading","total","page","page-size"])]),_:1}),l(Q,{modelValue:g.value,"onUpdate:modelValue":a[0]||(a[0]=n=>g.value=n),"goods-types":i.value,onSuccess:t},null,8,["modelValue","goods-types"]),l(W,{modelValue:m.value,"onUpdate:modelValue":a[1]||(a[1]=n=>m.value=n),"goods-id":c.value,"goods-types":i.value,onSuccess:t},null,8,["modelValue","goods-id","goods-types"]),l(X,{modelValue:v.value,"onUpdate:modelValue":a[2]||(a[2]=n=>v.value=n),"goods-id":c.value,"goods-type":_.value,"goods-title":p.value},null,8,["modelValue","goods-id","goods-type","goods-title"]),l(Y,{modelValue:y.value,"onUpdate:modelValue":a[3]||(a[3]=n=>y.value=n),"goods-id":c.value,"goods-title":p.value,onSuccess:t},null,8,["modelValue","goods-id","goods-title"])])}}}),De=H(ie,[["__scopeId","data-v-932f958d"]]);export{De as default};
