export function transformThousandth(value: number | string, fixed?: number): string { const needFixed = fixed != null const num = Number(value) if (isNaN(num)) { return needFixed ? (0).toFixed(fixed) : '0' } const str = needFixed ? num.toFixed(fixed) : num.toString() const arr = str.split('.')
let result = arr[0] ? arr[0].replace(/(?=(?!\b)(\d{3})+$)/g, ',') : '0' if (arr[1] != null) { result += `.${arr[1]}` }
return result}
export function isMoneyFormat(money: number | string): boolean { if (typeof money === 'number') { return money === money } const re1 = /^0\.[\d]{0,2}$/ const re2 = /^[1-9][\d]*(\.[\d]{0,2})?$/ const re3 = /^0$/ return re1.test(money) || re2.test(money) || re3.test(money)}