改进后台登录超时操作;文章系统增加批量移动;批量隐藏和显示操作
This commit is contained in:
@@ -466,5 +466,131 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 迁移文章
|
||||||
|
[HttpGet]
|
||||||
|
[MyAuthorize("batch", "article")]
|
||||||
|
public IActionResult MoveArticle()
|
||||||
|
{
|
||||||
|
//获取上级栏目
|
||||||
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
||||||
|
ViewBag.ListKinds = list;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("batch", "article", "JSON")]
|
||||||
|
public IActionResult MoveArticle(int from, int to)
|
||||||
|
{
|
||||||
|
if (from <= 0 || to <= 0)
|
||||||
|
{
|
||||||
|
tip.Message = "请选择好栏目";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if (from == to)
|
||||||
|
{
|
||||||
|
tip.Message = "迁移前后栏目一致,无法迁移";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
Article.Update("KId=" + to, "KId=" + from);
|
||||||
|
Core.Admin.WriteLogActions("迁移文章(from:" + from + ",to:" + to + ");");
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = "迁移文章成功";
|
||||||
|
tip.ReturnUrl = "close";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 批量隐藏文章
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("batch", "article", "JSON")]
|
||||||
|
public IActionResult DoBatchHideArticle(string ids)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ids))
|
||||||
|
{
|
||||||
|
tip.Message = "请最少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
List<int> listIds = new List<int>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
listIds = JsonConvert.DeserializeObject<List<int>>(ids);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tip.Message = "转换出错:" + ex.Message;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listIds == null || listIds.Count < 1)
|
||||||
|
{
|
||||||
|
tip.Message = "请至少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
IList<Article> list = Article.FindAll(Article._.Id.In(listIds), null, null, 0, 0);
|
||||||
|
if (list == null || list.Count < 1)
|
||||||
|
{
|
||||||
|
tip.Message = "请至少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
item.IsHide = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Update();
|
||||||
|
Admin.WriteLogActions($"批量隐藏文章:{ids};");
|
||||||
|
tip.Message = "批量隐藏文章成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 批量显示文章
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("batch", "article", "JSON")]
|
||||||
|
public IActionResult DoBatchShowArticle(string ids)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ids))
|
||||||
|
{
|
||||||
|
tip.Message = "请最少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
List<int> listIds = new List<int>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
listIds = JsonConvert.DeserializeObject<List<int>>(ids);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tip.Message = "转换出错:" + ex.Message;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listIds == null || listIds.Count < 1)
|
||||||
|
{
|
||||||
|
tip.Message = "请至少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
IList<Article> list = Article.FindAll(Article._.Id.In(listIds), null, null, 0, 0);
|
||||||
|
if (list == null || list.Count < 1)
|
||||||
|
{
|
||||||
|
tip.Message = "请至少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
item.IsHide = 0;
|
||||||
|
}
|
||||||
|
list.Update();
|
||||||
|
Admin.WriteLogActions($"批量显示文章:{ids};");
|
||||||
|
tip.Message = "批量显示文章成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
//判断并解密
|
//判断并解密
|
||||||
string key = SessionHelper.GetSession("des_key").ToString();
|
string key = SessionHelper.GetSession("des_key").ToString();
|
||||||
|
if (string.IsNullOrEmpty(key))
|
||||||
|
{
|
||||||
|
tip.Message = "页面访问超时,请刷新页面重新登录!";
|
||||||
|
tip.Other = "reload";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
//解密
|
//解密
|
||||||
string username = "";
|
string username = "";
|
||||||
string password = "";
|
string password = "";
|
||||||
@@ -67,14 +73,15 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
catch (Exception exp)
|
catch (Exception exp)
|
||||||
{
|
{
|
||||||
NewLife.Log.XTrace.WriteException(exp);
|
NewLife.Log.XTrace.WriteException(exp);
|
||||||
tip.Message = "用户名或者密码错误!";
|
tip.Message = "页面访问超时,请刷新页面重新登录!";
|
||||||
|
tip.Other = "reload";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
//验证用户
|
//验证用户
|
||||||
if (string.IsNullOrEmpty(username))
|
if (string.IsNullOrEmpty(username))
|
||||||
{
|
{
|
||||||
tip.Message = "请输入用户名!"+ key;
|
tip.Message = "请输入用户名!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(password) || Utils.GetStringLength(password) < 5)
|
if (string.IsNullOrEmpty(password) || Utils.GetStringLength(password) < 5)
|
||||||
|
|||||||
@@ -41,7 +41,15 @@
|
|||||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
<button id="btn_edit" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addarticle','批量迁移文章','/AdminCP/Article/MoveArticle',0,0)">
|
||||||
|
<span class="glyphicon glyphicon-move" aria-hidden="true"></span> 批量迁移
|
||||||
|
</button>
|
||||||
|
<button id="btn_delete" type="button" class="btn btn-outline btn-default" onclick="doBatchHide()">
|
||||||
|
<span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span> 批量隐藏
|
||||||
|
</button>
|
||||||
|
<button id="btn_delete" type="button" class="btn btn-outline btn-default" onclick="doBatchShow()">
|
||||||
|
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> 批量显示
|
||||||
|
</button>
|
||||||
@*<button id="btn_edit" type="button" class="btn btn-outline btn-default">
|
@*<button id="btn_edit" type="button" class="btn btn-outline btn-default">
|
||||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
|
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
|
||||||
</button>
|
</button>
|
||||||
@@ -105,45 +113,45 @@
|
|||||||
minimumCountColumns: 2, //最少允许的列数
|
minimumCountColumns: 2, //最少允许的列数
|
||||||
clickToSelect: true, //是否启用点击选中行
|
clickToSelect: true, //是否启用点击选中行
|
||||||
height: 0, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
|
height: 0, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
|
||||||
uniqueId: "Id", //每一行的唯一标识,一般为主键列
|
uniqueId: "id", //每一行的唯一标识,一般为主键列
|
||||||
showToggle: true, //是否显示详细视图和列表视图的切换按钮
|
showToggle: true, //是否显示详细视图和列表视图的切换按钮
|
||||||
cardView: false, //是否显示详细视图
|
cardView: false, //是否显示详细视图
|
||||||
detailView: false, //是否显示父子表
|
detailView: false, //是否显示父子表
|
||||||
columns: [{
|
columns: [{
|
||||||
checkbox: true
|
checkbox: true
|
||||||
}, {
|
}, {
|
||||||
field: 'Id',
|
field: 'id',
|
||||||
title: 'ID'
|
title: 'ID'
|
||||||
}, {
|
}, {
|
||||||
field: 'ArticleKind.KindName',
|
field: 'articleKind.kindName',
|
||||||
title: '所属栏目'
|
title: '所属栏目'
|
||||||
}, {
|
}, {
|
||||||
field: 'Title',
|
field: 'title',
|
||||||
title: '文章标题'
|
title: '文章标题'
|
||||||
}, {
|
}, {
|
||||||
field: 'Sequence',
|
field: 'sequence',
|
||||||
title: '排序'
|
title: '排序'
|
||||||
}, {
|
}, {
|
||||||
field: 'AddTime',
|
field: 'addTime',
|
||||||
title: '添加时间'
|
title: '添加时间'
|
||||||
}, {
|
}, {
|
||||||
field: 'IsNew',
|
field: 'isNew',
|
||||||
title: '最新',
|
title: '最新',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
formatter: 'newFormatter'
|
formatter: 'newFormatter'
|
||||||
}, {
|
}, {
|
||||||
field: 'IsRecommend',
|
field: 'isRecommend',
|
||||||
title: '推荐',
|
title: '推荐',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
formatter: 'recommendFormatter'
|
formatter: 'recommendFormatter'
|
||||||
}, {
|
}, {
|
||||||
field: 'IsHide',
|
field: 'isHide',
|
||||||
title: '隐藏',
|
title: '隐藏',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
formatter: 'hideFormatter'
|
formatter: 'hideFormatter'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'Id',
|
field: 'id',
|
||||||
title: '操作',
|
title: '操作',
|
||||||
formatter: 'actionFormatter'
|
formatter: 'actionFormatter'
|
||||||
}
|
}
|
||||||
@@ -205,6 +213,92 @@
|
|||||||
|
|
||||||
return oInit;
|
return oInit;
|
||||||
};
|
};
|
||||||
|
function doBatchHide() {
|
||||||
|
var list = $('#tb_departments').bootstrapTable('getAllSelections');
|
||||||
|
var ids = [];
|
||||||
|
if (!list || list.length <1) {
|
||||||
|
layer.alert("请至少选择一篇文章!", { icon: 2 });
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
list.map(function (item, index) {
|
||||||
|
if (item.Id) {
|
||||||
|
ids.push(item.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//alert(JSON.stringify(ids));
|
||||||
|
//执行操作
|
||||||
|
var loading = layer.load(0, {
|
||||||
|
shade: [0.2, '#000'] //0.1透明度的背景
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/AdminCP/Article/DoBatchHideArticle",
|
||||||
|
data: { ids: JSON.stringify(ids)},
|
||||||
|
dataType: "JSON",
|
||||||
|
success: function (data) {
|
||||||
|
if (data.status == "success") {
|
||||||
|
layer.close(loading);
|
||||||
|
layer.msg(data.message, {
|
||||||
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
||||||
|
}, function () {
|
||||||
|
doSearch();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.close(loading);
|
||||||
|
layer.alert(data.message, { icon: 2 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.close(loading);
|
||||||
|
layer.alert('执行错误,请联系管理员!', { icon: 2 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function doBatchShow() {
|
||||||
|
var list = $('#tb_departments').bootstrapTable('getAllSelections');
|
||||||
|
var ids = [];
|
||||||
|
if (!list || list.length <1) {
|
||||||
|
//alert('请至少选择一行!');
|
||||||
|
layer.alert("请至少选择一篇文章!", { icon: 2 });
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
list.map(function (item, index) {
|
||||||
|
if (item.Id) {
|
||||||
|
ids.push(item.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//alert(JSON.stringify(ids));
|
||||||
|
//执行操作
|
||||||
|
var loading = layer.load(0, {
|
||||||
|
shade: [0.2, '#000'] //0.1透明度的背景
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/AdminCP/Article/DoBatchShowArticle",
|
||||||
|
data: { ids: JSON.stringify(ids)},
|
||||||
|
dataType: "JSON",
|
||||||
|
success: function (data) {
|
||||||
|
if (data.status == "success") {
|
||||||
|
layer.close(loading);
|
||||||
|
layer.msg(data.message, {
|
||||||
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
||||||
|
}, function () {
|
||||||
|
doSearch();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.close(loading);
|
||||||
|
layer.alert(data.message, { icon: 2 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.close(loading);
|
||||||
|
layer.alert('执行错误,请联系管理员!', { icon: 2 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -37,6 +37,12 @@
|
|||||||
<input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="栏目副标题,非必填" value="@Model.SubTitle" maxlength="200">
|
<input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="栏目副标题,非必填" value="@Model.SubTitle" maxlength="200">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group" style="display:none">
|
||||||
|
<label class="col-sm-3 control-label">栏目优化名称:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="KindDomain" name="KindDomain" maxlength="200" type="text" class="form-control" value="@Model.KindDomain" aria-required="true" placeholder="栏目优化名称,请填写英文或数字或-">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">Banner图片:</label>
|
<label class="col-sm-3 control-label">Banner图片:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
@{
|
||||||
|
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 = "moveArticleForm", @class = "form-horizontal m-t" }))
|
||||||
|
{
|
||||||
|
<div class="alert alert-info">
|
||||||
|
注意:请务必确认迁移栏目文章,本操作不可逆,请慎重操作!
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">从本栏目:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select class="form-control m-b" name="from" id="from">
|
||||||
|
@foreach (var m in ViewBag.ListKinds)
|
||||||
|
{
|
||||||
|
<option value="@m.Id">@m.KindName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">迁移至此栏目:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select class="form-control m-b" name="to" id="to">
|
||||||
|
@foreach (var m in ViewBag.ListKinds)
|
||||||
|
{
|
||||||
|
<option value="@m.Id">@m.KindName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</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-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
|
||||||
|
<button class="btn btn-default" type="button" onclick="closethisdialog();"><i class="fa fa-close"></i> 取消 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
DoPost("moveArticleForm");
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -325,7 +325,17 @@ function DoAdminLogin(formId, rules, messages) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
layer.close(loading);
|
layer.close(loading);
|
||||||
layer.alert(data.message, { icon: 2 });
|
if (data.other == "reload") {
|
||||||
|
layer.msg('页面访问超时,正在刷新页面,请重新登录!', function () {
|
||||||
|
//关闭后的操作
|
||||||
|
setTimeout(function () {
|
||||||
|
window.location.href = window.location.href;
|
||||||
|
},1500)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.alert(data.message, { icon: 2 });
|
||||||
|
}
|
||||||
|
|
||||||
btn.removeAttr("disabled");
|
btn.removeAttr("disabled");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Tables Version="9.9.6911.41890" NameSpace="COMCMS.Core" ConnName="dbconn" Output="" BaseClass="Entity">
|
<Tables Version="9.9.6911.41890" NameSpace="COMCMS.Core" ConnName="dbconn" Output="" BaseClass="Entity" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://www.newlifex.com https://raw.githubusercontent.com/NewLifeX/X/master/XCode/ModelSchema.xsd" xmlns="http://www.newlifex.com/ModelSchema.xsd">
|
||||||
<Table Name="Admin" Description="管理员" DbType="SqlServer">
|
<Table Name="Admin" Description="管理员" DbType="SqlServer">
|
||||||
<Columns>
|
<Columns>
|
||||||
<Column Name="Id" DataType="Int32" Identity="True" PrimaryKey="True" Description="编号" />
|
<Column Name="Id" DataType="Int32" Identity="True" PrimaryKey="True" Description="编号" />
|
||||||
|
|||||||
Reference in New Issue
Block a user