import{B as j,am as E,a as x,a8 as N,w as R,I as i,X as c,C as p,O as b,P as n,H as s,G as L,F as h,u as e,$ as W,a7 as g,a6 as U,W as q,V as _,U as y,_ as w,D as A}from"./vue-DweYBrEc.js";import{c as K,e as O,x as M,_ as G}from"./index-fNs72j9w.js";import{F as H}from"./index-BlEwok4a.js";import{b as V}from"./validate-CEOscgyN.js";const X="/admin/user.ScoreLog/";function J(v){return K({url:X+"add",method:"get",params:{userId:v}})}const Q={class:"title"},Y=j({__name:"popupForm",setup(v){const I=O(),{t}=M.useI18n(),r=E("baTable"),S=x({user_id:[V({name:"required",message:t("Please select field",{field:t("user.moneyLog.User")})})],score:[V({name:"required",title:t("user.moneyLog.Change amount")}),{validator:(m,o,u)=>!o||parseInt(o)==0?u(new Error(t("Please enter the correct field",{field:t("user.moneyLog.Change amount")}))):u(),trigger:"blur"}],memo:[V({name:"required",title:t("user.moneyLog.remarks")})]}),f=N("formRef"),a=x({userInfo:{},after:0}),k=()=>{!r.form.items.user_id||parseInt(r.form.items.user_id)<=0||J(r.form.items.user_id).then(m=>{a.userInfo=m.data.user,a.after=m.data.user.score})},F=m=>{if(!a.userInfo||typeof a.userInfo>"u"){a.after=0;return}let o=m==""?0:parseFloat(m);a.after=parseFloat(a.userInfo.score)+o};return R(()=>r.form.operate,m=>{m&&k()}),(m,o)=>{const u=i("el-input"),d=i("el-form-item"),P=i("el-form"),D=i("el-scrollbar"),C=i("el-button"),z=i("el-dialog"),B=c("drag"),T=c("zoom"),$=c("blur");return p(),b(z,{class:"ba-operate-dialog","close-on-click-modal":!1,"model-value":["Add","Edit"].includes(e(r).form.operate),onClose:e(r).toggleForm},{header:n(()=>[w((p(),A("div",Q,[_(y(e(r).form.operate?e(t)(e(r).form.operate):""),1)])),[[B,[".ba-operate-dialog",".el-dialog__header"]],[T,".ba-operate-dialog"]])]),footer:n(()=>[L("div",{style:h("width: calc(100% - "+e(r).form.labelWidth/1.8+"px)")},[s(C,{onClick:o[10]||(o[10]=l=>e(r).toggleForm(""))},{default:n(()=>[_(y(e(t)("Cancel")),1)]),_:1}),w((p(),b(C,{loading:e(r).form.submitLoading,onClick:o[11]||(o[11]=l=>e(r).onSubmit(e(f))),type:"primary"},{default:n(()=>[_(y(e(r).form.operateIds.length>1?e(t)("Save and edit next item"):e(t)("Save")),1)]),_:1},8,["loading"])),[[$]])],4)]),default:n(()=>[s(D,{class:"ba-table-form-scrollbar"},{default:n(()=>[L("div",{class:W(["ba-operate-form","ba-"+e(r).form.operate+"-form"]),style:h(e(I).layout.shrink?"":"width: calc(100% - "+e(r).form.labelWidth/2+"px)")},[e(r).form.loading?q("",!0):(p(),b(P,{key:0,ref_key:"formRef",ref:f,onKeyup:o[9]||(o[9]=g(l=>e(r).onSubmit(e(f)),["enter"])),model:e(r).form.items,"label-position":e(I).layout.shrink?"top":"right","label-width":e(r).form.labelWidth+"px",rules:S},{default:n(()=>[s(H,{type:"remoteSelect",prop:"user_id",label:e(t)("user.moneyLog.User ID"),modelValue:e(r).form.items.user_id,"onUpdate:modelValue":o[0]||(o[0]=l=>e(r).form.items.user_id=l),placeholder:e(t)("Click select"),"input-attr":{pk:"user.id",field:"nickname_text",remoteUrl:"/admin/user.User/index",onChange:k}},null,8,["label","modelValue","placeholder","input-attr"]),s(d,{label:e(t)("user.moneyLog.User name")},{default:n(()=>[s(u,{modelValue:a.userInfo.username,"onUpdate:modelValue":o[1]||(o[1]=l=>a.userInfo.username=l),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),s(d,{label:e(t)("user.moneyLog.User nickname")},{default:n(()=>[s(u,{modelValue:a.userInfo.nickname,"onUpdate:modelValue":o[2]||(o[2]=l=>a.userInfo.nickname=l),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),s(d,{label:e(t)("user.scoreLog.Current points")},{default:n(()=>[s(u,{modelValue:a.userInfo.score,"onUpdate:modelValue":o[3]||(o[3]=l=>a.userInfo.score=l),disabled:"",type:"number"},null,8,["modelValue"])]),_:1},8,["label"]),s(d,{prop:"score",label:e(t)("user.moneyLog.Change amount")},{default:n(()=>[s(u,{onInput:F,modelValue:e(r).form.items.score,"onUpdate:modelValue":o[4]||(o[4]=l=>e(r).form.items.score=l),type:"number",placeholder:e(t)("user.scoreLog.Please enter the change amount of points")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(d,{label:e(t)("user.scoreLog.Points after change")},{default:n(()=>[s(u,{modelValue:a.after,"onUpdate:modelValue":o[5]||(o[5]=l=>a.after=l),type:"number",disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),s(d,{prop:"memo",label:e(t)("user.moneyLog.remarks")},{default:n(()=>[s(u,{onKeyup:[o[6]||(o[6]=g(U(()=>{},["stop"]),["enter"])),o[7]||(o[7]=g(U(l=>e(r).onSubmit(e(f)),["ctrl"]),["enter"]))],modelValue:e(r).form.items.memo,"onUpdate:modelValue":o[8]||(o[8]=l=>e(r).form.items.memo=l),type:"textarea",placeholder:e(t)("user.scoreLog.Please enter change remarks / description")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model","label-position","label-width","rules"]))],6)]),_:1})]),_:1},8,["model-value","onClose"])}}}),Z=G(Y,[["__scopeId","data-v-b7f4774b"]]),le=Object.freeze(Object.defineProperty({__proto__:null,default:Z},Symbol.toStringTag,{value:"Module"}));export{Z as P,J as a,le as p,X as u};
