fix: comma input & i18n
This commit is contained in:
parent
fb98ba3d32
commit
263a4fcedc
4 changed files with 13 additions and 8 deletions
|
|
@ -95,7 +95,7 @@ withDefaults(
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(v) => {
|
(v) => {
|
||||||
if (typeof v === 'string') price4Show = commaInput(v);
|
if (typeof v === 'string') price4Show = commaInput(v);
|
||||||
const x = parseInt(
|
const x = parseFloat(
|
||||||
price4Show && typeof price4Show === 'string'
|
price4Show && typeof price4Show === 'string'
|
||||||
? price4Show.replace(/,/g, '')
|
? price4Show.replace(/,/g, '')
|
||||||
: '',
|
: '',
|
||||||
|
|
@ -120,7 +120,7 @@ withDefaults(
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(v) => {
|
(v) => {
|
||||||
if (typeof v === 'string') agentPrice4Show = commaInput(v);
|
if (typeof v === 'string') agentPrice4Show = commaInput(v);
|
||||||
const x = parseInt(
|
const x = parseFloat(
|
||||||
agentPrice4Show && typeof agentPrice4Show === 'string'
|
agentPrice4Show && typeof agentPrice4Show === 'string'
|
||||||
? agentPrice4Show.replace(/,/g, '')
|
? agentPrice4Show.replace(/,/g, '')
|
||||||
: '',
|
: '',
|
||||||
|
|
@ -145,7 +145,7 @@ withDefaults(
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(v) => {
|
(v) => {
|
||||||
if (typeof v === 'string') serviceCharge4Show = commaInput(v);
|
if (typeof v === 'string') serviceCharge4Show = commaInput(v);
|
||||||
const x = parseInt(
|
const x = parseFloat(
|
||||||
serviceCharge4Show && typeof serviceCharge4Show === 'string'
|
serviceCharge4Show && typeof serviceCharge4Show === 'string'
|
||||||
? serviceCharge4Show.replace(/,/g, '')
|
? serviceCharge4Show.replace(/,/g, '')
|
||||||
: '',
|
: '',
|
||||||
|
|
|
||||||
|
|
@ -640,7 +640,7 @@ export default {
|
||||||
foreignRefNo: 'เลขที่อ้างอิงคนต่างด้าว',
|
foreignRefNo: 'เลขที่อ้างอิงคนต่างด้าว',
|
||||||
documentExpireDate: 'วันที่เอกสารหมดอายุ',
|
documentExpireDate: 'วันที่เอกสารหมดอายุ',
|
||||||
|
|
||||||
allProductPrice: 'ราคาสินค้าทั้งหมด (บาท)',
|
allProductPrice: 'ราคาสุทธิสินค้าที่เสียภาษี (บาท)',
|
||||||
pricePerUnit: 'ราคาต่อหน่วย (บาท)',
|
pricePerUnit: 'ราคาต่อหน่วย (บาท)',
|
||||||
priceBeforeVat: 'ราคาก่อนคิดภาษี (บาท)',
|
priceBeforeVat: 'ราคาก่อนคิดภาษี (บาท)',
|
||||||
sumPrice: 'ราคารวม',
|
sumPrice: 'ราคารวม',
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ let jobPositionENFilter = selectFilterOptionRefMod(
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(v) => {
|
(v) => {
|
||||||
if (typeof v === 'string') wageRate4Show = commaInput(v);
|
if (typeof v === 'string') wageRate4Show = commaInput(v);
|
||||||
const x = parseInt(
|
const x = parseFloat(
|
||||||
wageRate4Show && typeof wageRate4Show === 'string'
|
wageRate4Show && typeof wageRate4Show === 'string'
|
||||||
? wageRate4Show.replace(/,/g, '')
|
? wageRate4Show.replace(/,/g, '')
|
||||||
: '',
|
: '',
|
||||||
|
|
|
||||||
|
|
@ -417,12 +417,17 @@ export async function waitAll<T extends Promise<any>[]>(arr: T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function commaInput(text: string): string {
|
export function commaInput(text: string): string {
|
||||||
|
console.log(text);
|
||||||
if (typeof text !== 'string') return '0';
|
if (typeof text !== 'string') return '0';
|
||||||
if (!text) 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;
|
export default useUtilsStore;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue