新增日期格式化方法

pull/223/MERGE
RuoYi 2020-10-14 14:38:37 +08:00
parent 951a4d3707
commit 3f9d0cf2ea
1 changed files with 33 additions and 1 deletions

View File

@ -994,7 +994,6 @@ var table = {
$.operate.submit(url, "post", "json", data); $.operate.submit(url, "post", "json", data);
} }
}); });
}, },
// 批量删除信息 // 批量删除信息
removeAll: function() { removeAll: function() {
@ -1503,6 +1502,39 @@ var table = {
}); });
return flag ? str : ''; return flag ? str : '';
}, },
// 日期格式化 时间戳 -> yyyy-MM-dd HH-mm-ss
dateFormat: function(date, format) {
var that = this;
if (that.isEmpty(date)) return "";
if (!date) return;
if (!format) format = "yyyy-MM-dd";
switch (typeof date) {
case "string":
date = new Date(date.replace(/-/, "/"));
break;
case "number":
date = new Date(date);
break;
}
if (!date instanceof Date) return;
var dict = {
"yyyy": date.getFullYear(),
"M": date.getMonth() + 1,
"d": date.getDate(),
"H": date.getHours(),
"m": date.getMinutes(),
"s": date.getSeconds(),
"MM": ("" + (date.getMonth() + 101)).substr(1),
"dd": ("" + (date.getDate() + 100)).substr(1),
"HH": ("" + (date.getHours() + 100)).substr(1),
"mm": ("" + (date.getMinutes() + 100)).substr(1),
"ss": ("" + (date.getSeconds() + 100)).substr(1)
};
return format.replace(/(yyyy|MM?|dd?|HH?|ss?|mm?)/g,
function() {
return dict[arguments[0]];
});
},
// 获取节点数据,支持多层级访问 // 获取节点数据,支持多层级访问
getItemField: function (item, field) { getItemField: function (item, field) {
var value = item; var value = item;