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( function getSkuAttrOptionId(
row: ProductDetailSkuRowState, row: ProductDetailSkuRowState,
templateId: string, templateId: string,
@@ -218,6 +231,7 @@ export function createProductDetailSkuActions(
applySkuBatchPrice, applySkuBatchPrice,
applySkuBatchStock, applySkuBatchStock,
buildSkuRows, buildSkuRows,
getOptionDisplayText,
getOptionName, getOptionName,
getSkuAttrOptionId, getSkuAttrOptionId,
getTemplateName, getTemplateName,

View File

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

View File

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