优化商品库存明细里的时间格式

This commit is contained in:
季圣华
2020-04-01 23:13:23 +08:00
parent 2879aa1d94
commit 86c6ebe110
3 changed files with 29 additions and 2 deletions

View File

@@ -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;
}
}

View File

@@ -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');

View File

@@ -74,7 +74,7 @@ public class DepotItemController {
item.put("Number", d.getNumber()); //商品编号
item.put("Type", d.getNewtype()); //进出类型
item.put("BasicNumber", d.getBnum()); //数量
item.put("OperTime", d.getOtime()); //时间
item.put("OperTime", d.getOtime().getTime()); //时间
dataArray.add(item);
}
}