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