59 lines
1.7 KiB
TypeScript
59 lines
1.7 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 商品行修改参数(品名/供应商/包规/单位/成本/称重,一键同步该商品全部订货明细;sync_product 追加同步商品档案) */
|
|
export interface PurchaseRowUpdateParams {
|
|
product_name?: string;
|
|
supplier_id?: number;
|
|
product_spec?: string;
|
|
unit?: string;
|
|
cost_price?: number;
|
|
weight?: number;
|
|
/** true = 同时同步至商品档案(product 表) */
|
|
sync_product?: boolean;
|
|
}
|
|
|
|
/** C4 商品行修改 */
|
|
export async function updatePurchaseRow(
|
|
purchaseId: number,
|
|
productId: number,
|
|
data: PurchaseRowUpdateParams,
|
|
) {
|
|
return createAxios<{ count: number }>({
|
|
url: `/purchase/order/${purchaseId}/row/${productId}`,
|
|
method: 'put',
|
|
data,
|
|
});
|
|
}
|