import type { PageParam, PageResult } from '@vben/request';
|
|
import { requestClient } from '#/api/request';
|
import type { MesProBagCodeApi } from '#/api/mes/pro/bagCode';
|
import type { MesProPalletApi } from '#/api/mes/pro/pallet';
|
|
export namespace MesProBatchApi {
|
/** 生产批次人员配置 */
|
export interface BatchWorker {
|
id?: number; // 编号
|
batchId?: number; // 批次编号
|
userId?: number; // 生产人员用户编号
|
userName?: string; // 生产人员昵称
|
workerType?: number; // 岗位类型(字典 mes_pro_batch_worker_type)
|
remark?: string; // 备注
|
}
|
|
/** 生产批次 */
|
export interface Batch {
|
id?: number; // 编号
|
code?: string; // 批次号(自动生成)
|
itemId?: number; // 品种(产品物料)编号
|
itemCode?: string; // 品种编码(后端拼接)
|
itemName?: string; // 品种名称(后端拼接)
|
itemSpecification?: string; // 品种规格(后端拼接)
|
lineId?: number; // 产线编号
|
lineCode?: string; // 产线编码(后端回填)
|
lineName?: string; // 产线名称(后端回填)
|
produceDate?: string; // 生产日期
|
planQuantity?: number; // 计划数量
|
ownerUserId?: number; // 责任人用户编号
|
ownerUserName?: string; // 责任人昵称
|
bagQuantity?: number; // 已生成袋码数量
|
palletQuantity?: number; // 已生成托盘码数量
|
status?: number; // 批次状态(字典 mes_pro_batch_status)
|
remark?: string; // 备注
|
createTime?: string; // 创建时间
|
workers?: BatchWorker[]; // 生产人员配置列表
|
}
|
|
/** 生产批次扫码追溯 */
|
export interface BatchTrace {
|
id?: number; // 生产批次编号
|
code?: string; // 批次号(二维码内容)
|
status?: number; // 批次状态(字典 mes_pro_batch_status)
|
produceDate?: string; // 生产日期
|
lineCode?: string; // 产线编码
|
lineName?: string; // 产线名称
|
ownerUserId?: number; // 责任人用户编号
|
ownerUserName?: string; // 责任人昵称
|
planQuantity?: number; // 计划数量
|
bagQuantity?: number; // 已生成袋码数量
|
palletQuantity?: number; // 已生成托盘码数量
|
remark?: string; // 备注
|
itemId?: number; // 品种(物料)编号
|
itemCode?: string; // 品种编码
|
itemName?: string; // 品种名称
|
itemSpecification?: string; // 品种规格
|
workers?: BatchWorker[]; // 生产人员配置列表
|
pallets?: MesProPalletApi.Pallet[]; // 托盘码列表
|
bags?: MesProBagCodeApi.BagCode[]; // 袋码列表(最多前 2000 条,按袋序号升序)
|
bagTotal?: number; // 袋码总数
|
}
|
|
/** 生产批次分页查询参数 */
|
export interface PageParams extends PageParam {
|
code?: string;
|
itemId?: number;
|
lineId?: number;
|
lineCode?: string;
|
lineName?: string;
|
ownerUserId?: number;
|
status?: number;
|
produceDate?: string[];
|
createTime?: string[];
|
}
|
}
|
|
/** 查询生产批次分页 */
|
export function getBatchPage(params: MesProBatchApi.PageParams) {
|
return requestClient.get<PageResult<MesProBatchApi.Batch>>(
|
'/mes/pro/batch/page',
|
{ params },
|
);
|
}
|
|
/** 查询生产批次详情(含人员配置) */
|
export function getBatch(id: number) {
|
return requestClient.get<MesProBatchApi.Batch>(
|
`/mes/pro/batch/get?id=${id}`,
|
);
|
}
|
|
/** 新增生产批次(自动生成批次号) */
|
export function createBatch(data: MesProBatchApi.Batch) {
|
return requestClient.post<number>('/mes/pro/batch/create', data);
|
}
|
|
/** 修改生产批次 */
|
export function updateBatch(data: MesProBatchApi.Batch) {
|
return requestClient.put('/mes/pro/batch/update', data);
|
}
|
|
/** 删除生产批次 */
|
export function deleteBatch(id: number) {
|
return requestClient.delete(`/mes/pro/batch/delete?id=${id}`);
|
}
|
|
/** 更新生产批次状态 */
|
export function updateBatchStatus(id: number, status: number) {
|
return requestClient.put(
|
`/mes/pro/batch/update-status?id=${id}&status=${status}`,
|
);
|
}
|
|
/** 查询生产批次精简列表(供下拉选择) */
|
export function getBatchSimpleList() {
|
return requestClient.get<MesProBatchApi.Batch[]>('/mes/pro/batch/simple-list');
|
}
|
|
/** 导出生产批次 Excel */
|
export function exportBatchExcel(params: MesProBatchApi.PageParams) {
|
return requestClient.download('/mes/pro/batch/export-excel', { params });
|
}
|
|
/** 扫码追溯:根据批次号(二维码内容)反查批次、人员、托盘、袋码信息 */
|
export function getBatchByCode(code: string) {
|
return requestClient.get<MesProBatchApi.BatchTrace>(
|
`/mes/pro/batch/get-by-code?code=${encodeURIComponent(code)}`,
|
);
|
}
|
|
/** 批量导出批次二维码图片 ZIP(批次图 + 该批次全部托盘图) */
|
export function exportBatchQr(batchId: number) {
|
return requestClient.download(`/mes/pro/batch/export-qr?batchId=${batchId}`);
|
}
|