优化评查详情中用户操作的更新刷新为热更新
This commit is contained in:
@@ -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 {
|
||||
fileInfo: {
|
||||
@@ -19,66 +15,8 @@ interface FileInfoProps {
|
||||
onConfirmResults: () => void;
|
||||
}
|
||||
|
||||
export function FileInfo({ fileInfo, onConfirmResults }: FileInfoProps) {
|
||||
const navigate = useNavigate();
|
||||
const [isNavigating, setIsNavigating] = useState(false);
|
||||
export function FileInfo({ fileInfo }: FileInfoProps) {
|
||||
|
||||
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 = () => {
|
||||
// alert('导出评查报告功能');
|
||||
@@ -105,34 +43,6 @@ export function FileInfo({ fileInfo, onConfirmResults }: FileInfoProps) {
|
||||
</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>
|
||||
);
|
||||
|
||||
@@ -129,6 +129,10 @@ export function ReviewPointsList({
|
||||
const handleReviewAction = (reviewPointResultId: string, editAuditStatusId: string | number | undefined, action: 'approve' | 'reject' | 'review', message: string) => {
|
||||
// 更新评查点状态
|
||||
// console.log('handleReviewAction-------', reviewPointResultId, editAuditStatusId, action, message);
|
||||
if(message.trim() === ''){
|
||||
toastService.error('请输入审核意见');
|
||||
return;
|
||||
}
|
||||
if (action === 'review') {
|
||||
// 重新审核时,不更新结果状态,只更新审核意见和审核状态
|
||||
// console.log('重新审核-------', reviewPointResultId, editAuditStatusId || '', 'review', message);
|
||||
@@ -592,13 +596,13 @@ export function ReviewPointsList({
|
||||
{reviewPoint.editAuditStatus === 0 ? (
|
||||
<div className="w-full flex justify-end gap-2">
|
||||
<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)}
|
||||
>
|
||||
<i className="ri-check-line mr-1"></i> 通过
|
||||
</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)}
|
||||
>
|
||||
<i className="ri-close-line mr-1"></i> 不通过
|
||||
@@ -606,7 +610,7 @@ export function ReviewPointsList({
|
||||
</div>
|
||||
) : (
|
||||
<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)}
|
||||
>
|
||||
<i className="ri-refresh-line mr-1"></i> 重新审核
|
||||
|
||||
@@ -2,42 +2,146 @@
|
||||
* 评查选项卡组件
|
||||
* 提供三个选项卡:评查结果、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 {
|
||||
activeTab: string;
|
||||
onTabChange: (tabKey: string) => void;
|
||||
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 (
|
||||
<div className="tab-container w-full flex-1">
|
||||
<div className="tab-nav w-full flex">
|
||||
<button
|
||||
className={`tab-nav-item ${activeTab === 'preview' ? 'active' : ''}`}
|
||||
onClick={() => onTabChange('preview')}
|
||||
type="button"
|
||||
aria-pressed={activeTab === 'preview'}
|
||||
>
|
||||
<i className="ri-file-text-line"></i> 评查结果
|
||||
</button>
|
||||
{/* <button
|
||||
className={`tab-nav-item ${activeTab === 'analysis' ? 'active' : ''}`}
|
||||
onClick={() => onTabChange('analysis')}
|
||||
type="button"
|
||||
aria-pressed={activeTab === 'analysis'}
|
||||
>
|
||||
<i className="ri-lightbulb-line"></i> AI智能分析
|
||||
</button> */}
|
||||
<button
|
||||
className={`tab-nav-item ${activeTab === 'fileinfo' ? 'active' : ''}`}
|
||||
onClick={() => onTabChange('fileinfo')}
|
||||
type="button"
|
||||
aria-pressed={activeTab === 'fileinfo'}
|
||||
>
|
||||
<i className="ri-information-line"></i> 文件信息
|
||||
</button>
|
||||
<div className="tab-nav w-full flex justify-between">
|
||||
{/* 评查结果、AI智能分析、文件信息 */}
|
||||
<div className="flex">
|
||||
<button
|
||||
className={`tab-nav-item ${activeTab === 'preview' ? 'active' : ''}`}
|
||||
onClick={() => onTabChange('preview')}
|
||||
type="button"
|
||||
aria-pressed={activeTab === 'preview'}
|
||||
>
|
||||
<i className="ri-file-text-line"></i> 评查结果
|
||||
</button>
|
||||
{/* <button
|
||||
className={`tab-nav-item ${activeTab === 'analysis' ? 'active' : ''}`}
|
||||
onClick={() => onTabChange('analysis')}
|
||||
type="button"
|
||||
aria-pressed={activeTab === 'analysis'}
|
||||
>
|
||||
<i className="ri-lightbulb-line"></i> AI智能分析
|
||||
</button> */}
|
||||
<button
|
||||
className={`tab-nav-item ${activeTab === 'fileinfo' ? 'active' : ''}`}
|
||||
onClick={() => onTabChange('fileinfo')}
|
||||
type="button"
|
||||
aria-pressed={activeTab === 'fileinfo'}
|
||||
>
|
||||
<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 className="tab-content w-full">
|
||||
|
||||
Reference in New Issue
Block a user