feat: SKU规格列展示附加价格

This commit is contained in:
2026-02-24 10:08:54 +08:00
parent fb6b9945c8
commit 5e8b4c9e5a
3 changed files with 17 additions and 2 deletions

View File

@@ -67,6 +67,19 @@ export function createProductDetailSkuActions(
);
}
function formatOptionExtraPrice(extraPrice: number) {
const normalized = normalizeMoney(extraPrice);
const prefix = normalized >= 0 ? '+' : '-';
return `${prefix}¥${Math.abs(normalized).toFixed(2)}`;
}
function getOptionDisplayText(templateId: string, optionId: string) {
if (!optionId) return '-';
const name = getOptionName(templateId, optionId);
const extraPrice = resolveSpecOptionExtraPrice(templateId, optionId);
return `${name} (${formatOptionExtraPrice(extraPrice)})`;
}
function getSkuAttrOptionId(
row: ProductDetailSkuRowState,
templateId: string,
@@ -218,6 +231,7 @@ export function createProductDetailSkuActions(
applySkuBatchPrice,
applySkuBatchStock,
buildSkuRows,
getOptionDisplayText,
getOptionName,
getSkuAttrOptionId,
getTemplateName,

View File

@@ -138,6 +138,7 @@ export function useProductDetailPage() {
deleteCurrentProduct: dataActions.deleteCurrentProduct,
detail,
form,
getOptionDisplayText: skuActions.getOptionDisplayText,
getOptionName: skuActions.getOptionName,
getSkuAttrOptionId: skuActions.getSkuAttrOptionId,
getTemplateName: skuActions.getTemplateName,

View File

@@ -47,7 +47,7 @@ const {
deleteCurrentProduct,
detail,
form,
getOptionName,
getOptionDisplayText,
getSkuAttrOptionId,
goBack,
isLoading,
@@ -534,7 +534,7 @@ watch(
>
<span class="pd-sku-spec">
{{
getOptionName(
getOptionDisplayText(
column.id,
getSkuAttrOptionId(row, column.id) || '',
)