feat: SKU规格列展示附加价格
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -138,6 +138,7 @@ export function useProductDetailPage() {
|
||||
deleteCurrentProduct: dataActions.deleteCurrentProduct,
|
||||
detail,
|
||||
form,
|
||||
getOptionDisplayText: skuActions.getOptionDisplayText,
|
||||
getOptionName: skuActions.getOptionName,
|
||||
getSkuAttrOptionId: skuActions.getSkuAttrOptionId,
|
||||
getTemplateName: skuActions.getTemplateName,
|
||||
|
||||
@@ -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) || '',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user