Browse Source

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

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

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

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

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

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

54
src/components/UniversalResultDrawer.vue

@ -469,12 +469,21 @@
const dataToProcess = props.taskResultDetail.slice(1); //
//
return dataToProcess.map((category, index) => ({
key: category.name, // 使namekey
label: `${category.name} (${category.results?.length || 0})`,
dataIndex: index + 1, // +1
name: category.name
}));
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
label: label,
dataIndex: index + 1, // +1
name: category.name
};
});
});
//
@ -849,6 +858,12 @@
currentSelectItem.value = item;
currentSelectCategoryIndex.value = categoryIndex;
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 {
// PDF
//
await pdfContainerRef.value.locateByText(text, pdfSource);
//
@ -874,7 +889,27 @@
checkForPageModal();
}, 300); //
} 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 => {
const text = button.textContent || '';
console.log('button', button.textContent);
const match = text.match(/第(\d+)页/);
if (match) {
pages.push(parseInt(match[1]));
}
});
console.log('pages', pages);
//
if (pages.length > 0 && currentSelectFieldConfig.value && currentSelectItem.value &&
currentSelectCategoryIndex.value !== null && currentSelectItemIndex.value !== null) {

14
src/configs/documentTaskConfigs.ts

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

Loading…
Cancel
Save