diff --git a/change/@acedatacloud-nexior-5d8ce26a-e2db-48ad-973f-685e7828e3e3.json b/change/@acedatacloud-nexior-5d8ce26a-e2db-48ad-973f-685e7828e3e3.json new file mode 100644 index 00000000..d5cc3750 --- /dev/null +++ b/change/@acedatacloud-nexior-5d8ce26a-e2db-48ad-973f-685e7828e3e3.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "add price per count", + "packageName": "@acedatacloud/nexior", + "email": "office@acedata.cloud", + "dependentChangeType": "patch" +} diff --git a/src/components/service/Estimation.vue b/src/components/service/Estimation.vue index e8a5cd09..1c21d85c 100644 --- a/src/components/service/Estimation.vue +++ b/src/components/service/Estimation.vue @@ -4,6 +4,14 @@

≈ {{ item.name }} {{ Math.round(package.amount / item.cost) }} {{ $t('api.unit.count') }} + + - + {{ + getPriceString({ value: package.price / (package.amount / item.cost), fractionDigits: 3 }) + + ' / ' + + $t(`api.unit.count`) + }} + ({{ item.remark }}) - @@ -25,6 +33,7 @@ diff --git a/src/utils/price.ts b/src/utils/price.ts index 97cbbd5e..d1da4b58 100644 --- a/src/utils/price.ts +++ b/src/utils/price.ts @@ -28,8 +28,12 @@ export const getPrice = (payload: { value: number; currency?: string }) => { }; }; -export const getPriceString = (payload: { value: number | undefined; defaultValue?: number | undefined }) => { - let { value, defaultValue } = payload; +export const getPriceString = (payload: { + value: number | undefined; + defaultValue?: number | undefined; + fractionDigits?: number | undefined; +}) => { + let { value, defaultValue, fractionDigits = 2 } = payload; if (value === undefined) { value = defaultValue; } @@ -39,5 +43,5 @@ export const getPriceString = (payload: { value: number | undefined; defaultValu const price = getPrice({ value }); - return `${price.label}${price.value?.toFixed(2)}`; + return `${price.label}${price.value?.toFixed(fractionDigits)}`; };