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