diff --git a/src/components/04_product-service/PriceDataComponent.vue b/src/components/04_product-service/PriceDataComponent.vue index ed4235ed..1aee6669 100644 --- a/src/components/04_product-service/PriceDataComponent.vue +++ b/src/components/04_product-service/PriceDataComponent.vue @@ -95,7 +95,7 @@ withDefaults( @update:model-value=" (v) => { if (typeof v === 'string') price4Show = commaInput(v); - const x = parseInt( + const x = parseFloat( price4Show && typeof price4Show === 'string' ? price4Show.replace(/,/g, '') : '', @@ -120,7 +120,7 @@ withDefaults( @update:model-value=" (v) => { if (typeof v === 'string') agentPrice4Show = commaInput(v); - const x = parseInt( + const x = parseFloat( agentPrice4Show && typeof agentPrice4Show === 'string' ? agentPrice4Show.replace(/,/g, '') : '', @@ -145,7 +145,7 @@ withDefaults( @update:model-value=" (v) => { if (typeof v === 'string') serviceCharge4Show = commaInput(v); - const x = parseInt( + const x = parseFloat( serviceCharge4Show && typeof serviceCharge4Show === 'string' ? serviceCharge4Show.replace(/,/g, '') : '', diff --git a/src/i18n/tha/index.ts b/src/i18n/tha/index.ts index 92f271fe..c0f381fb 100644 --- a/src/i18n/tha/index.ts +++ b/src/i18n/tha/index.ts @@ -640,7 +640,7 @@ export default { foreignRefNo: 'เลขที่อ้างอิงคนต่างด้าว', documentExpireDate: 'วันที่เอกสารหมดอายุ', - allProductPrice: 'ราคาสินค้าทั้งหมด (บาท)', + allProductPrice: 'ราคาสุทธิสินค้าที่เสียภาษี (บาท)', pricePerUnit: 'ราคาต่อหน่วย (บาท)', priceBeforeVat: 'ราคาก่อนคิดภาษี (บาท)', sumPrice: 'ราคารวม', diff --git a/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue b/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue index 64d40fad..fc4e2695 100644 --- a/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue +++ b/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue @@ -302,7 +302,7 @@ let jobPositionENFilter = selectFilterOptionRefMod( @update:model-value=" (v) => { if (typeof v === 'string') wageRate4Show = commaInput(v); - const x = parseInt( + const x = parseFloat( wageRate4Show && typeof wageRate4Show === 'string' ? wageRate4Show.replace(/,/g, '') : '', diff --git a/src/stores/utils/index.ts b/src/stores/utils/index.ts index babef9e0..9a448e6c 100644 --- a/src/stores/utils/index.ts +++ b/src/stores/utils/index.ts @@ -417,12 +417,17 @@ export async function waitAll[]>(arr: T) { } export function commaInput(text: string): string { + console.log(text); if (typeof text !== 'string') return '0'; if (!text) return '0'; - const num = text.replace(/,/gi, ''); - const numF = num.split(/(?=(?:\d{3})+$)/).join(','); - return numF; + const num = Number(text.replace(/,/gi, '')); + + const parts = num.toString().split('.'); + const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); + const decimalPart = parts[1] || ''; + + return integerPart + (decimalPart ? `.${decimalPart}` : ''); } export default useUtilsStore;