Skip to content

Commit 17ef625

Browse files
committed
fix(List.vue): refactor user creation and deletion logic to utilize dedicated API functions for improved clarity and maintainability
1 parent 9691e72 commit 17ef625

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

apps/daas/src/views/user/List.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { fetchRoles } from '@tap/api/src/core/roles'
44
import {
55
batchUpdateUserListtags,
66
countUsers,
7+
createUser,
8+
deleteUser,
79
fetchUsers,
10+
updateUser,
811
updateUserInfo,
912
} from '@tap/api/src/core/users'
1013
import PageContainer from '@tap/business/src/components/PageContainer.vue'
@@ -507,9 +510,9 @@ export default {
507510
}))
508511
params.listtags = listtags
509512
510-
const data = await usersApi[this.createForm.id ? 'patch' : 'post'](
511-
params,
512-
).finally(() => {
513+
const method = this.createForm.id ? updateUser : createUser
514+
515+
const data = await method(params).finally(() => {
513516
this.createDialogVisible = false
514517
})
515518
@@ -532,8 +535,7 @@ export default {
532535
beforeClose: (action, instance, done) => {
533536
if (action === 'confirm') {
534537
instance.confirmButtonLoading = true
535-
usersApi
536-
.delete(item.id)
538+
deleteUser(item.id)
537539
.then(() => {
538540
this.$message.success(this.$t('public_message_delete_ok'))
539541
this.table.fetch()
@@ -611,8 +613,7 @@ export default {
611613
beforeClose: (action, instance, done) => {
612614
if (action === 'confirm') {
613615
instance.confirmButtonLoading = true
614-
usersApi
615-
.patch(data)
616+
updateUser(data)
616617
.then(() => {
617618
this.$message.success(successMsg)
618619
this.table.fetch()
@@ -1107,7 +1108,6 @@ export default {
11071108
11081109
<el-form-item
11091110
:label="$t('packages_component_classification_userTitle')"
1110-
required
11111111
>
11121112
<el-tree-select
11131113
ref="userGroupTree"

packages/api/src/core/users.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,7 @@ export function patchUser(params: any, config?: any) {
136136
export function batchUpdateUserListtags(params: any) {
137137
return requestClient.patch(`${BASE_URL}/batchUpdateListtags`, params)
138138
}
139+
140+
export function deleteUser(id: string) {
141+
return requestClient.delete(`${BASE_URL}/${id}`)
142+
}

0 commit comments

Comments
 (0)