| | |
| | | if (!caseId) return; |
| | | setActionLoading(prev => ({ ...prev, download: true })); |
| | | try { |
| | | await MediationAgreementAPIService.downloadAgreement(caseId); |
| | | // 调用API获取协议内容 |
| | | const response = await MediationAgreementAPIService.downloadAgreement(caseId); |
| | | |
| | | if (response?.data?.agreeContent) { |
| | | const agreementContent = response.data.agreeContent; |
| | | |
| | | // 创建Blob对象 |
| | | const blob = new Blob([agreementContent], { |
| | | type: 'application/pdf' |
| | | }); |
| | | |
| | | // 创建下载链接 |
| | | const url = window.URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = `调解协议_${caseId}.pdf`; |
| | | |
| | | // 触发下载 |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | |
| | | // 清理URL对象 |
| | | window.URL.revokeObjectURL(url); |
| | | |
| | | message.success('协议下载成功!'); |
| | | } else { |
| | | message.error('未获取到协议内容'); |
| | | } |
| | | } catch (err) { |
| | | console.error('下载协议失败:', err); |
| | | message.error('下载协议失败,请稍后重试'); |