59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import createAxios from '@/utils/request';
|
|
import type {
|
|
ExportFormat,
|
|
IPurchaseDetail,
|
|
PurchaseExportType,
|
|
} from '@/domain/iPurchaseOrder.ts';
|
|
import { downloadBlob } from '@/api/common/download.ts';
|
|
|
|
/** C1 合并「已接单」门店订单生成采购单(order_ids 为空 = 全部已接单;生成后源订单转采购中) */
|
|
export async function generatePurchase(purchase_date: string, order_ids?: number[]) {
|
|
return createAxios<{ id: number; purchase_no: string }>({
|
|
url: '/purchase/order/generate',
|
|
method: 'post',
|
|
data: { purchase_date, order_ids },
|
|
});
|
|
}
|
|
|
|
/** 采购单详情(商品行 × 门店列矩阵) */
|
|
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(
|
|
`/purchase/order/${id}/export`,
|
|
{ type, format },
|
|
`采购单_${id}.${format}`
|
|
);
|
|
}
|
|
|
|
/** 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,
|
|
});
|
|
}
|
|
|
|
/** C4 商品行修改(成本/实际称重,同步该商品全部订货明细) */
|
|
export async function updatePurchaseRow(
|
|
purchaseId: number,
|
|
productId: number,
|
|
data: { cost_price?: number; weight?: number },
|
|
) {
|
|
return createAxios<{ count: number }>({
|
|
url: `/purchase/order/${purchaseId}/row/${productId}`,
|
|
method: 'put',
|
|
data,
|
|
});
|
|
}
|