优化评查详情提示框的提示条件
This commit is contained in:
@@ -19,6 +19,9 @@ const API_BASE_URL = 'http://nas.7bm.co:3000';
|
||||
// const API_BASE_URL = 'http://172.16.0.119:9000/admin';
|
||||
// export const API_BASE_URL = 'http://nas.7bm.co:3000';
|
||||
|
||||
// 文档URL前缀
|
||||
export const DOCUMENT_URL = 'http://172.18.0.100:9000/docauditai/';
|
||||
|
||||
// 是否使用模拟数据(开发环境使用)
|
||||
const USE_MOCK_DATA = false; // 设置为true使用模拟数据,避免API连接问题
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ interface OcrDataResult {
|
||||
}
|
||||
|
||||
interface OcrData {
|
||||
[key: string]: OcrDataResult | unknown;
|
||||
ocr_result?: Record<string, OcrDataResult | unknown>;
|
||||
ocr_result?: Record<string, OcrDataResult>;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,6 +254,7 @@ export async function getReviewPoints(fileId: string) {
|
||||
let contentPage: Record<string, string> = {};
|
||||
// console.log('result-------', result.evaluated_results?.result);
|
||||
// console.log('datacontent-------', data);
|
||||
// console.log('documentData-------', documentData);
|
||||
if (data && typeof data === 'object') {
|
||||
// 4-22 更改数据结构:通过拿到的data数据(每一个key对应一个object),将object中的page提取出来
|
||||
try{
|
||||
@@ -263,10 +264,19 @@ export async function getReviewPoints(fileId: string) {
|
||||
let newPage = dataObj[key].page.toString();
|
||||
// 如果newPage里面有文本,则把文本去掉
|
||||
if(newPage.match(/\d+/g)){
|
||||
newPage = newPage.match(/\d+/g)?.map(Number).join('') || '';
|
||||
newPage = newPage.match(/^\d+/g)?.map(Number).join('') || '';
|
||||
}
|
||||
contentPage[key] = newPage;
|
||||
}
|
||||
|
||||
// 如果contentPage[key]为空,则需要根据这个key去ocrResult中找到对应的key,然后根据ocrResult中的pages数组,找到对应的页码
|
||||
if(!contentPage[key]){
|
||||
// 分割key获取数组的第一位
|
||||
const keyArray = key.split('-');
|
||||
const ocrResult = documentData?.data?.ocrResult as OcrData;
|
||||
const pages = ocrResult?.ocr_result?.[keyArray[0]]?.pages;
|
||||
contentPage[key] = pages?.[0]?.toString() || '';
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useNavigate } from "@remix-run/react";
|
||||
import { useState } from "react";
|
||||
import { loadingBarService } from "~/components/ui/LoadingBar";
|
||||
import { DOCUMENT_URL } from "~/api/client";
|
||||
|
||||
interface FileInfoProps {
|
||||
fileInfo: {
|
||||
@@ -24,8 +25,7 @@ export function FileInfo({ fileInfo, onConfirmResults }: FileInfoProps) {
|
||||
|
||||
const handleDownloadFile = async () => {
|
||||
try {
|
||||
const urlBefore = 'http://172.18.0.100:9000/docauditai/';
|
||||
const downloadUrl = `${urlBefore}${fileInfo.path}`;
|
||||
const downloadUrl = `${DOCUMENT_URL}${fileInfo.path}`;
|
||||
|
||||
// 使用fetch获取文件内容
|
||||
const response = await fetch(downloadUrl);
|
||||
|
||||
@@ -172,6 +172,10 @@ export function FilePreview({ fileContent, reviewPoints, activeReviewPointResult
|
||||
// 处理页面跳转
|
||||
const prevTargetPageRef = useRef<number | undefined>(undefined);
|
||||
useEffect(() => {
|
||||
// 如果有目标页码,并且与上次相同,提示用户
|
||||
if(targetPage && numPages && targetPage <= numPages && targetPage === prevTargetPageRef.current){
|
||||
toastService.success(`已跳转至目标页码`);
|
||||
}
|
||||
// 如果有目标页码,并且与上次不同或activeReviewPointId变化了,则执行跳转
|
||||
if (targetPage && numPages && targetPage <= numPages && (targetPage !== prevTargetPageRef.current || activeReviewPointResultId)) {
|
||||
prevTargetPageRef.current = targetPage;
|
||||
|
||||
@@ -450,14 +450,17 @@ export function ReviewPointsList({
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
console.log(`单独点击${key}----`, reviewPoint);
|
||||
// 检查value中的page属性是否存在
|
||||
if (value && typeof value === 'object' && value.page && parseInt(value.page as string) > 0) {
|
||||
// 获取当前 key 对应的第一个页码并跳转
|
||||
console.log(`单独点击${key}----页码---`, value.page);
|
||||
onReviewPointSelect(reviewPoint.id, parseInt(value.page as string));
|
||||
|
||||
} else {
|
||||
const valuePage = parseInt(value.page as string);
|
||||
const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
|
||||
// 检查value中的page属性是否存在,优先取value中的page
|
||||
if (valuePage > 0) {
|
||||
console.log(`存在page且不为空:单独点击${key}---------->evaluated_results内的页码:`, valuePage);
|
||||
onReviewPointSelect(reviewPoint.id, valuePage);
|
||||
|
||||
} else if(contentPage && contentPage > 0) {
|
||||
console.log(`存在page且为空:单独点击${key}---------->ocr_result内的页码:`, contentPage);
|
||||
onReviewPointSelect(reviewPoint.id, contentPage);
|
||||
}else {
|
||||
toastService.error(`无法找到"${key}"对应的索引内容`);
|
||||
console.log(`单独点击${key}--------没有对应页码`);
|
||||
}
|
||||
@@ -465,8 +468,13 @@ export function ReviewPointsList({
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
if (value && typeof value === 'object' && value.page && parseInt(value.page as string) > 0) {
|
||||
onReviewPointSelect(reviewPoint.id, parseInt(value.page as string));
|
||||
const valuePage = parseInt(value.page as string);
|
||||
const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
|
||||
// 检查value中的page属性是否存在,优先取value中的page
|
||||
if (valuePage > 0) {
|
||||
onReviewPointSelect(reviewPoint.id, valuePage);
|
||||
} else if(contentPage && contentPage > 0) {
|
||||
onReviewPointSelect(reviewPoint.id, contentPage);
|
||||
} else {
|
||||
toastService.error(`无法找到"${key}"对应的索引内容`);
|
||||
console.log(`单独点击${key}--------没有对应页码`);
|
||||
@@ -478,9 +486,12 @@ export function ReviewPointsList({
|
||||
aria-label={`查看${key}内容详情`}
|
||||
>
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs pr-5">{key}</span>
|
||||
<span className="text-xs pr-5">
|
||||
{key}
|
||||
</span>
|
||||
<span className={`flex-shrink-0 text-xs w-15 ${value.value?.toString().trim() ? 'text-error' : 'text-warning'}`}>
|
||||
{value.value?.toString().trim() ? '' : '缺失'}
|
||||
{parseInt(value.page as string)>0 || parseInt(reviewPoint.contentPage?.[key] as string)>0 ? '' : <i title="无法找到索引内容" className="ri-alert-line text-red-500 mr-2"></i>}
|
||||
{value.value?.toString().trim() ? '' : '缺失'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-left select-text">
|
||||
@@ -815,7 +826,7 @@ export function ReviewPointsList({
|
||||
}
|
||||
};
|
||||
|
||||
// 检查评查点的contentPage
|
||||
// 检查评查点的contentPage,如果contentPage内也没有page,则返回默认值
|
||||
const checkContentPage = (reviewPoint: ReviewPoint): { pageIndex: number, key?: string, id: string } => {
|
||||
// 返回对象初始化
|
||||
const result = { pageIndex: 0, id: reviewPoint.id };
|
||||
|
||||
+13
-10
@@ -97,23 +97,26 @@ export function Toast({
|
||||
// 自动关闭
|
||||
useEffect(() => {
|
||||
if (isOpen && autoClose && !isHovered) {
|
||||
// 根据消息长度调整显示时间,较长消息显示更长时间
|
||||
const messageLength = message.length;
|
||||
const baseDelay = autoCloseDelay || DEFAULT_AUTO_CLOSE_DELAY;
|
||||
// const messageLength = message.length;
|
||||
// const baseDelay = autoCloseDelay || DEFAULT_AUTO_CLOSE_DELAY;
|
||||
|
||||
// 按照文本长度比例延长显示时间
|
||||
const adjustedDelay = Math.min(
|
||||
baseDelay + (messageLength > 20 ? messageLength * 30 : 0),
|
||||
15000 // 最长不超过15秒
|
||||
);
|
||||
// // 按照文本长度比例延长显示时间
|
||||
// const adjustedDelay = Math.min(
|
||||
// baseDelay + (messageLength > 20 ? messageLength * 30 : 0),
|
||||
// 15000 // 最长不超过15秒
|
||||
// );
|
||||
// 不再根据消息长度调整显示时间,使用固定的延迟时间
|
||||
const delay = autoCloseDelay || DEFAULT_AUTO_CLOSE_DELAY;
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
handleClose();
|
||||
}, adjustedDelay);
|
||||
// }, adjustedDelay);
|
||||
}, delay);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [isOpen, autoClose, autoCloseDelay, handleClose, message, isHovered]);
|
||||
// }, [isOpen, autoClose, autoCloseDelay, handleClose, message, isHovered]);
|
||||
}, [isOpen, autoClose, autoCloseDelay, handleClose, isHovered]);
|
||||
|
||||
// 鼠标悬停处理
|
||||
const handleMouseEnter = () => {
|
||||
|
||||
@@ -15,6 +15,7 @@ import { updateDocumentAuditStatus } from "~/api/evaluation_points/rules-files";
|
||||
import { toastService } from "~/components/ui/Toast";
|
||||
import { messageService } from "~/components/ui/MessageModal";
|
||||
import { loadingBarService } from "~/components/ui/LoadingBar";
|
||||
import { DOCUMENT_URL } from "~/api/client";
|
||||
|
||||
// 导入样式
|
||||
export function links() {
|
||||
@@ -376,8 +377,7 @@ export default function DocumentsIndex() {
|
||||
// 下载文档
|
||||
const handleDownload = async (path: string) => {
|
||||
try {
|
||||
const urlBefore = 'http://172.18.0.100:9000/docauditai/';
|
||||
const downloadUrl = `${urlBefore}${path}`;
|
||||
const downloadUrl = `${DOCUMENT_URL}${path}`;
|
||||
|
||||
// 使用fetch获取文件内容
|
||||
const response = await fetch(downloadUrl);
|
||||
@@ -419,7 +419,7 @@ export default function DocumentsIndex() {
|
||||
toastService.warning("文件正在处理中,无法删除");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
messageService.show({
|
||||
title: "确认删除",
|
||||
message: `确定要删除文档"${name}"吗?`,
|
||||
@@ -511,8 +511,7 @@ export default function DocumentsIndex() {
|
||||
return;
|
||||
}
|
||||
|
||||
const urlBefore = 'http://172.18.0.100:9000/docauditai/';
|
||||
const downloadUrl = `${urlBefore}${doc.path}`;
|
||||
const downloadUrl = `${DOCUMENT_URL}${doc.path}`;
|
||||
|
||||
// 获取文件内容
|
||||
const response = await fetch(downloadUrl);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { getDocumentTypes } from "~/api/document-types/document-types";
|
||||
import { FileTag } from "~/components/ui/FileTag";
|
||||
import { toastService } from "~/components/ui/Toast";
|
||||
import { Document, Page , pdfjs } from "react-pdf";
|
||||
import { DOCUMENT_URL } from "~/api/client";
|
||||
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = '/pdf.worker.js';
|
||||
|
||||
@@ -302,7 +303,7 @@ export default function DocumentEdit() {
|
||||
return (
|
||||
<div className="preview-content relative overflow-y-auto max-h-[1000px]">
|
||||
<Document
|
||||
file={'http://172.18.0.100:9000/docauditai/'+document.path}
|
||||
file={DOCUMENT_URL + document.path}
|
||||
onLoadSuccess={onDocumentLoadSuccess}
|
||||
onLoadError={(error) => {
|
||||
console.error("PDF加载错误:", error);
|
||||
@@ -394,8 +395,7 @@ export default function DocumentEdit() {
|
||||
|
||||
// 在新窗口打开文档预览
|
||||
const openPreview = () => {
|
||||
const urlBefore = 'http://172.18.0.100:9000/docauditai/'
|
||||
const previewUrl = `${urlBefore}${document.path}`;
|
||||
const previewUrl = `${DOCUMENT_URL}${document.path}`;
|
||||
window.open(previewUrl, '_blank');
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from "~/api/evaluation_points/rules-files";
|
||||
import { getDocumentTypes } from "~/api/document-types/document-types";
|
||||
import { toastService } from "~/components/ui/Toast";
|
||||
import { DOCUMENT_URL } from "~/api/client";
|
||||
|
||||
export const links = () => [
|
||||
{ rel: "stylesheet", href: rulesFilesStyles }
|
||||
@@ -240,8 +241,7 @@ export default function RulesFiles() {
|
||||
// 下载文件
|
||||
const handleDownload = async (path: string) => {
|
||||
try {
|
||||
const urlBefore = 'http://172.18.0.100:9000/docauditai/';
|
||||
const downloadUrl = `${urlBefore}${path}`;
|
||||
const downloadUrl = `${DOCUMENT_URL}${path}`;
|
||||
|
||||
// 使用fetch获取文件内容
|
||||
const response = await fetch(downloadUrl);
|
||||
|
||||
@@ -65,7 +65,8 @@
|
||||
border-top: none;
|
||||
border-bottom-left-radius: 6px;
|
||||
border-bottom-right-radius: 6px;
|
||||
padding: 20px;
|
||||
/* padding: 3px; */
|
||||
/* padding: 20px; */
|
||||
}
|
||||
|
||||
/* 文件预览区域 */
|
||||
|
||||
Reference in New Issue
Block a user