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