Commit 59201b1c authored by nick zheng's avatar nick zheng

Merge branch 'beta' into 'master'

chore: [问答知识库]前端展示优化

See merge request !182
parents 63641405 31572f2e
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onMounted, ref } from 'vue' import { computed, onMounted, ref, useTemplateRef } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { DataTableInst } from 'naive-ui'
import { Left, Search } from '@icon-park/vue-next' import { Left, Search } from '@icon-park/vue-next'
import { useElementSize } from '@vueuse/core' import { useElementSize } from '@vueuse/core'
import { import {
...@@ -45,6 +46,7 @@ const userStore = useUserStore() ...@@ -45,6 +46,7 @@ const userStore = useUserStore()
const { paginationData } = usePagination() const { paginationData } = usePagination()
const knowledgeChunkListContainer = ref<HTMLDivElement | null>(null) const knowledgeChunkListContainer = ref<HTMLDivElement | null>(null)
const knowledgeChunkTableRef = useTemplateRef<DataTableInst>('knowledgeChunkTableRef')
const { height } = useElementSize(knowledgeChunkListContainer) const { height } = useElementSize(knowledgeChunkListContainer)
const totalChunk = ref(0) // 总分片数 const totalChunk = ref(0) // 总分片数
...@@ -143,12 +145,14 @@ async function handleQAKnowledgeChunkList() { ...@@ -143,12 +145,14 @@ async function handleQAKnowledgeChunkList() {
async function handleSearchKnowledgeChunkList() { async function handleSearchKnowledgeChunkList() {
paginationData.pageNo = 1 paginationData.pageNo = 1
await handleQAKnowledgeChunkList() await handleQAKnowledgeChunkList()
knowledgeChunkTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
} }
// 更新分页数获取分片列表 // 更新分页数获取分片列表
async function handleGetKnowledgeChunkListUpdatePageNo(pageNo: number) { async function handleGetKnowledgeChunkListUpdatePageNo(pageNo: number) {
paginationData.pageNo = pageNo paginationData.pageNo = pageNo
await handleQAKnowledgeChunkList() await handleQAKnowledgeChunkList()
knowledgeChunkTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
} }
// 更新分页大小获取分片列表 // 更新分页大小获取分片列表
...@@ -156,6 +160,7 @@ async function handleGetKnowledgeChunkListUpdatePageSize(pageSize: number) { ...@@ -156,6 +160,7 @@ async function handleGetKnowledgeChunkListUpdatePageSize(pageSize: number) {
paginationData.pageNo = 1 paginationData.pageNo = 1
paginationData.pageSize = pageSize paginationData.pageSize = pageSize
await handleQAKnowledgeChunkList() await handleQAKnowledgeChunkList()
knowledgeChunkTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
} }
// 更新知识库索引 // 更新知识库索引
...@@ -349,10 +354,20 @@ function handleBatchDeleteKnowledgeChunk() { ...@@ -349,10 +354,20 @@ function handleBatchDeleteKnowledgeChunk() {
<div class="flex-center mb-4.5 justify-between"> <div class="flex-center mb-4.5 justify-between">
<div class="flex-center gap-2.5"> <div class="flex-center gap-2.5">
<n-button type="primary" :disabled="isDisabledOperateBtn" @click="handleShowAddQAKnowledgeChunk(0)"> <n-button
type="primary"
:focusable="false"
:disabled="isDisabledOperateBtn"
@click="handleShowAddQAKnowledgeChunk(0)"
>
{{ t('personal_space_module.knowledge_module.add_QA') }} {{ t('personal_space_module.knowledge_module.add_QA') }}
</n-button> </n-button>
<n-button type="primary" :disabled="isDisabledOperateBtn" @click="showSettingChunkIndexModal = true"> <n-button
type="primary"
:focusable="false"
:disabled="isDisabledOperateBtn"
@click="showSettingChunkIndexModal = true"
>
{{ t('personal_space_module.knowledge_module.setting_index') }} {{ t('personal_space_module.knowledge_module.setting_index') }}
</n-button> </n-button>
</div> </div>
...@@ -383,6 +398,7 @@ function handleBatchDeleteKnowledgeChunk() { ...@@ -383,6 +398,7 @@ function handleBatchDeleteKnowledgeChunk() {
<div ref="knowledgeChunkListContainer" class="w-full flex-1 overflow-hidden rounded-[10px] bg-white p-6"> <div ref="knowledgeChunkListContainer" class="w-full flex-1 overflow-hidden rounded-[10px] bg-white p-6">
<n-data-table <n-data-table
ref="knowledgeChunkTableRef"
:loading="knowledgeChunkColumnTableLoading" :loading="knowledgeChunkColumnTableLoading"
:columns="knowledgeChunkColumn" :columns="knowledgeChunkColumn"
:data="knowledgeChunkList" :data="knowledgeChunkList"
...@@ -390,6 +406,7 @@ function handleBatchDeleteKnowledgeChunk() { ...@@ -390,6 +406,7 @@ function handleBatchDeleteKnowledgeChunk() {
:max-height="tableContentY" :max-height="tableContentY"
:row-key="(row: QAKnowledgeChunkContentItem) => row.chunkRelationId" :row-key="(row: QAKnowledgeChunkContentItem) => row.chunkRelationId"
:checked-row-keys="checkedChunkIdList" :checked-row-keys="checkedChunkIdList"
:pagination-behavior-on-filter="'first'"
@update:checked-row-keys="handleUpdateCheckedChunkId" @update:checked-row-keys="handleUpdateCheckedChunkId"
> >
<template #empty> <template #empty>
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue' import { computed, onMounted, ref, useTemplateRef, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { DataTableInst } from 'naive-ui'
import { Search } from '@icon-park/vue-next' import { Search } from '@icon-park/vue-next'
import { createKnowledgeColumn } from './columns.tsx' import { createKnowledgeColumn } from './columns.tsx'
import { KnowledgeItem } from './types.d' import { KnowledgeItem } from './types.d'
...@@ -14,6 +15,8 @@ const { t } = useI18n() ...@@ -14,6 +15,8 @@ const { t } = useI18n()
const router = useRouter() const router = useRouter()
const knowledgeListTableRef = useTemplateRef<DataTableInst>('knowledgeListTableRef')
const { pageContentWrapRef, tableContentY } = useTableScrollY(48 + 32 + 16 + 16 + 28) const { pageContentWrapRef, tableContentY } = useTableScrollY(48 + 32 + 16 + 16 + 28)
const { paginationData, handlePageNoChange, handlePageSizeChange } = usePagination() const { paginationData, handlePageNoChange, handlePageSizeChange } = usePagination()
...@@ -33,7 +36,10 @@ const emptyTableDataText = computed(() => { ...@@ -33,7 +36,10 @@ const emptyTableDataText = computed(() => {
return isSearchEmptyList.value ? t('common_module.search_empty_data') : t('common_module.empty_data') return isSearchEmptyList.value ? t('common_module.search_empty_data') : t('common_module.empty_data')
}) })
watch([() => paginationData.pageNo, () => paginationData.pageSize], handleGetKnowledgeList) watch([() => paginationData.pageNo, () => paginationData.pageSize], () => {
handleGetKnowledgeList()
knowledgeListTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
})
onMounted(async () => { onMounted(async () => {
await handleGetKnowledgeList() await handleGetKnowledgeList()
...@@ -100,6 +106,7 @@ async function handleDeleteKnowledge(knowledgeId: number) { ...@@ -100,6 +106,7 @@ async function handleDeleteKnowledge(knowledgeId: number) {
function handleSearchKnowledge() { function handleSearchKnowledge() {
paginationData.pageNo = 1 paginationData.pageNo = 1
handleGetKnowledgeList() handleGetKnowledgeList()
knowledgeListTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
} }
</script> </script>
...@@ -120,6 +127,7 @@ function handleSearchKnowledge() { ...@@ -120,6 +127,7 @@ function handleSearchKnowledge() {
<div class="mb-4" :style="{ height: tableContentY + 48 + 'px' }"> <div class="mb-4" :style="{ height: tableContentY + 48 + 'px' }">
<NDataTable <NDataTable
ref="knowledgeListTableRef"
:loading="knowledgeListTableLoading" :loading="knowledgeListTableLoading"
:bordered="true" :bordered="true"
:bottom-bordered="true" :bottom-bordered="true"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment