import{d as M,v as A,r as n,a as G,G as J,g as s,J as K,z as x,k as P,w as i,b as T,K as j,e as a,t as d,l as H,C as O,x as h,D as R,E as W,_ as X}from"./index-CUnFTKV2.js";import Y from"./QyLevelPrizeFormDialog-BSQSJnTT.js";import{g as Z,d as ee}from"./qylevel-DtP7HHIT.js";import"./coupon-C54tWHNa.js";const le={class:"toolbar"},te=M({__name:"QyLevelPrizeDialog",props:{modelValue:{type:Boolean},level:{}},emits:["update:modelValue"],setup(f,{emit:D}){const r=f,S=D,y=A({get:()=>r.modelValue,set:l=>S("update:modelValue",l)}),z=n(!1),V=n([]),b=n(0),o=G({page:1,pageSize:10,type:void 0,keyword:void 0}),p=n(!1),_=n(!1),C=n(null),u=async()=>{var l;if((l=r.level)!=null&&l.id){z.value=!0;try{const e=await Z(r.level.id,o);V.value=e.data.list,b.value=e.data.total}finally{z.value=!1}}};J(()=>r.modelValue,l=>{l&&r.level&&(o.page=1,o.type=void 0,o.keyword=void 0,u())});const L=l=>{o.page=l,u()},B=l=>{o.pageSize=l,o.page=1,u()},E=()=>{_.value=!1,C.value=null,p.value=!0},Q=l=>{_.value=!0,C.value={...l},p.value=!0},U=async l=>{try{await R.confirm("确定要删除该奖品吗？删除后不可恢复！","删除确认",{type:"warning"}),await ee(l.id),W.success("删除成功"),u()}catch{}},k=()=>{y.value=!1};return(l,e)=>{var w;const N=s("el-icon"),c=s("el-button"),g=s("el-table-column"),$=s("el-table"),q=s("el-pagination"),F=s("el-dialog"),I=K("loading");return P(),x(F,{modelValue:y.value,"onUpdate:modelValue":e[3]||(e[3]=v=>y.value=v),title:`${((w=f.level)==null?void 0:w.title)||"权益等级"} - 奖品管理`,width:"900px","close-on-click-modal":!1,onClose:k},{footer:i(()=>[a(c,{onClick:k},{default:i(()=>[...e[7]||(e[7]=[d("关闭",-1)])]),_:1})]),default:i(()=>{var v;return[T("div",le,[a(c,{type:"primary",onClick:E},{default:i(()=>[a(N,null,{default:i(()=>[a(H(O))]),_:1}),e[4]||(e[4]=d("新增奖品 ",-1))]),_:1})]),j((P(),x($,{data:V.value,border:"",stripe:"","max-height":"400"},{default:i(()=>[a(g,{prop:"id",label:"ID",width:"60",align:"center"}),a(g,{label:"优惠券名称","min-width":"150"},{default:i(({row:t})=>{var m;return[d(h(((m=t.coupon)==null?void 0:m.title)||t.title||"-"),1)]}),_:1}),a(g,{label:"数量",width:"80",align:"center"},{default:i(({row:t})=>[d(h(t.quantity??1)+"张 ",1)]),_:1}),a(g,{label:"操作",width:"130",align:"center",fixed:"right"},{default:i(({row:t})=>[a(c,{type:"primary",link:"",size:"small",onClick:m=>Q(t)},{default:i(()=>[...e[5]||(e[5]=[d(" 编辑 ",-1)])]),_:1},8,["onClick"]),a(c,{type:"danger",link:"",size:"small",onClick:m=>U(t)},{default:i(()=>[...e[6]||(e[6]=[d(" 删除 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[I,z.value]]),a(q,{"current-page":o.page,"onUpdate:currentPage":e[0]||(e[0]=t=>o.page=t),"page-size":o.pageSize,"onUpdate:pageSize":e[1]||(e[1]=t=>o.pageSize=t),"page-sizes":[10,20,50],total:b.value,layout:"total, sizes, prev, pager, next",onSizeChange:B,onCurrentChange:L,class:"pagination"},null,8,["current-page","page-size","total"]),a(Y,{modelValue:p.value,"onUpdate:modelValue":e[2]||(e[2]=t=>p.value=t),"level-id":(v=f.level)==null?void 0:v.id,prize:C.value,"is-edit":_.value,onSuccess:u},null,8,["modelValue","level-id","prize","is-edit"])]}),_:1},8,["modelValue","title"])}}}),se=X(te,[["__scopeId","data-v-a57d32cc"]]);export{se as default};
