import{_ as C,R as b,P as y,o as c,X as $,a7 as i,a as o,w as a,a6 as v,ab as m,c as p,V as u,a5 as h,W as g,U as d,a9 as E,aP as x,aQ as S,T as k}from"./app-014d9ed9.js";import{a as _,Q as w,c as q}from"./QItemLabel.b6dd3adb.js";import{Q as I}from"./QSelect.d7ce3d4c.js";import{d as B}from"./utils.9ce591f3.js";import{B as f}from"./BasicDialog.9dd9de92.js";import{B as P}from"./BasicPrompt.0f8aac67.js";import"./externalHosting.js";import"./position-engine.65ebcb34.js";import"./selection.2a17b691.js";import"./rtl.b51694b1.js";const D={name:"User",data(){return{RESOURCE:b,ACTION:y,pendingSave:!1,pendingDelete:!1,user:{},roles:[]}},computed:{getRoleColor(){return this.user.roleId?this.roles.find(e=>e.name=this.user.roleId).color:"primary"}},methods:{can:B,trySave(){this.pendingSave=!0,this.$axios.patch(`/api/users/save/${this.user.name}`,this.user).then(e=>{if(this.pendingSave=!1,!e.data.resCode){const r=e.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.${r}`,{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")})}).catch(e=>{})},tryDelete(){this.pendingDelete=!0,this.$q.dialog({component:f,componentProps:{title:this.$i18n.t("components.user.deleteHeader"),message:this.$i18n.t("components.user.deleteMsg",{name:this.user.name})},cancel:!0,persistent:!0}).onOk(()=>{this.$axios.delete(`/api/users/delete/${this.user.name}`).then(e=>{if(this.pendingDelete=!1,!e.data.resCode){const r=e.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.${r}`,{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.deleted")}),this.$router.push({name:"web-user-list"})}).catch(e=>{})}).onCancel(()=>{this.pendingDelete=!1})},resetPassword(){this.$q.dialog({component:f,componentProps:{title:this.$i18n.t("components.user.resetPasswordHeader"),message:this.$i18n.t("components.user.resetPasswordMsg",{name:this.user.name})},cancel:!0,persistent:!0}).onOk(()=>{this.$axios.post("/api/users/password/reset",{userId:this.user.name}).then(e=>{if(this.pendingSave=!1,!e.data.resCode){const r=e.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.${r}`,{name:this.user.name})});return}this.$q.dialog({component:P,componentProps:{title:this.$i18n.t("general.success"),message:`
${e.data.newPw}