diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs
index 72e10e1..7f32fa1 100644
--- a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs
+++ b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs
@@ -691,6 +691,26 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
}
#endregion
+ #region 修改文章排序
+ [HttpPost]
+ [MyAuthorize("edit", "article", "JSON")]
+ public IActionResult DoEditArticleSequence(int id, int rank)
+ {
+ Article entity = Article.Find(Article._.Id == id);
+ if (entity == null)
+ {
+ tip.Message = "系统找不到本记录";
+ return Json(tip);
+ }
+ entity.Sequence = rank;
+ entity.Update();
+ Admin.WriteLogActions($"修改文章排序(id:{id},排序:{rank});");
+ tip.Message = "修改排序成功!";
+ tip.Status = JsonTip.SUCCESS;
+ return Json(tip);
+ }
+ #endregion
+
#region 迁移文章
[HttpGet]
[MyAuthorize("batch", "article")]
diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs
index aacf44c..3a3b1f2 100644
--- a/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs
+++ b/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs
@@ -290,6 +290,26 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
}
#endregion
+ #region 修改商品排序
+ [HttpPost]
+ [MyAuthorize("edit", "product", "JSON")]
+ public IActionResult DoEditProductSequence(int id, int rank)
+ {
+ Product entity = Product.Find(Product._.Id == id);
+ if (entity == null)
+ {
+ tip.Message = "系统找不到本记录";
+ return Json(tip);
+ }
+ entity.Sequence = rank;
+ entity.Update();
+ Admin.WriteLogActions($"修改商品排序(id:{id},排序:{rank});");
+ tip.Message = "修改排序成功!";
+ tip.Status = JsonTip.SUCCESS;
+ return Json(tip);
+ }
+ #endregion
+
#region 添加商品
[HttpGet]
[MyAuthorize("add", "product")]
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleCategoryList.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleCategoryList.cshtml
index 4fa81bf..8726859 100644
--- a/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleCategoryList.cshtml
+++ b/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleCategoryList.cshtml
@@ -25,7 +25,7 @@
| 栏目名称 |
ID |
- 排序 |
+ 排序 |
文章数量 |
隐藏 |
操作 |
@@ -70,10 +70,10 @@
return false;
}
//console.log(rank);
- //if (!isIntNum(rank)) {
- // layer.alert("排序只能是数字!", { icon: 2 });
- // return false;
- //}
+ if (!isInt(rank)) {
+ layer.alert("排序只能是数字!", { icon: 2 });
+ return false;
+ }
var loading = layer.load(0, {
shade: [0.2, '#000'] //0.1透明度的背景
});
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml
index ae30fb0..9fd4456 100644
--- a/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml
+++ b/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml
@@ -142,33 +142,45 @@
title: '所属栏目'
}, {
field: 'title',
- title: '文章标题'
+ title: '文章标题',
+ formatter: function (value, row, index) {
+ return '' + value + ''
+ }
}, {
field: 'sequence',
- title: '排序'
+ title: '排序',
+ width: 130,
+ formatter: function (value, row, index) {
+ return ''
+ }
}, {
field: 'addTime',
- title: '添加时间'
+ title: '添加时间',
+ width:150
}, {
field: 'isNew',
title: '最新',
align: 'center',
- formatter: 'newFormatter'
+ formatter: 'newFormatter',
+ width: 65
}, {
field: 'isRecommend',
title: '推荐',
align: 'center',
- formatter: 'recommendFormatter'
+ formatter: 'recommendFormatter',
+ width: 65
}, {
field: 'isHide',
title: '隐藏',
align: 'center',
- formatter: 'hideFormatter'
+ formatter: 'hideFormatter',
+ width: 65
},
{
field: 'id',
title: '操作',
- formatter: 'actionFormatter'
+ formatter: 'actionFormatter',
+ width:140
}
]
});
@@ -228,7 +240,45 @@
};
return oInit;
- };
+ };
+ function doSaveSequence(id) {
+ var rank = $("#ac_rank_" + id).val();
+ if (rank == '') {
+ layer.alert("请输入排序!", { icon: 2 });
+ return false;
+ }
+ //console.log(rank);
+ if (!isInt(rank)) {
+ layer.alert("排序只能是数字!", { icon: 2 });
+ return false;
+ }
+ var loading = layer.load(0, {
+ shade: [0.2, '#000'] //0.1透明度的背景
+ });
+ $.ajax({
+ type: "POST",
+ url: "/AdminCP/Article/DoEditArticleSequence",
+ data: { id: id, rank: rank },
+ dataType: "JSON",
+ success: function (data) {
+ if (data.status == "success") {
+ layer.close(loading);
+ layer.msg(data.message, {
+ time: 1000 //2秒关闭(如果不配置,默认是3秒)
+ }, function () {
+ //window.location.href = window.location.href;
+ });
+ } else {
+ layer.close(loading);
+ layer.alert(data.message, { icon: 2 });
+ }
+ },
+ error: function () {
+ layer.close(loading);
+ layer.alert('执行错误,请联系管理员!', { icon: 2 });
+ }
+ });
+ }
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Product/ProductList.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Product/ProductList.cshtml
index 7a5d990..60f1abf 100644
--- a/COMCMS.Web/Areas/AdminCP/Views/Product/ProductList.cshtml
+++ b/COMCMS.Web/Areas/AdminCP/Views/Product/ProductList.cshtml
@@ -111,7 +111,7 @@
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 25, //每页的记录行数(*)
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
- search: true, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
+ search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: true,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
@@ -132,37 +132,47 @@
title: '所属分类'
}, {
field: 'Title',
- title: '商品标题'
+ title: '商品标题',
+
}, {
field: 'Price',
title: '商品价格'
},
{
field: 'Sequence',
- title: '排序'
+ title: '排序',
+ width: 130,
+ formatter: function (value, row, index) {
+ return ''
+ }
}, {
field: 'AddTime',
- title: '添加时间'
+ title: '添加时间',
+ width: 150
}, {
field: 'IsNew',
title: '最新',
align: 'center',
- formatter: 'newFormatter'
+ formatter: 'newFormatter',
+ width: 65
}, {
field: 'IsRecommend',
title: '推荐',
align: 'center',
- formatter: 'recommendFormatter'
+ formatter: 'recommendFormatter',
+ width: 65
}, {
field: 'IsHide',
title: '隐藏',
align: 'center',
- formatter: 'hideFormatter'
+ formatter: 'hideFormatter',
+ width: 65
},
{
field: 'Id',
title: '操作',
- formatter: 'actionFormatter'
+ formatter: 'actionFormatter',
+ width: 140
}
]
});
@@ -223,7 +233,45 @@
};
return oInit;
- };
+ };
+ function doSaveSequence(id) {
+ var rank = $("#ac_rank_" + id).val();
+ if (rank == '') {
+ layer.alert("请输入排序!", { icon: 2 });
+ return false;
+ }
+ //console.log(rank);
+ if (!isInt(rank)) {
+ layer.alert("排序只能是数字!", { icon: 2 });
+ return false;
+ }
+ var loading = layer.load(0, {
+ shade: [0.2, '#000'] //0.1透明度的背景
+ });
+ $.ajax({
+ type: "POST",
+ url: "/AdminCP/Product/DoEditProductSequence",
+ data: { id: id, rank: rank },
+ dataType: "JSON",
+ success: function (data) {
+ if (data.status == "success") {
+ layer.close(loading);
+ layer.msg(data.message, {
+ time: 1000 //2秒关闭(如果不配置,默认是3秒)
+ }, function () {
+ //window.location.href = window.location.href;
+ });
+ } else {
+ layer.close(loading);
+ layer.alert(data.message, { icon: 2 });
+ }
+ },
+ error: function () {
+ layer.close(loading);
+ layer.alert('执行错误,请联系管理员!', { icon: 2 });
+ }
+ });
+ }
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Shared/_CommonLayout.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Shared/_CommonLayout.cshtml
index e23171e..95611eb 100644
--- a/COMCMS.Web/Areas/AdminCP/Views/Shared/_CommonLayout.cshtml
+++ b/COMCMS.Web/Areas/AdminCP/Views/Shared/_CommonLayout.cshtml
@@ -98,11 +98,13 @@
if ($(this).attr("placeholder") && $(this).attr("placeholder") != "") {
var tipstr = $(this).attr("placeholder");
var id = $(this).attr("id");
- $(this).on("focusin", function () {
- layer.tips(tipstr, '#' + id, {
- tips: [1, '#3595CC'] //还可配置颜色
+ if (id) {
+ $(this).on("focusin", function () {
+ layer.tips(tipstr, '#' + id, {
+ tips: [1, '#3595CC'] //还可配置颜色
+ });
});
- });
+ }
}
})
diff --git a/COMCMS.Web/Controllers/ArticleController.cs b/COMCMS.Web/Controllers/ArticleController.cs
index a2f9e18..14d4605 100644
--- a/COMCMS.Web/Controllers/ArticleController.cs
+++ b/COMCMS.Web/Controllers/ArticleController.cs
@@ -109,6 +109,10 @@ namespace COMCMS.Web.Controllers
{
return AlertAndGoBack("系统找不到本记录!");
}
+ if (entity.IsHide == 1 && !Admin.IsAdminLogin())
+ {
+ return EchoTip("系统找不到本文章!");
+ }
ArticleCategory kind = ArticleCategory.FindById(entity.KId);
if (kind == null)
{
diff --git a/COMCMS.Web/wwwroot/hplus/js/common.js b/COMCMS.Web/wwwroot/hplus/js/common.js
index c454fa1..75439dc 100644
--- a/COMCMS.Web/wwwroot/hplus/js/common.js
+++ b/COMCMS.Web/wwwroot/hplus/js/common.js
@@ -37,4 +37,17 @@ function showEdit(id) {
function cancelEdit(id) {
$("#row_" + id + " .rt-editpanel").show();
$("#row_" + id + " .rt-savepanel").addClass('hidden');
+}
+
+/*********
+验证是否是数字
+**********/
+function isInt(str) {
+ //如果为空,则通过校验
+ if (str == "")
+ return false;
+ if (/^(\-?)(\d+)$/.test(str))
+ return true;
+ else
+ return false;
}
\ No newline at end of file