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>
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, useTemplateRef } from 'vue'
import { useI18n } from 'vue-i18n'
import { DataTableInst } from 'naive-ui'
import { Left, Search } from '@icon-park/vue-next'
import { useElementSize } from '@vueuse/core'
import {
......@@ -45,6 +46,7 @@ const userStore = useUserStore()
const { paginationData } = usePagination()
const knowledgeChunkListContainer = ref<HTMLDivElement | null>(null)
const knowledgeChunkTableRef = useTemplateRef<DataTableInst>('knowledgeChunkTableRef')
const { height } = useElementSize(knowledgeChunkListContainer)
const totalChunk = ref(0) // 总分片数
......@@ -143,12 +145,14 @@ async function handleQAKnowledgeChunkList() {
async function handleSearchKnowledgeChunkList() {
paginationData.pageNo = 1
await handleQAKnowledgeChunkList()
knowledgeChunkTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
}
// 更新分页数获取分片列表
async function handleGetKnowledgeChunkListUpdatePageNo(pageNo: number) {
paginationData.pageNo = pageNo
await handleQAKnowledgeChunkList()
knowledgeChunkTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
}
// 更新分页大小获取分片列表
......@@ -156,6 +160,7 @@ async function handleGetKnowledgeChunkListUpdatePageSize(pageSize: number) {
paginationData.pageNo = 1
paginationData.pageSize = pageSize
await handleQAKnowledgeChunkList()
knowledgeChunkTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
}
// 更新知识库索引
......@@ -349,10 +354,20 @@ function handleBatchDeleteKnowledgeChunk() {
<div class="flex-center mb-4.5 justify-between">
<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') }}
</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') }}
</n-button>
</div>
......@@ -383,6 +398,7 @@ function handleBatchDeleteKnowledgeChunk() {
<div ref="knowledgeChunkListContainer" class="w-full flex-1 overflow-hidden rounded-[10px] bg-white p-6">
<n-data-table
ref="knowledgeChunkTableRef"
:loading="knowledgeChunkColumnTableLoading"
:columns="knowledgeChunkColumn"
:data="knowledgeChunkList"
......@@ -390,6 +406,7 @@ function handleBatchDeleteKnowledgeChunk() {
:max-height="tableContentY"
:row-key="(row: QAKnowledgeChunkContentItem) => row.chunkRelationId"
:checked-row-keys="checkedChunkIdList"
:pagination-behavior-on-filter="'first'"
@update:checked-row-keys="handleUpdateCheckedChunkId"
>
<template #empty>
......
<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 { useI18n } from 'vue-i18n'
import { DataTableInst } from 'naive-ui'
import { Search } from '@icon-park/vue-next'
import { createKnowledgeColumn } from './columns.tsx'
import { KnowledgeItem } from './types.d'
......@@ -14,6 +15,8 @@ const { t } = useI18n()
const router = useRouter()
const knowledgeListTableRef = useTemplateRef<DataTableInst>('knowledgeListTableRef')
const { pageContentWrapRef, tableContentY } = useTableScrollY(48 + 32 + 16 + 16 + 28)
const { paginationData, handlePageNoChange, handlePageSizeChange } = usePagination()
......@@ -33,7 +36,10 @@ const emptyTableDataText = computed(() => {
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 () => {
await handleGetKnowledgeList()
......@@ -100,6 +106,7 @@ async function handleDeleteKnowledge(knowledgeId: number) {
function handleSearchKnowledge() {
paginationData.pageNo = 1
handleGetKnowledgeList()
knowledgeListTableRef.value?.scrollTo({ top: 0, behavior: 'smooth' })
}
</script>
......@@ -120,6 +127,7 @@ function handleSearchKnowledge() {
<div class="mb-4" :style="{ height: tableContentY + 48 + 'px' }">
<NDataTable
ref="knowledgeListTableRef"
:loading="knowledgeListTableLoading"
: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