diff --git a/frontend/src/api/exportTask.ts b/frontend/src/api/exportTask.ts new file mode 100644 index 0000000..41fe9aa --- /dev/null +++ b/frontend/src/api/exportTask.ts @@ -0,0 +1,83 @@ +import { get, post } from '@/utils/request' +import request from '@/utils/request' + +/** 导出类型:出入库记录 / 商品 / 订单 */ +export type ExportType = 'stock_record' | 'product' | 'order' + +/** 导出任务状态:0待处理 1处理中 2已完成 3失败 */ +export type ExportStatus = 0 | 1 | 2 | 3 + +/** 导出类型选项(后端返回) */ +export interface ExportTypeOption { + value: ExportType + label: string +} + +/** 导出任务项 */ +export interface ExportTaskItem { + id: number + principal_id: number + type: ExportType + type_label?: string + status: ExportStatus + status_label?: string + sql?: string + file_name: string | null + file_path: string | null + total_count: number + processed_count: number + progress: number + error_message: string | null + created_at: string +} + +/** 导出筛选条件(按类型可选字段) */ +export interface ExportFilters { + product_id?: number | null + warehouse_id?: number | null + biz_type?: string + direction?: number | string + bill_type?: number | string + item_type?: string + bill_no?: string + keyword?: string + category_name?: string + status?: number | string + submit_status?: number | string + shop_id?: number | null + start_time?: string + end_time?: string + [key: string]: unknown +} + +/** 导出类型选项 */ +export function getExportTypes() { + return get('/export-tasks/types') +} + +/** 提交导出任务:立即返回任务ID */ +export function submitExport(payload: { type: ExportType; filters?: ExportFilters }) { + return post<{ id: number; type: ExportType; status: number }>('/export-tasks', payload) +} + +/** 导出任务列表(按主体隔离) */ +export function getExportTasks(params?: object) { + return get<{ list: ExportTaskItem[]; total: number; page: number; pageSize: number }>( + '/export-tasks', + params, + ) +} + +/** 导出任务进度 */ +export function getExportTask(id: number) { + return get('/export-tasks/' + id) +} + +/** + * 下载导出文件:以 blob 形式拉取(走鉴权拦截器),由调用方触发浏览器下载 + * @param id 任务ID + * @return Promise CSV 文件流 + */ +export function downloadExport(id: number) { + return request.get('/export-tasks/' + id + '/download', { responseType: 'blob' }) as unknown as Promise +} diff --git a/frontend/src/layouts/BasicLayout.vue b/frontend/src/layouts/BasicLayout.vue index 711198d..cec625b 100644 --- a/frontend/src/layouts/BasicLayout.vue +++ b/frontend/src/layouts/BasicLayout.vue @@ -1,17 +1,92 @@ + + + + diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue index d467fbd..91ed69f 100644 --- a/frontend/src/views/Login.vue +++ b/frontend/src/views/Login.vue @@ -304,7 +304,7 @@ onUnmounted(() => {