金额格式设置
This commit is contained in:
@ -62,7 +62,23 @@ export const addDateRange = (params: any, dateRange: any[], propName?: string) =
|
||||
}
|
||||
return search;
|
||||
};
|
||||
// 价格格式化函数
|
||||
export const formatPrice = (price, show = true) => {
|
||||
if ((!show && price == 0) || price == '' || price == undefined || price == null) return '';
|
||||
if (!price && price !== 0) return '0.0000';
|
||||
|
||||
// 转换为数字并保留四位小数
|
||||
const num = Number(price);
|
||||
if (isNaN(num)) return '0.0000';
|
||||
|
||||
const fixedNum = num.toFixed(4);
|
||||
const [integer, decimal] = fixedNum.split('.');
|
||||
|
||||
// 千分位处理
|
||||
const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
|
||||
return `${formattedInteger}.${decimal}`;
|
||||
};
|
||||
// 回显数据字典
|
||||
export const selectDictLabel = (datas: any, value: number | string) => {
|
||||
if (value === undefined) {
|
||||
|
Reference in New Issue
Block a user