Skip to content

Commit 75fd815

Browse files
committed
refactor: chat user
1 parent 9f6cde3 commit 75fd815

File tree

2 files changed

+54
-31
lines changed

2 files changed

+54
-31
lines changed

ui/src/api/system/user-group.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Result } from '@/request/Result'
2-
import { get, post, del } from '@/request/index'
3-
import type { Ref } from 'vue'
4-
import type { ChatUserGroupUserItem, } from '@/api/type/systemChatUser'
5-
import type { pageRequest, PageList, ListItem } from '@/api/type/common'
1+
import {Result} from '@/request/Result'
2+
import {get, post, del} from '@/request/index'
3+
import type {Ref} from 'vue'
4+
import type {ChatUserGroupUserItem,} from '@/api/type/systemChatUser'
5+
import type {pageRequest, PageList, ListItem} from '@/api/type/common'
66

77
const prefix = '/system/group'
88

@@ -67,12 +67,12 @@ const postRemoveMember: (
6767
const getUserListByGroup: (
6868
user_group_id: string,
6969
page: pageRequest,
70-
username: string,
70+
params ?: any,
7171
loading?: Ref<boolean>,
72-
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (user_group_id, page, username, loading) => {
72+
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (user_group_id, page, params, loading) => {
7373
return get(
7474
`${prefix}/${user_group_id}/user_list/${page.current_page}/${page.page_size}`,
75-
username ? { username } : undefined,
75+
params ? params : undefined,
7676
loading,
7777
)
7878
}

ui/src/views/system-chat-user/group/index.vue

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
[PermissionConst.WORKSPACE_USER_GROUP_CREATE, PermissionConst.USER_GROUP_CREATE],
2828
[],'OR',)"
2929
>
30-
<el-icon :size="18"><Plus /></el-icon>
30+
<el-icon :size="18">
31+
<Plus/>
32+
</el-icon>
3133
</el-button>
3234
</el-tooltip>
3335
</div>
@@ -57,7 +59,7 @@
5759
<el-dropdown :teleported="false">
5860
<el-button text>
5961
<el-icon class="color-secondary">
60-
<MoreFilled />
62+
<MoreFilled/>
6163
</el-icon>
6264
</el-button>
6365
<template #dropdown>
@@ -70,7 +72,9 @@
7072
[PermissionConst.WORKSPACE_USER_GROUP_EDIT, PermissionConst.USER_GROUP_EDIT],
7173
[],'OR',),'OR',)"
7274
>
73-
<el-icon><EditPen /></el-icon>
75+
<el-icon>
76+
<EditPen/>
77+
</el-icon>
7478
{{ $t('common.rename') }}
7579
</el-dropdown-item>
7680
<el-dropdown-item
@@ -81,7 +85,9 @@
8185
[PermissionConst.WORKSPACE_USER_GROUP_DELETE, PermissionConst.USER_GROUP_DELETE],
8286
[],'OR',),'OR',)"
8387
>
84-
<el-icon><Delete /></el-icon>
88+
<el-icon>
89+
<Delete/>
90+
</el-icon>
8591
{{ $t('common.delete') }}
8692
</el-dropdown-item>
8793
</el-dropdown-menu>
@@ -102,7 +108,7 @@
102108
<div class="user-right" v-loading="rightLoading">
103109
<div class="flex align-center">
104110
<h4 class="medium">{{ current?.name }}</h4>
105-
<el-divider direction="vertical" class="mr-8 ml-8" />
111+
<el-divider direction="vertical" class="mr-8 ml-8"/>
106112
<AppIcon
107113
iconName="app-workspace"
108114
style="font-size: 16px"
@@ -140,7 +146,9 @@
140146
</div>
141147
<div class="flex-between complex-search">
142148
<el-select class="complex-search__left" v-model="searchType" style="width: 120px">
143-
<el-option :label="$t('views.login.loginForm.username.label')" value="username" />
149+
<el-option :label="$t('views.login.loginForm.username.label')" value="username"/>
150+
<el-option :label="$t('views.userManage.userForm.nick_name.label')"
151+
value="nick_name"/>
144152
</el-select>
145153
<el-input
146154
v-if="searchType === 'username'"
@@ -150,6 +158,14 @@
150158
style="width: 220px"
151159
clearable
152160
/>
161+
<el-input
162+
v-else-if="searchType === 'nick_name'"
163+
v-model="searchForm.nick_name"
164+
@change="getList"
165+
:placeholder="$t('common.searchBar.placeholder')"
166+
style="width: 220px"
167+
clearable
168+
/>
153169
</div>
154170
</div>
155171

