修改BUG:MVC默认json返回日期时间字符串格式为yyyy-MM-ddTHH:mm:ss

This commit is contained in:
Argo-Lenovo 2016-11-16 22:52:34 +08:00
parent 7521492088
commit 73057e5ca4
4 changed files with 13 additions and 22 deletions

View File

@ -16,6 +16,9 @@ namespace Bootstrap.Admin
routeTemplate: "api/{controller}/{id}", routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional } defaults: new { id = RouteParameter.Optional }
); );
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings;
json.DateFormatString = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
} }
} }
} }

View File

@ -8,18 +8,14 @@
$('table').smartTable({ $('table').smartTable({
url: '../api/Exceptions', url: '../api/Exceptions',
sortName: 'ErrorPage', sortName: 'LogTime',
queryParams: function (params) { return $.extend(params, { OperateTimeStart: $("#txt_operate_start").val(), OperateTimeEnd: $("#txt_operate_end").val() }); }, queryParams: function (params) { return $.extend(params, { OperateTimeStart: $("#txt_operate_start").val(), OperateTimeEnd: $("#txt_operate_end").val() }); },
columns: [{ checkbox: true }, columns: [{ checkbox: true },
{ title: "请求网址", field: "ErrorPage", sortable: false }, { title: "请求网址", field: "ErrorPage", sortable: false },
{ title: "用户名", field: "UserID", sortable: false }, { title: "用户名", field: "UserID", sortable: false },
{ title: "IP", field: "UserIp", sortable: false }, { title: "IP", field: "UserIp", sortable: false },
{ title: "错误", field: "Message", sortable: false }, { title: "错误", field: "Message", sortable: false },
{ { title: "记录时间", field: "LogTime", sortable: true }
title: "异常捕获时间", field: "LogTime", sortable: true, formatter: function (value, row, index) {
return new Date(value).format("yyyy-MM-dd HH:mm:ss");
}
}
] ]
}); });

View File

@ -1,20 +1,15 @@
$(function () { $(function () {
$('table').smartTable({ $('table').smartTable({
url: '../api/Logs', //请求后台的URL* url: '../api/Logs',
sortName: 'OperationType', sortName: 'OperationType',
queryParams: function (params) { return $.extend(params, { operateType: $("#txt_operate_type").val(), OperateTimeStart: $("#txt_operate_start").val(), OperateTimeEnd: $("#txt_operate_end").val() }); }, //传递参数(* queryParams: function (params) { return $.extend(params, { operateType: $("#txt_operate_type").val(), OperateTimeStart: $("#txt_operate_start").val(), OperateTimeEnd: $("#txt_operate_end").val() }); },
columns: [{ checkbox: true }, columns: [{ checkbox: true },
{ title: "操作类型", field: "CRUD", sortable: true }, { title: "操作类型", field: "CRUD", sortable: true },
{ title: "用户名称", field: "UserName", sortable: false }, { title: "用户名称", field: "UserName", sortable: false },
{ { title: "操作时间", field: "LogTime", sortable: false },
title: "操作时间", field: "LogTime", sortable: false,
formatter: function (value, row, index) {
return value.substring(0, 19).replace("T", " ");
}
},
{ title: "操作IP", field: "ClientIp", sortable: false }, { title: "操作IP", field: "ClientIp", sortable: false },
{ title: "备注", field: "ClientAgent", sortable: false }, { title: "Url", field: "RequestUrl", sortable: false },
{ title: "操作模块", field: "RequestUrl", sortable: false } { title: "备注", field: "ClientAgent", sortable: false }
] ]
}); });

View File

@ -16,22 +16,19 @@
if (result) { if (result) {
if (category == '0' || category == '') { if (category == '0' || category == '') {
var content = result.Users.map(function (noti) { var content = result.Users.map(function (noti) {
var t = new Date(noti.RegisterTime).format('yyyy-MM-dd HH:mm:ss'); return $.format(htmlNewUsers, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
return $.format(htmlNewUsers, noti.Title, noti.Content, t, noti.ID);
}).join(''); }).join('');
$('#tasks-users').html(content); $('#tasks-users').html(content);
} }
if (category == '1' || category == '') { if (category == '1' || category == '') {
var content = result.Apps.map(function (noti) { var content = result.Apps.map(function (noti) {
var t = new Date(noti.RegisterTime).format('yyyy-MM-dd HH:mm:ss'); return $.format(htmlApp, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
return $.format(htmlApp, noti.Title, noti.Content, t, noti.ID);
}).join(''); }).join('');
$('#tasks-app').html(content); $('#tasks-app').html(content);
} }
if (category == '2' || category == '') { if (category == '2' || category == '') {
var content = result.Dbs.map(function (noti) { var content = result.Dbs.map(function (noti) {
var t = new Date(noti.RegisterTime).format('yyyy-MM-dd HH:mm:ss'); return $.format(htmlDb, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
return $.format(htmlDb, noti.Title, noti.Content, t, noti.ID);
}).join(''); }).join('');
$('#tasks-db').html(content); $('#tasks-db').html(content);
} }