fix: comma input
This commit is contained in:
parent
157944f470
commit
6f887edd42
2 changed files with 7 additions and 3 deletions
|
|
@ -228,7 +228,8 @@ watch(
|
|||
:model-value="authorizedCapital"
|
||||
@update:model-value="
|
||||
(v) => {
|
||||
if (typeof v === 'string') authorizedCapital = commaInput(v);
|
||||
if (typeof v === 'string')
|
||||
authorizedCapital = commaInput(v, 'string');
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -461,7 +461,10 @@ export async function waitAll<T extends Promise<any>[]>(arr: T) {
|
|||
return await Promise.all(arr);
|
||||
}
|
||||
|
||||
export function commaInput(text: string): string {
|
||||
export function commaInput(
|
||||
text: string,
|
||||
type: 'string' | 'number' = 'number',
|
||||
): string {
|
||||
if (typeof text !== 'string') return '0';
|
||||
if (!text) return '0';
|
||||
|
||||
|
|
@ -469,7 +472,7 @@ export function commaInput(text: string): string {
|
|||
|
||||
const parts = num.toString().split('.');
|
||||
const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
const decimalPart = parts[1]?.slice(0, 2) || '00';
|
||||
const decimalPart = parts[1]?.slice(0, 2) || (type === 'number' && '00');
|
||||
|
||||
return integerPart + (decimalPart ? `.${decimalPart}` : '');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue