add skuFulfillmentList
This commit is contained in:
@@ -6,6 +6,7 @@ import type {
|
||||
ProductPage,
|
||||
ProductPageResult,
|
||||
ProductSku,
|
||||
FulfillmentProductSku,
|
||||
ProductSpec,
|
||||
ProductSpecValue,
|
||||
ProductStock,
|
||||
@@ -72,6 +73,10 @@ async function skuDetail(id: string): Promise<ProductSku> {
|
||||
return await axios.post(`${PRODUCT_URI}/sku/detail`, undefined, { params: { id } });
|
||||
}
|
||||
|
||||
async function fulfillmentSkuList(idList: string[]): Promise<FulfillmentProductSku[]> {
|
||||
return await axios.post(`${PRODUCT_URI}/sku/fulfillment-list`, idList);
|
||||
}
|
||||
|
||||
async function skuCreate(sku: ProductSku): Promise<string> {
|
||||
return await axios.post(`${PRODUCT_URI}/sku/create`, withCurrentStoreId(sku));
|
||||
}
|
||||
@@ -175,6 +180,7 @@ export default {
|
||||
disable,
|
||||
remove,
|
||||
skuDetail,
|
||||
fulfillmentSkuList,
|
||||
skuCreate,
|
||||
skuUpdate,
|
||||
skuDisable,
|
||||
|
||||
@@ -145,7 +145,7 @@ import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import type { GaoOrderFulfillmentItemRequest } from "@/types/Fulfillment";
|
||||
import type { GaoSalesOrderItem, SalesOrder } from "@/types/SalesOrder";
|
||||
import type { ProductSku, ProductSkuUnit } from "@/types/Product";
|
||||
import type { FulfillmentProductSku, ProductSkuUnit } from "@/types/Product";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import {
|
||||
comparePackageQuantity,
|
||||
@@ -180,7 +180,7 @@ const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const order = ref<SalesOrder>();
|
||||
const quantityMap = reactive<Record<string, string | number>>({});
|
||||
const fulfillmentSkuMap = reactive<Record<string, ProductSku>>({});
|
||||
const fulfillmentSkuMap = reactive<Record<string, FulfillmentProductSku>>({});
|
||||
const fulfillmentUnitMap = reactive<Record<string, string>>({});
|
||||
const deliveredAtText = ref("");
|
||||
const remark = ref("");
|
||||
@@ -245,13 +245,16 @@ async function loadData(): Promise<void> {
|
||||
|
||||
async function loadFulfillmentSkuList(): Promise<void> {
|
||||
const skuIdList = [...new Set(sourceItems.value.map(item => item.skuId).filter((skuId): skuId is string => !!skuId))];
|
||||
await Promise.all(skuIdList.map(async skuId => {
|
||||
if (skuIdList.length) {
|
||||
try {
|
||||
fulfillmentSkuMap[skuId] = await ProductAPI.skuDetail(skuId);
|
||||
const skuList = await ProductAPI.fulfillmentSkuList(skuIdList);
|
||||
for (const sku of skuList) {
|
||||
if (sku.id) fulfillmentSkuMap[sku.id] = sku;
|
||||
}
|
||||
} catch {
|
||||
// 提交时仍由后端校验实际履约单位,单个 SKU 加载失败不影响其他明细
|
||||
// 提交时仍由后端校验实际履约单位
|
||||
}
|
||||
}));
|
||||
}
|
||||
for (const item of sourceItems.value) {
|
||||
if (!item.id) {
|
||||
continue;
|
||||
@@ -411,7 +414,7 @@ function buildAttachments(): Partial<Attachment>[] {
|
||||
async function validateDirectStock(showShortageMessage = true): Promise<boolean> {
|
||||
stockPreviewList.value = [];
|
||||
const selected = sourceItems.value.filter(hasFulfillmentQuantity);
|
||||
const skuMap = new Map<string, ProductSku>();
|
||||
const skuMap = new Map<string, FulfillmentProductSku>();
|
||||
for (const item of selected) {
|
||||
if (!item.skuId) {
|
||||
continue;
|
||||
|
||||
@@ -80,6 +80,8 @@ export type ProductSku = {
|
||||
attachmentList?: Attachment[];
|
||||
} & Model;
|
||||
|
||||
export type FulfillmentProductSku = Pick<ProductSku, "id" | "stockEnabled" | "allowDecimalQuantity" | "unitList">;
|
||||
|
||||
export type ProductSkuSpecSnapshot = {
|
||||
specId?: string;
|
||||
specName?: string;
|
||||
|
||||
Reference in New Issue
Block a user