mirror of
http://112.124.100.131/ebiz-ai/ebiz-ai-knowledge-manage.git
synced 2025-12-11 03:46:50 +08:00
feat(knowledge): 实现题词功能并优化知识库创建流程- 新增题词预览组件和相关 API 接口
- 重构知识库创建流程,支持自动和自定义题词 - 优化题词结果展示和保存逻辑 - 调整知识库详情页面布局
This commit is contained in:
@@ -160,6 +160,24 @@ export function execExtract(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 题词-查询题词结果详情
|
||||||
|
export function getExtractResultList(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/document/attribute/extract/result/list`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 题词-保存
|
||||||
|
export function saveContentToDocument(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/saveContentToDocument`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
//知识库文件上传-自定义
|
//知识库文件上传-自定义
|
||||||
export function uploadFileByCustom(data) {
|
export function uploadFileByCustom(data) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -218,10 +218,6 @@ export default {
|
|||||||
|
|
||||||
// 4. 显示预览组件
|
// 4. 显示预览组件
|
||||||
this.showPreview(previewData)
|
this.showPreview(previewData)
|
||||||
|
|
||||||
// 5. 处理成功响应
|
|
||||||
// const result = this.handleSuccessResponse(execSplitData, previewData)
|
|
||||||
// resolve(result)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 6. 处理错误
|
// 6. 处理错误
|
||||||
const errorResult = this.handleOperationError(error)
|
const errorResult = this.handleOperationError(error)
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ export default {
|
|||||||
{ id: 2, name: 'Item 2', selected: false },
|
{ id: 2, name: 'Item 2', selected: false },
|
||||||
{ id: 3, name: 'Item 3', selected: false }
|
{ id: 3, name: 'Item 3', selected: false }
|
||||||
],
|
],
|
||||||
addRuleVisible: false // 控制 AddRule 组件的显示状态
|
addRuleVisible: false, // 控制 AddRule 组件的显示状态
|
||||||
|
selectData: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -53,6 +54,7 @@ export default {
|
|||||||
},
|
},
|
||||||
getCheckData(value) {
|
getCheckData(value) {
|
||||||
console.log(value)
|
console.log(value)
|
||||||
|
this.selectData = value
|
||||||
this.ruleId = value[0].id
|
this.ruleId = value[0].id
|
||||||
},
|
},
|
||||||
getDataList() {
|
getDataList() {
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<!-- src/views/knowledge/detail/components/words/ExtractPreview.vue -->
|
||||||
|
<template>
|
||||||
|
<div class="extract-preview">
|
||||||
|
<el-dialog title="题词结果预览" :visible.sync="visible" width="700px" :close-on-click-modal="false">
|
||||||
|
<div class="preview-content">
|
||||||
|
<template v-if="extractResults && extractResults.length > 0">
|
||||||
|
<el-table :data="extractResults" border style="width: 100%">
|
||||||
|
<el-table-column prop="attribute" label="属性" align="center" width="180"></el-table-column>
|
||||||
|
<el-table-column prop="attributeContent" label="题词内容" align="center"></el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</template>
|
||||||
|
<el-empty v-else-if="!extractResults || extractResults.length === 0" description="暂无题词结果"></el-empty>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="handleConfirm">完成</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'ExtractPreview',
|
||||||
|
props: {
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
extractResults: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
loading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleClose() {
|
||||||
|
this.$emit('update:visible', false)
|
||||||
|
},
|
||||||
|
handleConfirm() {
|
||||||
|
this.$emit('confirm', this.extractResults)
|
||||||
|
this.handleClose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.extract-preview {
|
||||||
|
.preview-content {
|
||||||
|
min-height: 300px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -56,22 +56,36 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<!-- 弹窗组件 -->
|
<!-- 弹窗组件 -->
|
||||||
<custom-split-dialog class="active" ref="customTable"> </custom-split-dialog>
|
<custom-split-dialog class="active" ref="customTable"> </custom-split-dialog>
|
||||||
|
|
||||||
|
<!-- 添加题词预览组件 -->
|
||||||
|
<extract-preview
|
||||||
|
:visible.sync="previewVisible"
|
||||||
|
:extract-results="extractResults"
|
||||||
|
:is-auto-extract="activeIndex === 0"
|
||||||
|
:loading="previewLoading"
|
||||||
|
@confirm="handlePreviewConfirm"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CustomSplitDialog from './CustomWords.vue'
|
import CustomSplitDialog from './CustomWords.vue'
|
||||||
import { execExtract, execSplit } from '@/api/generatedApi'
|
import ExtractPreview from './ExtractPreview.vue'
|
||||||
|
import { execExtract, getExtractResultList, saveContentToDocument } from '@/api/generatedApi'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'splitConfig',
|
name: 'splitConfig',
|
||||||
components: {
|
components: {
|
||||||
CustomSplitDialog
|
CustomSplitDialog,
|
||||||
|
ExtractPreview
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
|
previewVisible: false,
|
||||||
|
extractResults: [],
|
||||||
|
previewLoading: false,
|
||||||
splitOptions: [
|
splitOptions: [
|
||||||
{
|
{
|
||||||
icon: 'el-icon-setting',
|
icon: 'el-icon-setting',
|
||||||
@@ -85,7 +99,8 @@ export default {
|
|||||||
description: '使用自定义题词方式可以根据具体需求灵活调整文本分割逻辑,但需要权衡灵活性与复杂度,需要用户具备一定的题词经验。',
|
description: '使用自定义题词方式可以根据具体需求灵活调整文本分割逻辑,但需要权衡灵活性与复杂度,需要用户具备一定的题词经验。',
|
||||||
tip: ''
|
tip: ''
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
documentId: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {},
|
props: {},
|
||||||
@@ -100,21 +115,103 @@ export default {
|
|||||||
this.$refs.customTable.close()
|
this.$refs.customTable.close()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 构建执行题词的参数
|
||||||
|
buildExecExtractParams(documentId) {
|
||||||
|
const params = {
|
||||||
|
documentId: documentId,
|
||||||
|
beAuto: this.activeIndex === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!params.beAuto && this.$refs.customTable.ruleId) {
|
||||||
|
params.rulesId = this.$refs.customTable.ruleId
|
||||||
|
}
|
||||||
|
|
||||||
|
return params
|
||||||
|
},
|
||||||
|
|
||||||
|
// 执行题词操作
|
||||||
|
async execExtractOperation(params) {
|
||||||
|
const res = await execExtract(params)
|
||||||
|
console.log('execExtract result:', res.content)
|
||||||
|
|
||||||
|
if (res.content.result !== '0') {
|
||||||
|
throw new Error(res.content.resultMessage || '执行题词失败')
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.content.content
|
||||||
|
},
|
||||||
|
|
||||||
|
// 显示预览
|
||||||
|
showExtractPreview(results) {
|
||||||
|
this.extractResults = results || []
|
||||||
|
this.previewVisible = true
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取题词结果列表 - 修改后的方法
|
||||||
|
async getExtractResultOperation(documentId) {
|
||||||
|
this.previewLoading = true
|
||||||
|
const params = { documentId }
|
||||||
|
const res = await getExtractResultList(params)
|
||||||
|
console.log('getExtractResultList result:', res.content)
|
||||||
|
|
||||||
|
if (res.content.result !== '0') {
|
||||||
|
throw new Error(res.content.resultMessage || '获取题词结果失败')
|
||||||
|
}
|
||||||
|
|
||||||
|
const results = res.content.content || []
|
||||||
|
|
||||||
|
// 显示预览弹窗
|
||||||
|
this.showExtractPreview(results)
|
||||||
|
},
|
||||||
|
// 处理预览确认
|
||||||
|
handlePreviewConfirm(extractResults) {
|
||||||
|
console.log('selectData')
|
||||||
|
console.log(this.$refs.customTable.selectData)
|
||||||
|
this.saveContentToDocumentOperation(this.documentId, extractResults)
|
||||||
|
},
|
||||||
|
// 保存题词内容到文档
|
||||||
|
async saveContentToDocumentOperation(documentId, resultList) {
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
documentId,
|
||||||
|
resultDTOList: resultList.map(item => ({
|
||||||
|
attribute: item.attribute,
|
||||||
|
attributeContent: item.attributeContent
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await saveContentToDocument(params)
|
||||||
|
console.log('saveContentToDocument result:', res.content)
|
||||||
|
|
||||||
|
if (res.content.result !== '0') {
|
||||||
|
throw new Error(res.content.resultMessage || '保存题词内容失败')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$router.go(-1)
|
||||||
|
} catch (error) {
|
||||||
|
this.$message.error('保存题词内容失败: ' + error.message)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 主方法
|
||||||
nextStep(documentId) {
|
nextStep(documentId) {
|
||||||
|
this.documentId = documentId
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let params = {
|
try {
|
||||||
documentId: documentId,
|
// 1. 执行题词
|
||||||
beAuto: this.activeIndex === 0
|
const params = this.buildExecExtractParams(documentId)
|
||||||
|
await this.execExtractOperation(params)
|
||||||
|
// 2.
|
||||||
|
await this.getExtractResultOperation(documentId)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('题词操作失败:', error)
|
||||||
|
reject({
|
||||||
|
success: false,
|
||||||
|
message: error.message || '题词操作失败'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if (params.beAuto === false) {
|
|
||||||
params.rulesId = this.$refs.customTable.ruleId
|
|
||||||
}
|
|
||||||
let res = await execExtract(params)
|
|
||||||
console.log(res.content)
|
|
||||||
resolve({
|
|
||||||
result: res.content.result,
|
|
||||||
data: res.content
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -88,19 +88,9 @@ export default {
|
|||||||
if (this.active === 0) {
|
if (this.active === 0) {
|
||||||
this.$refs.stepPreProcessing.uploadFiled()
|
this.$refs.stepPreProcessing.uploadFiled()
|
||||||
} else if (this.active === 1) {
|
} else if (this.active === 1) {
|
||||||
const res = await this.$refs.splitConfig.nextStep(this.documentId)
|
await this.$refs.splitConfig.nextStep(this.documentId)
|
||||||
if (res.result === '0') {
|
|
||||||
// 处理成功的情况
|
|
||||||
console.log('拆分成功', res.content)
|
|
||||||
this.active++
|
|
||||||
}
|
|
||||||
} else if (this.active === 2) {
|
} else if (this.active === 2) {
|
||||||
const res = await this.$refs.words.nextStep(this.documentId)
|
await this.$refs.words.nextStep(this.documentId)
|
||||||
if (res.result === '0') {
|
|
||||||
// 处理成功的情况
|
|
||||||
console.log('拆分成功', res.content)
|
|
||||||
this.$message.success('创建成功')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 预览完成
|
// 预览完成
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ export default {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
// 删除当前行
|
// 删除当前行
|
||||||
this.tableData.splice(index, 1)
|
this.tableData.splice(index, 1)
|
||||||
this.getTableData();
|
this.getTableData()
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
this.$notify.error({
|
this.$notify.error({
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {},
|
||||||
},
|
|
||||||
methods: {}
|
methods: {}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user