增加后台操作日志管理

This commit is contained in:
2018-04-23 00:56:58 +08:00
parent b89a78652c
commit d793309bb5
5 changed files with 293 additions and 3 deletions
@@ -962,7 +962,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
string IsVerifySellers = Request.Form["IsVerifySellers"];
entity.UserName = model.UserName;
entity.Email = model.Email;
entity.Tel = model.UserName;
entity.Tel = model.Tel;
entity.Parent = model.Parent;
entity.Grandfather = model.Grandfather;
entity.RoleId = model.RoleId;
@@ -1009,5 +1009,61 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
return Json(tip);
}
#endregion
#region 后台管理日志列表
[MyAuthorize("viewlist", "admincplog")]
public IActionResult AdminCPLogList()
{
return View();
}
[MyAuthorize("viewlist", "admincplog")]
public IActionResult GetAdminCPLogList(string keyword, int page = 1, int limit = 20)
{
int numPerPage, currentPage, startRowIndex;
numPerPage = limit;
currentPage = page;
startRowIndex = (currentPage - 1) * numPerPage;
Expression ex = AdminLog._.Id > 0;
if (!string.IsNullOrWhiteSpace(keyword))
{
if (Utils.IsInt(keyword))
{
ex &= (AdminLog._.Id == int.Parse(keyword) | AdminLog._.UserName.Contains(keyword));
}
else
{
ex &= AdminLog._.UserName.Contains(keyword);
}
}
string kid = Request.Query["kid"];
//if (Utils.IsInt(kid) && int.Parse(kid) > 0)
//{
// ex &= AdminLog._.KId == int.Parse(kid);
//}
IList<AdminLog> list = AdminLog.FindAll(ex, AdminLog._.Id.Desc(), null, startRowIndex, numPerPage);
long totalCount = AdminLog.FindCount(ex, AdminLog._.Id.Desc(), null, startRowIndex, numPerPage);
Core.Admin.WriteLogActions("后台管理日志留言列表(page:" + page + ");");
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
}
#endregion
#region 查看管理日志详情
[MyAuthorize("view", "admincplog")]
public IActionResult ViewAdminLogDetail(int id)
{
AdminLog entity = AdminLog.Find(AdminLog._.Id == id);
if (entity == null)
{
return EchoTipPage("系统找不到本记录!");
}
Core.Admin.WriteLogActions("查看管理日志详情(" + id + ");");
return View(entity);
}
#endregion
}
}
@@ -3,7 +3,7 @@
ViewBag.title = "编辑/审核留言详情";
}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="wrapper wrapper-content ">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>@ViewBag.title</h5>
@@ -2,7 +2,7 @@
@{
ViewBag.title = "留言管理";
}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="wrapper wrapper-content ">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>@ViewBag.title</h5>
@@ -0,0 +1,163 @@
@{
ViewBag.title = "后台管理日志";
}
<div class="wrapper wrapper-content ">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>@ViewBag.title</h5>
<div class="ibox-tools">
</div>
</div>
<div class="ibox-content">
<div class="panel panel-default">
<div class="panel-heading">筛选条件</div>
<div class="panel-body">
<form id="formSearch" class="form-horizontal form-inline" onsubmit="doSearch(); return false; ">
<div>
@*<label class="control-label">留言分类:</label>
<select class="form-control" name="kid" id="kid">
<option value="0">所有分类</option>
</select>*@
<label class="control-label">关键字:</label>
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
</div>
</form>
</div>
</div>
<table id="tb_departments"></table>
<script>
$(function () {
//1.初始化Table
var oTable = new TableInit();
oTable.Init();
//2.初始化Button的点击事件
var oButtonInit = new ButtonInit();
oButtonInit.Init();
});
function doSearch() {
var params = $('#tb_departments').bootstrapTable('getOptions');
//console.log(params);
params.queryParams = function (params) {
var temp = { //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
limit: params.limit, //页面大小
page: (params.offset / params.limit) + 1, //页码
kid: $("#kid").val(),
keyword: $("#keyword").val()
};
return temp;
}
$('#tb_departments').bootstrapTable('refresh', params);
}
var TableInit = function () {
var oTableInit = new Object();
//初始化Table
oTableInit.Init = function () {
$('#tb_departments').bootstrapTable({
url: '/AdminCP/Member/GetAdminCPLogList', //请求后台的URL(*)
method: 'get', //请求方式(*)
toolbar: '#toolbar', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
sortable: false, //是否启用排序
sortOrder: "asc", //排序方式
queryParams: oTableInit.queryParams,//传递参数(*)
sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 25, //每页的记录行数(*)
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: true,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: true, //是否启用点击选中行
height: 0, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
uniqueId: "Id", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
columns: [{
checkbox: true
}, {
field: 'Id',
title: 'ID'
},{
field: 'UserName',
title: '登录用户名'
},
{
field: 'LoginIP',
title: '登录IP'
},
{
field: 'LoginTime',
title: '登录时间'
},
{
field: 'IsLoginOK',
title: '是否登录成功',
formatter: function (value, row, index) {
if (value == 0) {
return '失败'
}
return '成功';
}
},
{
field: 'LastUpdateTime',
title: '最后操作时间'
},
{
field: 'Id',
title: '操作',
formatter: 'actionFormatter'
}
]
});
};
//得到查询的参数
oTableInit.queryParams = function (params) {
var temp = { //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
limit: params.limit, //页面大小
page: (params.offset / params.limit) + 1, //页码
kid:$("#kid").val(),
departmentname: $("#keyword").val()
};
return temp;
};
return oTableInit;
};
function actionFormatter(value, row, index) {
return [
'<a href="javascript:;" class="btn btn-xs btn-primary" title="编辑" onclick="top.showDialog(\'viewadminlogdetail\', \'查看管理日志详情\', \'/AdminCP/Member/ViewAdminLogDetail/' + value + '\', 0, 0)"><i class="fa fa-edit"></i> 查看详情</a>'
].join('');
}
var ButtonInit = function () {
var oInit = new Object();
var postdata = {};
oInit.Init = function () {
//初始化页面上面的按钮事件
};
return oInit;
};
</script>
</div>
</div>
</div>
@@ -0,0 +1,71 @@
@model COMCMS.Core.AdminLog
@{
ViewBag.title = "查看管理日志详情";
}
<div class="wrapper wrapper-content ">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>@ViewBag.title</h5>
<div class="ibox-tools">
</div>
</div>
<div class="ibox-content">
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editGuestbookForm", @class = "form-horizontal m-t" }))
{
<div class="form-group">
<label class="col-sm-3 control-label">唯一编号:</label>
<div class="col-sm-8">
<label class="control-label">@Model.GUID</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">登录用户名:</label>
<div class="col-sm-8">
<label class="control-label">@Model.UserName</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">尝试登录密码:</label>
<div class="col-sm-8">
<label class="control-label">@Model.PassWord (成功则隐藏)</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">登录时间:</label>
<div class="col-sm-8">
<label class="control-label">@Model.LoginTime.ToString("yyyy-MM-dd HH:mm")</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">登录IP:</label>
<div class="col-sm-8">
<label class="control-label">@Model.LoginIP</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">最后操作时间:</label>
<div class="col-sm-8">
<label class="control-label">@Model.LastUpdateTime.ToString("yyyy-MM-dd HH:mm")</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">操作详细日志:</label>
<div class="col-sm-8">
<label class="control-label">@Model.Actions</label>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
<button class="btn btn-default" type="button" onclick="closethisdialog();"><i class="fa fa-close"></i> 关闭 </button>
</div>
</div>
}
</div>
</div>
</div>