|
|
@@ -161,7 +161,15 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getAddUserRoleList, getUserList, getUserRole } from '@/api/devops'
|
|
|
+import {
|
|
|
+ addUser,
|
|
|
+ deleteUser,
|
|
|
+ getAddUserRoleList,
|
|
|
+ getUserList,
|
|
|
+ getUserRole,
|
|
|
+ updateUserPasswd,
|
|
|
+ updateUserRole
|
|
|
+} from '@/api/devops'
|
|
|
|
|
|
export default {
|
|
|
name: 'User',
|
|
|
@@ -240,13 +248,18 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
onAdd() {
|
|
|
- this.showAddDialog = false
|
|
|
- this.$message.info('add account')
|
|
|
- console.log(this.addForm)
|
|
|
const formData = new FormData()
|
|
|
- formData.append('userId', this.addForm.username)
|
|
|
+ formData.append('username', this.addForm.username)
|
|
|
formData.append('password', this.addForm.password)
|
|
|
formData.append('roles', this.addForm.roles)
|
|
|
+ addUser(formData).then(resp => {
|
|
|
+ this.getData()
|
|
|
+ this.$message.info(resp.msg)
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error(error.message)
|
|
|
+ }).finally(() => {
|
|
|
+ this.showAddDialog = false
|
|
|
+ })
|
|
|
},
|
|
|
handleUpdateRole(index, row) {
|
|
|
this.updateRoleForm.userId = row.userId
|
|
|
@@ -266,8 +279,13 @@ export default {
|
|
|
const formData = new FormData()
|
|
|
formData.append('userId', this.updateRoleForm.userId)
|
|
|
formData.append('roles', this.userRoleList)
|
|
|
- console.log(this.userRoleList)
|
|
|
- this.showUpdateRoleDialog = false
|
|
|
+ updateUserRole(formData).then(resp => {
|
|
|
+ this.$message.info(resp.msg)
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error(error.message)
|
|
|
+ }).finally(() => {
|
|
|
+ this.showUpdateRoleDialog = false
|
|
|
+ })
|
|
|
},
|
|
|
handleUpdatePasswd(index, row) {
|
|
|
this.updatePasswdForm.userId = row.userId
|
|
|
@@ -275,14 +293,37 @@ export default {
|
|
|
this.showUpdatePasswdDialog = true
|
|
|
},
|
|
|
onUpdatePasswd() {
|
|
|
- this.showUpdatePasswdDialog = false
|
|
|
- this.$message.info('update passwd')
|
|
|
const formData = new FormData()
|
|
|
formData.append('userId', this.updatePasswdForm.userId)
|
|
|
formData.append('password', this.updatePasswdForm.password)
|
|
|
+ updateUserPasswd(formData).then(resp => {
|
|
|
+ this.$message.info(resp.msg)
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error(error.message)
|
|
|
+ }).finally(() => {
|
|
|
+ this.showUpdatePasswdDialog = false
|
|
|
+ })
|
|
|
},
|
|
|
handleDelete(index, row) {
|
|
|
- this.$message.info('delete -> ' + row.username)
|
|
|
+ this.$confirm('确定要删除 ' + row.username + '?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('userId', row.userId)
|
|
|
+ deleteUser(formData).then(resp => {
|
|
|
+ this.getData()
|
|
|
+ this.$message.info(resp.msg)
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error(error.message)
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消'
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|