| | |
| | | import { message } from 'antd'; |
| | | import ProcessAPIService from '../services/ProcessAPIService'; |
| | | import OutboundBotAPIService from '../services/OutboundBotAPIService'; |
| | | import EvidenceAPIService from '../services/EvidenceAPIService'; |
| | | import MediationAgreementAPIService from '../services/MediationAgreementAPIService'; |
| | | import { getMergedParams } from '../utils/urlParams'; |
| | | import { mockTimelineData } from '../mocks/timeline'; |
| | | import { getFallbackStartTime, parseTimeString } from '../utils/timeFormatter'; |
| | |
| | | const [taskStartTime, setTaskStartTime] = useState(null); // 任务开始时间 |
| | | const [isTaskTimeFallback, setIsTaskTimeFallback] = useState(false); // 是否降级模式 |
| | | const [hasLoaded, setHasLoaded] = useState(false); // 防止重复加载 |
| | | |
| | | // 证据材料数据 |
| | | const [evidenceData, setEvidenceData] = useState({ |
| | | applicantMaterials: [], |
| | | respondentMaterials: [], |
| | | loading: false, |
| | | error: null |
| | | }); |
| | | |
| | | // 调解协议数据 |
| | | const [agreementData, setAgreementData] = useState({ |
| | | content: '', |
| | | loading: false, |
| | | error: null |
| | | }); |
| | | |
| | | /** |
| | | * 保存数据到localStorage |
| | |
| | | console.log('Using fallback start time:', new Date(fallbackTime).toLocaleString()); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 加载证据材料数据 |
| | | * @param {Object} params - 参数对象 |
| | | * @param {string} params.caseId - 案件ID |
| | | * @param {string} params.caseType - 案件类型 |
| | | * @param {string} params.platformCode - 平台编码 |
| | | */ |
| | | const loadEvidenceData = async (params) => { |
| | | setEvidenceData(prev => ({ ...prev, loading: true, error: null })); |
| | | |
| | | try { |
| | | const response = await EvidenceAPIService.getEvidenceList({ |
| | | case_id: params.caseId, |
| | | case_type: params.caseType || params.caseTypeFirst, |
| | | platform_code: params.platformCode |
| | | }); |
| | | |
| | | console.log('Evidence API response:', response); |
| | | |
| | | const responseData = response.data || []; |
| | | |
| | | // 分离申请人和被申请人材料 |
| | | const applicantData = responseData.find(item => item.per_type === '15_020008-1'); |
| | | const respondentData = responseData.find(item => item.per_type === '15_020008-2'); |
| | | |
| | | const applicantList = applicantData?.file_list?.slice(0, applicantData.file_count) || []; |
| | | const respondentList = respondentData?.file_list?.slice(0, respondentData.file_count) || []; |
| | | |
| | | setEvidenceData({ |
| | | applicantMaterials: applicantList, |
| | | respondentMaterials: respondentList, |
| | | loading: false, |
| | | error: null |
| | | }); |
| | | |
| | | console.log('Evidence data loaded:', { applicantList, respondentList }); |
| | | } catch (err) { |
| | | console.error('加载证据材料失败:', err); |
| | | setEvidenceData(prev => ({ |
| | | ...prev, |
| | | loading: false, |
| | | error: err.message || '加载证据材料失败' |
| | | })); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 加载调解协议数据 |
| | | * @param {string} caseId - 案件ID |
| | | */ |
| | | const loadAgreementData = async (caseId) => { |
| | | setAgreementData(prev => ({ ...prev, loading: true, error: null })); |
| | | |
| | | try { |
| | | const response = await MediationAgreementAPIService.generateAgreement(caseId); |
| | | |
| | | if (response?.data?.agreeContent) { |
| | | setAgreementData({ |
| | | content: response.data.agreeContent, |
| | | loading: false, |
| | | error: null |
| | | }); |
| | | console.log('Agreement data loaded'); |
| | | } else { |
| | | setAgreementData({ |
| | | content: '', |
| | | loading: false, |
| | | error: '协议内容为空' |
| | | }); |
| | | } |
| | | } catch (err) { |
| | | console.error('加载调解协议失败:', err); |
| | | setAgreementData({ |
| | | content: '', |
| | | loading: false, |
| | | error: err.message || '加载调解协议失败' |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 加载案件数据 |
| | | */ |
| | |
| | | setLoading(false); |
| | | return; |
| | | } |
| | | |
| | | EvidenceAPIService.processCaseFilesOcr(params.caseId).catch((ocrError) => { |
| | | console.error('触发案件文件OCR失败:', ocrError); |
| | | }); |
| | | |
| | | try { |
| | | await OutboundBotAPIService.syncStatusByCase({ caseId: params.caseId }); |
| | |
| | | setCaseData(timelineData); |
| | | setProcessNodes(Array.isArray(nodesData) ? nodesData : []); // 确保为数组 |
| | | setHasLoaded(true); // 标记已加载 |
| | | |
| | | // 并行加载证据材料和调解协议数据(在终态检查之前,确保数据完整性) |
| | | await Promise.all([ |
| | | loadEvidenceData({ |
| | | caseId: params.caseId, |
| | | caseType: params.caseType || params.caseTypeFirst, |
| | | caseTypeFirst: params.caseTypeFirst, |
| | | platformCode: params.platform_code |
| | | }), |
| | | loadAgreementData(params.caseId) |
| | | ]); |
| | | |
| | | // 检查终态状态(调解成功/失败/人工接管),终态不执行外呼和存储 |
| | | const mediationState = timelineData.mediation?.state; |
| | |
| | | refreshData, |
| | | loadCaseData, |
| | | taskStartTime, // 任务开始时间 |
| | | isTaskTimeFallback // 是否降级模式 |
| | | isTaskTimeFallback, // 是否降级模式 |
| | | // 证据材料数据 |
| | | evidenceData, |
| | | loadEvidenceData, |
| | | // 调解协议数据 |
| | | agreementData, |
| | | loadAgreementData |
| | | }; |
| | | |
| | | return ( |