From 5c096ae753737b9b0f086903683c962ee476b87c Mon Sep 17 00:00:00 2001 From: ntnt Date: Sat, 14 Mar 2026 00:35:15 +0800 Subject: [PATCH] fix: reports --- frontend/src/pages/analysis/Analysis.tsx | 57 ++---------------------- frontend/src/pages/reports/Reports.tsx | 14 +++++- 2 files changed, 16 insertions(+), 55 deletions(-) diff --git a/frontend/src/pages/analysis/Analysis.tsx b/frontend/src/pages/analysis/Analysis.tsx index 7933efb..46175c2 100644 --- a/frontend/src/pages/analysis/Analysis.tsx +++ b/frontend/src/pages/analysis/Analysis.tsx @@ -1,14 +1,13 @@ import React, { useMemo } from 'react'; import { useParams } from 'react-router-dom'; -import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { App, Card, Row, Col, Tag, Typography, Space, Timeline, Statistic, Alert, Button } from 'antd'; +import { useQuery } from '@tanstack/react-query'; +import { Card, Row, Col, Tag, Typography, Space, Timeline, Statistic, Alert } from 'antd'; import { ApartmentOutlined, ClockCircleOutlined, - ThunderboltOutlined, } from '@ant-design/icons'; import ReactECharts from 'echarts-for-react'; -import { fetchTransactions, fetchFlows, triggerAnalysis } from '../../services/api'; +import { fetchTransactions, fetchFlows } from '../../services/api'; import type { FundFlowNode, FundFlowEdge, TransactionRecord } from '../../types'; const nodeColorMap: Record = { @@ -20,8 +19,6 @@ const nodeColorMap: Record = { const Analysis: React.FC = () => { const { id = '1' } = useParams(); - const queryClient = useQueryClient(); - const { message } = App.useApp(); const { data: txData } = useQuery({ queryKey: ['transactions', id], @@ -32,36 +29,6 @@ const Analysis: React.FC = () => { queryFn: () => fetchFlows(id), }); - const analysisMutation = useMutation({ - mutationFn: () => triggerAnalysis(id), - onMutate: () => { - message.open({ - key: 'analysis-page-analysis', - type: 'loading', - content: '正在提交案件分析任务...', - duration: 0, - }); - }, - onSuccess: (res) => { - message.open({ - key: 'analysis-page-analysis', - type: 'success', - content: res.message || '分析任务已提交', - }); - queryClient.invalidateQueries({ queryKey: ['assessments', id] }); - queryClient.invalidateQueries({ queryKey: ['suggestions', id] }); - queryClient.invalidateQueries({ queryKey: ['transactions', id] }); - queryClient.invalidateQueries({ queryKey: ['flows', id] }); - queryClient.invalidateQueries({ queryKey: ['case', id] }); - }, - onError: () => - message.open({ - key: 'analysis-page-analysis', - type: 'error', - content: '案件分析提交失败', - }), - }); - const transactions: TransactionRecord[] = useMemo(() => txData?.items ?? [], [txData?.items]); const flowNodes: FundFlowNode[] = useMemo(() => flowData?.nodes ?? [], [flowData?.nodes]); const flowEdges: FundFlowEdge[] = useMemo(() => flowData?.edges ?? [], [flowData?.edges]); @@ -211,24 +178,6 @@ const Analysis: React.FC = () => { return (
- - - - 分析入口 - - - - - - - {transactions.length === 0 && ( { const Reports: React.FC = () => { const { id = '1' } = useParams(); + const navigate = useNavigate(); const qc = useQueryClient(); + const { modal } = App.useApp(); const [generated, setGenerated] = useState(false); const [selectedFormats, setSelectedFormats] = useState>([ 'excel', @@ -350,6 +353,15 @@ const Reports: React.FC = () => { icon={} loading={genMutation.isPending} onClick={() => { + if (allAssessments.length === 0) { + modal.warning({ + title: '需要先执行案件分析', + content: '请先前往认定复核页面执行案件分析,完成后再生成报告。', + okText: '前往认定复核', + onOk: () => navigate(`/cases/${id}/review`), + }); + return; + } if (selectedFormats.length === 0) { message.warning('请至少选择一种导出格式'); return;