feat: 商品详情保存统一走异步SKU任务
All checks were successful
Build and Deploy TenantUI / build-and-deploy (push) Successful in 52s
All checks were successful
Build and Deploy TenantUI / build-and-deploy (push) Successful in 52s
This commit is contained in:
@@ -25,7 +25,6 @@ import {
|
|||||||
getProductLabelListApi,
|
getProductLabelListApi,
|
||||||
getProductSkuSaveJobApi,
|
getProductSkuSaveJobApi,
|
||||||
getProductSpecListApi,
|
getProductSpecListApi,
|
||||||
saveProductApi,
|
|
||||||
saveProductAsyncApi,
|
saveProductAsyncApi,
|
||||||
} from '#/api/product';
|
} from '#/api/product';
|
||||||
|
|
||||||
@@ -43,7 +42,6 @@ const ALLOWED_PRODUCT_IMAGE_MIME_SET = new Set([
|
|||||||
'image/webp',
|
'image/webp',
|
||||||
]);
|
]);
|
||||||
const ALLOWED_PRODUCT_IMAGE_EXT = ['.jpg', '.jpeg', '.png', '.webp'];
|
const ALLOWED_PRODUCT_IMAGE_EXT = ['.jpg', '.jpeg', '.png', '.webp'];
|
||||||
const ASYNC_SKU_THRESHOLD = 10;
|
|
||||||
const ASYNC_SKU_POLL_INTERVAL_MS = 1000;
|
const ASYNC_SKU_POLL_INTERVAL_MS = 1000;
|
||||||
const ASYNC_SKU_POLL_MAX_ATTEMPTS = 180;
|
const ASYNC_SKU_POLL_MAX_ATTEMPTS = 180;
|
||||||
|
|
||||||
@@ -513,7 +511,6 @@ export function createProductDetailDataActions(
|
|||||||
}))
|
}))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
const shouldSaveSkuAsync = normalizedSkus.length > ASYNC_SKU_THRESHOLD;
|
|
||||||
const payload = {
|
const payload = {
|
||||||
id: form.id,
|
id: form.id,
|
||||||
storeId: storeId.value,
|
storeId: storeId.value,
|
||||||
@@ -553,7 +550,6 @@ export function createProductDetailDataActions(
|
|||||||
tags: [],
|
tags: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (shouldSaveSkuAsync) {
|
|
||||||
const asyncSaved = await saveProductAsyncApi(payload);
|
const asyncSaved = await saveProductAsyncApi(payload);
|
||||||
if (asyncSaved.productId) {
|
if (asyncSaved.productId) {
|
||||||
form.id = asyncSaved.productId;
|
form.id = asyncSaved.productId;
|
||||||
@@ -574,9 +570,7 @@ export function createProductDetailDataActions(
|
|||||||
asyncSaved.skuJobId,
|
asyncSaved.skuJobId,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
message.warning(
|
message.warning(asyncSaved.message || 'SKU 任务已创建,请稍后刷新查看状态');
|
||||||
asyncSaved.message || 'SKU 任务已创建,请稍后刷新查看状态',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -590,13 +584,6 @@ export function createProductDetailDataActions(
|
|||||||
asyncSaved.message || '商品基础信息已保存,但 SKU 异步任务创建失败',
|
asyncSaved.message || '商品基础信息已保存,但 SKU 异步任务创建失败',
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
const saved = await saveProductApi(payload);
|
|
||||||
message.success('商品详情已保存');
|
|
||||||
detail.value = saved;
|
|
||||||
patchForm(saved);
|
|
||||||
buildSkuRows();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user