fix: comma input & i18n

This commit is contained in:
puriphatt 2024-10-09 09:43:18 +07:00
parent fb98ba3d32
commit 263a4fcedc
4 changed files with 13 additions and 8 deletions

View file

@ -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, '')
: '',

View file

@ -640,7 +640,7 @@ export default {
foreignRefNo: 'เลขที่อ้างอิงคนต่างด้าว',
documentExpireDate: 'วันที่เอกสารหมดอายุ',
allProductPrice: 'ราคาสินค้าทั้งหมด (บาท)',
allProductPrice: 'ราคาสุทธิสินค้าที่เสียภาษี (บาท)',
pricePerUnit: 'ราคาต่อหน่วย (บาท)',
priceBeforeVat: 'ราคาก่อนคิดภาษี (บาท)',
sumPrice: 'ราคารวม',

View file

@ -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, '')
: '',

View file

@ -417,12 +417,17 @@ export async function waitAll<T extends Promise<any>[]>(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;