refactor: chat user
This commit is contained in:
parent
9f6cde37c3
commit
75fd815e31
@ -1,8 +1,8 @@
|
|||||||
import { Result } from '@/request/Result'
|
import {Result} from '@/request/Result'
|
||||||
import { get, post, del } from '@/request/index'
|
import {get, post, del} from '@/request/index'
|
||||||
import type { Ref } from 'vue'
|
import type {Ref} from 'vue'
|
||||||
import type { ChatUserGroupUserItem, } from '@/api/type/systemChatUser'
|
import type {ChatUserGroupUserItem,} from '@/api/type/systemChatUser'
|
||||||
import type { pageRequest, PageList, ListItem } from '@/api/type/common'
|
import type {pageRequest, PageList, ListItem} from '@/api/type/common'
|
||||||
|
|
||||||
const prefix = '/system/group'
|
const prefix = '/system/group'
|
||||||
|
|
||||||
@ -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,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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>
|
||||||
@ -57,7 +59,7 @@
|
|||||||
<el-dropdown :teleported="false">
|
<el-dropdown :teleported="false">
|
||||||
<el-button text>
|
<el-button text>
|
||||||
<el-icon class="color-secondary">
|
<el-icon class="color-secondary">
|
||||||
<MoreFilled />
|
<MoreFilled/>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
@ -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>
|
||||||
@ -102,7 +108,7 @@
|
|||||||
<div class="user-right" v-loading="rightLoading">
|
<div class="user-right" v-loading="rightLoading">
|
||||||
<div class="flex align-center">
|
<div class="flex align-center">
|
||||||
<h4 class="medium">{{ current?.name }}</h4>
|
<h4 class="medium">{{ current?.name }}</h4>
|
||||||
<el-divider direction="vertical" class="mr-8 ml-8" />
|
<el-divider direction="vertical" class="mr-8 ml-8"/>
|
||||||
<AppIcon
|
<AppIcon
|
||||||
iconName="app-workspace"
|
iconName="app-workspace"
|
||||||
style="font-size: 16px"
|
style="font-size: 16px"
|
||||||
@ -140,7 +146,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<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>
|
||||||
|
|
||||||
@ -160,12 +176,12 @@
|
|||||||
@changePage="getList"
|
@changePage="getList"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55"/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="nick_name"
|
prop="nick_name"
|
||||||
:label="$t('views.userManage.userForm.nick_name.label')"
|
:label="$t('views.userManage.userForm.nick_name.label')"
|
||||||
/>
|
/>
|
||||||
<el-table-column prop="username" :label="$t('views.login.loginForm.username.label')" />
|
<el-table-column prop="username" :label="$t('views.login.loginForm.username.label')"/>
|
||||||
<el-table-column prop="source" :label="$t('views.userManage.source.label')">
|
<el-table-column prop="source" :label="$t('views.userManage.source.label')">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{
|
{{
|
||||||
@ -197,7 +213,7 @@
|
|||||||
[],'OR',)"
|
[],'OR',)"
|
||||||
>
|
>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<EditPen />
|
<EditPen/>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@ -208,23 +224,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<CreateOrUpdateGroupDialog ref="createOrUpdateGroupDialogRef" @refresh="refresh" />
|
<CreateOrUpdateGroupDialog ref="createOrUpdateGroupDialogRef" @refresh="refresh"/>
|
||||||
<CreateGroupUserDialog ref="createGroupUserDialogRef" @refresh="getList" />
|
<CreateGroupUserDialog ref="createGroupUserDialogRef" @refresh="getList"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref, watch, reactive } from 'vue'
|
import {onMounted, ref, watch, reactive} from 'vue'
|
||||||
import SystemGroupApi from '@/api/system/user-group'
|
import SystemGroupApi from '@/api/system/user-group'
|
||||||
import { t } from '@/locales'
|
import {t} from '@/locales'
|
||||||
import type { ChatUserGroupUserItem } from '@/api/type/systemChatUser'
|
import type {ChatUserGroupUserItem} from '@/api/type/systemChatUser'
|
||||||
import CreateOrUpdateGroupDialog from './component/CreateOrUpdateGroupDialog.vue'
|
import CreateOrUpdateGroupDialog from './component/CreateOrUpdateGroupDialog.vue'
|
||||||
import CreateGroupUserDialog from './component/CreateGroupUserDialog.vue'
|
import CreateGroupUserDialog from './component/CreateGroupUserDialog.vue'
|
||||||
import type { ListItem } from '@/api/type/common'
|
import type {ListItem} from '@/api/type/common'
|
||||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import {MsgSuccess, MsgConfirm} from '@/utils/message'
|
||||||
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
import {PermissionConst, RoleConst} from '@/utils/permission/data'
|
||||||
import { ComplexPermission } from '@/utils/permission/type'
|
import {ComplexPermission} from '@/utils/permission/type'
|
||||||
import { hasPermission } from '@/utils/permission/index'
|
import {hasPermission} from '@/utils/permission/index'
|
||||||
|
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@ -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
|
||||||
@ -351,7 +372,7 @@ function handleDeleteUser(item?: ChatUserGroupUserItem) {
|
|||||||
MsgConfirm(
|
MsgConfirm(
|
||||||
item
|
item
|
||||||
? `${t('views.workspace.member.delete.confirmTitle')}${item.nick_name} ?`
|
? `${t('views.workspace.member.delete.confirmTitle')}${item.nick_name} ?`
|
||||||
: t('views.chatUser.group.batchDeleteMember', { count: multipleSelection.value.length }),
|
: t('views.chatUser.group.batchDeleteMember', {count: multipleSelection.value.length}),
|
||||||
'',
|
'',
|
||||||
{
|
{
|
||||||
confirmButtonText: t('common.confirm'),
|
confirmButtonText: t('common.confirm'),
|
||||||
@ -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) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user