@@ -160,12 +176,12 @@
160176
@changePage="getList"
161177
@selection-change="handleSelectionChange"
162178
>
163-
<el-table-column type="selection" width="55" />
179+
<el-table-column type="selection" width="55"/>
164180
<el-table-column
165181
prop="nick_name"
166182
:label="$t('views.userManage.userForm.nick_name.label')"
167183
/>
168-
<el-table-column prop="username" :label="$t('views.login.loginForm.username.label')" />
184+
<el-table-column prop="username" :label="$t('views.login.loginForm.username.label')"/>
169185
<el-table-column prop="source" :label="$t('views.userManage.source.label')">
170186
<template #default="{ row }">
171187
{{
@@ -197,7 +213,7 @@
197213
[],'OR',)"
198214
>
199215
<el-icon>
200-
<EditPen />
216+
<EditPen/>
201217
</el-icon>
202218
</el-button>
203219
</el-tooltip>
@@ -208,23 +224,23 @@
208224
</div>
209225
</el-card>
210226

211-
<CreateOrUpdateGroupDialog ref="createOrUpdateGroupDialogRef" @refresh="refresh" />
212-
<CreateGroupUserDialog ref="createGroupUserDialogRef" @refresh="getList" />
227+
<CreateOrUpdateGroupDialog ref="createOrUpdateGroupDialogRef" @refresh="refresh"/>
228+
<CreateGroupUserDialog ref="createGroupUserDialogRef" @refresh="getList"/>
213229
</div>
214230
</template>
215231

216232
<script lang="ts" setup>
217-
import { onMounted, ref, watch, reactive } from 'vue'
233+
import {onMounted, ref, watch, reactive} from 'vue'
218234
import SystemGroupApi from '@/api/system/user-group'
219-
import { t } from '@/locales'
220-
import type { ChatUserGroupUserItem } from '@/api/type/systemChatUser'
235+
import {t} from '@/locales'
236+
import type {ChatUserGroupUserItem} from '@/api/type/systemChatUser'
221237
import CreateOrUpdateGroupDialog from './component/CreateOrUpdateGroupDialog.vue'
222238
import CreateGroupUserDialog from './component/CreateGroupUserDialog.vue'
223-
import type { ListItem } from '@/api/type/common'
224-
import { MsgSuccess, MsgConfirm } from '@/utils/message'
225-
import { PermissionConst, RoleConst } from '@/utils/permission/data'
226-
import { ComplexPermission } from '@/utils/permission/type'
227-
import { hasPermission } from '@/utils/permission/index'
239+
import type {ListItem} from '@/api/type/common'
240+
import {MsgSuccess, MsgConfirm} from '@/utils/message'
241+
import {PermissionConst, RoleConst} from '@/utils/permission/data'
242+
import {ComplexPermission} from '@/utils/permission/type'
243+
import {hasPermission} from '@/utils/permission/index'
228244
229245
const filterText = ref('')
230246
const loading = ref(false)
@@ -284,7 +300,8 @@ function deleteGroup(item: ListItem) {
284300
current.value = item.id === current.value?.id ? list.value[0] : current.value
285301
})
286302
})
287-
.catch(() => {})
303+
.catch(() => {
304+
})
288305
}
289306
290307
async function refresh(group?: ListItem) {
@@ -298,6 +315,7 @@ const rightLoading = ref(false)
298315
const searchType = ref('username')
299316
const searchForm = ref<Record<string, any>>({
300317
username: '',
318+
nick_name: '',
301319
})
302320
const paginationConfig = reactive({
303321
current_page: 1,
@@ -310,10 +328,13 @@ const tableData = ref<ChatUserGroupUserItem[]>([])
310328
async function getList() {
311329
if (!current.value?.id) return
312330
try {
331+
const params = {
332+
[searchType.value]: searchForm.value[searchType.value as keyof typeof searchForm.value],
333+
}
313334
const res = await SystemGroupApi.getUserListByGroup(
314335
current.value?.id,
315336
paginationConfig,
316-
searchForm.value.username,
337+
params,
317338
rightLoading,
318339
)
319340
tableData.value = res.data.records
@@ -351,7 +372,7 @@ function handleDeleteUser(item?: ChatUserGroupUserItem) {
351372
MsgConfirm(
352373
item
353374
? `${t('views.workspace.member.delete.confirmTitle')}${item.nick_name} ?`
354-
: t('views.chatUser.group.batchDeleteMember', { count: multipleSelection.value.length }),
375+
: t('views.chatUser.group.batchDeleteMember', {count: multipleSelection.value.length}),
355376
'',
356377
{
357378
confirmButtonText: t('common.confirm'),
@@ -372,8 +393,10 @@ function handleDeleteUser(item?: ChatUserGroupUserItem) {
372393
await getList()
373394
})
374395
})
375-
.catch(() => {})
396+
.catch(() => {
397+
})
376398
}
399+
377400
const mouseId = ref('')
378401
379402
function mouseenter(row: any) {

0 commit comments

Comments
 (0)