import{P as S,Q as F}from"./index.DLhCD1Qz.js";import{_ as y}from"./yb_admin_plugin.DNFUAscl.js";import{aZ as a,aL as m,s as d,bJ as o,v as i,I as s,bb as c,t as f,H as V}from"./@vue.Da0bZ210.js";import"./vue.Bj6dTZYa.js";import"./@element-plus.pQhr8KT1.js";import"./echarts.Dms41JYJ.js";import"./tslib.BDyQ-Jie.js";import"./zrender.BueMfJu3.js";import"./axios.BjtuyMK1.js";import"./pinia.Tngw-S_5.js";import"./vue-router.DaVMGKLh.js";import"./element-plus.DC208N5p.js";import"./lodash-es.DVGGNlzX.js";import"./@vueuse.BhH-hw9p.js";import"./async-validator.9PlIezaS.js";import"./@popperjs.C5az9QE8.js";import"./@ctrl.C4Rzlq_k.js";import"./dayjs.BLMYetss.js";import"./memoize-one.BdPwpGay.js";import"./normalize-wheel-es.BQoi3Ox2.js";import"./@floating-ui.DCXYYTka.js";import"./vue-i18n.C7BagGww.js";import"./@intlify.TnaUIxGf.js";import"./moment.C5S46NFB.js";const B={props:{user:{type:Object,default:null}},data(){return{surplus_list:[],loading:!1,currentFees:0,form:{recharge_num:0,payment_type:1,remark:""},paymentOptions:[{value:1,label:"系统充值"},{value:2,label:"支付宝"},{value:3,label:"微信支付"},{value:4,label:"银行转账"},{value:5,label:"其他方式"}],originalSurplusList:[]}},created(){this.user&&(this.currentFees=this.user.surplus_num||0),this.loadMealOrderData()},methods:{loadMealOrderData(){!this.user||!this.user.user_id||F({user_id:this.user.user_id}).then(e=>{this.surplus_list=e.data,this.originalSurplusList=JSON.parse(JSON.stringify(e.data)),this.calculateTotalFees()})},calculateTotalFees(){if(!this.surplus_list||this.surplus_list.length===0){this.currentFees=0;return}this.currentFees=this.surplus_list.reduce((e,t)=>e+parseFloat(t.surplus_num||0),0)},handleSurplusChange(e){this.calculateTotalFees()},formatDate(e){if(!e)return"";const t=new Date(e*1e3);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`},onSubmit(){this.loading=!0;const e=this.getUpdatedRows();e.length>0?this.batchUpdateSurplus(e):this.callBack&&this.callBack()},getUpdatedRows(){return this.surplus_list.filter((e,t)=>{const r=this.originalSurplusList[t];return r&&parseFloat(r.surplus_num)!==parseFloat(e.surplus_num)})},batchUpdateSurplus(e){const t=e.map(r=>({id:r.id,surplus_num:r.surplus_num}));S({user_id:this.user.user_id,meal_orders:t}).then(r=>{this.$message.success("批量更新套餐余额成功"),this.callBack&&this.callBack()}).catch(r=>{this.$message.error("批量更新套餐余额失败"),this.callBack&&this.callBack()}).finally(()=>{this.loading=!1})},cancel(){this.$emit("callback",{success:!1}),this.$emit("close")}}},D={class:"user-info"},O={class:"user-detail"},C={class:"user-id"};function U(e,t,r,I,u,_){const b=a("el-avatar"),n=a("el-form-item"),p=a("el-table-column"),g=a("el-input-number"),k=a("el-table"),v=a("el-input"),w=a("el-form");return m(),d(w,{ref:"formRef",model:u.form,"label-width":"120px",class:"recharge-form"},{default:o(()=>[r.user?(m(),d(n,{key:0,label:e.translateI18n("会员信息")},{default:o(()=>[i("div",D,[s(b,{src:r.user.user_headimg||""},null,8,["src"]),i("div",O,[i("div",null,c(r.user.nick_name||"未设置昵称"),1),i("div",C,"当前余额: "+c(u.currentFees)+"点",1)])])]),_:1},8,["label"])):f("",!0),u.surplus_list.length>0?(m(),d(n,{key:1,label:e.translateI18n("套餐余额列表")},{default:o(()=>[s(k,{data:u.surplus_list,style:{width:"100%"},border:""},{default:o(()=>[s(p,{prop:"id",label:"ID",width:"80"}),s(p,{prop:"surplus_num",label:"余额点数"},{default:o(l=>[s(g,{modelValue:l.row.surplus_num,"onUpdate:modelValue":h=>l.row.surplus_num=h,precision:2,"controls-position":"right",min:"0",onChange:h=>_.handleSurplusChange(l.row)},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:1}),s(p,{prop:"end_time",label:"到期时间"},{default:o(l=>[V(c(l.row.end_time===0?"永不过期":_.formatDate(l.row.end_time)),1)]),_:1})]),_:1},8,["data"]),t[1]||(t[1]=i("div",{class:"tips"},"直接修改点数可调整套餐余额",-1))]),_:1},8,["label"])):f("",!0),s(n,{label:e.translateI18n("备注"),prop:"remark"},{default:o(()=>[s(v,{modelValue:u.form.remark,"onUpdate:modelValue":t[0]||(t[0]=l=>u.form.remark=l),type:"textarea",rows:3,placeholder:"请输入充值备注信息"},null,8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["model"])}const re=y(B,[["render",U],["__scopeId","data-v-ba581566"]]);export{re as default};
