- 新增 views/ExportTask/Index.vue:发起导出、轮询进度、完成后自动下载、历史列表, 以及 api/exportTask.ts - 新增 store/tabs.ts:顶部多标签页(打开/关闭/固定),BasicLayout 接入;顶栏账号头像 改走 mediaUrl 拼 API origin - 路由新增 /export-tasks,默认落地与已登录访问登录页时跳转改为 /dashboard (动态路由尚未注册时由守卫重新解析当前目标) - 登录页标题改为「天豹 OMS 管理系统」
84 lines
2.3 KiB
TypeScript
84 lines
2.3 KiB
TypeScript
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<ExportTypeOption[]>('/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<ExportTaskItem>('/export-tasks/' + id)
|
||
}
|
||
|
||
/**
|
||
* 下载导出文件:以 blob 形式拉取(走鉴权拦截器),由调用方触发浏览器下载
|
||
* @param id 任务ID
|
||
* @return Promise<Blob> CSV 文件流
|
||
*/
|
||
export function downloadExport(id: number) {
|
||
return request.get('/export-tasks/' + id + '/download', { responseType: 'blob' }) as unknown as Promise<Blob>
|
||
}
|