采购单优化

This commit is contained in:
liu
2026-08-12 14:38:20 +08:00
parent ce1f36b5b4
commit dadfdc1511
30 changed files with 1059 additions and 1441 deletions
+25 -37
View File
@@ -1,21 +1,11 @@
import createAxios from '@/utils/request';
import type {
ExportFormat,
IAllocationResult,
IPurchaseOrderItem,
IPurchaseDetail,
PurchaseExportType,
} from '@/domain/iPurchaseOrder.ts';
import { downloadBlob } from '@/api/common/download.ts';
export interface PurchaseItemUpdateParams {
product_name?: string;
product_spec?: string;
price: number | string;
quantity: number | string;
weight?: number | string;
remark?: string;
}
/** C1 合并「已接单」门店订单生成采购单(order_ids 为空 = 全部已接单;生成后源订单转采购中) */
export async function generatePurchase(purchase_date: string, order_ids?: number[]) {
return createAxios<{ id: number; purchase_no: string }>({
@@ -25,6 +15,14 @@ export async function generatePurchase(purchase_date: string, order_ids?: number
});
}
/** 采购单详情(商品行 × 门店列矩阵) */
export async function getPurchaseDetail(id: number) {
return createAxios<IPurchaseDetail>({
url: `/purchase/order/${id}`,
method: 'get',
});
}
/** C2/C3 导出采购单(blob 下载) */
export async function exportPurchase(id: number, type: PurchaseExportType, format: ExportFormat) {
return downloadBlob(
@@ -34,37 +32,27 @@ export async function exportPurchase(id: number, type: PurchaseExportType, forma
);
}
/** C4 修改采购明细(amount 由后端重算 */
export async function updatePurchaseItem(id: number, data: PurchaseItemUpdateParams) {
return createAxios<{ amount: string }>({
url: `/purchase/order/item/${id}`,
/** C4 门店单元格修改(数量/称重,同步订货明细并重算汇总 */
export async function updatePurchaseCell(
orderItemId: number,
data: { quantity: number; weight?: number },
) {
return createAxios<{ quantity: number; weight: number; amount: number }>({
url: `/purchase/order/cell/${orderItemId}`,
method: 'put',
data,
});
}
/** C5/C6 明细发送供应商 */
export async function sendPurchaseItem(id: number) {
return createAxios({
url: `/purchase/order/item/${id}/send`,
method: 'put',
});
}
/** D3 执行金额分摊 */
export async function allocatePurchase(id: number) {
/** C4 商品行修改(成本/实际称重,同步该商品全部订货明细) */
export async function updatePurchaseRow(
purchaseId: number,
productId: number,
data: { cost_price?: number; weight?: number },
) {
return createAxios<{ count: number }>({
url: `/purchase/order/${id}/allocate`,
method: 'post',
url: `/purchase/order/${purchaseId}/row/${productId}`,
method: 'put',
data,
});
}
/** 分摊结果(按门店 / 按商品聚合) */
export async function getAllocation(id: number) {
return createAxios<IAllocationResult>({
url: `/purchase/order/${id}/allocation`,
method: 'get',
});
}
export type { IPurchaseOrderItem };