diff --git a/web/src/api/index.js b/web/src/api/index.js index 1b92614..ec1734d 100644 --- a/web/src/api/index.js +++ b/web/src/api/index.js @@ -68,5 +68,6 @@ export default { request.post(`/valuations/${data.valuation_id || data.id}/reject`, { admin_notes: data.admin_notes }), updateValuationNotes: (data = {}) => request.put(`/valuations/${data.valuation_id || data.id}/admin-notes`, { admin_notes: data.admin_notes }), + getValuationReport: (params = {}) => request.get(`/valuations/${params.valuation_id || params.id}/report`, { isRaw: true }), sendSmsReport: (data = {}) => request.post('/sms/send-report', data), } diff --git a/web/src/utils/http/interceptors.js b/web/src/utils/http/interceptors.js index e782eba..aa2ab19 100644 --- a/web/src/utils/http/interceptors.js +++ b/web/src/utils/http/interceptors.js @@ -21,7 +21,10 @@ export function reqReject(error) { } export function resResolve(response) { - const { data, status, statusText } = response + const { data, status, statusText, config } = response + if (config?.isRaw) { + return Promise.resolve(data) + } if (data?.code !== 200) { const code = data?.code ?? status /** 根据code处理对应的操作,并返回处理后的message */ diff --git a/web/src/views/valuation/audit/components/AuditDetail.vue b/web/src/views/valuation/audit/components/AuditDetail.vue index fec3c02..61887f6 100644 --- a/web/src/views/valuation/audit/components/AuditDetail.vue +++ b/web/src/views/valuation/audit/components/AuditDetail.vue @@ -42,6 +42,8 @@ const emit = defineEmits(['back', 'approve', 'reject']) const $message = useMessage() const activeDetailTab = ref('audit') +const reportLoading = ref(false) +const reportContent = ref('') const pickFilledValue = (...values) => values.find((val) => val !== undefined && val !== null && val !== '') const formatEnumField = (key, ...values) => formatEnumByKey(pickFilledValue(...values), key) @@ -55,9 +57,34 @@ watch( () => props.detailData?.id, () => { activeDetailTab.value = 'audit' + reportContent.value = '' } ) +// 监听 tab 切换,当切换到计算流程时加载报告 +watch(activeDetailTab, async (newTab) => { + if (newTab === 'flow' && props.detailData?.id && !reportContent.value) { + await fetchReport() + } +}) + +// 获取报告内容 +const fetchReport = async () => { + if (!props.detailData?.id) return + + reportLoading.value = true + try { + const response = await api.getValuationReport({ valuation_id: props.detailData.id }) + reportContent.value = response.data || response || '' + } catch (error) { + console.error('获取报告失败:', error) + $message.error('获取报告失败') + reportContent.value = '# 获取报告失败\n\n请稍后重试' + } finally { + reportLoading.value = false + } +} + const detailSections = computed(() => { const detail = props.detailData if (!detail) return [] @@ -232,10 +259,8 @@ const calcFlow = computed(() => props.detailData?.calculation_result?.flow || [] -const mockFlowHtml = ref(mockReportMarkdown) - const renderedFlowHtml = computed(() => { - return marked.parse(mockFlowHtml.value) + return marked.parse(reportContent.value || mockReportMarkdown) }) @@ -351,7 +376,7 @@ const handleCertificateConfirm = async (data) => { - +