diff --git a/src/api/generatedApi/index.js b/src/api/generatedApi/index.js index 38d9a2c..43cd987 100644 --- a/src/api/generatedApi/index.js +++ b/src/api/generatedApi/index.js @@ -59,7 +59,7 @@ export function datasetsExTaskPages(data) { //minerU 获取bbox export function minerUBbox(params) { return request({ - url: getUrl('/document/mineru/bbox_json', 'zixi'), + url: getUrl('/document/mineru/bbox_json'), method: 'get', params: params }) @@ -67,7 +67,7 @@ export function minerUBbox(params) { //minerU 重试 export function minerURetry(params) { return request({ - url: getUrl('/document/mineru/retry', 'zixi'), + url: getUrl('/document/mineru/retry'), method: 'get', params: params, noLoading: true @@ -76,7 +76,7 @@ export function minerURetry(params) { //minerU 获取文档处理状态 export function minerUQuery(params) { return request({ - url: getUrl('/dataset/document/query', 'zixi'), + url: getUrl('/dataset/document/query'), method: 'get', params: params, noLoading: true @@ -84,17 +84,17 @@ export function minerUQuery(params) { } //minerU 获取markdown export function minerUMarkDown(params) { - return getUrl(`/document/mineru/md?documentId=${params.documentId}`, 'zixi') + return getUrl(`/document/mineru/md?documentId=${params.documentId}`) } // minerU 获取pdf export function getPdfUrl(params) { - return getUrl(`/datasetDocumentEx/preview?id=${params.documentId}`, 'zixi') + return getUrl(`/datasetDocumentEx/preview?id=${params.documentId}`) } export function minerUMarkDownUpdate(data) { return request({ - url: getUrl(`/document/mineru/md/update`, 'zixi'), + url: getUrl(`/document/mineru/md/update`), method: 'post', data }) @@ -209,7 +209,7 @@ export function saveContentToDocument(data) { export function uploadFileByCustom(data) { return request({ - url: getUrl(`/datasetDocumentEx/upload/custom`, 'zixi'), + url: getUrl(`/datasetDocumentEx/upload/custom`), method: 'post', data, headers: { diff --git a/src/api/generatedApi/pdfApi.js b/src/api/generatedApi/pdfApi.js new file mode 100644 index 0000000..f782379 --- /dev/null +++ b/src/api/generatedApi/pdfApi.js @@ -0,0 +1,34 @@ +import request from '@/assets/js/utils/request' +import getUrl from '@/assets/js/utils/get-url' + +// 用户新增 +export function preprocessEmbedding(data) { + return request({ + url: getUrl('/datasetDocumentEx/preprocess/embedding'), + method: 'post', + data + }) +} + +export function contentPage(data) { + return request({ + url: getUrl('/document/mineru/content/page'), + method: 'get', + params: data + }) +} + +export function documentPdfStatus(data) { + return request({ + url: getUrl('/document/mineru/status'), + method: 'get', + params: data + }) +} +export function contentUpdate(data) { + return request({ + url: getUrl('/document/mineru/md/page/update'), + method: 'post', + data + }) +} diff --git a/src/assets/sass/renderSass/button.scss b/src/assets/sass/renderSass/button.scss index db53469..71736e8 100644 --- a/src/assets/sass/renderSass/button.scss +++ b/src/assets/sass/renderSass/button.scss @@ -97,6 +97,10 @@ border: none; color: #fff; } + &.is-disabled { + background: var(--color-primary-disabled); + border-color: transparent; + } } &.el-button--medium { padding: 8px 20px; diff --git a/src/components/RenderMinerU/index.vue b/src/components/RenderMinerU/index.vue index 95bfb13..51dcc4c 100644 --- a/src/components/RenderMinerU/index.vue +++ b/src/components/RenderMinerU/index.vue @@ -34,6 +34,14 @@ :disabled="finishedMiner" >保存并处理 + 直接上传至知识库 @@ -53,7 +61,7 @@ class="ebiz-pdf el-card " >
@@ -99,6 +106,12 @@ import { import { DEFAULT_COLOR_SECTION, PDF_COLOR_PICKER } from './pdf-color' import MarkdownIt from 'markdown-it' import markdownItKatex from 'markdown-it-katex' +import { + contentPage, + contentUpdate, + documentPdfStatus, + preprocessEmbedding +} from '@/api/generatedApi/pdfApi' const md = new MarkdownIt({ html: true }).use(markdownItKatex) @@ -107,7 +120,10 @@ export default { name: 'index', data() { return { + mdJsons: {}, + fileName: '', + recordId: '', //pdf 记录的id endEmit: false, tab: '0', mdPges: 0, @@ -260,7 +276,9 @@ export default { page: { handler(newVal, oldVal) { if (newVal) { - this.changePage(newVal, this.tab) + // this.changePage(newVal, this.tab) + + this.getPDFDetailMarkDown() } } } @@ -268,6 +286,21 @@ export default { components: {}, filters: {}, methods: { + uploadKnowledge() { + preprocessEmbedding({ documentId: this.documentId }).then(res => { + if (res) { + this.$message.success('上传成功') + this.$router.push({ + path: '/knowledge/detail/segments', + query: { + documentId: this.documentId, + datasetId: this.$route.query.datasetId + } + }) + } + }) + }, + //changePage // 分页发生改变时 changePage(page) { @@ -375,6 +408,7 @@ export default { buttonContainer.appendChild(button) } }, + // 查找匹配的表格 findMatchingTable(tableElement) { let chooseItem = null @@ -447,41 +481,30 @@ export default { }) }) }, - // 填充对照表 - fillSelectionTable(selection) { - selection.map(item => { - if (item.preproc_blocks && item.preproc_blocks.length > 0) { - item.preproc_blocks.forEach(block => { - if (block.type === 'table') { - this.extractTableData(block) - } - }) - } - // 处理丢弃块 - if (item.discarded_blocks && item.discarded_blocks.length > 0) { - item.discarded_blocks.forEach(block => { - if (block.type === 'table') { - this.extractTableData(block) - } - }) - } - }) - }, // 导出 emitMarkDown() { let pre = document.getElementById('md-editor').innerText this.$emit('getMarkDownIt', { innerText: pre }) }, // 保存markdown - saveMarkDown() { - let pre = document.getElementById('md-editor').innerHTML - // pre + ebiz-code标签 - minerUMarkDownUpdate({ - documentId: this.documentId, - newMd: pre - }).then(res => { + async saveMarkDown() { + let promises = [] + for (let item in this.mdJsons) { + let promise = contentUpdate({ + documentId: this.documentId, + pageIndex: item, + newMd: this.mdJsons[item] + }) + promises.push(promise) + } + try { + await Promise.all(promises) this.$emit('saveMarkDown', true) - }) + this.$message.success('保存成功') + } catch (error) { + this.$message.error('保存失败') + console.error(error) + } }, // 给文件增加色块 formatJson(data) { @@ -514,37 +537,43 @@ export default { } }) }, + // 填充对照表 + fillSelectionTable(selection) { + selection.map(item => { + if (item.preproc_blocks && item.preproc_blocks.length > 0) { + item.preproc_blocks.forEach(block => { + if (block.type === 'table') { + this.extractTableData(block) + } + }) + } + // 处理丢弃块 + if (item.discarded_blocks && item.discarded_blocks.length > 0) { + item.discarded_blocks.forEach(block => { + if (block.type === 'table') { + this.extractTableData(block) + } + }) + } + }) + }, + // bbox 解析 传递 颜色 getPDFDetailBbox() { minerUBbox({ documentId: this.documentId }).then(res => { this.bboxList = this.formatJson( - JSON.parse(JSON.stringify(res.content.content)) + JSON.parse(JSON.stringify(res.content.content.pdf_info)) ) - this.fillSelectionTable(JSON.parse(JSON.stringify(res.content.content))) + this.fillSelectionTable( + JSON.parse(JSON.stringify(res.content.content.pdf_info)) + ) // this.$refs.iframe 重新刷新iframe this.$refs.iframe.contentWindow.location.reload() this.getPDFDetailMarkDown() }) }, - // 获取md分页 - getMdPage(back) { - let responseText = '' - getMd_info({ documentId: this.documentId }).then(async res => { - if (res) { - this.mdPges = res.content.content.indexList - - for (let i = 0; i < this.mdPges.length; i++) { - let text = await mdIndex({ index: i, documentId: this.documentId }) - - responseText += ` -${text}` - } - back(responseText) - } - }) - }, // 渲染markdown renderMarkDown() { this.markdown = this.markdown @@ -555,9 +584,7 @@ ${text}` .replace(/