/**
* FormatUtil 客户端数据格式化工具类
* @author cls
* @date 2021-01-30
* import { FormatUtil } from "@birt/funclib/FormatUtil"
*/
import { DateUtil } from "@birt/funclib/DateUtil";
import { NumberUtil } from "@birt/funclib/NumberUtil";
import { $CONST } from "@birt/funclib/ConstUtil";
export const FormatUtil = {
/**
* showdoc
* @catalog JS工具类/FormatUtil
* @title 获取数据格式化值
* @description 获取数据格式化值
* @method static
* @url FormatUtil.getFmtValue({ value, fmt, fieldObj })
* @param value 原始值
* @param fmt 格式化
* @param fieldObj 字段配置
* @return 格式化值
*/
getFmtValue({ value, fmt, fieldObj }) {
if (fieldObj[$CONST.DBTYPE] == $CONST.DBDATETIME) {
return DateUtil.format(value, fmt);
} else {
return NumberUtil.format(value, fmt);
}
return value;
}
};