import{_ as c,M as f,$ as a,a as l,w as t,Z as h,a3 as g,o as y,Y as d,a1 as i,an as w,ao as b,L as v,N as C,K as u,Q as V}from"./app-Cox3Klmm.js";import{a as q,Q as $,c as Q}from"./QItemLabel-BhKjsO0f.js";import{Q as S}from"./QSelect-SR9QxmCO.js";import{Q as x}from"./QForm-DFZPIaNn.js";import"./externalHosting.js";import"./QChip-ubeLtWhp.js";import"./position-engine-Dz9uviBh.js";import"./selection-DztvFjhq.js";import"./rtl-DFPa-2ov.js";const P={name:"UserCreate",data(){return{pendingSave:!1,user:{name:"",roleId:"",password:"",fxname:""},isPwd:!0,passwordCon:"",roles:[]}},computed:{ConfirmPWD(){return[s=>!!s||this.$t("rules.required"),s=>s===this.user.password||this.$t("rules.passwordConfirm"),s=>s&&!/\s/.test(s)||this.$t("rules.noSpace")]}},methods:{trySave(){this.$refs.userForm.validate().then(s=>{if(!s){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.user.msg.error.missingFields",{name:this.user.name})});return}this.pendingSave=!0,this.$axios.post("/api/users/create",this.user).then(o=>{if(this.pendingSave=!1,!o.data.resCode){const n=o.data.resMsg;this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t(`components.user.msg.error.${n}`,{name:this.user.name})});return}this.$q.notify({message:this.$i18n.t("general.success"),position:"top",color:"green",icon:"fas fa-check",caption:this.$i18n.t("general.saved")}),this.$router.push({name:"web-user-list"})}).catch(o=>{})})}},mounted(){this.$axios.get("/api/roles/list").then(s=>{const o=s.data.roles;if(!o){this.$q.notify({message:s.data.msg,position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:"Error"});return}this.roles=Object.freeze(o)}).catch(s=>{console.error(s)})}},_={class:"row"},I={class:"col-12"},U={class:"q-ma-sm row"},k={class:"text-main"},z={class:"col-12"},B={class:"q-ma-sm row justify-end"};function F(s,o,p,n,r,m){return y(),f("div",_,[a("div",I,[a("div",U,[l(h,{class:"dashboard-card full-width"},{default:t(()=>[l(x,{ref:"userForm",class:"row"},{default:t(()=>[l(d,{class:"col-12 col-md-6"},{default:t(()=>[l(i,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:r.user.name,"onUpdate:modelValue":o[0]||(o[0]=e=>r.user.name=e),label:s.$t("general.username"),"lazy-rules":"",rules:[e=>e&&e.length>0||s.$t("rules.required"),e=>e&&!/\s/.test(e)||s.$t("rules.noSpace")]},null,8,["modelValue","label","rules"]),l(i,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",placeholder:"Unlimited.wtf",modelValue:r.user.fxname,"onUpdate:modelValue":o[1]||(o[1]=e=>r.user.fxname=e),label:s.$t("components.user.fxname")},null,8,["modelValue","label"]),l(S,{class:"q-mt-md",label:s.$t("components.user.role"),color:"primary","label-color":"primary",filled:"",modelValue:r.user.roleId,"onUpdate:modelValue":o[2]||(o[2]=e=>r.user.roleId=e),"emit-value":"","input-class":"text-main","input-debounce":"0",options:r.roles,"popup-content-class":"dashboard-card text-main"},{selected:t(()=>[a("div",k,u(r.user.roleId),1)]),option:t(e=>[l(q,w(b(e.itemProps)),{default:t(()=>[l($,null,{default:t(()=>[l(Q,{class:v(`text-${e.opt.color}`)},{default:t(()=>[C(u(e.opt.value),1)]),_:2},1032,["class"])]),_:2},1024)]),_:2},1040)]),_:1},8,["label","modelValue","options"])]),_:1}),l(d,{class:"col-12 col-md-6"},{default:t(()=>[l(i,{"label-color":"primary","input-style":{color:"var(--q-main)"},label:s.$t("general.password"),modelValue:r.user.password,"onUpdate:modelValue":o[4]||(o[4]=e=>r.user.password=e),filled:"","lazy-rules":"",type:r.isPwd?"password":"text",rules:[e=>e&&e.length>0||s.$t("rules.required"),e=>e&&!/\s/.test(e)||s.$t("rules.noSpace")]},{append:t(()=>[l(V,{name:r.isPwd?"visibility_off":"visibility",class:"cursor-pointer text-primary",onClick:o[3]||(o[3]=e=>r.isPwd=!r.isPwd)},null,8,["name"])]),_:1},8,["label","modelValue","type","rules"]),l(i,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:r.passwordCon,"onUpdate:modelValue":o[5]||(o[5]=e=>r.passwordCon=e),label:s.$t("general.confirmPassword"),"lazy-rules":"",type:r.isPwd?"password":"text",rules:m.ConfirmPWD},null,8,["modelValue","label","type","rules"])]),_:1})]),_:1},512)]),_:1})])]),a("div",z,[a("div",B,[l(g,{"text-color":"main",loading:r.pendingSave,color:"primary",onClick:m.trySave,label:s.$t("general.create"),class:"q-mr-sm"},null,8,["loading","onClick","label"])])])])}const R=c(P,[["render",F],["__scopeId","data-v-f2f238aa"]]);export{R as default};
