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