feat(numberToCurrency): 货币单位更换

This commit is contained in:
ywk 2025-04-07 16:40:35 +08:00
parent cb6ec60ad3
commit 8b13e5271a
1 changed files with 10 additions and 14 deletions

View File

@ -10,11 +10,10 @@ export function stateFormat(row, column, cellValue) {
return Number(cellValue)
.toFixed(2)
.replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
return $1 + ',';
return $1 + ','
})
.replace(/\.$/, "");
.replace(/\.$/, '')
}
}
// 千分号
@ -36,7 +35,6 @@ export function numberToCurrencyNo(value) {
return intPartFormat + '.' + floatPart
// 使用JS内置 API toLocaleString实现数字、金额等等数值的格式化
// xxx.toLocaleString()
}
return intPartFormat + floatPart
}
@ -67,7 +65,7 @@ export function isOther(value) {
}
// 海外添加当地币
export function isLocals(value) {
return '$'
return '¥'
}
// let userAll = JSON.parse(localStorage.getItem('userAll'))
// console.error(userAll)
@ -79,18 +77,16 @@ export function isLocalSymbol(value) {
} else {
return '¥'
}
}
export function toThousandthAndKeepDecimal(element, decimal = 2) {
if (!element || element === '') {//值不存在 或为空
if (!element || element === '') { // 值不存在 或为空
return '0.00'
} else if (typeof element == 'string') {
return Number(element).toLocaleString(undefined, { minimumFractionDigits: decimal, maximumFractionDigits: decimal });
} else if (typeof element == 'number') {
return element.toLocaleString(undefined, { minimumFractionDigits: decimal, maximumFractionDigits: decimal });
} else if (typeof element === 'string') {
return Number(element).toLocaleString(undefined, { minimumFractionDigits: decimal, maximumFractionDigits: decimal })
} else if (typeof element === 'number') {
return element.toLocaleString(undefined, { minimumFractionDigits: decimal, maximumFractionDigits: decimal })
} else {
return element;
return element
}
}
}