1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { requestClient } from '#/api/request';
 
export namespace MesProQrExportApi {
  /** 业务类型 */
  export type BizType =
    | 'BAG_BUSINESS'
    | 'BAG_LABEL'
    | 'BATCH_BUSINESS'
    | 'BATCH_LABEL'
    | 'PALLET_BUSINESS'
    | 'PALLET_LABEL';
 
  /** 导出方式:SYNC 同步直接下载(秒出)/ ASYNC 后台任务 */
  export type ExportMode = 'ASYNC' | 'SYNC';
 
  /** 导出任务状态:10 排队中 20 生成中 30 待下载 40 已取消 50 已失败 60 已下载 */
  export type TaskStatus = 10 | 20 | 30 | 40 | 50 | 60;
 
  /** 导出参数 */
  export interface ExportParams {
    bizType: BizType;
    batchId?: number;
    uuid?: string;
  }
 
  /** 导出数量与方式 */
  export interface ExportCount {
    mode: ExportMode;
    syncThreshold: number;
    totalCount: number;
  }
 
  /** 导出任务 */
  export interface ExportTask {
    id: number;
    bizType: string;
    taskName: string;
    status: TaskStatus;
    statusName: string;
    totalCount: number;
    finishedCount: number;
    progress: number;
    fileSize?: number;
    errorMsg?: string;
    downloadable: boolean;
    createTime?: string;
    finishTime?: string;
  }
}
 
/** 统计导出张数并给出导出方式 */
export function getQrExportCount(params: MesProQrExportApi.ExportParams) {
  return requestClient.get<MesProQrExportApi.ExportCount>(
    '/mes/pro/qr-export/count',
    { params },
  );
}
 
/** 提交后台导出任务 */
export function submitQrExportTask(data: MesProQrExportApi.ExportParams) {
  return requestClient.post<MesProQrExportApi.ExportTask>(
    '/mes/pro/qr-export/task',
    data,
  );
}
 
/** 查询导出任务进度 */
export function getQrExportTask(id: number) {
  return requestClient.get<MesProQrExportApi.ExportTask>(
    '/mes/pro/qr-export/task/get',
    { params: { id } },
  );
}
 
/** 取消导出任务 */
export function cancelQrExportTask(id: number) {
  return requestClient.post<boolean>('/mes/pro/qr-export/task/cancel', null, {
    params: { id },
  });
}
 
/** 导出任务产物下载地址(不带鉴权头,供流式下载自行附加 token) */
export function getQrExportDownloadPath(id: number) {
  return `/mes/pro/qr-export/task/download?id=${id}`;
}