|
|
@ -56,7 +56,7 @@ |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-button type="text" size="small" @click="handleResetPassword(scope.row.id)">重置密码</el-button> |
|
|
|
<el-button type="text" size="small" @click="handleEdit(scope.$index)">编辑</el-button> |
|
|
|
<el-button type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button> |
|
|
|
<el-button v-if="scope.row.isAdmin === 0" type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
@ -121,6 +121,21 @@ export default { |
|
|
|
callback() |
|
|
|
} |
|
|
|
} |
|
|
|
const validatePass = (rule, value, callback) => { |
|
|
|
if (value.length < 5) { |
|
|
|
callback(new Error('密码不能小于5位')) |
|
|
|
} else { |
|
|
|
callback() |
|
|
|
} |
|
|
|
} |
|
|
|
const validateName = (rule, value, callback) => { |
|
|
|
const reg = /^[a-z_A-Z]+$/ |
|
|
|
if (!reg.test(value)) { |
|
|
|
callback(new Error('登录名称只能包含字母和下划线')) |
|
|
|
} else { |
|
|
|
callback() |
|
|
|
} |
|
|
|
} |
|
|
|
return { |
|
|
|
form: { |
|
|
|
nickname: '', |
|
|
@ -134,10 +149,10 @@ export default { |
|
|
|
{ required: true, message: '用户名称不能为空', trigger: 'blur' } |
|
|
|
], |
|
|
|
name: [ |
|
|
|
{ required: true, message: '登录名称不能为空', trigger: 'blur' } |
|
|
|
{ required: true, trigger: 'blur', validator: validateName } |
|
|
|
], |
|
|
|
password: [ |
|
|
|
{ required: true, message: '密码不能为空', trigger: 'blur' } |
|
|
|
{ required: true, trigger: 'blur', validator: validatePass } |
|
|
|
], |
|
|
|
phone: [ |
|
|
|
{ required: true, trigger: 'blur', validator: validPhone } |
|
|
@ -205,14 +220,13 @@ export default { |
|
|
|
if (valid) { |
|
|
|
if (this.addVisible) { |
|
|
|
add(this.form).then(response => { |
|
|
|
this.form.createTime = new Date() |
|
|
|
this.userList.push(this.form) |
|
|
|
this.handleSearch() |
|
|
|
}) |
|
|
|
this.addVisible = false |
|
|
|
} |
|
|
|
if (this.editVisible) { |
|
|
|
edit(this.form).then(response => { |
|
|
|
console.log(response) |
|
|
|
edit(this.form, this.form.id).then(response => { |
|
|
|
this.handleSearch() |
|
|
|
}) |
|
|
|
this.editVisible = false |
|
|
|
} |
|
|
@ -225,7 +239,7 @@ export default { |
|
|
|
}, |
|
|
|
handleResetPassword(id) { |
|
|
|
resetPassword(id).then(response => { |
|
|
|
const newPassword = response.data |
|
|
|
const newPassword = response.data.password |
|
|
|
this.$alert(newPassword, '新密码', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
@ -239,7 +253,7 @@ export default { |
|
|
|
}).then(() => { |
|
|
|
this.listLoading = true |
|
|
|
del(code).then(response => { |
|
|
|
this.assetList.splice(index, 1) |
|
|
|
this.userList.splice(index, 1) |
|
|
|
this.listLoading = false |
|
|
|
}) |
|
|
|
this.$message({ |
|
|
|