import{d as L,r as n,z as M,c as q,a as t,w as l,a$ as A,a0 as G,B as g,b as y,q as J,b3 as K,b4 as O,i as Y,h as s,aY as Z,Z as H,b0 as Q,t as w,b1 as R,bm as W,b2 as X,bc as ee,J as te,K as ae,bh as le,C as m,o as B}from"./index-DqVhJ65C.js";/* empty css                        *//* empty css                *//* empty css                      *//* empty css               *//* empty css                  *//* empty css                     *//* empty css                  *//* empty css                        *//* empty css                    */import"./el-tooltip-l0sNRNKZ.js";/* empty css                      *//* empty css                   */const oe={class:"p-6"},ne={class:"mb-4 flex justify-between"},se={class:"flex gap-2"},ie={class:"mt-4 flex justify-end"},Ve=L({__name:"Cards",setup(re){const C=n([]),p=n(!1),c=n(1),V=n(20),E=n(0),_=n(""),u=n(!1),f=n(10),v=n(10),r=async()=>{p.value=!0;try{const o=await g.get("/admin/card/list",{params:{page:c.value,limit:V.value,status:_.value}});o.code===0&&(C.value=o.data.data,E.value=o.data.total)}catch(o){console.error(o)}finally{p.value=!1}},D=async()=>{try{await g.post("/admin/card/generate",{amount:f.value,count:v.value}),m.success("生成成功"),u.value=!1,r()}catch(o){m.error(o.message)}},U=async o=>{try{await g.post(`/admin/card/delete/${o.id}`),m.success("删除成功"),r()}catch(e){m.error(e.message)}};return M(()=>{r()}),(o,e)=>{const x=O,$=K,d=Y,i=Q,N=R,T=W,z=X,I=ee,P=A,k=le,h=ae,S=te,j=G,F=Z;return B(),q("div",oe,[t(P,{shadow:"hover"},{default:l(()=>[y("div",ne,[y("div",se,[t($,{modelValue:_.value,"onUpdate:modelValue":e[0]||(e[0]=a=>_.value=a),placeholder:"状态",clearable:"",onChange:r},{default:l(()=>[t(x,{label:"未使用",value:0}),t(x,{label:"已使用",value:1})]),_:1},8,["modelValue"]),t(d,{onClick:r},{default:l(()=>[...e[7]||(e[7]=[s("刷新",-1)])]),_:1})]),t(d,{type:"primary",onClick:e[1]||(e[1]=a=>u.value=!0)},{default:l(()=>[...e[8]||(e[8]=[s("生成卡密",-1)])]),_:1})]),J((B(),H(z,{data:C.value,stripe:"",border:""},{default:l(()=>[t(i,{prop:"id",label:"ID",width:"80"}),t(i,{prop:"code",label:"卡密代码","min-width":"200"}),t(i,{prop:"amount",label:"面额",width:"100"},{default:l(({row:a})=>[s("¥"+w(a.amount),1)]),_:1}),t(i,{prop:"status",label:"状态",width:"100"},{default:l(({row:a})=>[t(N,{type:a.status===1?"info":"success"},{default:l(()=>[s(w(a.status===1?"已使用":"未使用"),1)]),_:2},1032,["type"])]),_:1}),t(i,{label:"使用者",width:"120"},{default:l(({row:a})=>{var b;return[s(w(((b=a.user)==null?void 0:b.username)||"-"),1)]}),_:1}),t(i,{prop:"create_time",label:"生成时间",width:"180"}),t(i,{label:"操作",width:"100",fixed:"right"},{default:l(({row:a})=>[t(T,{title:"确定删除吗？",onConfirm:b=>U(a)},{reference:l(()=>[t(d,{link:"",type:"danger"},{default:l(()=>[...e[9]||(e[9]=[s("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])]),_:1})]),_:1},8,["data"])),[[F,p.value]]),y("div",ie,[t(I,{background:"",layout:"prev, pager, next",total:E.value,"current-page":c.value,"onUpdate:currentPage":e[2]||(e[2]=a=>c.value=a),"page-size":V.value,onCurrentChange:r},null,8,["total","current-page","page-size"])])]),_:1}),t(j,{modelValue:u.value,"onUpdate:modelValue":e[6]||(e[6]=a=>u.value=a),title:"生成充值卡",width:"400px"},{footer:l(()=>[t(d,{onClick:e[5]||(e[5]=a=>u.value=!1)},{default:l(()=>[...e[10]||(e[10]=[s("取消",-1)])]),_:1}),t(d,{type:"primary",onClick:D},{default:l(()=>[...e[11]||(e[11]=[s("开始生成",-1)])]),_:1})]),default:l(()=>[t(S,{"label-width":"80px"},{default:l(()=>[t(h,{label:"面额"},{default:l(()=>[t(k,{modelValue:f.value,"onUpdate:modelValue":e[3]||(e[3]=a=>f.value=a),min:1},null,8,["modelValue"])]),_:1}),t(h,{label:"数量"},{default:l(()=>[t(k,{modelValue:v.value,"onUpdate:modelValue":e[4]||(e[4]=a=>v.value=a),min:1,max:100},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}});export{Ve as default};
