-
this.delUser(row.username)}
- >
- 删除
-
+
+
+ this.delUser(row.username)}
+ >
+ 删除
+
+
+
+ this.updateUser(row)}
+ >
+ 修改
+
+
)
}
@@ -162,8 +178,26 @@ export default {
],
}
},
-
methods: {
+ addUser() {
+ this.operType = 1
+ this.formData = {
+ username: '',
+ role: '',
+ password: '',
+ }
+ this.visible = true
+ },
+ updateUser(row) {
+ console.log(row)
+ this.formData = {
+ username: row.username,
+ role: row.role,
+ password: '',
+ }
+ this.operType = 2
+ this.visible = true
+ },
handleClose() {
this.formData = { ...INITIAL_DATA }
this.visible = false
@@ -197,14 +231,19 @@ export default {
async onSubmit({ validateResult, firstError }) {
if (validateResult === true) {
// 新增用户
- const res = await addUserApi(this.formData)
- if (res?.code == 200) {
- this.formData = { ...INITIAL_DATA }
- this.visible = false
- this.$message.success('提交成功')
- this.getUserList()
+ if (this.operType == 1) {
+ const res = await addUserApi(this.formData)
+ if (res?.code == 200) {
+ this.formData = { ...INITIAL_DATA }
+ this.visible = false
+ this.$message.success('提交成功')
+ this.getUserList()
+ } else {
+ this.$message.error(res.msg)
+ }
} else {
- this.$message.error(res.msg)
+ // 更新用户
+ console.log(123)
}
} else {
this.$message.warning(firstError)