Skip to content

Commit 809fb9f

Browse files
committed
【功能新增】AI:知识库文档上传:70%,SplitStep 已完成
1 parent de41b6c commit 809fb9f

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

src/api/ai/knowledge/document/index.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,27 @@ export const KnowledgeDocumentApi = {
2525
},
2626

2727
// 新增知识库文档(单个)
28-
createKnowledgeDocument: async (data: KnowledgeDocumentVO) => {
28+
createKnowledgeDocument: async (data: any) => {
2929
return await request.post({ url: `/ai/knowledge/document/create`, data })
3030
},
3131

32-
// 新增知识库文档(批量
32+
// 新增知识库文档(多个
3333
createKnowledgeDocumentList: async (data: any) => {
3434
return await request.post({ url: `/ai/knowledge/document/create-list`, data })
3535
},
3636

37-
// // 修改AI 知识库文档
38-
// updateKnowledgeDocument: async (data: KnowledgeDocumentVO) => {
39-
// return await request.put({ url: `/ai/knowledge/document/update`, data })
40-
// },
37+
// 修改知识库文档
38+
updateKnowledgeDocument: async (data: any) => {
39+
return await request.put({ url: `/ai/knowledge/document/update`, data })
40+
},
41+
42+
// 修改知识库文档状态
43+
updateKnowledgeDocumentStatus: async (data: any) => {
44+
return await request.put({
45+
url: `/ai/knowledge/document/update-status`,
46+
data
47+
})
48+
},
4149

4250
// 删除知识库文档
4351
deleteKnowledgeDocument: async (id: number) => {

src/views/ai/knowledge/document/form/SplitStep.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<div class="segment-settings mb-20px">
2323
<el-form label-width="120px">
2424
<el-form-item label="最大 Token 数">
25-
<el-input-number v-model="modelData.segmentMaxTokens" :min="100" :max="2000" />
25+
<el-input-number v-model="modelData.segmentMaxTokens" :min="1" :max="2048" />
2626
</el-form-item>
2727
</el-form>
2828
</div>
@@ -38,6 +38,9 @@
3838
<div class="flex items-center cursor-pointer">
3939
<Icon icon="ep:document" class="text-danger mr-5px" />
4040
<span>{{ currentFile?.name || '请选择文件' }}</span>
41+
<span v-if="currentFile?.segments" class="ml-5px text-gray-500 text-12px">
42+
({{ currentFile.segments.length }}个分片)
43+
</span>
4144
<Icon icon="ep:arrow-down" class="ml-5px" />
4245
</div>
4346
<template #dropdown>
@@ -48,6 +51,9 @@
4851
@click="selectFile(index)"
4952
>
5053
{{ file.name }}
54+
<span v-if="file.segments" class="ml-5px text-gray-500 text-12px">
55+
({{ file.segments.length }}个分片)
56+
</span>
5157
</el-dropdown-item>
5258
</el-dropdown-menu>
5359
</template>
@@ -182,7 +188,7 @@ const handleSave = async () => {
182188
try {
183189
if (modelData.value.id) {
184190
// 修改场景
185-
modelData.value.ids = await KnowledgeDocumentApi.createKnowledgeDocumentList({
191+
modelData.value.ids = await KnowledgeDocumentApi.updateKnowledgeDocument({
186192
id: modelData.value.id,
187193
segmentMaxTokens: modelData.value.segmentMaxTokens
188194
})

src/views/ai/knowledge/document/index.vue

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@
5353
<el-table-column label="召回次数" align="center" prop="retrievalCount" />
5454
<el-table-column label="是否启用" align="center" prop="status">
5555
<template #default="scope">
56-
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
56+
<el-switch
57+
v-model="scope.row.status"
58+
:active-value="0"
59+
:inactive-value="1"
60+
@change="handleStatusChange(scope.row)"
61+
:disabled="!checkPermi(['ai:knowledge:update'])"
62+
/>
5763
</template>
5864
</el-table-column>
5965
<el-table-column
@@ -102,6 +108,8 @@ import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
102108
import { dateFormatter } from '@/utils/formatTime'
103109
import { KnowledgeDocumentApi, KnowledgeDocumentVO } from '@/api/ai/knowledge/document'
104110
import { useRoute, useRouter } from 'vue-router'
111+
import { checkPermi } from '@/utils/permission'
112+
import { CommonStatusEnum } from '@/utils/constants'
105113
// import KnowledgeDocumentForm from './KnowledgeDocumentForm.vue'
106114
107115
/** AI 知识库文档 列表 */
@@ -177,6 +185,24 @@ const handleDelete = async (id: number) => {
177185
} catch {}
178186
}
179187
188+
/** 修改状态操作 */
189+
const handleStatusChange = async (row: KnowledgeDocumentVO) => {
190+
try {
191+
// 修改状态的二次确认
192+
const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '禁用'
193+
await message.confirm('确认要"' + text + '""' + row.name + '"文档吗?')
194+
// 发起修改状态
195+
await KnowledgeDocumentApi.updateKnowledgeDocumentStatus({ id: row.id, status: row.status })
196+
message.success(t('common.updateSuccess'))
197+
// 刷新列表
198+
await getList()
199+
} catch {
200+
// 取消后,进行恢复按钮
201+
row.status =
202+
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
203+
}
204+
}
205+
180206
/** 初始化 **/
181207
onMounted(() => {
182208
// 如果知识库 ID 不存在,显示错误提示并关闭页面

0 commit comments

Comments
 (0)