fix: reports
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { App, Card, Row, Col, Tag, Typography, Space, Timeline, Statistic, Alert, Button } from 'antd';
|
import { Card, Row, Col, Tag, Typography, Space, Timeline, Statistic, Alert } from 'antd';
|
||||||
import {
|
import {
|
||||||
ApartmentOutlined,
|
ApartmentOutlined,
|
||||||
ClockCircleOutlined,
|
ClockCircleOutlined,
|
||||||
ThunderboltOutlined,
|
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import ReactECharts from 'echarts-for-react';
|
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';
|
import type { FundFlowNode, FundFlowEdge, TransactionRecord } from '../../types';
|
||||||
|
|
||||||
const nodeColorMap: Record<string, string> = {
|
const nodeColorMap: Record<string, string> = {
|
||||||
@@ -20,8 +19,6 @@ const nodeColorMap: Record<string, string> = {
|
|||||||
|
|
||||||
const Analysis: React.FC = () => {
|
const Analysis: React.FC = () => {
|
||||||
const { id = '1' } = useParams();
|
const { id = '1' } = useParams();
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { message } = App.useApp();
|
|
||||||
|
|
||||||
const { data: txData } = useQuery({
|
const { data: txData } = useQuery({
|
||||||
queryKey: ['transactions', id],
|
queryKey: ['transactions', id],
|
||||||
@@ -32,36 +29,6 @@ const Analysis: React.FC = () => {
|
|||||||
queryFn: () => fetchFlows(id),
|
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 transactions: TransactionRecord[] = useMemo(() => txData?.items ?? [], [txData?.items]);
|
||||||
const flowNodes: FundFlowNode[] = useMemo(() => flowData?.nodes ?? [], [flowData?.nodes]);
|
const flowNodes: FundFlowNode[] = useMemo(() => flowData?.nodes ?? [], [flowData?.nodes]);
|
||||||
const flowEdges: FundFlowEdge[] = useMemo(() => flowData?.edges ?? [], [flowData?.edges]);
|
const flowEdges: FundFlowEdge[] = useMemo(() => flowData?.edges ?? [], [flowData?.edges]);
|
||||||
@@ -211,24 +178,6 @@ const Analysis: React.FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Card style={{ marginBottom: 16 }}>
|
|
||||||
<Row justify="space-between" align="middle">
|
|
||||||
<Col>
|
|
||||||
<Typography.Text type="secondary">分析入口</Typography.Text>
|
|
||||||
</Col>
|
|
||||||
<Col>
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
icon={<ThunderboltOutlined />}
|
|
||||||
loading={analysisMutation.isPending}
|
|
||||||
onClick={() => analysisMutation.mutate()}
|
|
||||||
>
|
|
||||||
{analysisMutation.isPending ? '分析中...' : '执行案件分析'}
|
|
||||||
</Button>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{transactions.length === 0 && (
|
{transactions.length === 0 && (
|
||||||
<Alert
|
<Alert
|
||||||
type="info"
|
type="info"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams, useNavigate } from 'react-router-dom';
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
Alert,
|
Alert,
|
||||||
message,
|
message,
|
||||||
Result,
|
Result,
|
||||||
|
App,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import {
|
||||||
FileTextOutlined,
|
FileTextOutlined,
|
||||||
@@ -76,7 +77,9 @@ const splitDateTime = (raw: string): { date: string; time: string } => {
|
|||||||
|
|
||||||
const Reports: React.FC = () => {
|
const Reports: React.FC = () => {
|
||||||
const { id = '1' } = useParams();
|
const { id = '1' } = useParams();
|
||||||
|
const navigate = useNavigate();
|
||||||
const qc = useQueryClient();
|
const qc = useQueryClient();
|
||||||
|
const { modal } = App.useApp();
|
||||||
const [generated, setGenerated] = useState(false);
|
const [generated, setGenerated] = useState(false);
|
||||||
const [selectedFormats, setSelectedFormats] = useState<Array<'excel' | 'pdf'>>([
|
const [selectedFormats, setSelectedFormats] = useState<Array<'excel' | 'pdf'>>([
|
||||||
'excel',
|
'excel',
|
||||||
@@ -350,6 +353,15 @@ const Reports: React.FC = () => {
|
|||||||
icon={<FileTextOutlined />}
|
icon={<FileTextOutlined />}
|
||||||
loading={genMutation.isPending}
|
loading={genMutation.isPending}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (allAssessments.length === 0) {
|
||||||
|
modal.warning({
|
||||||
|
title: '需要先执行案件分析',
|
||||||
|
content: '请先前往认定复核页面执行案件分析,完成后再生成报告。',
|
||||||
|
okText: '前往认定复核',
|
||||||
|
onOk: () => navigate(`/cases/${id}/review`),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (selectedFormats.length === 0) {
|
if (selectedFormats.length === 0) {
|
||||||
message.warning('请至少选择一种导出格式');
|
message.warning('请至少选择一种导出格式');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user