| | |
| | | import { ref } from 'vue' |
| | | import { ElMessage } from 'element-plus' |
| | | import { guardRequestWithMessage } from '@/utils/sys/requestGuard' |
| | | |
| | | export function usePrintExportPage({ |
| | | downloadFileName, |
| | | requestExport, |
| | | resolvePrintRecords, |
| | | buildPreviewRows, |
| | | buildPreviewMeta |
| | | buildPreviewMeta, |
| | | timeoutMs |
| | | }) { |
| | | const previewVisible = ref(false) |
| | | const previewRows = ref([]) |
| | |
| | | |
| | | const handleExport = async (payload) => { |
| | | try { |
| | | const response = await requestExport(payload) |
| | | const response = await guardRequestWithMessage(requestExport(payload), null, { |
| | | timeoutMs, |
| | | timeoutMessage: '导出请求超时,已停止等待' |
| | | }) |
| | | if (!response) { |
| | | return |
| | | } |
| | | if (!response.ok) { |
| | | throw new Error(`导出失败 (${response.status})`) |
| | | } |
| | |
| | | previewMeta.value = {} |
| | | |
| | | try { |
| | | const records = await resolvePrintRecords(payload) |
| | | const records = await guardRequestWithMessage(resolvePrintRecords(payload), null, { |
| | | timeoutMs, |
| | | timeoutMessage: '打印数据加载超时,已停止等待' |
| | | }) |
| | | if (activePrintToken.value !== token) { |
| | | return |
| | | } |
| | | if (!records) { |
| | | return |
| | | } |
| | | |
| | | const rows = buildPreviewRows(records) |
| | | previewRows.value = rows |