优化评查详情中用户操作的更新刷新为热更新
This commit is contained in:
@@ -18,6 +18,7 @@ interface PreviousRouteData {
|
|||||||
interface Handle {
|
interface Handle {
|
||||||
breadcrumb: string | ((data: unknown) => string);
|
breadcrumb: string | ((data: unknown) => string);
|
||||||
previousRoute?: PreviousRouteData | ((data: unknown) => PreviousRouteData | undefined);
|
previousRoute?: PreviousRouteData | ((data: unknown) => PreviousRouteData | undefined);
|
||||||
|
breadcrumbClassName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Match {
|
interface Match {
|
||||||
@@ -64,12 +65,22 @@ export function Breadcrumb({ items = [], className = '' }: BreadcrumbProps) {
|
|||||||
})
|
})
|
||||||
.flat(); // 扁平化数组
|
.flat(); // 扁平化数组
|
||||||
|
|
||||||
|
// 获取自定义类名
|
||||||
|
const getCustomClassName = () => {
|
||||||
|
const lastMatch = matches[matches.length - 1];
|
||||||
|
return lastMatch?.handle?.breadcrumbClassName || '';
|
||||||
|
};
|
||||||
|
|
||||||
if (breadcrumbs.length === 0) {
|
if (breadcrumbs.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 应用自定义类名
|
||||||
|
const customClassName = getCustomClassName();
|
||||||
|
const finalClassName = `mb-4 ${className} ${customClassName}`.trim();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className={`mb-4 ${className}`} aria-label="面包屑导航">
|
<nav className={finalClassName} aria-label="面包屑导航">
|
||||||
<ol className="flex items-center space-x-2 text-sm text-gray-500">
|
<ol className="flex items-center space-x-2 text-sm text-gray-500">
|
||||||
<li>
|
<li>
|
||||||
<Link to="/" className="hover:text-primary-600 flex items-center">
|
<Link to="/" className="hover:text-primary-600 flex items-center">
|
||||||
|
|||||||
@@ -1,14 +1,33 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Sidebar } from './Sidebar';
|
import { Sidebar } from './Sidebar';
|
||||||
import { Header } from './Header';
|
// import { Header } from './Header';
|
||||||
import { Breadcrumb } from './Breadcrumb';
|
import { Breadcrumb } from './Breadcrumb';
|
||||||
|
import { useMatches } from '@remix-run/react';
|
||||||
|
|
||||||
interface LayoutProps {
|
interface LayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加一个接口表示路由handle可能包含的属性
|
||||||
|
interface RouteHandle {
|
||||||
|
hideBreadcrumb?: boolean;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Match {
|
||||||
|
handle?: RouteHandle;
|
||||||
|
pathname: string;
|
||||||
|
data: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
export function Layout({ children }: LayoutProps) {
|
export function Layout({ children }: LayoutProps) {
|
||||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
||||||
|
const matches = useMatches() as Match[];
|
||||||
|
|
||||||
|
// 检查当前路由是否应该隐藏默认面包屑
|
||||||
|
const shouldHideBreadcrumb = matches.some(match =>
|
||||||
|
match.handle && match.handle.hideBreadcrumb === true
|
||||||
|
);
|
||||||
|
|
||||||
// 从本地存储中获取侧边栏状态
|
// 从本地存储中获取侧边栏状态
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -34,7 +53,7 @@ export function Layout({ children }: LayoutProps) {
|
|||||||
<div className={`main-content ${sidebarCollapsed ? 'sidebar-collapsed' : ''}`}>
|
<div className={`main-content ${sidebarCollapsed ? 'sidebar-collapsed' : ''}`}>
|
||||||
{/* <Header username="系统管理员" /> */}
|
{/* <Header username="系统管理员" /> */}
|
||||||
<div className="content-container">
|
<div className="content-container">
|
||||||
<Breadcrumb />
|
{!shouldHideBreadcrumb && <Breadcrumb />}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import { useNavigate } from "@remix-run/react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { loadingBarService } from "~/components/ui/LoadingBar";
|
|
||||||
import { DOCUMENT_URL } from "~/api/client";
|
|
||||||
|
|
||||||
interface FileInfoProps {
|
interface FileInfoProps {
|
||||||
fileInfo: {
|
fileInfo: {
|
||||||
@@ -19,66 +15,8 @@ interface FileInfoProps {
|
|||||||
onConfirmResults: () => void;
|
onConfirmResults: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FileInfo({ fileInfo, onConfirmResults }: FileInfoProps) {
|
export function FileInfo({ fileInfo }: FileInfoProps) {
|
||||||
const navigate = useNavigate();
|
|
||||||
const [isNavigating, setIsNavigating] = useState(false);
|
|
||||||
|
|
||||||
const handleDownloadFile = async () => {
|
|
||||||
try {
|
|
||||||
const downloadUrl = `${DOCUMENT_URL}${fileInfo.path}`;
|
|
||||||
|
|
||||||
// 使用fetch获取文件内容
|
|
||||||
const response = await fetch(downloadUrl);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`下载失败: ${response.status} ${response.statusText}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将响应转换为Blob
|
|
||||||
const blob = await response.blob();
|
|
||||||
|
|
||||||
// 创建Blob URL
|
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
|
||||||
|
|
||||||
// 创建一个隐藏的a标签并点击它
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.style.display = 'none';
|
|
||||||
a.href = blobUrl;
|
|
||||||
// 从路径中获取文件名
|
|
||||||
const fileName = fileInfo.path?.split('/').pop() || 'document';
|
|
||||||
a.download = decodeURIComponent(fileName);
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
|
|
||||||
// 清理
|
|
||||||
setTimeout(() => {
|
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(blobUrl);
|
|
||||||
}, 100);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('下载文件失败:', error);
|
|
||||||
alert(`下载文件失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleBack = () => {
|
|
||||||
// 防抖处理 - 如果已经在导航中,不重复触发
|
|
||||||
if (isNavigating) return;
|
|
||||||
|
|
||||||
// 设置导航状态为true
|
|
||||||
setIsNavigating(true);
|
|
||||||
loadingBarService.show();
|
|
||||||
|
|
||||||
// 根据来源页面返回
|
|
||||||
const previousRoute = fileInfo.previousRoute || 'documents';
|
|
||||||
const returnTo = previousRoute === 'documents'
|
|
||||||
? "/documents"
|
|
||||||
: previousRoute === 'filesUpload'
|
|
||||||
? "/files/upload"
|
|
||||||
: "/rules-files";
|
|
||||||
|
|
||||||
// 立即导航返回
|
|
||||||
navigate(returnTo);
|
|
||||||
};
|
|
||||||
|
|
||||||
// const handleExportReport = () => {
|
// const handleExportReport = () => {
|
||||||
// alert('导出评查报告功能');
|
// alert('导出评查报告功能');
|
||||||
@@ -105,34 +43,6 @@ export function FileInfo({ fileInfo, onConfirmResults }: FileInfoProps) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex space-x-3">
|
|
||||||
{/* 返回上一级 */}
|
|
||||||
<button
|
|
||||||
className="ant-btn ant-btn-default flex items-center"
|
|
||||||
onClick={() => handleBack()}
|
|
||||||
disabled={isNavigating}
|
|
||||||
>
|
|
||||||
<i className="ri-arrow-left-line mr-1"></i> {isNavigating ? '返回中...' : '返回'}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="ant-btn ant-btn-default flex items-center"
|
|
||||||
onClick={handleDownloadFile}
|
|
||||||
>
|
|
||||||
<i className="ri-file-download-line mr-1"></i> 下载原文件
|
|
||||||
</button>
|
|
||||||
{/* <button
|
|
||||||
className="ant-btn ant-btn-default flex items-center"
|
|
||||||
onClick={handleExportReport}
|
|
||||||
>
|
|
||||||
<i className="ri-file-copy-line mr-1"></i> 导出评查报告
|
|
||||||
</button> */}
|
|
||||||
<button
|
|
||||||
className={`ant-btn ant-btn-primary flex items-center ${fileInfo.auditStatus === 1 ? 'hidden' : ''}`}
|
|
||||||
onClick={onConfirmResults}
|
|
||||||
>
|
|
||||||
<i className="ri-check-double-line mr-1"></i> 确认评查结果
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ export function ReviewPointsList({
|
|||||||
const handleReviewAction = (reviewPointResultId: string, editAuditStatusId: string | number | undefined, action: 'approve' | 'reject' | 'review', message: string) => {
|
const handleReviewAction = (reviewPointResultId: string, editAuditStatusId: string | number | undefined, action: 'approve' | 'reject' | 'review', message: string) => {
|
||||||
// 更新评查点状态
|
// 更新评查点状态
|
||||||
// console.log('handleReviewAction-------', reviewPointResultId, editAuditStatusId, action, message);
|
// console.log('handleReviewAction-------', reviewPointResultId, editAuditStatusId, action, message);
|
||||||
|
if(message.trim() === ''){
|
||||||
|
toastService.error('请输入审核意见');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (action === 'review') {
|
if (action === 'review') {
|
||||||
// 重新审核时,不更新结果状态,只更新审核意见和审核状态
|
// 重新审核时,不更新结果状态,只更新审核意见和审核状态
|
||||||
// console.log('重新审核-------', reviewPointResultId, editAuditStatusId || '', 'review', message);
|
// console.log('重新审核-------', reviewPointResultId, editAuditStatusId || '', 'review', message);
|
||||||
@@ -592,13 +596,13 @@ export function ReviewPointsList({
|
|||||||
{reviewPoint.editAuditStatus === 0 ? (
|
{reviewPoint.editAuditStatus === 0 ? (
|
||||||
<div className="w-full flex justify-end gap-2">
|
<div className="w-full flex justify-end gap-2">
|
||||||
<button
|
<button
|
||||||
className="bg-[#1890ff] hover:bg-blue-600 text-xs text-white py-1 px-2 rounded-md flex items-center justify-center"
|
className="bg-[#1890ff] hover:bg-blue-600 text-sm text-white py-1 px-2 rounded-md flex items-center justify-center"
|
||||||
onClick={() => handleReviewAction(reviewPoint.id, reviewPoint.editAuditStatusId, 'approve', note)}
|
onClick={() => handleReviewAction(reviewPoint.id, reviewPoint.editAuditStatusId, 'approve', note)}
|
||||||
>
|
>
|
||||||
<i className="ri-check-line mr-1"></i> 通过
|
<i className="ri-check-line mr-1"></i> 通过
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="bg-[#f5222d] hover:bg-red-600 text-xs text-white py-1 px-2 rounded-md flex items-center justify-center"
|
className="bg-[#f5222d] hover:bg-red-600 text-sm text-white py-1 px-2 rounded-md flex items-center justify-center"
|
||||||
onClick={() => handleReviewAction(reviewPoint.id, reviewPoint.editAuditStatusId, 'reject', note)}
|
onClick={() => handleReviewAction(reviewPoint.id, reviewPoint.editAuditStatusId, 'reject', note)}
|
||||||
>
|
>
|
||||||
<i className="ri-close-line mr-1"></i> 不通过
|
<i className="ri-close-line mr-1"></i> 不通过
|
||||||
@@ -606,7 +610,7 @@ export function ReviewPointsList({
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<button
|
<button
|
||||||
className="bg-purple-600 hover:bg-purple-700 text-xs text-white py-1 px-2 rounded-md flex items-center justify-center"
|
className="bg-purple-600 hover:bg-purple-700 text-sm text-white py-1 px-2 rounded-md flex items-center justify-center"
|
||||||
onClick={() => handleReviewAction(reviewPoint.id, reviewPoint.editAuditStatusId, 'review', note)}
|
onClick={() => handleReviewAction(reviewPoint.id, reviewPoint.editAuditStatusId, 'review', note)}
|
||||||
>
|
>
|
||||||
<i className="ri-refresh-line mr-1"></i> 重新审核
|
<i className="ri-refresh-line mr-1"></i> 重新审核
|
||||||
|
|||||||
@@ -2,42 +2,146 @@
|
|||||||
* 评查选项卡组件
|
* 评查选项卡组件
|
||||||
* 提供三个选项卡:评查结果、AI智能分析、文件信息
|
* 提供三个选项卡:评查结果、AI智能分析、文件信息
|
||||||
*/
|
*/
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { loadingBarService } from '~/components/ui/LoadingBar';
|
||||||
|
import { DOCUMENT_URL } from "~/api/client";
|
||||||
|
|
||||||
interface ReviewTabsProps {
|
interface ReviewTabsProps {
|
||||||
activeTab: string;
|
activeTab: string;
|
||||||
onTabChange: (tabKey: string) => void;
|
onTabChange: (tabKey: string) => void;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
|
fileInfo: {
|
||||||
|
previousRoute?: string;
|
||||||
|
path?: string;
|
||||||
|
auditStatus?: number;
|
||||||
|
};
|
||||||
|
onConfirmResults: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ReviewTabs({ activeTab, onTabChange, children }: ReviewTabsProps) {
|
export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfirmResults }: ReviewTabsProps) {
|
||||||
|
const [isNavigating, setIsNavigating] = useState(false);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
// 返回上一级
|
||||||
|
const handleBack = () => {
|
||||||
|
// 防抖处理 - 如果已经在导航中,不重复触发
|
||||||
|
if (isNavigating) return;
|
||||||
|
|
||||||
|
// 设置导航状态为true
|
||||||
|
setIsNavigating(true);
|
||||||
|
loadingBarService.show();
|
||||||
|
|
||||||
|
// 根据来源页面返回
|
||||||
|
const previousRoute = fileInfo.previousRoute || 'documents';
|
||||||
|
const returnTo = previousRoute === 'documents'
|
||||||
|
? "/documents"
|
||||||
|
: previousRoute === 'filesUpload'
|
||||||
|
? "/files/upload"
|
||||||
|
: "/rules-files";
|
||||||
|
|
||||||
|
// 立即导航返回
|
||||||
|
navigate(returnTo);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 下载原文件
|
||||||
|
const handleDownloadFile = async () => {
|
||||||
|
try {
|
||||||
|
const downloadUrl = `${DOCUMENT_URL}${fileInfo.path}`;
|
||||||
|
|
||||||
|
// 使用fetch获取文件内容
|
||||||
|
const response = await fetch(downloadUrl);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`下载失败: ${response.status} ${response.statusText}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将响应转换为Blob
|
||||||
|
const blob = await response.blob();
|
||||||
|
|
||||||
|
// 创建Blob URL
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
// 创建一个隐藏的a标签并点击它
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.style.display = 'none';
|
||||||
|
a.href = blobUrl;
|
||||||
|
// 从路径中获取文件名
|
||||||
|
const fileName = fileInfo.path?.split('/').pop() || 'document';
|
||||||
|
a.download = decodeURIComponent(fileName);
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
|
||||||
|
// 清理
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(a);
|
||||||
|
URL.revokeObjectURL(blobUrl);
|
||||||
|
}, 100);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('下载文件失败:', error);
|
||||||
|
alert(`下载文件失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="tab-container w-full flex-1">
|
<div className="tab-container w-full flex-1">
|
||||||
<div className="tab-nav w-full flex">
|
<div className="tab-nav w-full flex justify-between">
|
||||||
<button
|
{/* 评查结果、AI智能分析、文件信息 */}
|
||||||
className={`tab-nav-item ${activeTab === 'preview' ? 'active' : ''}`}
|
<div className="flex">
|
||||||
onClick={() => onTabChange('preview')}
|
<button
|
||||||
type="button"
|
className={`tab-nav-item ${activeTab === 'preview' ? 'active' : ''}`}
|
||||||
aria-pressed={activeTab === 'preview'}
|
onClick={() => onTabChange('preview')}
|
||||||
>
|
type="button"
|
||||||
<i className="ri-file-text-line"></i> 评查结果
|
aria-pressed={activeTab === 'preview'}
|
||||||
</button>
|
>
|
||||||
{/* <button
|
<i className="ri-file-text-line"></i> 评查结果
|
||||||
className={`tab-nav-item ${activeTab === 'analysis' ? 'active' : ''}`}
|
</button>
|
||||||
onClick={() => onTabChange('analysis')}
|
{/* <button
|
||||||
type="button"
|
className={`tab-nav-item ${activeTab === 'analysis' ? 'active' : ''}`}
|
||||||
aria-pressed={activeTab === 'analysis'}
|
onClick={() => onTabChange('analysis')}
|
||||||
>
|
type="button"
|
||||||
<i className="ri-lightbulb-line"></i> AI智能分析
|
aria-pressed={activeTab === 'analysis'}
|
||||||
</button> */}
|
>
|
||||||
<button
|
<i className="ri-lightbulb-line"></i> AI智能分析
|
||||||
className={`tab-nav-item ${activeTab === 'fileinfo' ? 'active' : ''}`}
|
</button> */}
|
||||||
onClick={() => onTabChange('fileinfo')}
|
<button
|
||||||
type="button"
|
className={`tab-nav-item ${activeTab === 'fileinfo' ? 'active' : ''}`}
|
||||||
aria-pressed={activeTab === 'fileinfo'}
|
onClick={() => onTabChange('fileinfo')}
|
||||||
>
|
type="button"
|
||||||
<i className="ri-information-line"></i> 文件信息
|
aria-pressed={activeTab === 'fileinfo'}
|
||||||
</button>
|
>
|
||||||
|
<i className="ri-information-line"></i> 文件信息
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/* 操作按钮 */}
|
||||||
|
<div className="flex space-x-3">
|
||||||
|
{/* 返回上一级 */}
|
||||||
|
<button
|
||||||
|
className="ant-btn ant-btn-default flex items-center my-2"
|
||||||
|
onClick={() => handleBack()}
|
||||||
|
disabled={isNavigating}
|
||||||
|
>
|
||||||
|
<i className="ri-arrow-left-line mr-1"></i> {isNavigating ? '返回中...' : '返回'}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="ant-btn ant-btn-default flex items-center my-2"
|
||||||
|
onClick={handleDownloadFile}
|
||||||
|
>
|
||||||
|
<i className="ri-file-download-line mr-1"></i> 下载原文件
|
||||||
|
</button>
|
||||||
|
{/* <button
|
||||||
|
className="ant-btn ant-btn-default flex items-center"
|
||||||
|
onClick={handleExportReport}
|
||||||
|
>
|
||||||
|
<i className="ri-file-copy-line mr-1"></i> 导出评查报告
|
||||||
|
</button> */}
|
||||||
|
<button
|
||||||
|
className={`ant-btn ant-btn-primary my-2 flex items-center ${fileInfo.auditStatus === 1 ? 'hidden' : ''}`}
|
||||||
|
onClick={onConfirmResults}
|
||||||
|
>
|
||||||
|
<i className="ri-check-double-line mr-1"></i> 确认评查结果
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="tab-content w-full">
|
<div className="tab-content w-full">
|
||||||
|
|||||||
@@ -77,12 +77,9 @@ export async function loader() {
|
|||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
const { homeData, recentFiles } = useLoaderData<typeof loader>();
|
const { homeData, recentFiles } = useLoaderData<typeof loader>();
|
||||||
const [currentDateTime, setCurrentDateTime] = useState<{
|
const [currentDateTime, setCurrentDateTime] = useState({
|
||||||
date: string;
|
date: '',
|
||||||
time: string;
|
time: ''
|
||||||
}>({
|
|
||||||
date: dayjs().format('YYYY年MM月DD日'),
|
|
||||||
time: dayjs().format('HH:mm:ss')
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 更新当前时间
|
// 更新当前时间
|
||||||
|
|||||||
+181
-100
@@ -46,6 +46,7 @@ import {
|
|||||||
import { type ReviewPoint } from '~/components/reviews';
|
import { type ReviewPoint } from '~/components/reviews';
|
||||||
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 { Breadcrumb } from "~/components/layout/Breadcrumb";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件信息组件
|
* 文件信息组件
|
||||||
@@ -151,9 +152,7 @@ interface ReviewData {
|
|||||||
aiAnalysis: AnalysisData;
|
aiAnalysis: AnalysisData;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LoaderData {
|
|
||||||
previousRoute: string;
|
|
||||||
}
|
|
||||||
export const meta: MetaFunction = () => {
|
export const meta: MetaFunction = () => {
|
||||||
return [
|
return [
|
||||||
{ title: "评查详情 - 中国烟草AI合同及卷宗审核系统" },
|
{ title: "评查详情 - 中国烟草AI合同及卷宗审核系统" },
|
||||||
@@ -169,33 +168,9 @@ export function links() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const handle = {
|
export const handle = {
|
||||||
breadcrumb: "评查详情",
|
hideBreadcrumb: true
|
||||||
// 添加一个previousRoute属性用于支持自定义的面包屑导航
|
|
||||||
previousRoute: (data:LoaderData)=>{
|
|
||||||
if(data.previousRoute){
|
|
||||||
if(data.previousRoute === 'filesUpload'){
|
|
||||||
return {
|
|
||||||
title: "文件上传",
|
|
||||||
to: "/files/upload"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(data.previousRoute === 'documents'){
|
|
||||||
return {
|
|
||||||
title: "文档列表",
|
|
||||||
to: "/documents"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(data.previousRoute === 'rulesFiles'){
|
|
||||||
return {
|
|
||||||
title: "评查文件列表",
|
|
||||||
to: "/rules-files"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export async function loader({ request }: LoaderFunctionArgs) {
|
export async function loader({ request }: LoaderFunctionArgs) {
|
||||||
try {
|
try {
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
@@ -320,76 +295,76 @@ export default function ReviewDetails() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 刷新评审数据
|
// 刷新评审数据
|
||||||
async function refreshReviewData(documentId: string) {
|
// async function refreshReviewData(documentId: string) {
|
||||||
// 设置加载状态
|
// // 设置加载状态
|
||||||
setIsLoading(true);
|
// setIsLoading(true);
|
||||||
try {
|
// try {
|
||||||
// 获取最新的评审数据
|
// // 获取最新的评审数据
|
||||||
const response = await getReviewPoints(documentId);
|
// const response = await getReviewPoints(documentId);
|
||||||
|
|
||||||
if ('error' in response && response.error) {
|
// if ('error' in response && response.error) {
|
||||||
console.error('刷新评审数据失败:', response.error);
|
// console.error('刷新评审数据失败:', response.error);
|
||||||
alert(`刷新评审数据失败: ${response.error}`);
|
// toastService.error(`刷新评审数据失败: ${response.error}`);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 确保response有效且具有预期的属性
|
// // 确保response有效且具有预期的属性
|
||||||
if ('data' in response && 'stats' in response && 'reviewInfo' in response) {
|
// if ('data' in response && 'stats' in response && 'reviewInfo' in response) {
|
||||||
const reviewPointsData = response.data || [];
|
// const reviewPointsData = response.data || [];
|
||||||
const statisticsData = response.stats || { total: 0, success: 0, warning: 0, error: 0, score: 0 };
|
// const statisticsData = response.stats || { total: 0, success: 0, warning: 0, error: 0, score: 0 };
|
||||||
const reviewInfoData = response.reviewInfo || {
|
// const reviewInfoData = response.reviewInfo || {
|
||||||
reviewTime: '',
|
// reviewTime: '',
|
||||||
reviewModel: '',
|
// reviewModel: '',
|
||||||
ruleGroup: '',
|
// ruleGroup: '',
|
||||||
result: '',
|
// result: '',
|
||||||
issueCount: 0
|
// issueCount: 0
|
||||||
};
|
// };
|
||||||
|
|
||||||
// 更新评审数据和统计信息
|
// // 更新评审数据和统计信息
|
||||||
setReviewData(prevData => {
|
// setReviewData(prevData => {
|
||||||
if (!prevData) {
|
// if (!prevData) {
|
||||||
// 如果prevData为null,创建一个新的ReviewData对象
|
// // 如果prevData为null,创建一个新的ReviewData对象
|
||||||
return {
|
// return {
|
||||||
fileInfo: {
|
// fileInfo: {
|
||||||
fileName: document?.name || "",
|
// fileName: document?.name || "",
|
||||||
contractNumber: document?.documentNumber || "",
|
// contractNumber: document?.documentNumber || "",
|
||||||
fileSize: document?.size ? formatFileSize(document.size) : "",
|
// fileSize: document?.size ? formatFileSize(document.size) : "",
|
||||||
fileFormat: document?.fileType ? document.fileType.toUpperCase() : "",
|
// fileFormat: document?.fileType ? document.fileType.toUpperCase() : "",
|
||||||
pageCount: document?.pageCount || 0,
|
// pageCount: document?.pageCount || 0,
|
||||||
uploadTime: document?.uploadTime || "",
|
// uploadTime: document?.uploadTime || "",
|
||||||
uploadUser: document?.uploadUser || "",
|
// uploadUser: document?.uploadUser || "",
|
||||||
auditStatus: document?.auditStatus || 0
|
// auditStatus: document?.auditStatus || 0
|
||||||
},
|
// },
|
||||||
contractInfo: getMockReviewData().contractInfo,
|
// contractInfo: getMockReviewData().contractInfo,
|
||||||
reviewInfo: reviewInfoData as ReviewInfo,
|
// reviewInfo: reviewInfoData as ReviewInfo,
|
||||||
statistics: statisticsData as Statistics,
|
// statistics: statisticsData as Statistics,
|
||||||
fileContent: getMockReviewData().fileContent,
|
// fileContent: getMockReviewData().fileContent,
|
||||||
reviewPoints: reviewPointsData as unknown as ReviewPoint[],
|
// reviewPoints: reviewPointsData as unknown as ReviewPoint[],
|
||||||
aiAnalysis: getMockReviewData().aiAnalysis
|
// aiAnalysis: getMockReviewData().aiAnalysis
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 处理prevData非null的情况
|
// // 处理prevData非null的情况
|
||||||
return {
|
// return {
|
||||||
...prevData,
|
// ...prevData,
|
||||||
reviewPoints: reviewPointsData as unknown as ReviewPoint[],
|
// reviewPoints: reviewPointsData as unknown as ReviewPoint[],
|
||||||
statistics: statisticsData as Statistics,
|
// statistics: statisticsData as Statistics,
|
||||||
reviewInfo: reviewInfoData as ReviewInfo
|
// reviewInfo: reviewInfoData as ReviewInfo
|
||||||
};
|
// };
|
||||||
});
|
// });
|
||||||
|
|
||||||
toastService.success('评审数据已更新');
|
// toastService.success('评审数据已更新');
|
||||||
} else {
|
// } else {
|
||||||
console.error('返回的数据格式不正确');
|
// console.error('返回的数据格式不正确');
|
||||||
toastService.error('刷新评审数据失败: 返回的数据格式不正确');
|
// toastService.error('刷新评审数据失败: 返回的数据格式不正确');
|
||||||
}
|
// }
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('刷新评审数据失败:', error);
|
// console.error('刷新评审数据失败:', error);
|
||||||
toastService.error(`刷新评审数据失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
// toastService.error(`刷新评审数据失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
||||||
} finally {
|
// } finally {
|
||||||
setIsLoading(false);
|
// setIsLoading(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 处理评审点状态变更
|
// 处理评审点状态变更
|
||||||
const handleReviewPointStatusChange = async (reviewPointResultId: string, editAuditStatusId: string | number, newStatus: string, message: string) => {
|
const handleReviewPointStatusChange = async (reviewPointResultId: string, editAuditStatusId: string | number, newStatus: string, message: string) => {
|
||||||
@@ -417,25 +392,66 @@ export default function ReviewDetails() {
|
|||||||
|
|
||||||
// 更新本地状态
|
// 更新本地状态
|
||||||
if (reviewData) {
|
if (reviewData) {
|
||||||
|
// 找到要更新的评查点和它的原始状态
|
||||||
|
const reviewPointToUpdate = reviewData.reviewPoints.find(point => point.id === reviewPointResultId);
|
||||||
|
const oldStatus = reviewPointToUpdate?.status || '';
|
||||||
|
const wasSuccess = reviewPointToUpdate?.result === true;
|
||||||
|
const newIsSuccess = newStatus === 'true';
|
||||||
|
|
||||||
|
// 更新评查点
|
||||||
const updatedReviewPoints = reviewData.reviewPoints.map(point =>
|
const updatedReviewPoints = reviewData.reviewPoints.map(point =>
|
||||||
point.id === reviewPointResultId ? {
|
point.id === reviewPointResultId ? {
|
||||||
...point,
|
...point,
|
||||||
result: newStatus === 'true' ? true : (newStatus === 'false' ? false : point.result),
|
result: newStatus === 'true' ? true : (newStatus === 'false' ? false : point.result),
|
||||||
message: message
|
editAuditStatus: boolResult === 'review' ? 0 : 1,
|
||||||
|
title: message
|
||||||
} : point
|
} : point
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 更新统计数据
|
||||||
|
const updatedStatistics = { ...reviewData.statistics };
|
||||||
|
|
||||||
|
// 只处理结果实际变化的情况,即从通过变为不通过,或从不通过变为通过
|
||||||
|
if (newStatus !== 'review' && wasSuccess !== newIsSuccess) {
|
||||||
|
if (newIsSuccess) {
|
||||||
|
// 从不通过变为通过
|
||||||
|
updatedStatistics.success += 1;
|
||||||
|
// 减少对应的错误或警告数量
|
||||||
|
if (oldStatus === 'warning') {
|
||||||
|
updatedStatistics.warning = Math.max(0, updatedStatistics.warning - 1);
|
||||||
|
} else if (oldStatus === 'error') {
|
||||||
|
updatedStatistics.error = Math.max(0, updatedStatistics.error - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 从通过变为不通过
|
||||||
|
updatedStatistics.success = Math.max(0, updatedStatistics.success - 1);
|
||||||
|
// 增加对应的错误或警告数量
|
||||||
|
if (oldStatus === 'warning') {
|
||||||
|
updatedStatistics.warning += 1;
|
||||||
|
} else if (oldStatus === 'error') {
|
||||||
|
updatedStatistics.error += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 更新 UI 状态
|
// 更新 UI 状态
|
||||||
setReviewData({
|
setReviewData({
|
||||||
...reviewData,
|
...reviewData,
|
||||||
reviewPoints: updatedReviewPoints,
|
reviewPoints: updatedReviewPoints,
|
||||||
// statistics: calculateStatistics(updatedReviewPoints)
|
statistics: updatedStatistics
|
||||||
});
|
});
|
||||||
|
|
||||||
// 从API获取最新数据刷新列表
|
// 显示成功消息
|
||||||
if (document && document.id && newStatus !== 'review') {
|
if(document && document.id && newStatus !== 'review'){
|
||||||
await refreshReviewData(document.id.toString());
|
toastService.success('评查点状态已更新');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("newReviewPoints",updatedReviewPoints);
|
||||||
|
|
||||||
|
// 如果是review操作才调用API刷新
|
||||||
|
// if (document && document.id && newStatus === 'review') {
|
||||||
|
// await refreshReviewData(document.id.toString());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('更新评查结果出错:', error);
|
console.error('更新评查结果出错:', error);
|
||||||
@@ -475,6 +491,26 @@ export default function ReviewDetails() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 构建自定义面包屑项
|
||||||
|
const getBreadcrumbItems = () => {
|
||||||
|
const items = [
|
||||||
|
{ title: "评查详情", to: `/reviews?id=${document?.id}` }
|
||||||
|
];
|
||||||
|
|
||||||
|
// 添加前置路由
|
||||||
|
if (loaderData.previousRoute) {
|
||||||
|
if (loaderData.previousRoute === 'filesUpload') {
|
||||||
|
items.unshift({ title: "文件上传", to: "/files/upload" });
|
||||||
|
} else if (loaderData.previousRoute === 'documents') {
|
||||||
|
items.unshift({ title: "文档列表", to: "/documents" });
|
||||||
|
} else if (loaderData.previousRoute === 'rulesFiles') {
|
||||||
|
items.unshift({ title: "评查文件列表", to: "/rules-files" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
@@ -484,19 +520,64 @@ export default function ReviewDetails() {
|
|||||||
</div>
|
</div>
|
||||||
) : reviewData && (
|
) : reviewData && (
|
||||||
<>
|
<>
|
||||||
|
{/* 自定义面包屑 */}
|
||||||
|
<div className="flex justify-between items-center mb-2">
|
||||||
|
<Breadcrumb
|
||||||
|
items={getBreadcrumbItems()}
|
||||||
|
className="items-center flex !mb-0"
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 在面包屑右侧显示精简版的FileInfo */}
|
||||||
|
<div className=" ml-10 text-left flex-1 flex flex-row flex-wrap">
|
||||||
|
<span className="text-xl font-medium">
|
||||||
|
{reviewData.fileInfo.fileName}
|
||||||
|
</span>
|
||||||
|
<div className="ml-2 text-xs text-gray-500 flex items-center">
|
||||||
|
合同编号:{reviewData.fileInfo.contractNumber}
|
||||||
|
{reviewData.fileInfo.fileSize && (
|
||||||
|
<span className="text-xs text-gray-500 ml-2">
|
||||||
|
| {reviewData.fileInfo.fileSize} | {reviewData.fileInfo.fileFormat} | {reviewData.fileInfo.pageCount}页
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{reviewData.fileInfo.uploadTime && (
|
||||||
|
<div className="text-xs text-gray-500">
|
||||||
|
| 上传时间:{reviewData.fileInfo.uploadTime} | 上传用户:{reviewData.fileInfo.uploadUser}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <div className="text-xs text-gray-500 flex items-center mb-1">
|
||||||
|
合同编号:{reviewData.fileInfo.contractNumber}
|
||||||
|
{reviewData.fileInfo.fileSize && (
|
||||||
|
<span className="text-xs text-gray-500 ml-2">
|
||||||
|
| {reviewData.fileInfo.fileSize} | {reviewData.fileInfo.fileFormat} | {reviewData.fileInfo.pageCount}页
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{reviewData.fileInfo.uploadTime && (
|
||||||
|
<div className="text-xs text-gray-500">
|
||||||
|
| 上传时间:{reviewData.fileInfo.uploadTime} | 上传用户:{reviewData.fileInfo.uploadUser}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div> */}
|
||||||
|
|
||||||
{/* 文件信息和操作按钮 */}
|
{/* 文件信息和操作按钮 */}
|
||||||
<FileInfo
|
{/* <FileInfo
|
||||||
fileInfo={{
|
fileInfo={{
|
||||||
...reviewData.fileInfo,
|
...reviewData.fileInfo,
|
||||||
previousRoute: loaderData.previousRoute
|
previousRoute: loaderData.previousRoute
|
||||||
}}
|
}}
|
||||||
onConfirmResults={handleConfirmResults}
|
onConfirmResults={handleConfirmResults}
|
||||||
/>
|
/> */}
|
||||||
|
|
||||||
{/* 选项卡 */}
|
{/* 选项卡 */}
|
||||||
<ReviewTabs
|
<ReviewTabs
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
onTabChange={handleTabChange}
|
onTabChange={handleTabChange}
|
||||||
|
fileInfo={{
|
||||||
|
previousRoute: loaderData.previousRoute
|
||||||
|
}}
|
||||||
|
onConfirmResults={handleConfirmResults}
|
||||||
>
|
>
|
||||||
{/* 评查结果选项卡内容 */}
|
{/* 评查结果选项卡内容 */}
|
||||||
{activeTab === 'preview' && (
|
{activeTab === 'preview' && (
|
||||||
|
|||||||
Reference in New Issue
Block a user