mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
refactor: update user search parameters and improve code formatting in chat user components
This commit is contained in:
parent
dd7b2a7bda
commit
549aa62349
|
|
@ -33,12 +33,12 @@ const getUserGroupUserList: (
|
|||
resource: any,
|
||||
user_group_id: string,
|
||||
page: pageRequest,
|
||||
username_or_nickname: string,
|
||||
params?: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (resource, user_group_id, page, username_or_nickname, loading) => {
|
||||
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (resource, user_group_id, page, params, loading) => {
|
||||
return get(
|
||||
`${prefix.value}/${resource.resource_type}/${resource.resource_id}/user_group_id/${user_group_id}/${page.current_page}/${page.page_size}`,
|
||||
username_or_nickname ? { username_or_nickname } : undefined,
|
||||
params,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import { Result } from '@/request/Result'
|
||||
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
|
||||
import { type Ref } from 'vue'
|
||||
import type { PageList, pageRequest } from '@/api/type/common'
|
||||
import type { knowledgeData } from '@/api/type/knowledge'
|
||||
import {Result} from '@/request/Result'
|
||||
import {get, post, del, put, exportFile, exportExcel} from '@/request/index'
|
||||
import {type Ref} from 'vue'
|
||||
import type {PageList, pageRequest} from '@/api/type/common'
|
||||
import type {knowledgeData} from '@/api/type/knowledge'
|
||||
|
||||
import useStore from '@/stores'
|
||||
import type { ChatUserGroupItem } from './type/workspaceChatUser'
|
||||
import type {ChatUserGroupItem} from './type/workspaceChatUser'
|
||||
|
||||
const prefix = '/system/shared'
|
||||
const prefix_workspace: any = { _value: 'workspace/' }
|
||||
const prefix_workspace: any = {_value: 'workspace/'}
|
||||
Object.defineProperty(prefix_workspace, 'value', {
|
||||
get: function () {
|
||||
const { user } = useStore()
|
||||
const {user} = useStore()
|
||||
return this._value + user.getWorkspaceId()
|
||||
},
|
||||
})
|
||||
|
|
@ -47,9 +47,9 @@ const getKnowledgeDetail: (knowledge_id: string, loading?: Ref<boolean>) => Prom
|
|||
* 文档分页列表
|
||||
* @param 参数 knowledge_id,
|
||||
* param {
|
||||
"name": "string",
|
||||
folder_id: "string",
|
||||
}
|
||||
"name": "string",
|
||||
folder_id: "string",
|
||||
}
|
||||
*/
|
||||
|
||||
const getDocumentPage: (
|
||||
|
|
@ -85,8 +85,8 @@ const getDocumentDetail: (
|
|||
* 问题分页列表
|
||||
* @param 参数 knowledge_id,
|
||||
* query {
|
||||
"content": "string",
|
||||
}
|
||||
"content": "string",
|
||||
}
|
||||
*/
|
||||
|
||||
const getProblemsPage: (
|
||||
|
|
@ -107,14 +107,14 @@ const getProblemsPage: (
|
|||
*/
|
||||
const getUserGroupUserList: (
|
||||
resource: any,
|
||||
user_group_id:string,
|
||||
user_group_id: string,
|
||||
page: pageRequest,
|
||||
username_or_nickname: string,
|
||||
params?: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<PageList<ChatUserGroupItem[]>>> = (resource, user_group_id, page, username_or_nickname, loading) => {
|
||||
return get (
|
||||
`${prefix}/${prefix_workspace.value}/KNOWLEDGE/${resource.resource_id}/user_group_id/${user_group_id}/${page.current_page}/${page.page_size}`
|
||||
,username_or_nickname ? {username_or_nickname} : undefined, loading,
|
||||
) => Promise<Result<PageList<ChatUserGroupItem[]>>> = (resource, user_group_id, page, params, loading) => {
|
||||
return get(
|
||||
`${prefix}/${prefix_workspace.value}/KNOWLEDGE/${resource.resource_id}/user_group_id/${user_group_id}/${page.current_page}/${page.page_size}`,
|
||||
params, loading,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -122,16 +122,16 @@ const getUserGroupUserList: (
|
|||
* 获取工作空间下共享知识库的用户组
|
||||
*/
|
||||
const getUserGroupList: (resource: any, loading?: Ref<boolean>) => Promise<Result<ChatUserGroupItem[]>> = (resource, loading) => {
|
||||
return get (`${prefix}/${prefix_workspace.value}/KNOWLEDGE/${resource.resource_id}/user_group`, undefined, loading)
|
||||
return get(`${prefix}/${prefix_workspace.value}/KNOWLEDGE/${resource.resource_id}/user_group`, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 段落分页列表
|
||||
* @param 参数 knowledge_id document_id
|
||||
* param {
|
||||
"title": "string",
|
||||
"content": "string",
|
||||
}
|
||||
"title": "string",
|
||||
"content": "string",
|
||||
}
|
||||
*/
|
||||
const getParagraphPage: (
|
||||
knowledge_id: string,
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ const getUserGroupUserList: (
|
|||
resource: any,
|
||||
user_group_id: string,
|
||||
page: pageRequest,
|
||||
username_or_nickname: string,
|
||||
param?: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (resource, user_group_id, page, username_or_nickname, loading) => {
|
||||
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (resource, user_group_id, page, param, loading) => {
|
||||
return get(
|
||||
`${prefix}/${resource.resource_type}/${resource.resource_id}/user_group_id/${user_group_id}/${page.current_page}/${page.page_size}`,
|
||||
username_or_nickname ? {username_or_nickname} : undefined,
|
||||
param,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ import type { pageRequest, PageList } from '@/api/type/common'
|
|||
|
||||
const prefix = '/system/shared/knowledge'
|
||||
/**
|
||||
* 获取共享知识库用户组列表
|
||||
* 获取共享知识库用户组列表
|
||||
*/
|
||||
const getUserGroupList: (resource: any, loading?: Ref<boolean>) =>
|
||||
const getUserGroupList: (resource: any, loading?: Ref<boolean>) =>
|
||||
Promise<Result<ChatUserGroupItem[]>> = (resource, loading) => {
|
||||
return get(`${prefix}/${resource.resource_type}/${resource.resource_id}/user_group`, undefined, loading)
|
||||
return get(`${prefix}/${resource.resource_type}/${resource.resource_id}/user_group`, undefined, loading)
|
||||
}
|
||||
|
||||
/*
|
||||
* 修改共享知识库用户组列表授权
|
||||
*/
|
||||
const editUserGroupList: (resource: any, data: { user_group_id: string, is_auth: boolean }[], loading?: Ref<boolean>) =>
|
||||
const editUserGroupList: (resource: any, data: { user_group_id: string, is_auth: boolean }[], loading?: Ref<boolean>) =>
|
||||
Promise<Result<any>> = (resource, data, loading) => {
|
||||
return put(`${prefix}/${resource.resource_type}/${resource.resource_id}/user_group`, data, undefined, loading)
|
||||
}
|
||||
|
|
@ -29,12 +29,12 @@ const getUserGroupUserList: (
|
|||
resource: any,
|
||||
user_group_id: string,
|
||||
page: pageRequest,
|
||||
username_or_nickname: string,
|
||||
params?: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (resource, user_group_id, page, username_or_nickname, loading) => {
|
||||
) => Promise<Result<PageList<ChatUserGroupUserItem[]>>> = (resource, user_group_id, page, params, loading) => {
|
||||
return get(
|
||||
`${prefix}/${resource.resource_type}/${resource.resource_id}/user_group_id/${user_group_id}/${page.current_page}/${page.page_size}`,
|
||||
username_or_nickname ? {username_or_nickname} : undefined,
|
||||
params,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
|
@ -56,4 +56,4 @@ export default {
|
|||
editUserGroupList,
|
||||
getUserGroupUserList,
|
||||
putUserGroupUser
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,11 @@
|
|||
<div class="flex-between">
|
||||
<div class="flex align-center">
|
||||
<h4 class="medium ellipsis" :title="current?.name">{{ current?.name || '-' }}</h4>
|
||||
<el-divider direction="vertical" class="mr-8 ml-8" />
|
||||
<el-divider direction="vertical" class="mr-8 ml-8"/>
|
||||
|
||||
<el-icon class="color-input-placeholder"><UserFilled /></el-icon>
|
||||
<el-icon class="color-input-placeholder">
|
||||
<UserFilled/>
|
||||
</el-icon>
|
||||
<span class="color-input-placeholder ml-4">
|
||||
{{ paginationConfig.total }}
|
||||
</span>
|
||||
|
|
@ -76,16 +78,69 @@
|
|||
<div class="flex-between mb-16" style="margin-top: 18px">
|
||||
<div class="flex complex-search">
|
||||
<el-select class="complex-search__left" v-model="searchType" style="width: 120px">
|
||||
<el-option :label="$t('views.login.loginForm.username.label')" value="name" />
|
||||
<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-option :label="$t('views.userManage.source.label')" value="source"/>
|
||||
</el-select>
|
||||
<el-input
|
||||
v-if="searchType === 'name'"
|
||||
v-model="searchForm.name"
|
||||
v-if="searchType === 'username'"
|
||||
v-model="searchForm.username"
|
||||
@change="getList"
|
||||
:placeholder="$t('common.inputPlaceholder')"
|
||||
style="width: 220px"
|
||||
clearable
|
||||
/>
|
||||
<el-input
|
||||
v-else-if="searchType === 'nick_name'"
|
||||
v-model="searchForm.nick_name"
|
||||
@change="getList"
|
||||
:placeholder="$t('common.inputPlaceholder')"
|
||||
style="width: 220px"
|
||||
clearable
|
||||
/>
|
||||
<el-select
|
||||
v-else-if="searchType === 'source'"
|
||||
v-model="searchForm.source"
|
||||
@change="getList"
|
||||
:placeholder="$t('common.selectPlaceholder')"
|
||||
style="width: 220px"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
:label="$t('views.userManage.source.local')"
|
||||
value="LOCAL"
|
||||
/>
|
||||
<el-option
|
||||
label="CAS"
|
||||
value="CAS"
|
||||
/>
|
||||
<el-option
|
||||
label="LDAP"
|
||||
value="LDAP"
|
||||
/>
|
||||
<el-option
|
||||
label="OIDC"
|
||||
value="OIDC"
|
||||
/>
|
||||
<el-option
|
||||
label="OAuth2"
|
||||
value="OAuth2"
|
||||
/>
|
||||
<el-option
|
||||
:label="$t('views.userManage.source.wecom')"
|
||||
value="wecom"
|
||||
/>
|
||||
<el-option
|
||||
:label="$t('views.userManage.source.lark')"
|
||||
value="lark"
|
||||
/>
|
||||
<el-option
|
||||
:label="$t('views.userManage.source.dingtalk')"
|
||||
value="dingtalk"
|
||||
/>
|
||||
</el-select>
|
||||
|
||||
</div>
|
||||
<div
|
||||
class="flex align-center"
|
||||
|
|
@ -121,7 +176,7 @@
|
|||
prop="nick_name"
|
||||
: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')">
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
|
|
@ -146,7 +201,8 @@
|
|||
:indeterminate="allIndeterminate"
|
||||
:disabled="current?.is_auth"
|
||||
@change="handleCheckAll"
|
||||
>{{ $t('views.chatUser.authorization') }}</el-checkbox
|
||||
>{{ $t('views.chatUser.authorization') }}
|
||||
</el-checkbox
|
||||
>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
|
|
@ -166,22 +222,22 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref, watch, reactive, computed } from 'vue'
|
||||
import {onMounted, ref, watch, reactive, computed} from 'vue'
|
||||
|
||||
import { t } from '@/locales'
|
||||
import type { ChatUserGroupItem, ChatUserGroupUserItem } from '@/api/type/workspaceChatUser'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { SourceTypeEnum } from '@/enums/common'
|
||||
import { MsgSuccess } from '@/utils/message'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
import { RoleConst, PermissionConst } from '@/utils/permission/data'
|
||||
import { hasPermission } from '@/utils/permission/index'
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
import {t} from '@/locales'
|
||||
import type {ChatUserGroupItem, ChatUserGroupUserItem} from '@/api/type/workspaceChatUser'
|
||||
import {useRoute} from 'vue-router'
|
||||
import {SourceTypeEnum} from '@/enums/common'
|
||||
import {MsgSuccess} from '@/utils/message'
|
||||
import {ComplexPermission} from '@/utils/permission/type'
|
||||
import {RoleConst, PermissionConst} from '@/utils/permission/data'
|
||||
import {hasPermission} from '@/utils/permission/index'
|
||||
import {loadSharedApi} from '@/utils/dynamics-api/shared-api'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const {
|
||||
params: { id, folderId },
|
||||
params: {id, folderId},
|
||||
} = route as any
|
||||
|
||||
const permissionObj = ref<any>({
|
||||
|
|
@ -214,15 +270,17 @@ const permissionObj = ref<any>({
|
|||
})
|
||||
|
||||
const currentPermissionKey = computed(() => {
|
||||
if (route.path.includes('shared')) return 'SHAREDKNOWLEDGE'
|
||||
if (route.path.includes('resource-management')) {
|
||||
if (route.meta?.resourceType === 'KNOWLEDGE') { return 'RESOURCE_KNOWLEDGE' }
|
||||
else if (route.meta?.resourceType === 'APPLICATION') { return 'RESOURCE_APPLICATION' }
|
||||
if (route.path.includes('shared')) return 'SHAREDKNOWLEDGE'
|
||||
if (route.path.includes('resource-management')) {
|
||||
if (route.meta?.resourceType === 'KNOWLEDGE') {
|
||||
return 'RESOURCE_KNOWLEDGE'
|
||||
} else if (route.meta?.resourceType === 'APPLICATION') {
|
||||
return 'RESOURCE_APPLICATION'
|
||||
}
|
||||
return route.meta?.resourceType as string
|
||||
}
|
||||
return route.meta?.resourceType as string
|
||||
})
|
||||
|
||||
console.log(currentPermissionKey.value)
|
||||
|
||||
const resource = reactive({
|
||||
resource_id: route.params.id as string,
|
||||
|
|
@ -285,7 +343,7 @@ function clickUserGroup(item: ChatUserGroupItem) {
|
|||
}
|
||||
|
||||
async function changeAuth() {
|
||||
const params = [{ user_group_id: current.value?.id as string, is_auth: !current.value?.is_auth }]
|
||||
const params = [{user_group_id: current.value?.id as string, is_auth: !current.value?.is_auth}]
|
||||
try {
|
||||
await loadSharedApi({
|
||||
type: 'chatUser',
|
||||
|
|
@ -305,9 +363,11 @@ async function changeAuth() {
|
|||
|
||||
const rightLoading = ref(false)
|
||||
|
||||
const searchType = ref('name')
|
||||
const searchType = ref('username')
|
||||
const searchForm = ref<Record<string, any>>({
|
||||
name: '',
|
||||
username: '',
|
||||
nick_name: '',
|
||||
source: '',
|
||||
})
|
||||
const paginationConfig = reactive({
|
||||
current_page: 1,
|
||||
|
|
@ -323,6 +383,11 @@ const isShared = computed(() => {
|
|||
|
||||
async function getList() {
|
||||
if (!current.value?.id) return
|
||||
const params: any = {}
|
||||
const searchValue = searchForm.value[searchType.value as keyof typeof searchForm.value];
|
||||
if (searchValue !== undefined && searchValue !== null && searchValue !== '') {
|
||||
params[searchType.value] = searchValue;
|
||||
}
|
||||
try {
|
||||
const res = await loadSharedApi({
|
||||
type: 'chatUser',
|
||||
|
|
@ -332,7 +397,7 @@ async function getList() {
|
|||
resource,
|
||||
current.value?.id,
|
||||
paginationConfig,
|
||||
searchForm.value.name,
|
||||
params,
|
||||
rightLoading,
|
||||
)
|
||||
// 更新缓存和回显状态
|
||||
|
|
|
|||
Loading…
Reference in New Issue