mirror of https://gitee.com/y_project/RuoYi.git
新增日期格式化方法
parent
951a4d3707
commit
3f9d0cf2ea
|
@ -994,7 +994,6 @@ var table = {
|
|||
$.operate.submit(url, "post", "json", data);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
// 批量删除信息
|
||||
removeAll: function() {
|
||||
|
@ -1503,6 +1502,39 @@ var table = {
|
|||
});
|
||||
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) {
|
||||
var value = item;
|
||||
|
|
Loading…
Reference in New Issue