Commit 460cbbf0 by lixiaomin

修改用户和角色的判断

parent 602a89e0
......@@ -221,6 +221,7 @@ export default {
rules: {
roleName: [
{ required: true, message: "角色名称不能为空", trigger: "blur" },
{ min: 2, message: '最少输入2个字符', trigger: 'blur' }
]
},
};
......
......@@ -108,13 +108,13 @@
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="姓名" prop="nickName">
<el-input v-model="form.nickName" placeholder="请输入人员姓名" maxlength="30" />
<el-input v-model="form.nickName" placeholder="请输入人员姓名" />
</el-form-item>
<el-form-item label="手机号" prop="phonenumber">
<el-input v-model="form.phonenumber" placeholder="请输入手机号" maxlength="11"/>
</el-form-item>
<el-form-item label="角色" prop="roleIds">
<el-select v-model="form.roleIds" multiple placeholder="请选择" clearable>
<el-form-item label="角色" prop="roleId">
<el-select v-model="form.roleId" placeholder="请选择" clearable>
<el-option
v-for="item in roleOptions"
:key="item.roleId"
......@@ -188,8 +188,9 @@ export default {
rules: {
nickName: [
{ required: true, message: "姓名不能为空", trigger: "blur" },
{ min: 2, message: '最少输入2个字符', trigger: 'blur' }
],
roleIds: [
roleId: [
{ required: true, message: "角色不能为空", trigger: "blur" },
],
phonenumber: [
......@@ -269,6 +270,7 @@ export default {
email: null,
status: "0",
remark: null,
roleId: null,
roleIds: [],
};
this.resetForm("form");
......@@ -302,9 +304,14 @@ export default {
const userId = row.userId || this.ids;
getUser(userId).then((response) => {
if(response.code=="200"){
this.form = response.data;
this.roleOptions = response.roles;
this.form.roleIds = response.roleIds;
this.form.userId = response.data.userId;
this.form.nickName = response.data.nickName;
this.form.userName = response.data.userName;
this.form.phonenumber = response.data.phonenumber;
this.form.email = response.data.email;
this.form.remark= response.data.remark ;
this.form.roleId = response.roleIds[0];
this.roleOptions = response.roles;
this.open = true;
this.title = "修改人员";
this.form.password = "";
......@@ -315,7 +322,15 @@ export default {
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
if(this.form.email){
let reg=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/
if(!reg.test(this.form.email)){
this.$message.error('邮箱格式不正确!');
return ;
}
}
this.form.userName=this.form.phonenumber;
this.form.roleIds.push(this.form.roleId);
if (this.form.userId != null) {
updateUser(this.form).then((response) => {
if(response.code=="200"){
......@@ -340,7 +355,7 @@ export default {
handleDelete(row) {
const userIds = row.userId || this.ids;
this.$modal
.confirm('是否确认删除人员编号为"' + row.nickName + '"的数据项?')
.confirm('是否确认删除人员姓名为"' + row.nickName + '"的数据项?')
.then(function () {
return delUser(userIds);
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment