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(
|
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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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) || '',
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user