优化商品库存明细里的时间格式
This commit is contained in:
@@ -456,4 +456,29 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 格式化日期,如月、日、时、分、秒保证为2位数
|
||||
function formatNumber (n) {
|
||||
n = n.toString();
|
||||
return n[1] ? n : '0' + n;
|
||||
}
|
||||
|
||||
// 参数number为毫秒时间戳,format为需要转换成的日期格式
|
||||
function formatTime(number, format) {
|
||||
if(number) {
|
||||
var time = new Date(number);
|
||||
var newArr = [];
|
||||
var formatArr = ['Y', 'M', 'D', 'h', 'm', 's'];
|
||||
newArr.push(time.getFullYear());
|
||||
newArr.push(formatNumber(time.getMonth() + 1));
|
||||
newArr.push(formatNumber(time.getDate()));
|
||||
newArr.push(formatNumber(time.getHours()));
|
||||
newArr.push(formatNumber(time.getMinutes()));
|
||||
newArr.push(formatNumber(time.getSeconds()));
|
||||
for (var i in newArr) {
|
||||
format = format.replace(formatArr[i], newArr[i]);
|
||||
}
|
||||
return format;
|
||||
}
|
||||
}
|
||||
@@ -586,7 +586,9 @@
|
||||
},
|
||||
{title: '类型', field: 'Type', width: 100},
|
||||
{title: '数量', field: 'BasicNumber', width: 80},
|
||||
{title: '日期', field: 'OperTime', width: 180}
|
||||
{title: '日期', field: 'OperTime', width: 180, formatter: function (value) {
|
||||
return formatTime(value, 'Y-M-D h:m:s');
|
||||
}}
|
||||
]],
|
||||
onLoadError: function () {
|
||||
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
|
||||
|
||||
Reference in New Issue
Block a user