1 |
- "use strict";(self["webpackChunkRaingad_IM"]=self["webpackChunkRaingad_IM"]||[]).push([[584],{3584:function(e,t,s){s.r(t),s.d(t,{default:function(){return p}});var a=function(){var e=this,t=e._self._c;return t("div",{staticClass:"m-20"},[t("div",{staticClass:"mb-15 lz-flex lz-space-between"},[t("div",[t("el-button",{staticClass:"mr-15",on:{click:e.addUser}},[e._v("添加成员")])],1),t("div",[t("el-input",{staticStyle:{width:"300px"},attrs:{placeholder:"请输入关键字搜索","prefix-icon":"el-icon-search"},nativeOn:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.handleChange.apply(null,arguments)}},model:{value:e.params.keywords,callback:function(t){e.$set(e.params,"keywords",t)},expression:"params.keywords"}},[t("el-button",{attrs:{slot:"append",icon:"el-icon-search"},on:{click:e.handleChange},slot:"append"})],1)],1)]),t("el-table",{staticStyle:{width:"100%",border:"solid 1px #e3e3e3"},attrs:{data:e.userList,stripe:"",height:"calc(100vh - 200px)","header-cell-style":{"background-color":"#f5f7fa",color:"#909399"}},on:{"sort-change":e.sortChange,"row-dblclick":e.handleClick}},[t("el-table-column",{attrs:{fixed:"",prop:"user_id",label:"ID",sortable:"custom",width:"150"}}),t("el-table-column",{attrs:{prop:"realname",label:"姓名",width:"120"}}),t("el-table-column",{attrs:{prop:"account",label:"账号",width:"120"}}),t("el-table-column",{attrs:{prop:"sex",label:"性别",sortable:"custom",width:"120"},scopedSlots:e._u([{key:"default",fn:function(s){return[0==s.row.sex?t("span",{staticClass:"el-dropdown-link"},[e._v("女")]):e._e(),1==s.row.sex?t("span",{staticClass:"el-dropdown-link"},[e._v("男")]):e._e(),2==s.row.sex?t("span",{staticClass:"el-dropdown-link"},[e._v("未知")]):e._e()]}}])}),t("el-table-column",{attrs:{prop:"role",label:"角色",sortable:"custom",width:"120"},scopedSlots:e._u([{key:"default",fn:function(s){return[1==s.row.role?t("span",{staticClass:"el-dropdown-link"},[e._v(" 超级管理员 ")]):t("el-dropdown",{on:{command:function(t){return e.handleCommand(s.row,t)}}},[t("span",{staticClass:"el-dropdown-link cur-handle"},[e._v(" "+e._s(0==s.row.role?"普通用户":"管理员")),t("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[t("el-dropdown-item",{attrs:{command:0}},[e._v("普通用户")]),t("el-dropdown-item",{attrs:{command:2}},[e._v("管理员")])],1)],1)]}}])}),t("el-table-column",{attrs:{prop:"create_time",label:"注册时间",width:"140"},scopedSlots:e._u([{key:"default",fn:function(s){return[t("el-popover",{attrs:{placement:"top-start",title:"位置信息",width:"250",trigger:"hover"}},[e._v(" IP: "+e._s(s.row.register_ip)+" "),t("br"),e._v(" 位置:"+e._s(s.row.reg_location||"--")+" "),t("span",{attrs:{slot:"reference"},slot:"reference"},[e._v(e._s(s.row.create_time))])])]}}])}),t("el-table-column",{attrs:{prop:"last_login_time",label:"最后登录时间",width:"140"},scopedSlots:e._u([{key:"default",fn:function(s){return[t("el-popover",{attrs:{placement:"top-start",title:"位置信息",width:"250",trigger:"hover"}},[e._v(" IP: "+e._s(s.row.last_login_ip)+" "),t("br"),e._v(" 位置:"+e._s(s.row.location||"--")+" "),t("span",{attrs:{slot:"reference"},slot:"reference"},[e._v(e._s(s.row.last_login_time))])])]}}])}),t("el-table-column",{attrs:{prop:"remark",label:"备注","min-width":"300"}}),t("el-table-column",{attrs:{prop:"status",label:"状态",width:"120"},scopedSlots:e._u([{key:"default",fn:function(s){return[1!=s.row.user_id?t("el-switch",{attrs:{"active-value":1,"inactive-value":0},on:{change:function(t){return e.setStatus(s.row)}},model:{value:s.row.status,callback:function(t){e.$set(s.row,"status",t)},expression:"scope.row.status"}}):t("span",[e._v("--")])]}}])}),t("el-table-column",{attrs:{fixed:"right",label:"操作",width:"130"},scopedSlots:e._u([{key:"default",fn:function(s){return[t("el-button",{attrs:{type:"text",size:"small"},on:{click:function(t){return e.handleClick(s.row)}}},[e._v("查看")]),s.row.user_id>1?t("el-button",{attrs:{type:"text",size:"small"},on:{click:function(t){return e.editUser(s.row)}}},[e._v("编辑")]):e._e(),t("el-button",{attrs:{type:"text",size:"small"},on:{click:function(t){return e.editPass(s.row)}}},[e._v("改密")])]}}])})],1),t("div",{staticClass:"mt-15"},[t("el-pagination",{attrs:{background:"","current-page":e.params.page,"page-sizes":[20,50,100,200,300,400,500],"page-size":e.params.limit,layout:"total, sizes, prev, pager, next, jumper",total:e.total},on:{"size-change":e.handleChange,"current-change":e.getUserList,"update:currentPage":function(t){return e.$set(e.params,"page",t)},"update:current-page":function(t){return e.$set(e.params,"page",t)},"update:pageSize":function(t){return e.$set(e.params,"limit",t)},"update:page-size":function(t){return e.$set(e.params,"limit",t)}}})],1),t("el-dialog",{attrs:{title:e.formTitle,visible:e.dialogVisible,modal:!0,width:"500px","append-to-body":""},on:{"update:visible":function(t){e.dialogVisible=t},close:function(t){e.dialogVisible=!1}}},[t("el-form",{ref:"userinfo",attrs:{model:e.detail,rules:e.rules,"label-width":"100px"}},[t("el-form-item",{attrs:{label:"账号",prop:"account"}},[t("el-input",{attrs:{placeholder:"请输入邮箱或者手机号"},model:{value:e.detail.account,callback:function(t){e.$set(e.detail,"account",t)},expression:"detail.account"}})],1),t("el-form-item",{directives:[{name:"show",rawName:"v-show",value:"add"==e.formType,expression:"formType=='add'"}],attrs:{label:"密码",prop:"password"}},[t("el-input",{attrs:{"show-password":"",placeholder:"请输入密码"},model:{value:e.detail.password,callback:function(t){e.$set(e.detail,"password",t)},expression:"detail.password"}})],1),t("el-form-item",{attrs:{label:"姓名",prop:"realname"}},[t("el-input",{attrs:{placeholder:"请输入用户名称"},model:{value:e.detail.realname,callback:function(t){e.$set(e.detail,"realname",t)},expression:"detail.realname"}})],1),t("el-form-item",{attrs:{label:"e-mail",prop:"email"}},[t("el-input",{attrs:{placeholder:"请输入邮箱地址"},model:{value:e.detail.email,callback:function(t){e.$set(e.detail,"email",t)},expression:"detail.email"}})],1),t("el-form-item",{attrs:{label:"性别",prop:"sex"}},[t("el-radio-group",{model:{value:e.detail.sex,callback:function(t){e.$set(e.detail,"sex",t)},expression:"detail.sex"}},[t("el-radio",{attrs:{label:2,border:""}},[e._v("未知")]),t("el-radio",{attrs:{label:1,border:""}},[e._v("男")]),t("el-radio",{attrs:{label:0,border:""}},[e._v("女")])],1)],1),t("el-form-item",{attrs:{label:"角色",prop:"role"}},[t("el-radio-group",{model:{value:e.detail.role,callback:function(t){e.$set(e.detail,"role",t)},expression:"detail.role"}},[t("el-radio",{attrs:{label:0,border:""}},[e._v("普通用户")]),t("el-radio",{attrs:{label:2,border:""}},[e._v("管理员")])],1)],1),t("el-form-item",{attrs:{label:"状态",prop:"status"}},[t("el-radio-group",{model:{value:e.detail.status,callback:function(t){e.$set(e.detail,"status",t)},expression:"detail.status"}},[t("el-radio",{attrs:{label:1,border:""}},[e._v("正常")]),t("el-radio",{attrs:{label:0,border:""}},[e._v("禁用")])],1)],1),t("el-form-item",{attrs:{label:"备注",prop:"remark"}},[t("el-input",{attrs:{type:"textarea",rows:2},model:{value:e.detail.remark,callback:function(t){e.$set(e.detail,"remark",t)},expression:"detail.remark"}})],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.submitForm("userinfo")}}},[e._v("保存")])],1)],1)],1),t("el-dialog",{attrs:{title:"修改密码",visible:e.dialogPass,modal:!0,width:"400px","append-to-body":""},on:{"update:visible":function(t){e.dialogPass=t}}},[t("el-form",{attrs:{"label-width":"100px"}},[t("el-form-item",{attrs:{label:"新密码"}},[t("el-input",{attrs:{"show-password":"",placeholder:"请输入密码"},model:{value:e.password,callback:function(t){e.password=t},expression:"password"}})],1),t("el-form-item",{attrs:{label:"重复密码"}},[t("el-input",{attrs:{"show-password":"",placeholder:"请输入重复输入密码"},model:{value:e.repass,callback:function(t){e.repass=t},expression:"repass"}})],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.editPassword()}}},[e._v("保存")])],1)],1)],1)],1)},r=[],l=(s(7658),s(3822)),i={data(){return{total:0,params:{page:1,limit:20,keywords:"",order_field:"",order_type:1},userList:[],formTitle:"添加成员",formType:"add",dialogVisible:!1,detail:{},originDetail:{realname:"",password:"123456",email:"",sex:2,role:0,remark:"",status:1},rules:{account:[{min:4,max:32,message:"长度在 4 到 32 个字符",trigger:"blur"}],realname:[{required:!0,message:"请输入用户名称",trigger:"blur"},{min:2,max:16,message:"长度在 2 到 16 个字符",trigger:"blur"}],email:[{type:"email",message:"请输入正确的邮箱地址",trigger:["blur","change"]}],password:[{required:!0,message:"请输入密码",trigger:"blur"},{min:6,max:16,message:"长度在 6 到 16 个字符",trigger:"blur"}]},dialogPass:!1,password:"",repass:"",currentUser:{}}},computed:{...(0,l.rn)({globalConfig:e=>e.globalConfig})},watch:{dialogVisible(e){e||(this.detail=this.originDetail)}},mounted(){this.detail=this.originDetail,this.getUserList();let e=this.globalConfig.sysInfo.regauth??0,t="请输入账号:4-32个字符";switch(parseInt(e)){case 1:t="请输入正确的手机号";break;case 2:t="请输入正确的邮箱";break;case 3:t="请输入正确的手机号或者邮箱";break;default:t="请输入正确的账号";break}let s={required:!0,message:t,trigger:"blur"};this.rules.account.push(s);let a={type:"email",message:t,trigger:"blur",validator:this.validateContact},r={type:"phone",message:t,trigger:"blur",validator:this.validateContact};1==e?this.rules.account.push(r):2==e?this.rules.account.push(a):3==e&&(this.rules.account.push(a),this.rules.account.push(r))},methods:{getUserList(){this.$api.userApi.getUserList(this.params).then((e=>{0==e.code&&(this.userList=e.data,this.total=e.count,this.params.page=e.page)}))},sortChange(e){this.params.order_field=e.prop,null==e.order&&(this.params.order_field=null),this.params.order_type="ascending"==e.order?1:2,this.getUserList()},handleClick(e){this.$user(e.user_id,{isManage:!0,editDataCallbak:e=>{this.editUser(e)}})},handleChange(){this.params.page=1,this.getUserList()},addUser(){this.formTitle="添加成员",this.formType="add",this.dialogVisible=!0},editUser(e){let t=e;this.formTitle="修改成员",this.formType="edit",this.dialogVisible=!0,t.password="rainagd",this.detail=t},validateContact(e,t,s){t?/^1[3456789]\d{9}$/.test(t)||/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(t)?s():s(new Error("请输入正确的手机号或邮箱")):s()},submitForm(e){this.$refs[e].validate((e=>{if(!e)return console.log("error submit!!"),!1;if("add"==this.formType)this.$api.userApi.addUser(this.detail).then((e=>{0==e.code&&(this.dialogVisible=!1,this.getUserList(),this.$message({message:e.msg,type:"success"}))}));else{let e=JSON.parse(JSON.stringify(this.detail));delete e.password,this.$api.userApi.editUser(e).then((e=>{0==e.code&&(this.dialogVisible=!1,this.getUserList(),this.$message({message:e.msg,type:"success"}))}))}}))},editPass(e){this.currentUser=e,this.dialogPass=!0},editPassword(){if(""==this.password||this.password.length<6||this.password.length>16)return this.$message({message:"请输入6-16个字符串的密码",type:"warning"}),!1;if(this.password!=this.repass)return this.$message({message:"两次密码不一致",type:"warning"}),!1;let e={user_id:this.currentUser.user_id,password:this.password};this.$api.userApi.editPassword(e).then((e=>{0==e.code&&(this.dialogPass=!1,this.password="",this.repass="",this.$message({message:e.msg,type:"success"}))}))},setStatus(e){let t={user_id:e.user_id,status:e.status};this.$api.userApi.setStatus(t).then((e=>{0==e.code&&this.$message({message:e.msg,type:"success"})}))},handleCommand(e,t){let s={user_id:e.user_id,role:t};this.$api.userApi.setRole(s).then((s=>{0==s.code&&(e.role=t,this.$message({message:s.msg,type:"success"}))}))},delUser(e){this.$confirm("此操作将永久删除该用户, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((()=>{let t={user_id:e.user_id};this.$api.userApi.delUser(t).then((e=>{0==e.code&&(this.$message({message:e.msg,type:"success"}),this.getUserList())}))})).catch((()=>{this.$message({type:"info",message:"已取消删除"})}))}}},o=i,n=s(1001),d=(0,n.Z)(o,a,r,!1,null,"6960981b",null),p=d.exports}}]);
|