Commit 3404f8e7 authored by nick zheng's avatar nick zheng

fix: 重新训练点击无反应及限制最多上传五份文件

parent f5e1b260
......@@ -115,6 +115,9 @@ export function createKnowledgeDocumentColumn(
{
type: 'selection',
fixed: 'left',
disabled(row: KnowledgeDocumentItem) {
return !['Complete', 'Fail'].includes(row.trainStatus)
},
},
{
title: () => <span>{t('personal_space_module.knowledge_module.knowledge_document_name')}</span>,
......@@ -235,7 +238,7 @@ export function createKnowledgeDocumentColumn(
trigger: () => (
<span
class={[
row.trainStatus === 'Complete'
['Complete', 'Fail'].includes(row.trainStatus)
? 'text-error-font-color mr-5 cursor-pointer hover:opacity-80'
: 'text-gray-font-color pointer-events-none mr-5 cursor-not-allowed',
]}
......
......@@ -11,6 +11,7 @@ import {
fetchDelKnowledgeDocument,
fetchGetKnowledgeDetail,
fetchGetKnowledgeDocumentList,
fetchTrainKnowledge,
fetchUpdateKnowledgeInfo,
} from '@/apis/knowledge'
import useTableScrollY from '@/composables/useTableScrollY'
......@@ -125,6 +126,8 @@ function handleClickKnowledgeDocumentTableAction(actionType: string, knowledgeDo
case 'delete':
handleDeleteKnowledgeDocument(knowledgeDocumentItem.kdId)
break
case 'train':
handleTrainKnowledgeDocument(knowledgeDocumentItem)
}
}
......@@ -144,6 +147,16 @@ async function handleDeleteKnowledgeDocument(kdId: number) {
}
}
async function handleTrainKnowledgeDocument(knowledgeDocumentItem: KnowledgeDocumentItem) {
await fetchTrainKnowledge({
knowledgeInfoId: currentKnowledgeId.value,
kdIds: [knowledgeDocumentItem.kdId],
segmentationConfig: knowledgeDocumentItem.segmentationConfig,
})
await handleGetKnowledgeDocumentList()
}
function handleShowEditKnowledgeModal() {
isShowEditKnowledgeModal.value = true
}
......
......@@ -113,26 +113,28 @@ async function handleUpload(file: any) {
kdId: 0,
}
uploadFileList.value.push(fileData)
fetchUploadKnowledgeDocument<{ kdId: number }[]>(formData)
.then((res) => {
if (res.code === 0) {
if (uploadFileList.value.length < 5) {
await uploadFileList.value.push(fileData)
fetchUploadKnowledgeDocument<{ kdId: number }[]>(formData)
.then((res) => {
if (res.code === 0) {
uploadFileList.value.forEach((fileItem) => {
if (fileItem.id === file.file.id) {
fileItem.status = FileItemStatus.FINISHED
fileItem.kdId = res.data?.[0]?.kdId
}
})
}
})
.catch(() => {
uploadFileList.value.forEach((fileItem) => {
if (fileItem.id === file.file.id) {
fileItem.status = FileItemStatus.FINISHED
fileItem.kdId = res.data?.[0]?.kdId
fileItem.status = FileItemStatus.ERROR
}
})
}
})
.catch(() => {
uploadFileList.value.forEach((fileItem) => {
if (fileItem.id === file.file.id) {
fileItem.status = FileItemStatus.ERROR
}
})
})
}
}
function handleRemoveFile(id: string) {
......
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