feat: implement order export to Excel with excelize library
Build and Push Docker Image / build-and-push (push) Failing after 16s
Build and Push Docker Image / deploy (push) Has been skipped

This commit is contained in:
nuyue
2026-07-17 05:33:01 +08:00
parent 9107affb85
commit 0d7e0f3b1e
5 changed files with 146 additions and 10 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ export const adminApi = {
getOrders: (params?: any) => api.get('/admin/orders', { params }),
getOrderById: (id: number) => api.get(`/admin/orders/${id}`),
exportOrders: () => api.get('/admin/orders/export'),
exportOrders: () => api.get('/admin/orders/export', { responseType: 'blob' }),
processRefund: (id: number, data: any) => api.put(`/admin/orders/${id}/refund`, data),
updateOrderStatus: (id: number, data: any) => api.put(`/admin/orders/${id}/status`, data),
+15 -2
View File
@@ -254,8 +254,21 @@ async function processRefund(id: number, status: string) {
}
async function exportOrders() {
await adminApi.exportOrders()
ElMessage.success('导出完成')
try {
const res = await adminApi.exportOrders()
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = `orders_${new Date().toISOString().slice(0, 10)}.xlsx`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
ElMessage.success('导出完成')
} catch {
ElMessage.error('导出失败')
}
}
onMounted(fetchOrders)