import{d as S,r as u,a as $,o as q,g as i,J as z,c as A,k,e,w as l,K as M,z as T,t as s,x as m,b as v,l as F,a2 as J,E as K,_ as j}from"./index-CUnFTKV2.js";import{t as G,u as H}from"./user-EiTTpYhZ.js";const O={class:"page-container"},Q={class:"number-text"},W=S({__name:"vip",setup(X){const c=u(!1),V=u([]),d=u(!1),p=u(!1),_=u(),o=$({id:0,level:0,title:"",number:0}),h={title:[{required:!0,message:"请输入等级名称",trigger:"blur"},{max:50,message:"等级名称不能超过50个字符",trigger:"blur"}],number:[{required:!0,message:"请输入升级所需积分",trigger:"blur"},{type:"number",min:0,message:"积分不能为负数",trigger:"blur"}]},y=n=>n?new Date(n).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"-",w=async()=>{c.value=!0;try{const n=await G();V.value=n.data||[]}catch(n){console.error("获取VIP等级列表失败:",n)}finally{c.value=!1}},C=n=>{o.id=n.id,o.level=n.level,o.title=n.title,o.number=n.number,d.value=!0},D=async()=>{if(_.value)try{await _.value.validate(),p.value=!0,await H(o.id,{title:o.title,number:o.number}),K.success("更新成功"),d.value=!1,w()}catch(n){console.error("更新VIP等级失败:",n)}finally{p.value=!1}};return q(()=>{w()}),(n,t)=>{const I=i("el-tag"),r=i("el-table-column"),L=i("el-icon"),f=i("el-button"),P=i("el-table"),B=i("el-card"),x=i("el-input"),g=i("el-form-item"),E=i("el-input-number"),N=i("el-form"),U=i("el-dialog"),R=z("loading");return k(),A("div",O,[e(B,null,{header:l(()=>[...t[5]||(t[5]=[v("div",{class:"card-header"},[v("span",null,"VIP等级管理")],-1)])]),default:l(()=>[M((k(),T(P,{data:V.value,border:"",stripe:""},{default:l(()=>[e(r,{label:"等级",align:"center",width:"80"},{default:l(({row:a})=>[e(I,{type:"warning"},{default:l(()=>[s("VIP"+m(a.level),1)]),_:2},1024)]),_:1}),e(r,{label:"等级名称",prop:"title","min-width":"150"}),e(r,{label:"升级所需积分",align:"right",width:"150"},{default:l(({row:a})=>{var b;return[v("span",Q,m(((b=a.number)==null?void 0:b.toLocaleString())||0),1)]}),_:1}),e(r,{label:"创建时间",width:"180"},{default:l(({row:a})=>[s(m(y(a.createdAt)),1)]),_:1}),e(r,{label:"更新时间",width:"180"},{default:l(({row:a})=>[s(m(y(a.updatedAt)),1)]),_:1}),e(r,{label:"操作",align:"center",width:"120",fixed:"right"},{default:l(({row:a})=>[e(f,{type:"primary",link:"",onClick:b=>C(a)},{default:l(()=>[e(L,null,{default:l(()=>[e(F(J))]),_:1}),t[6]||(t[6]=s("编辑 ",-1))]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[R,c.value]])]),_:1}),e(U,{modelValue:d.value,"onUpdate:modelValue":t[4]||(t[4]=a=>d.value=a),title:`编辑VIP${o.level}等级`,width:"500px","close-on-click-modal":!1},{footer:l(()=>[e(f,{onClick:t[3]||(t[3]=a=>d.value=!1)},{default:l(()=>[...t[7]||(t[7]=[s("取消",-1)])]),_:1}),e(f,{type:"primary",onClick:D,loading:p.value},{default:l(()=>[...t[8]||(t[8]=[s("确定",-1)])]),_:1},8,["loading"])]),default:l(()=>[e(N,{ref_key:"formRef",ref:_,model:o,rules:h,"label-width":"120px"},{default:l(()=>[e(g,{label:"等级",prop:"level"},{default:l(()=>[e(x,{modelValue:o.level,"onUpdate:modelValue":t[0]||(t[0]=a=>o.level=a),disabled:""},null,8,["modelValue"])]),_:1}),e(g,{label:"等级名称",prop:"title"},{default:l(()=>[e(x,{modelValue:o.title,"onUpdate:modelValue":t[1]||(t[1]=a=>o.title=a),placeholder:"请输入等级名称",maxlength:"50"},null,8,["modelValue"])]),_:1}),e(g,{label:"升级所需积分",prop:"number"},{default:l(()=>[e(E,{modelValue:o.number,"onUpdate:modelValue":t[2]||(t[2]=a=>o.number=a),min:0,max:999999999,step:100,style:{width:"100%"}},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}}),ee=j(W,[["__scopeId","data-v-513a5002"]]);export{ee as default};
