refactor: chat user

This commit is contained in:
wxg0103 2025-07-01 14:32:29 +08:00
parent 9f6cde37c3
commit 75fd815e31
2 changed files with 54 additions and 31 deletions

View File

@ -67,12 +67,12 @@ const postRemoveMember: (
const getUserListByGroup: ( const getUserListByGroup: (
user_group_id: string, user_group_id: string,
page: pageRequest, page: pageRequest,
username: string, params ?: any,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (user_group_id, page, username, loading) => { ) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (user_group_id, page, params, loading) => {
return get( return get(
`${prefix}/${user_group_id}/user_list/${page.current_page}/${page.page_size}`, `${prefix}/${user_group_id}/user_list/${page.current_page}/${page.page_size}`,
username ? { username } : undefined, params ? params : undefined,
loading, loading,
) )
} }

View File

@ -27,7 +27,9 @@
[PermissionConst.WORKSPACE_USER_GROUP_CREATE, PermissionConst.USER_GROUP_CREATE], [PermissionConst.WORKSPACE_USER_GROUP_CREATE, PermissionConst.USER_GROUP_CREATE],
[],'OR',)" [],'OR',)"
> >
<el-icon :size="18"><Plus /></el-icon> <el-icon :size="18">
<Plus/>
</el-icon>
</el-button> </el-button>
</el-tooltip> </el-tooltip>
</div> </div>
@ -70,7 +72,9 @@
[PermissionConst.WORKSPACE_USER_GROUP_EDIT, PermissionConst.USER_GROUP_EDIT], [PermissionConst.WORKSPACE_USER_GROUP_EDIT, PermissionConst.USER_GROUP_EDIT],
[],'OR',),'OR',)" [],'OR',),'OR',)"
> >
<el-icon><EditPen /></el-icon> <el-icon>
<EditPen/>
</el-icon>
{{ $t('common.rename') }} {{ $t('common.rename') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
@ -81,7 +85,9 @@
[PermissionConst.WORKSPACE_USER_GROUP_DELETE, PermissionConst.USER_GROUP_DELETE], [PermissionConst.WORKSPACE_USER_GROUP_DELETE, PermissionConst.USER_GROUP_DELETE],
[],'OR',),'OR',)" [],'OR',),'OR',)"
> >
<el-icon><Delete /></el-icon> <el-icon>
<Delete/>
</el-icon>
{{ $t('common.delete') }} {{ $t('common.delete') }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
@ -141,6 +147,8 @@
<div class="flex-between complex-search"> <div class="flex-between complex-search">
<el-select class="complex-search__left" v-model="searchType" style="width: 120px"> <el-select class="complex-search__left" v-model="searchType" style="width: 120px">
<el-option :label="$t('views.login.loginForm.username.label')" value="username"/> <el-option :label="$t('views.login.loginForm.username.label')" value="username"/>
<el-option :label="$t('views.userManage.userForm.nick_name.label')"
value="nick_name"/>
</el-select> </el-select>
<el-input <el-input
v-if="searchType === 'username'" v-if="searchType === 'username'"
@ -150,6 +158,14 @@
style="width: 220px" style="width: 220px"
clearable clearable
/> />
<el-input
v-else-if="searchType === 'nick_name'"
v-model="searchForm.nick_name"
@change="getList"
:placeholder="$t('common.searchBar.placeholder')"
style="width: 220px"
clearable
/>
</div> </div>
</div> </div>
@ -284,7 +300,8 @@ function deleteGroup(item: ListItem) {
current.value = item.id === current.value?.id ? list.value[0] : current.value current.value = item.id === current.value?.id ? list.value[0] : current.value
}) })
}) })
.catch(() => {}) .catch(() => {
})
} }
async function refresh(group?: ListItem) { async function refresh(group?: ListItem) {
@ -298,6 +315,7 @@ const rightLoading = ref(false)
const searchType = ref('username') const searchType = ref('username')
const searchForm = ref<Record<string, any>>({ const searchForm = ref<Record<string, any>>({
username: '', username: '',
nick_name: '',
}) })
const paginationConfig = reactive({ const paginationConfig = reactive({
current_page: 1, current_page: 1,
@ -310,10 +328,13 @@ const tableData = ref<ChatUserGroupUserItem[]>([])
async function getList() { async function getList() {
if (!current.value?.id) return if (!current.value?.id) return
try { try {
const params = {
[searchType.value]: searchForm.value[searchType.value as keyof typeof searchForm.value],
}
const res = await SystemGroupApi.getUserListByGroup( const res = await SystemGroupApi.getUserListByGroup(
current.value?.id, current.value?.id,
paginationConfig, paginationConfig,
searchForm.value.username, params,
rightLoading, rightLoading,
) )
tableData.value = res.data.records tableData.value = res.data.records
@ -372,8 +393,10 @@ function handleDeleteUser(item?: ChatUserGroupUserItem) {
await getList() await getList()
}) })
}) })
.catch(() => {}) .catch(() => {
})
} }
const mouseId = ref('') const mouseId = ref('')
function mouseenter(row: any) { function mouseenter(row: any) {