2 天以前 d2cd585f4d3b015789a5f6c8d75e352605932f85
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
export namespace MesProBagCodeApi {
  /** 袋码(一袋一码) */
  export interface BagCode {
    id?: number; // 编号
    uuid?: string; // 生成组 UUID
    code?: string; // 袋码(二维码内容)
    bagNo?: number; // 批次内袋序号
    batchId?: number; // 生产批次编号
    batchCode?: string; // 批次号
    lineCode?: string; // 产线编码
    lineName?: string; // 产线名称
    palletId?: number; // 绑定托盘编号
    palletCode?: string; // 托盘码
    status?: number; // 状态(字典 mes_pro_bag_code_status)
    printTime?: string; // 导出(交付印刷)时间
    cancelTime?: string; // 作废时间
    cancelReason?: string; // 作废原因
    remark?: string; // 备注
    createTime?: string; // 创建时间
  }
 
  /** 袋码分页查询参数 */
  export interface PageParams extends PageParam {
    code?: string;
    batchId?: number;
    batchCode?: string;
    uuid?: string;
    palletId?: number;
    status?: number;
    createTime?: string[];
  }
 
  /** 生成数据包请求 */
  export interface GenerateParams {
    batchId: number; // 生产批次编号
    count: number; // 生成袋数
    remark?: string; // 备注
  }
 
  /** 绑定/解绑托盘请求 */
  export interface BindParams {
    palletId: number; // 托盘编号
    ids: number[]; // 袋码编号列表
  }
 
  /** 破损袋码替换请求 */
  export interface ReplaceParams {
    batchId: number; // 生产批次编号
    oldIds: number[]; // 待替换旧袋码编号列表
    reason: string; // 替换原因
  }
 
  /** 破损袋码替换明细 */
  export interface ReplaceItem {
    oldBagCodeId?: number;
    oldCode?: string;
    oldBagNo?: number;
    oldStatus?: number;
    oldPalletId?: number;
    oldPalletCode?: string;
    newBagCodeId?: number;
    newCode?: string;
    newBagNo?: number;
    newPalletId?: number;
    newPalletCode?: string;
    reason?: string;
    replaceTime?: string;
  }
 
  /** 破损袋码替换结果 */
  export interface ReplaceResult {
    replaceUuid?: string;
    batchId?: number;
    batchCode?: string;
    count?: number;
    items?: ReplaceItem[];
  }
 
  /** 扫码追溯信息 */
  export interface BagCodeTrace {
    id?: number; // 袋码编号
    code?: string; // 袋码(二维码内容)
    bagNo?: number; // 袋序号
    status?: number; // 袋码状态
    printTime?: string; // 导出印刷时间
    cancelTime?: string; // 作废时间
    cancelReason?: string; // 作废原因
    replacementUuid?: string; // 替换组 UUID
    replacedByCode?: string; // 替换后的新袋码
    replacementOfCode?: string; // 被替换的旧袋码
    batchId?: number; // 批次编号
    batchCode?: string; // 批次号
    batchStatus?: number; // 批次状态
    produceDate?: string; // 生产日期
    lineCode?: string; // 产线编码
    lineName?: string; // 产线名称
    ownerUserId?: number; // 责任人编号
    ownerUserName?: string; // 责任人昵称
    palletId?: number; // 托盘编号
    palletCode?: string; // 托盘码
    itemId?: number; // 品种(物料)编号
    itemCode?: string; // 品种编码
    itemName?: string; // 品种名称
    itemSpecification?: string; // 品种规格
  }
}
 
/** 生成袋码数据包(返回生成组 UUID) */
export function generateBagCodes(data: MesProBagCodeApi.GenerateParams) {
  return requestClient.post<string>('/mes/pro/bag-code/generate', data);
}
 
/** 删除袋码生成组 */
export function deleteBagCodesByUuid(uuid: string) {
  return requestClient.delete(`/mes/pro/bag-code/delete-by-uuid?uuid=${uuid}`);
}
 
/** 袋码绑定托盘 */
export function bindBagCodePallet(data: MesProBagCodeApi.BindParams) {
  return requestClient.put('/mes/pro/bag-code/bind-pallet', data);
}
 
/** 袋码解绑托盘 */
export function unbindBagCodePallet(data: MesProBagCodeApi.BindParams) {
  return requestClient.put('/mes/pro/bag-code/unbind-pallet', data);
}
 
/** 作废破损袋码并生成等量替换袋码 */
export function replaceBagCodes(data: MesProBagCodeApi.ReplaceParams) {
  return requestClient.post<MesProBagCodeApi.ReplaceResult>(
    '/mes/pro/bag-code/replace',
    data,
  );
}
 
/** 查询袋码详情 */
export function getBagCode(id: number) {
  return requestClient.get<MesProBagCodeApi.BagCode>(
    `/mes/pro/bag-code/get?id=${id}`,
  );
}
 
/** 扫码追溯:根据袋码反查批次、产线、责任人等信息 */
export function getBagCodeByCode(code: string) {
  return requestClient.get<MesProBagCodeApi.BagCodeTrace>(
    `/mes/pro/bag-code/get-by-code?code=${encodeURIComponent(code)}`,
  );
}
 
/** 查询袋码分页 */
export function getBagCodePage(params: MesProBagCodeApi.PageParams) {
  return requestClient.get<PageResult<MesProBagCodeApi.BagCode>>(
    '/mes/pro/bag-code/page',
    { params },
  );
}
 
/** 查询生成组的袋码列表 */
export function getBagCodeListByUuid(uuid: string) {
  return requestClient.get<MesProBagCodeApi.BagCode[]>(
    `/mes/pro/bag-code/list-by-uuid?uuid=${uuid}`,
  );
}
 
/** 批量导出袋码 Excel(交付印刷) */
export function exportBagCodeExcel(params: MesProBagCodeApi.PageParams) {
  return requestClient.download('/mes/pro/bag-code/export-excel', { params });
}
 
/** 批量导出袋码二维码图片 ZIP(uuid 优先,否则按 batchId) */
export function exportBagQr(params: { uuid?: string; batchId?: number }) {
  return requestClient.download('/mes/pro/bag-code/export-qr', { params });
}