"use strict";(self["webpackChunkx_php_admin"]=self["webpackChunkx_php_admin"]||[]).push([[633],{6633:function(e,a,l){l.r(a),l.d(a,{default:function(){return i}});var s=l(6808);function o(e,a,l,o,t,r){const d=(0,s.up)("x-upload"),i=(0,s.up)("el-form-item"),m=(0,s.up)("el-input"),p=(0,s.up)("el-cascader"),u=(0,s.up)("el-option"),n=(0,s.up)("el-select"),f=(0,s.up)("el-form"),h=(0,s.up)("el-button"),w=(0,s.up)("x-dialog");return(0,s.wg)(),(0,s.j4)(w,{title:t.titleMap[t.mode],modelValue:t.visible,"onUpdate:modelValue":a[9]||(a[9]=e=>t.visible=e),width:"500",padding:"20","destroy-on-close":"",onClosed:a[10]||(a[10]=a=>e.$emit("closed"))},{footer:(0,s.w5)((()=>[(0,s.Wm)(h,{onClick:a[7]||(a[7]=e=>t.visible=!1)},{default:(0,s.w5)((()=>[(0,s.Uk)("取 消")])),_:1}),"show"!=t.mode?((0,s.wg)(),(0,s.j4)(h,{key:0,type:"primary",loading:t.isSaveing,onClick:a[8]||(a[8]=e=>r.submit())},{default:(0,s.w5)((()=>[(0,s.Uk)("保 存")])),_:1},8,["loading"])):(0,s.kq)("",!0)])),default:(0,s.w5)((()=>[(0,s.Wm)(f,{model:t.form,rules:t.rules,disabled:"show"==t.mode,ref:"dialogForm","label-width":"100px","label-position":"left"},{default:(0,s.w5)((()=>[(0,s.Wm)(i,{label:"头像",prop:"avatar"},{default:(0,s.w5)((()=>[(0,s.Wm)(d,{modelValue:t.form.avatar,"onUpdate:modelValue":a[0]||(a[0]=e=>t.form.avatar=e),title:"上传头像"},null,8,["modelValue"])])),_:1}),(0,s.Wm)(i,{label:"登录账号",prop:"userName"},{default:(0,s.w5)((()=>[(0,s.Wm)(m,{modelValue:t.form.userName,"onUpdate:modelValue":a[1]||(a[1]=e=>t.form.userName=e),placeholder:"用于登录系统",clearable:""},null,8,["modelValue"])])),_:1}),(0,s.Wm)(i,{label:"姓名",prop:"name"},{default:(0,s.w5)((()=>[(0,s.Wm)(m,{modelValue:t.form.name,"onUpdate:modelValue":a[2]||(a[2]=e=>t.form.name=e),placeholder:"请输入完整的真实姓名",clearable:""},null,8,["modelValue"])])),_:1}),"add"==t.mode?((0,s.wg)(),(0,s.iD)(s.HY,{key:0},[(0,s.Wm)(i,{label:"登录密码",prop:"password"},{default:(0,s.w5)((()=>[(0,s.Wm)(m,{type:"password",modelValue:t.form.password,"onUpdate:modelValue":a[3]||(a[3]=e=>t.form.password=e),clearable:"","show-password":""},null,8,["modelValue"])])),_:1}),(0,s.Wm)(i,{label:"确认密码",prop:"password2"},{default:(0,s.w5)((()=>[(0,s.Wm)(m,{type:"password",modelValue:t.form.password2,"onUpdate:modelValue":a[4]||(a[4]=e=>t.form.password2=e),clearable:"","show-password":""},null,8,["modelValue"])])),_:1})],64)):(0,s.kq)("",!0),(0,s.Wm)(i,{label:"所属部门",prop:"dept"},{default:(0,s.w5)((()=>[(0,s.Wm)(p,{modelValue:t.form.dept,"onUpdate:modelValue":a[5]||(a[5]=e=>t.form.dept=e),options:t.depts,props:t.deptsProps,clearable:"",style:{width:"100%"}},null,8,["modelValue","options","props"])])),_:1}),(0,s.Wm)(i,{label:"所属角色",prop:"group"},{default:(0,s.w5)((()=>[(0,s.Wm)(n,{modelValue:t.form.group,"onUpdate:modelValue":a[6]||(a[6]=e=>t.form.group=e),multiple:"",filterable:"",style:{width:"100%"}},{default:(0,s.w5)((()=>[((0,s.wg)(!0),(0,s.iD)(s.HY,null,(0,s.Ko)(t.groups,(e=>((0,s.wg)(),(0,s.j4)(u,{key:e.id,label:e.label,value:e.id},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1})])),_:1},8,["model","rules","disabled"])])),_:1},8,["title","modelValue"])}var t={emits:["success","closed"],data(){return{mode:"add",titleMap:{add:"新增用户",edit:"编辑用户",show:"查看"},visible:!1,isSaveing:!1,form:{id:"",userName:"",avatar:"",name:"",dept:"",group:[]},rules:{avatar:[{required:!0,message:"请上传头像"}],userName:[{required:!0,message:"请输入登录账号"}],name:[{required:!0,message:"请输入真实姓名"}],password:[{required:!0,message:"请输入登录密码"},{validator:(e,a,l)=>{""!==this.form.password2&&this.$refs.dialogForm.validateField("password2"),l()}}],password2:[{required:!0,message:"请再次输入密码"},{validator:(e,a,l)=>{a!==this.form.password?l(new Error("两次输入密码不一致!")):l()}}],dept:[{required:!0,message:"请选择所属部门"}],group:[{required:!0,message:"请选择所属角色",trigger:"change"}]},groups:[],groupsProps:{value:"id",multiple:!0,checkStrictly:!0},depts:[],deptsProps:{value:"id",checkStrictly:!0}}},mounted(){this.getGroup(),this.getDept()},methods:{open(e="add"){return this.mode=e,this.visible=!0,this},async getGroup(){var e=await this.$api.system.role.list.get();this.groups=e.data.rows},async getDept(){var e=await this.$api.system.dept.list.get();this.depts=e.data},submit(){this.$refs.dialogForm.validate((async e=>{if(!e)return!1;this.isSaveing=!0;var a=await this.$api.demo.post.post(this.form);this.isSaveing=!1,200==a.code?(this.$emit("success",this.form,this.mode),this.visible=!1,this.$message.success("操作成功")):this.$alert(a.message,"提示",{type:"error"})}))},setData(e){this.form.id=e.id,this.form.userName=e.userName,this.form.avatar=e.avatar,this.form.name=e.name,this.form.group=e.group,this.form.dept=e.dept}}},r=l(8700);const d=(0,r.Z)(t,[["render",o]]);var i=d}}]);