You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
12 KiB

"use strict";(self["webpackChunkeatwhat_admin"]=self["webpackChunkeatwhat_admin"]||[]).push([[801],{3801:function(e,r,t){t.r(r),t.d(r,{default:function(){return m}});var s=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("el-card",[t("div",{staticClass:"user"},[t("div",{staticClass:"title"},[t("el-alert",{attrs:{title:"用户管理界面",type:"success",center:"",closable:!1}})],1),t("div",{staticClass:"btn"},[t("el-button",{attrs:{type:"primary",size:"small",round:"",icon:"el-icon-plus"},on:{click:function(r){e.addUserDialogVisible=!0}}},[e._v("添加用户")])],1),t("div",{staticClass:"table"},[t("el-table",{staticStyle:{width:"100%"},attrs:{data:e.user.filter((function(r){return!e.userSearch||r.userName.toLowerCase().includes(e.userSearch.toLowerCase())})),fit:"",lazy:"",stripe:!0,border:!0,"highlight-current-row":!0,"empty-text":"🥶正在努力加载中..."}},[t("el-table-column",{attrs:{label:"用户昵称",align:"center"},scopedSlots:e._u([{key:"default",fn:function(r){return[e._v(" "+e._s(r.row.userName||"神秘人")+" ")]}}])}),t("el-table-column",{attrs:{label:"性别",align:"center",width:"100"},scopedSlots:e._u([{key:"default",fn:function(r){return[e._v(" "+e._s(r.row.userGend||"隐私")+" ")]}}])}),t("el-table-column",{attrs:{label:"手机账号",align:"center"},scopedSlots:e._u([{key:"default",fn:function(r){return[e._v(" "+e._s(r.row.userNumb||"未知")+" ")]}}])}),t("el-table-column",{attrs:{label:"喜好",align:"center"},scopedSlots:e._u([{key:"default",fn:function(r){return[e._v(" "+e._s(r.row.userLike||"未知")+" ")]}}])}),t("el-table-column",{attrs:{label:"住址",align:"center"},scopedSlots:e._u([{key:"default",fn:function(r){return[e._v(" "+e._s(r.row.userAdd||"未知")+" ")]}}])}),t("el-table-column",{attrs:{align:"center"},scopedSlots:e._u([{key:"header",fn:function(r){return[t("el-input",{attrs:{size:"mini",placeholder:"输入用户名称搜索"},model:{value:e.userSearch,callback:function(r){e.userSearch=r},expression:"userSearch"}})]}},{key:"default",fn:function(r){return[t("el-button",{attrs:{type:"primary",size:"mini",plain:""},on:{click:function(t){return e.showUpdateUser(r.row.userId)}}},[e._v("编辑")]),t("el-popconfirm",{staticStyle:{"margin-left":"5px"},attrs:{title:"确定删除该用户?此操作不可逆"},on:{confirm:function(t){return e.deleteUser(r.row.userId)}}},[t("el-button",{attrs:{slot:"reference",type:"danger",size:"mini",plain:""},slot:"reference"},[e._v("删除")])],1)]}}])})],1)],1)]),t("el-dialog",{attrs:{title:"添加用户",visible:e.addUserDialogVisible,width:"45%",center:!0},on:{"update:visible":function(r){e.addUserDialogVisible=r},close:e.addUserDialogClosed}},[t("el-form",{ref:"addUserFormRef",attrs:{model:e.addUserForm,"label-width":"80px",size:"small",rules:e.addUserFormRules}},[t("el-form-item",{attrs:{label:"用户昵称",prop:"userName"}},[t("el-input",{attrs:{"prefix-icon":"el-icon-user-solid",autocomplete:"off",maxlength:"8",clearable:!0},model:{value:e.addUserForm.userName,callback:function(r){e.$set(e.addUserForm,"userName",r)},expression:"addUserForm.userName"}})],1),t("el-form-item",{attrs:{label:"用户性别",prop:"userGend"}},[t("el-radio-group",{model:{value:e.addUserForm.userGend,callback:function(r){e.$set(e.addUserForm,"userGend",r)},expression:"addUserForm.userGend"}},[t("el-radio",{attrs:{label:"男"}},[e._v("男")]),t("el-radio",{attrs:{label:"女"}},[e._v("女")])],1)],1),t("el-form-item",{attrs:{label:"用户电话",prop:"userNumb"}},[t("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-phone",clearable:!0,maxlength:"11"},model:{value:e.addUserForm.userNumb,callback:function(r){e.$set(e.addUserForm,"userNumb",e._n(r))},expression:"addUserForm.userNumb"}})],1),t("el-form-item",{attrs:{label:"登陆密码",prop:"userPwd"}},[t("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-lock",clearable:!0,minlength:"6",maxlength:"13","show-password":""},model:{value:e.addUserForm.userPwd,callback:function(r){e.$set(e.addUserForm,"userPwd",r)},expression:"addUserForm.userPwd"}})],1),t("el-form-item",{attrs:{label:"用户喜好",prop:"userLike"}},[t("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-sugar",clearable:!0},model:{value:e.addUserForm.userLike,callback:function(r){e.$set(e.addUserForm,"userLike",r)},expression:"addUserForm.userLike"}})],1),t("el-form-item",{attrs:{label:"用户住址",prop:"userAdd"}},[t("el-cascader",{staticStyle:{width:"100%"},attrs:{options:e.citys,filterable:"",clearable:"",props:{expandTrigger:"hover"}},model:{value:e.addUserForm.userAdd,callback:function(r){e.$set(e.addUserForm,"userAdd",r)},expression:"addUserForm.userAdd"}})],1)],1),t("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(r){e.addUserDialogVisible=!1}}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.addUser}},[e._v("确 定")])],1)],1),t("el-dialog",{attrs:{title:"更新用户信息",visible:e.updateUserDialogVisible,width:"45%",center:!0},on:{"update:visible":function(r){e.updateUserDialogVisible=r}}},[t("el-form",{ref:"updateUserFormRef",attrs:{model:e.updateUserForm,"label-width":"80px",size:"small",rules:e.addUserFormRules}},[t("el-form-item",{attrs:{label:"用户昵称",prop:"userName"}},[t("el-input",{attrs:{"prefix-icon":"el-icon-user-solid",autocomplete:"off",maxlength:"8",clearable:!0},model:{value:e.updateUserForm.userName,callback:function(r){e.$set(e.updateUserForm,"userName",r)},expression:"updateUserForm.userName"}})],1),t("el-form-item",{attrs:{label:"用户性别",prop:"userGend"}},[t("el-radio-group",{model:{value:e.updateUserForm.userGend,callback:function(r){e.$set(e.updateUserForm,"userGend",r)},expression:"updateUserForm.userGend"}},[t("el-radio",{attrs:{label:"男"}},[e._v("男")]),t("el-radio",{attrs:{label:"女"}},[e._v("女")])],1)],1),t("el-form-item",{attrs:{label:"用户电话",prop:"userNumb"}},[t("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-phone",clearable:!0,maxlength:"11"},model:{value:e.updateUserForm.userNumb,callback:function(r){e.$set(e.updateUserForm,"userNumb",e._n(r))},expression:"updateUserForm.userNumb"}})],1),t("el-form-item",{attrs:{label:"登陆密码",prop:"userPwd"}},[t("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-lock",clearable:!0,minlength:"6",maxlength:"13","show-password":""},model:{value:e.updateUserForm.userPwd,callback:function(r){e.$set(e.updateUserForm,"userPwd",r)},expression:"updateUserForm.userPwd"}})],1),t("el-form-item",{attrs:{label:"用户喜好",prop:"userLike"}},[t("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-sugar",clearable:!0},model:{value:e.updateUserForm.userLike,callback:function(r){e.$set(e.updateUserForm,"userLike",r)},expression:"updateUserForm.userLike"}})],1),t("el-form-item",{attrs:{label:"用户住址",prop:"userAdd"}},[t("el-cascader",{staticStyle:{width:"100%"},attrs:{options:e.citys,filterable:"",clearable:"",props:{expandTrigger:"hover"}},model:{value:e.updateUserForm.userAdd,callback:function(r){e.$set(e.updateUserForm,"userAdd",r)},expression:"updateUserForm.userAdd"}})],1)],1),t("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(r){e.updateUserDialogVisible=!1}}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.updateUser}},[e._v("确 定")])],1)],1)],1)},a=[],l=t(7906),o=t(6198),u=(t(4916),t(5306),t(1539),t(9714),t(4747),t(3325)),n={name:"User",data:function(){return{user:[],userSearch:"",addUserDialogVisible:!1,updateUserDialogVisible:!1,addUserForm:{userId:"",userPwd:"123456",userName:"神秘人",userNumb:"",userLike:"",userAdd:"",userGend:"男"},updateUserForm:{userId:"",userPwd:"",userName:"",userNumb:"",userLike:"",userAdd:"",userGend:""},addUserFormRules:{userName:[{required:!0,message:"请输入用户昵称",trigger:"blur"},{min:1,max:8,message:"长度在 1 到 8 个字符",trigger:"blur"}],userPwd:[{required:!0,message:"请输入用户登录密码",trigger:"blur"},{min:6,max:13,message:"长度在 6 到 13 个字符",trigger:"blur"}],userNumb:[{required:!0,message:"请输入电话号码",trigger:"blur"},{pattern:/^((13[0-9])|(14[5-9])|(15([0-3]|[5-9]))|(16[6-7])|(17[1-8])|(18[0-9])|(19[1|3])|(19[5|6])|(19[8|9]))\d{8}$/,message:"手机号码格式不符合",trigger:"blur"}],userLike:[],userAdd:[{required:!0,message:"住址不可为空",trigger:"blur"}],userGend:[{required:!0,message:"性别不可为空",trigger:"blur"}]},citys:u.Z}},methods:{getUser:function(){var e=this;return(0,o.Z)((0,l.Z)().mark((function r(){var t,s;return(0,l.Z)().wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.next=2,e.$http.get("user");case 2:t=r.sent,s=t.data,e.user=s;case 5:case"end":return r.stop()}}),r)})))()},addUserDialogClosed:function(){this.$refs.addUserFormRef.resetFields()},addUser:function(){var e=this;this.$refs.addUserFormRef.validate(function(){var r=(0,o.Z)((0,l.Z)().mark((function r(t){var s;return(0,l.Z)().wrap((function(r){while(1)switch(r.prev=r.next){case 0:if(t){r.next=3;break}return e.$message.error("添加新用户验证失败"),r.abrupt("return");case 3:s=0;case 4:if(!(s<e.user.length)){r.next=11;break}if(e.user[s].userNumb!==e.addUserForm.userNumb){r.next=8;break}return e.$message.warning("该用户已存在,请勿重复添加"),r.abrupt("return");case 8:s++,r.next=4;break;case 11:return e.addUserForm.userId=e.guid(),e.addUserForm.userAdd=e.getLocationTransform(e.addUserForm.userAdd),r.next=15,e.$http.post("user",e.addUserForm);case 15:e.getUser(),e.$message.success("添加新用户成功");case 17:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()),this.addUserDialogVisible=!1},showUpdateUser:function(e){var r=this;return(0,o.Z)((0,l.Z)().mark((function t(){var s,a;return(0,l.Z)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,r.$http.get("user/"+e);case 2:s=t.sent,a=s.data,r.updateUserForm=a[0],r.updateUserDialogVisible=!0;case 6:case"end":return t.stop()}}),t)})))()},updateUser:function(){var e=this;this.$refs.updateUserFormRef.validate(function(){var r=(0,o.Z)((0,l.Z)().mark((function r(t){return(0,l.Z)().wrap((function(r){while(1)switch(r.prev=r.next){case 0:if(t){r.next=3;break}return e.$message.error("更新用户信息验证失败"),r.abrupt("return");case 3:return e.updateUserForm.userAdd=e.getLocationTransform(e.updateUserForm.userAdd),r.next=6,e.$http.put("user",e.updateUserForm);case 6:e.getUser(),e.$message.success("更新用户信息成功");case 8:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()),this.updateUserDialogVisible=!1},deleteUser:function(e){var r=this;return(0,o.Z)((0,l.Z)().mark((function t(){return(0,l.Z)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,r.$http.delete("user/"+e);case 2:r.getUser(),r.$message.success("删除用户成功!");case 4:case"end":return t.stop()}}),t)})))()},guid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=16*Math.random()|0,t="x"==e?r:3&r|8;return t.toString(16)}))},getLocationTransform:function(e){var r=e,t=r[0],s=r[1],a=r[2],l=[],o=(e=[],"");return this.citys.forEach((function(e){e.value===t&&(o+=e.label,l=e.children)})),l.forEach((function(r){r.value===s&&(o=o+"/"+r.label,e=r.children)})),e.forEach((function(e){e.value===a&&(o=o+"/"+e.label)})),o}},created:function(){this.getUser()}},i=n,d=t(1001),c=(0,d.Z)(i,s,a,!1,null,null,null),m=c.exports}}]);
//# sourceMappingURL=801-legacy.76c5c387.js.map