import{d as U,r as _,H as L,z as T,c as j,a as t,w as o,a$ as F,a0 as M,B as c,b,q as S,i as q,h as s,aY as z,Z as G,b0 as H,t as J,bm as K,b2 as O,J as P,K as Y,L as Z,bh as A,C as m,o as V}from"./index-DqVhJ65C.js";/* empty css                        *//* empty css                *//* empty css                        *//* empty css                    */import"./el-tooltip-l0sNRNKZ.js";/* empty css                  *//* empty css                     *//* empty css                      *//* empty css                   *//* empty css               */const Q={class:"p-6"},R={class:"mb-4 flex justify-between"},de=U({__name:"Groups",setup(W){const v=_([]),u=_(!1),i=_(!1),l=L({id:0,name:"",discount:100,sort:0}),p=async()=>{u.value=!0;try{const n=await c.get("/admin/user_group/list");n.code===0&&(v.value=n.data)}catch(n){console.error(n)}finally{u.value=!1}},g=n=>{n?Object.assign(l,n):(l.id=0,l.name="",l.discount=100,l.sort=0),i.value=!0},E=async()=>{try{await c.post("/admin/user_group/save",l),m.success("保存成功"),i.value=!1,p()}catch(n){m.error(n.message)}},w=async n=>{try{await c.post(`/admin/user_group/delete/${n.id}`),m.success("删除成功"),p()}catch(e){m.error(e.message)}};return T(()=>{p()}),(n,e)=>{const r=q,d=H,x=K,C=O,k=F,B=Z,f=Y,y=A,$=P,D=M,I=z;return V(),j("div",Q,[t(k,{shadow:"hover"},{default:o(()=>[b("div",R,[e[7]||(e[7]=b("h3",{class:"font-bold"},"会员组管理",-1)),t(r,{type:"primary",onClick:e[0]||(e[0]=a=>g(null))},{default:o(()=>[...e[6]||(e[6]=[s("添加会员组",-1)])]),_:1})]),S((V(),G(C,{data:v.value,stripe:"",border:""},{default:o(()=>[t(d,{prop:"id",label:"ID",width:"80"}),t(d,{prop:"name",label:"名称"}),t(d,{prop:"discount",label:"折扣",width:"100"},{default:o(({row:a})=>[s(J(a.discount)+"% ",1)]),_:1}),t(d,{prop:"sort",label:"排序",width:"80"}),t(d,{label:"操作",width:"150",fixed:"right"},{default:o(({row:a})=>[t(r,{link:"",type:"primary",onClick:N=>g(a)},{default:o(()=>[...e[8]||(e[8]=[s("编辑",-1)])]),_:1},8,["onClick"]),t(x,{title:"确定删除吗？",onConfirm:N=>w(a)},{reference:o(()=>[t(r,{link:"",type:"danger"},{default:o(()=>[...e[9]||(e[9]=[s("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])]),_:1})]),_:1},8,["data"])),[[I,u.value]])]),_:1}),t(D,{modelValue:i.value,"onUpdate:modelValue":e[5]||(e[5]=a=>i.value=a),title:l.id?"编辑会员组":"添加会员组",width:"400px"},{footer:o(()=>[t(r,{onClick:e[4]||(e[4]=a=>i.value=!1)},{default:o(()=>[...e[11]||(e[11]=[s("取消",-1)])]),_:1}),t(r,{type:"primary",onClick:E},{default:o(()=>[...e[12]||(e[12]=[s("保存",-1)])]),_:1})]),default:o(()=>[t($,{model:l,"label-width":"80px"},{default:o(()=>[t(f,{label:"名称"},{default:o(()=>[t(B,{modelValue:l.name,"onUpdate:modelValue":e[1]||(e[1]=a=>l.name=a)},null,8,["modelValue"])]),_:1}),t(f,{label:"折扣(%)"},{default:o(()=>[t(y,{modelValue:l.discount,"onUpdate:modelValue":e[2]||(e[2]=a=>l.discount=a),min:1,max:100},null,8,["modelValue"]),e[10]||(e[10]=b("div",{class:"text-xs text-gray-400 mt-1"},"100表示不打折, 90表示九折",-1))]),_:1}),t(f,{label:"排序"},{default:o(()=>[t(y,{modelValue:l.sort,"onUpdate:modelValue":e[3]||(e[3]=a=>l.sort=a),min:0},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}});export{de as default};
