heli-mes/mes-ui/mes-ui-admin-vue3/src/utils/formatter.ts
2026-01-07 15:11:02 +08:00

21 lines
522 B
TypeScript

import { floatToFixed2 } from '@/utils'
// 格式化金额【分转元】
// @ts-ignore
export const fenToYuanFormat = (_, __, cellValue: any, ___) => {
return `${floatToFixed2(cellValue)}`
}
/** 数字格式化为两位小数 */
const formatNumber = (row: any, column: any, cellValue: any) => {
if (cellValue === null || cellValue === undefined) {
return '-'
}
// 确保是数字类型后再格式化
const num = Number(cellValue)
if (isNaN(num)) {
return cellValue
}
return num.toFixed(2)
}