采购单优化

This commit is contained in:
liu
2026-08-12 23:20:05 +08:00
parent c2c56408a0
commit 0211e5e98d
22 changed files with 768 additions and 1425 deletions
+40 -32
View File
@@ -1,12 +1,27 @@
import createAxios from '@/utils/request';
import type {
ExportFormat,
IPurchaseCell,
IPurchaseDetail,
PurchaseExportType,
} from '@/domain/iPurchaseOrder.ts';
import { downloadBlob } from '@/api/common/download.ts';
/** C1 合并「已接单」门店订单生成采购单(order_ids 为空 = 全部已接单;生成后源订单转采购中) */
/** 订单商品参数修改 */
export interface PurchaseRowUpdateParams {
product_name: string;
supplier_id: number;
product_spec: string;
unit: string;
cost_price: number;
}
/** 修改门店订单明细参数 */
export interface PurchaseCellUpdateParams {
quantity: number;
price: number;
weight?: number;
}
/** 生成采购单 */
export async function generatePurchase(purchase_date: string, order_ids?: number[]) {
return createAxios<{ id: number; purchase_no: string }>({
url: '/purchase/order/generate',
@@ -15,7 +30,7 @@ export async function generatePurchase(purchase_date: string, order_ids?: number
});
}
/** 采购单详情(商品行 × 门店列矩阵) */
/** 采购单详情 */
export async function getPurchaseDetail(id: number) {
return createAxios<IPurchaseDetail>({
url: `/purchase/order/${id}`,
@@ -23,36 +38,29 @@ export async function getPurchaseDetail(id: number) {
});
}
/** 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,
) {
/** 商品行修改 */
export async function updatePurchaseRow(purchaseId: number, productId: number, data: PurchaseRowUpdateParams) {
return createAxios<{ count: number }>({
url: `/purchase/order/${purchaseId}/row/${productId}`,
method: 'put',
data,
});
}
/** 单元格下钻:采购单中某门店某商品的全部订货明细 */
export async function getPurchaseCell(purchaseId: number, productId: number, storeId: number) {
return createAxios<IPurchaseCell>({
url: `/purchase/order/${purchaseId}/cell`,
method: 'get',
params: { product_id: productId, store_id: storeId },
});
}
/** 门店订单明细修改(订货量、重量、单价),自动重算价格 */
export async function updatePurchaseCellItem(itemId: number, data: PurchaseCellUpdateParams) {
return createAxios({
url: `/purchase/order/cell/${itemId}`,
method: 'put',
data,
});
}