feat: 增加出库单前端聚合接口与汇总逻辑
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import type { PageParam, PageResult } from '@vben/request';
|
|
||||||
import type { Dayjs } from 'dayjs';
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
export namespace WmsIostorInvApi {
|
export namespace WmsIostorInvApi {
|
||||||
@@ -10,7 +11,7 @@ export namespace WmsIostorInvApi {
|
|||||||
billCode?: string; // 单据编号
|
billCode?: string; // 单据编号
|
||||||
ioType?: string; // 出入类型
|
ioType?: string; // 出入类型
|
||||||
billType?: string; // 单据类型
|
billType?: string; // 单据类型
|
||||||
bizDate?: string | Dayjs; // 业务日期
|
bizDate?: Dayjs | string; // 业务日期
|
||||||
storId: string; // 仓库标识
|
storId: string; // 仓库标识
|
||||||
storCode: string; // 仓库编码
|
storCode: string; // 仓库编码
|
||||||
storName: string; // 仓库名称
|
storName: string; // 仓库名称
|
||||||
@@ -24,15 +25,70 @@ export namespace WmsIostorInvApi {
|
|||||||
remark: string; // 备注
|
remark: string; // 备注
|
||||||
createMode?: string; // 生成方式
|
createMode?: string; // 生成方式
|
||||||
disOptid: string; // 分配人
|
disOptid: string; // 分配人
|
||||||
disTime?: string | Dayjs; // 分配时间
|
disTime?: Dayjs | string; // 分配时间
|
||||||
confirmOptid: string; // 确认人
|
confirmOptid: string; // 确认人
|
||||||
confirmTime?: string | Dayjs; // 确认时间
|
confirmTime?: Dayjs | string; // 确认时间
|
||||||
sysdeptid: string; // 部门ID
|
sysdeptid: string; // 部门ID
|
||||||
syscompanyid: string; // 公司ID
|
syscompanyid: string; // 公司ID
|
||||||
isUpload?: string; // 是否已上传
|
isUpload?: string; // 是否已上传
|
||||||
uploadOptid: string; // 回传人
|
uploadOptid: string; // 回传人
|
||||||
uploadTime: string; // 回传时间
|
uploadTime: string; // 回传时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 出库单可持久化明细 */
|
||||||
|
export interface OutboundDetail {
|
||||||
|
materialCode: string; // 物料编码
|
||||||
|
materialId?: string; // 物料标识
|
||||||
|
pcsn?: string; // 批次序列号
|
||||||
|
planQty: number; // 出库重量
|
||||||
|
qtyUnitId?: string; // 数量单位标识
|
||||||
|
qtyUnitName?: string; // 数量单位名称
|
||||||
|
sourceBillCode?: string; // 来源单据编号
|
||||||
|
sourceBillType?: string; // 来源单据类型
|
||||||
|
sourceBilldtlId?: string; // 来源单据明细标识
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 出库单新增请求 */
|
||||||
|
export interface OutboundCreateReq {
|
||||||
|
billType: string; // 单据类型
|
||||||
|
storId: string; // 仓库标识
|
||||||
|
bizDate: Dayjs | string; // 业务日期
|
||||||
|
remark?: string; // 备注
|
||||||
|
details: OutboundDetail[]; // 出库单明细
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 可用库存 */
|
||||||
|
export interface AvailableInventory {
|
||||||
|
vehicleCode: string; // 箱号
|
||||||
|
pcsn: string; // 批次
|
||||||
|
materialId: string; // 物料标识
|
||||||
|
materialCode: string; // 物料编码
|
||||||
|
materialName: string; // 物料名称
|
||||||
|
availableQty: number; // 可用数量
|
||||||
|
qtyUnitId: string; // 计量单位标识
|
||||||
|
qtyUnitName: string; // 计量单位名称
|
||||||
|
extCode: string; // 来源单据号
|
||||||
|
extType: string; // 来源单据类型
|
||||||
|
extDtlCode: string; // 来源单据明细号
|
||||||
|
storId: string; // 仓库标识
|
||||||
|
storCode: string; // 仓库编码
|
||||||
|
storName: string; // 仓库名称
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 可用库存分页请求 */
|
||||||
|
export interface AvailableInventoryPageReq extends PageParam {
|
||||||
|
storId: string; // 仓库标识
|
||||||
|
materialCode?: string; // 物料编码
|
||||||
|
vehicleCode?: string; // 箱号
|
||||||
|
pcsn?: string; // 批次
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按箱号展开可用库存请求 */
|
||||||
|
export interface ExpandAvailableInventoryReq {
|
||||||
|
storId: string; // 仓库标识
|
||||||
|
vehicleCodes: string[]; // 箱号列表
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询出入库单主表分页 */
|
/** 查询出入库单主表分页 */
|
||||||
@@ -77,4 +133,27 @@ export function exportIostorInv(params: any) {
|
|||||||
return requestClient.download('/wms/iostor-inv/export-excel', { params });
|
return requestClient.download('/wms/iostor-inv/export-excel', { params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 查询可用库存分页 */
|
||||||
|
export function getAvailableInventoryPage(
|
||||||
|
params: WmsIostorInvApi.AvailableInventoryPageReq,
|
||||||
|
) {
|
||||||
|
return requestClient.get<
|
||||||
|
PageResult<WmsIostorInvApi.AvailableInventory>
|
||||||
|
>('/wms/iostor-inv/availableInventoryPage', { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按箱号展开可用库存 */
|
||||||
|
export function expandAvailableInventory(
|
||||||
|
data: WmsIostorInvApi.ExpandAvailableInventoryReq,
|
||||||
|
) {
|
||||||
|
return requestClient.post<WmsIostorInvApi.AvailableInventory[]>(
|
||||||
|
'/wms/iostor-inv/expandAvailableInventory',
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建出库单 */
|
||||||
|
export function createOutbound(data: WmsIostorInvApi.OutboundCreateReq) {
|
||||||
|
return requestClient.post<string>('/wms/iostor-inv/createOutbound', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import { summarizeDetails } from './detail-summary';
|
||||||
|
|
||||||
|
describe('summarizeDetails', () => {
|
||||||
|
it('汇总明细数量和总重量', () => {
|
||||||
|
expect(
|
||||||
|
summarizeDetails([{ planQty: 12.5 }, { planQty: 7.25 }]),
|
||||||
|
).toEqual({ detailCount: 2, totalWeight: 19.75 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('空明细返回零值', () => {
|
||||||
|
expect(summarizeDetails([])).toEqual({ detailCount: 0, totalWeight: 0 });
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
export interface OutboundDetailLike {
|
||||||
|
planQty: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 汇总出库明细数量和重量 */
|
||||||
|
export function summarizeDetails(details: OutboundDetailLike[]) {
|
||||||
|
return {
|
||||||
|
detailCount: details.length,
|
||||||
|
totalWeight: details.reduce(
|
||||||
|
(total, detail) => total + Number(detail.planQty),
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user