Browse Source

修复跨页无法定位的问题,修复页面显示错误的问题

ai_dev
zhouhaibin 5 days ago
parent
commit
f0dec240a7
  1. 1
      src/components/Preview/src/PdfPreview/PageSelectModal.vue
  2. 7
      src/components/Preview/src/PdfPreview/PdfPreviewComponent.vue
  3. 48
      src/components/UniversalResultDrawer.vue
  4. 14
      src/configs/documentTaskConfigs.ts

1
src/components/Preview/src/PdfPreview/PageSelectModal.vue

@ -7,6 +7,7 @@
width="400" width="400"
:maskClosable="true" :maskClosable="true"
:closable="true" :closable="true"
:destroyOnClose="true"
> >
<p>该文本在以下页面出现</p> <p>该文本在以下页面出现</p>
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;"> <div style="display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;">

7
src/components/Preview/src/PdfPreview/PdfPreviewComponent.vue

@ -254,8 +254,8 @@
} }
if (foundPages.length === 0) { if (foundPages.length === 0) {
message.warning('未在PDF中找到该文本'); // message.warning('PDF');
return; throw new Error('未在PDF中找到该文本');
} }
// ** // **
@ -273,9 +273,6 @@
// //
matchedPages.value = foundPages; matchedPages.value = foundPages;
showPageSelectModal.value = true; showPageSelectModal.value = true;
} catch (error) {
console.error('文本定位失败:', error);
message.error('文本定位失败');
} finally { } finally {
loading.value = false; loading.value = false;
loadingTip.value = ''; loadingTip.value = '';

48
src/components/UniversalResultDrawer.vue

@ -469,12 +469,21 @@
const dataToProcess = props.taskResultDetail.slice(1); // const dataToProcess = props.taskResultDetail.slice(1); //
// //
return dataToProcess.map((category, index) => ({ return dataToProcess.map((category, index) => {
let label = `${category.name} (${category.results?.length || 0})`;
//
if (category.name === '实质性审查' && props.taskInfo?.contractPartyRole) {
label = `${props.taskInfo.contractPartyRole})实质性审查 (${category.results?.length || 0})`;
}
return {
key: category.name, // 使namekey key: category.name, // 使namekey
label: `${category.name} (${category.results?.length || 0})`, label: label,
dataIndex: index + 1, // +1 dataIndex: index + 1, // +1
name: category.name name: category.name
})); };
});
}); });
// //
@ -849,6 +858,12 @@
currentSelectItem.value = item; currentSelectItem.value = item;
currentSelectCategoryIndex.value = categoryIndex; currentSelectCategoryIndex.value = categoryIndex;
currentSelectItemIndex.value = itemIndex; currentSelectItemIndex.value = itemIndex;
//
const fieldKey = getFieldKey(item, fieldConfig, categoryIndex, itemIndex);
console.log('fieldKey', fieldKey);
delete fieldPageButtons.value[fieldKey];
console.log('fieldPageButtons', fieldPageButtons.value);
} }
// 使 // 使
@ -866,7 +881,7 @@
} }
try { try {
// PDF //
await pdfContainerRef.value.locateByText(text, pdfSource); await pdfContainerRef.value.locateByText(text, pdfSource);
// //
@ -874,7 +889,27 @@
checkForPageModal(); checkForPageModal();
}, 300); // }, 300); //
} catch (error) { } catch (error) {
console.error('PDF定位失败:', error); console.error('完整文本定位失败,尝试使用前10个字符定位:', error);
// 10
const shortText = text.trim().substring(0, 10);
if (shortText && shortText !== text.trim()) {
try {
console.log('使用前10个字符进行定位:', shortText);
message.warning('完整文本定位失败,尝试使用前10个字符定位');
await pdfContainerRef.value.locateByText(shortText, pdfSource);
//
setTimeout(() => {
checkForPageModal();
}, 300); //
} catch (shortError) {
console.error('前10个字符定位也失败:', shortError);
message.warning('文本定位失败,该内容可能不在PDF中');
}
} else {
message.warning('文本定位失败,该内容可能不在PDF中');
}
} }
}; };
@ -912,12 +947,13 @@
modalButtons.forEach(button => { modalButtons.forEach(button => {
const text = button.textContent || ''; const text = button.textContent || '';
console.log('button', button.textContent);
const match = text.match(/第(\d+)页/); const match = text.match(/第(\d+)页/);
if (match) { if (match) {
pages.push(parseInt(match[1])); pages.push(parseInt(match[1]));
} }
}); });
console.log('pages', pages);
// //
if (pages.length > 0 && currentSelectFieldConfig.value && currentSelectItem.value && if (pages.length > 0 && currentSelectFieldConfig.value && currentSelectItem.value &&
currentSelectCategoryIndex.value !== null && currentSelectItemIndex.value !== null) { currentSelectCategoryIndex.value !== null && currentSelectItemIndex.value !== null) {

14
src/configs/documentTaskConfigs.ts

@ -7,7 +7,7 @@ export const DOCUMENT_TASK_CONFIGS: Record<string, TaskConfig> = {
// 文档错误检查 // 文档错误检查
"checkDocumentError": { "checkDocumentError": {
taskType: "checkDocumentError", taskType: "checkDocumentError",
name: "文错误检查", name: "文错误检查",
mode: "single", mode: "single",
pdfConfig: { pdfConfig: {
layout: "single", layout: "single",
@ -48,7 +48,7 @@ export const DOCUMENT_TASK_CONFIGS: Record<string, TaskConfig> = {
// 重复文本检查 // 重复文本检查
"checkRepeatText": { "checkRepeatText": {
taskType: "checkRepeatText", taskType: "checkRepeatText",
name: "重复文本检查", name: "文档相似性检查",
mode: "single", mode: "single",
pdfConfig: { pdfConfig: {
layout: "single", layout: "single",
@ -83,7 +83,7 @@ export const DOCUMENT_TASK_CONFIGS: Record<string, TaskConfig> = {
// 全文重复检查 // 全文重复检查
"allCheckRepeatText": { "allCheckRepeatText": {
taskType: "allCheckRepeatText", taskType: "allCheckRepeatText",
name: "全文重复检查", name: "全文档相似性检查",
mode: "single", mode: "single",
pdfConfig: { pdfConfig: {
layout: "single", layout: "single",
@ -140,7 +140,7 @@ export const DOCUMENT_TASK_CONFIGS: Record<string, TaskConfig> = {
// 标题名称检查 // 标题名称检查
"checkTitleName": { "checkTitleName": {
taskType: "checkTitleName", taskType: "checkTitleName",
name: "标题名称检查", name: "文档结构检查",
mode: "single", mode: "single",
pdfConfig: { pdfConfig: {
layout: "single", layout: "single",
@ -151,10 +151,10 @@ export const DOCUMENT_TASK_CONFIGS: Record<string, TaskConfig> = {
fields: [ fields: [
{ {
field: 'modificationDisplay', field: 'modificationDisplay',
title: '相关原文', title: '结构检查情况',
dataType: 'string', dataType: 'string',
displayType: 'markdown', displayType: 'markdown',
pdfSource: 'document' // pdfSource: 'document'
} }
] ]
}, },
@ -184,7 +184,7 @@ export const DOCUMENT_TASK_CONFIGS: Record<string, TaskConfig> = {
// 政策依据检查 // 政策依据检查
"policyBases": { "policyBases": {
taskType: "policyBases", taskType: "policyBases",
name: "政策依据检查", name: "建设依据检查",
mode: "single", mode: "single",
pdfConfig: { pdfConfig: {
layout: "single", layout: "single",

Loading…
Cancel
Save