From fef23579ac8357b2d3088947e50ce77147b3d2e0 Mon Sep 17 00:00:00 2001 From: teukkk Date: Tue, 17 Jun 2025 19:37:43 +0800 Subject: [PATCH] refactor: chat user --- ui/src/api/chat-user/chat-user.ts | 8 +++++ ui/src/api/system/user-group.ts | 2 +- ui/src/views/chat-user/index.vue | 33 +++++++++++++------ ui/src/views/system-chat-user/group/index.vue | 14 ++++---- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/ui/src/api/chat-user/chat-user.ts b/ui/src/api/chat-user/chat-user.ts index f9f0d1739..716cba9fa 100644 --- a/ui/src/api/chat-user/chat-user.ts +++ b/ui/src/api/chat-user/chat-user.ts @@ -19,6 +19,13 @@ const getUserGroupList: (resource: ChatUserResourceParams, loading?: Ref) => Promise> = (resource, data, loading) => { + return put(`${prefix}/${resource.resource_type}/${resource.resource_id}/user_group`, data, undefined, loading) +} + /** * 获取用户组的用户列表 */ @@ -50,6 +57,7 @@ const putUserGroupUser: ( export default { getUserGroupList, + editUserGroupList, getUserGroupUserList, putUserGroupUser } diff --git a/ui/src/api/system/user-group.ts b/ui/src/api/system/user-group.ts index 64438c830..e6826bfde 100644 --- a/ui/src/api/system/user-group.ts +++ b/ui/src/api/system/user-group.ts @@ -55,7 +55,7 @@ const postAddMember: ( */ const postRemoveMember: ( user_group_id: string, - body: string[], + body: any, loading?: Ref, ) => Promise> = (user_group_id, body, loading) => { return post(`${prefix}/${user_group_id}/remove_member`, body, {}, loading) diff --git a/ui/src/views/chat-user/index.vue b/ui/src/views/chat-user/index.vue index 05dc09e70..0c5e6c7c1 100644 --- a/ui/src/views/chat-user/index.vue +++ b/ui/src/views/chat-user/index.vue @@ -40,7 +40,7 @@ {{ paginationConfig.total }} - + {{ t('common.save') }} @@ -50,12 +50,13 @@ - +
{{ $t('views.chatUser.autoAuthorization') }}
- +
@@ -82,11 +83,12 @@ @@ -104,12 +106,11 @@ import { t } from '@/locales' import type { ChatUserGroupItem, ChatUserResourceParams, ChatUserGroupUserItem } from '@/api/type/workspaceChatUser' import { useRoute } from 'vue-router' import { ChatUserResourceEnum } from '@/enums/workspaceChatUser' +import { MsgSuccess } from '@/utils/message' const route = useRoute() const resource: ChatUserResourceParams = { resource_id: route.params.id as string, resource_type: route.meta.resourceType as ChatUserResourceEnum } -const disabled = computed(() => false) // TODO - const filterText = ref('') const loading = ref(false) const list = ref([]) @@ -148,13 +149,24 @@ function clickUserGroup(item: ChatUserGroupItem) { current.value = item } +async function changeAuth() { + const params = [{ user_group_id: current.value?.id as string, is_auth: !current.value?.is_auth }] + try { + await ChatUserApi.editUserGroupList(resource, params, loading) + await getUserGroupList() + current.value = { name: current.value?.name as string, id: current.value?.id as string, is_auth: !current.value?.is_auth } + getList() + } catch (error) { + console.error(error) + } +} + const rightLoading = ref(false) const searchType = ref('name') const searchForm = ref>({ name: '', }) -const automaticAuthorization = ref(false) const paginationConfig = reactive({ current_page: 1, page_size: 20, @@ -205,6 +217,7 @@ async function handleSave() { try { const params = tableData.value.map(item => ({ chat_user_id: item.id, is_auth: item.is_auth })) await ChatUserApi.putUserGroupUser(resource, current.value?.id as string, params, rightLoading) + MsgSuccess(t('common.saveSuccess')) } catch (error) { console.error(error) } diff --git a/ui/src/views/system-chat-user/group/index.vue b/ui/src/views/system-chat-user/group/index.vue index 826d07689..50641346d 100644 --- a/ui/src/views/system-chat-user/group/index.vue +++ b/ui/src/views/system-chat-user/group/index.vue @@ -78,7 +78,7 @@
- {{ t('views.userManage.createUser') }} + {{ t('views.role.member.add') }} {{ $t('common.delete') }} @@ -132,7 +132,7 @@ - +