Compare commits

2 Commits

Author SHA1 Message Date
wangyang
63a9a1def5 Merge remote-tracking branch 'origin/develop-718' into develop-718 2025-08-26 11:33:41 +08:00
wangyang
a0ddac37f5 CRM-提交日期格式化 2025-08-26 11:32:49 +08:00

View File

@@ -22,19 +22,19 @@ export function maskIdNumber() {
* 金额格式化
* num 金额
* decimals 保留几位小数默认2位
* units 默认 units ¥
* units 默认 units ¥
*/
export function formatMoney(num, decimals,units){
units = units || '¥ '
num = parseFloat(num/100);
if (isNaN(num)) return units+0;
decimals = typeof decimals === 'undefined' ? 2 : decimals;
var parts = num.toFixed(decimals).split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
let retVal = 0;
// let part1 = parts[1]
// if(parseInt(part1)==0){
@@ -44,4 +44,24 @@ export function formatMoney(num, decimals,units){
// }
return units+retVal;
}
}
export function dateFormat(fmt, date) {
let ret;
const opt = {
"Y+": date.getFullYear().toString(), // 年
"m+": (date.getMonth() + 1).toString(), // 月
"d+": date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 时
"M+": date.getMinutes().toString(), // 分
"S+": date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (let k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
}