From ddc25564b9c7404936cbfe9e7954f3f3508e4fcd Mon Sep 17 00:00:00 2001 From: MSuMshk <2039814060@qq.com> Date: Wed, 25 Feb 2026 11:21:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=BB=9F=E4=B8=80=E8=B5=B0=E5=BC=82=E6=AD=A5?= =?UTF-8?q?SKU=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product-detail-page/data-actions.ts | 71 ++++++++----------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/apps/web-antd/src/views/product/detail/composables/product-detail-page/data-actions.ts b/apps/web-antd/src/views/product/detail/composables/product-detail-page/data-actions.ts index f81a0ec..2f02ea1 100644 --- a/apps/web-antd/src/views/product/detail/composables/product-detail-page/data-actions.ts +++ b/apps/web-antd/src/views/product/detail/composables/product-detail-page/data-actions.ts @@ -25,7 +25,6 @@ import { getProductLabelListApi, getProductSkuSaveJobApi, getProductSpecListApi, - saveProductApi, saveProductAsyncApi, } from '#/api/product'; @@ -43,7 +42,6 @@ const ALLOWED_PRODUCT_IMAGE_MIME_SET = new Set([ 'image/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_MAX_ATTEMPTS = 180; @@ -513,7 +511,6 @@ export function createProductDetailDataActions( })) : []; - const shouldSaveSkuAsync = normalizedSkus.length > ASYNC_SKU_THRESHOLD; const payload = { id: form.id, storeId: storeId.value, @@ -553,50 +550,40 @@ export function createProductDetailDataActions( tags: [], }; - if (shouldSaveSkuAsync) { - const asyncSaved = await saveProductAsyncApi(payload); - if (asyncSaved.productId) { - form.id = asyncSaved.productId; - } + const asyncSaved = await saveProductAsyncApi(payload); + if (asyncSaved.productId) { + form.id = asyncSaved.productId; + } - if ( - asyncSaved.skuJobStatus === 'queued' || - asyncSaved.skuJobStatus === 'running' - ) { - if (asyncSaved.skuJobId) { - message.success( - asyncSaved.message || - `商品基础信息已保存,${normalizedSkus.length} 条 SKU 正在后台处理`, - ); - void watchSkuSaveJobInBackground( - storeId.value, - asyncSaved.productId || form.id, - asyncSaved.skuJobId, - ); - } else { - message.warning( - asyncSaved.message || 'SKU 任务已创建,请稍后刷新查看状态', - ); - } - return; + if ( + asyncSaved.skuJobStatus === 'queued' || + asyncSaved.skuJobStatus === 'running' + ) { + if (asyncSaved.skuJobId) { + message.success( + asyncSaved.message || + `商品基础信息已保存,${normalizedSkus.length} 条 SKU 正在后台处理`, + ); + void watchSkuSaveJobInBackground( + storeId.value, + asyncSaved.productId || form.id, + asyncSaved.skuJobId, + ); + } else { + message.warning(asyncSaved.message || 'SKU 任务已创建,请稍后刷新查看状态'); } - - if (asyncSaved.skuJobStatus === 'not_required') { - message.success(asyncSaved.message || '商品详情已保存'); - return; - } - - message.error( - asyncSaved.message || '商品基础信息已保存,但 SKU 异步任务创建失败', - ); return; } - const saved = await saveProductApi(payload); - message.success('商品详情已保存'); - detail.value = saved; - patchForm(saved); - buildSkuRows(); + if (asyncSaved.skuJobStatus === 'not_required') { + message.success(asyncSaved.message || '商品详情已保存'); + return; + } + + message.error( + asyncSaved.message || '商品基础信息已保存,但 SKU 异步任务创建失败', + ); + return; } catch (error) { console.error(error); } finally {