Commit 5755d530 authored by nick zheng's avatar nick zheng

chore: 【问答知识库】设置索引取消底部按钮&&开关阻止同时多次执行

parent 77c8748e
...@@ -244,6 +244,10 @@ export function fetchOpenQAKnowledgeChunk<T>(payload: { kdId: number; chunkRelat ...@@ -244,6 +244,10 @@ export function fetchOpenQAKnowledgeChunk<T>(payload: { kdId: number; chunkRelat
export function fetchBatchDeleteQAKnowledgeChunks<T>(kdId: number, chunkRelationIds: string[]) { export function fetchBatchDeleteQAKnowledgeChunks<T>(kdId: number, chunkRelationIds: string[]) {
return request.post<T>( return request.post<T>(
`/qAKnowledgeRest/batchDeleteKnowledgeChunks.json?kdId=${kdId}&chunkRelationIds=${chunkRelationIds}`, `/qAKnowledgeRest/batchDeleteKnowledgeChunks.json?kdId=${kdId}&chunkRelationIds=${chunkRelationIds}`,
null,
{
timeout: 15000,
},
) )
} }
......
...@@ -133,6 +133,7 @@ export function createQAKnowledgeChunkColumn( ...@@ -133,6 +133,7 @@ export function createQAKnowledgeChunkColumn(
<NSwitch <NSwitch
value={row.isOpen === 'Y'} value={row.isOpen === 'Y'}
size='small' size='small'
loading={row.isOpenLoading}
onUpdateValue={() => handleKnowledgeChunkTableAction('updateOpen', row.chunkRelationId, row)} onUpdateValue={() => handleKnowledgeChunkTableAction('updateOpen', row.chunkRelationId, row)}
/> />
</div> </div>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { computed, h } from 'vue' import { computed, h } from 'vue'
import { NSwitch } from 'naive-ui' import { NSwitch } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useDebounceFn } from '@vueuse/core'
import CustomModal from '@/components/custom-modal/custom-modal.vue' import CustomModal from '@/components/custom-modal/custom-modal.vue'
import { QAKnowledgeChunkKeyItem } from '../../../types' import { QAKnowledgeChunkKeyItem } from '../../../types'
...@@ -42,7 +43,11 @@ function createChunkIndexColumns() { ...@@ -42,7 +43,11 @@ function createChunkIndexColumns() {
render: (row: QAKnowledgeChunkKeyItem) => { render: (row: QAKnowledgeChunkKeyItem) => {
return h( return h(
NSwitch, NSwitch,
{ value: row.isIndex === 'Y', size: 'small', onUpdateValue: () => handleKnowledgeTableAction(row) }, {
value: row.isIndex === 'Y',
size: 'small',
onUpdateValue: () => handleKnowledgeTableAction(row),
},
{}, {},
) )
}, },
...@@ -50,7 +55,7 @@ function createChunkIndexColumns() { ...@@ -50,7 +55,7 @@ function createChunkIndexColumns() {
] ]
} }
function handleKnowledgeTableAction(chunkKeyItem: QAKnowledgeChunkKeyItem) { const handleKnowledgeTableAction = useDebounceFn((chunkKeyItem: QAKnowledgeChunkKeyItem) => {
chunkKeyItem.isIndex = chunkKeyItem.isIndex === 'Y' ? 'N' : 'Y' chunkKeyItem.isIndex = chunkKeyItem.isIndex === 'Y' ? 'N' : 'Y'
if (!isHasChunkIndex.value) { if (!isHasChunkIndex.value) {
...@@ -60,7 +65,7 @@ function handleKnowledgeTableAction(chunkKeyItem: QAKnowledgeChunkKeyItem) { ...@@ -60,7 +65,7 @@ function handleKnowledgeTableAction(chunkKeyItem: QAKnowledgeChunkKeyItem) {
} }
emit('updateKnowledgeChunkIndex', chunkKeyItem) emit('updateKnowledgeChunkIndex', chunkKeyItem)
} }, 500)
</script> </script>
<template> <template>
...@@ -75,7 +80,15 @@ function handleKnowledgeTableAction(chunkKeyItem: QAKnowledgeChunkKeyItem) { ...@@ -75,7 +80,15 @@ function handleKnowledgeTableAction(chunkKeyItem: QAKnowledgeChunkKeyItem) {
{{ t('personal_space_module.knowledge_module.setting_index_desc') }} {{ t('personal_space_module.knowledge_module.setting_index_desc') }}
</p> </p>
<n-data-table :single-line="false" :columns="chunkIndexColumns" :data="knowledgeChunkKeyList" :max-height="300" /> <n-data-table
:single-line="false"
:columns="chunkIndexColumns"
:data="knowledgeChunkKeyList"
:max-height="300"
class="mb-1"
/>
</template> </template>
<template #footer></template>
</CustomModal> </CustomModal>
</template> </template>
...@@ -290,6 +290,7 @@ async function handleDeleteQAKnowledgeChunk(chunkRelationId: string) { ...@@ -290,6 +290,7 @@ async function handleDeleteQAKnowledgeChunk(chunkRelationId: string) {
// 更新知识库是否开启 // 更新知识库是否开启
function handleUpdateQAKnowledgeChunkOpen(chunkRelationId: string, chunkContentItem: QAKnowledgeChunkContentItem) { function handleUpdateQAKnowledgeChunkOpen(chunkRelationId: string, chunkContentItem: QAKnowledgeChunkContentItem) {
chunkContentItem.isOpen = chunkContentItem.isOpen === 'Y' ? 'N' : 'Y' chunkContentItem.isOpen = chunkContentItem.isOpen === 'Y' ? 'N' : 'Y'
chunkContentItem.isOpenLoading = true
const payload = { const payload = {
kdId: props.kdId, kdId: props.kdId,
...@@ -297,9 +298,13 @@ function handleUpdateQAKnowledgeChunkOpen(chunkRelationId: string, chunkContentI ...@@ -297,9 +298,13 @@ function handleUpdateQAKnowledgeChunkOpen(chunkRelationId: string, chunkContentI
isOpen: chunkContentItem.isOpen, isOpen: chunkContentItem.isOpen,
} }
fetchOpenQAKnowledgeChunk(payload).catch(() => { fetchOpenQAKnowledgeChunk(payload)
chunkContentItem.isOpen = chunkContentItem.isOpen === 'Y' ? 'N' : 'Y' .catch(() => {
}) chunkContentItem.isOpen = chunkContentItem.isOpen === 'Y' ? 'N' : 'Y'
})
.finally(() => {
chunkContentItem.isOpenLoading = false
})
} }
// 批量删除知识库分片 // 批量删除知识库分片
......
...@@ -60,6 +60,7 @@ export interface QAKnowledgeChunkContentItem { ...@@ -60,6 +60,7 @@ export interface QAKnowledgeChunkContentItem {
chunkSort: number chunkSort: number
chunkInfo: QAKnowledgeChunkInfoItem[] chunkInfo: QAKnowledgeChunkInfoItem[]
isOpen: 'Y' | 'N' isOpen: 'Y' | 'N'
isOpenLoading?: boolean
} }
export interface QAKnowledgeChunkInfoItem { export interface QAKnowledgeChunkInfoItem {
......
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