完善商品栏目管理选择模板,商品栏目、商品伪静态地址生成
This commit is contained in:
@@ -43,7 +43,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web.Views") > -1)
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
@@ -174,7 +174,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web.Views") > -1)
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
|
||||
@@ -36,6 +36,24 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
//获取上级栏目
|
||||
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
||||
ViewBag.ListTree = list;
|
||||
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||
List<string> listTpls = new List<string>();
|
||||
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Product")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
foreach (var type in types)
|
||||
{
|
||||
string viewName = type.Name.Replace("Views_Product_", "") + ".cshtml";
|
||||
listTpls.Add(viewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewBag.ListTpl = listTpls;
|
||||
//获取模板
|
||||
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
|
||||
//ViewBag.ListTpl = listtpl;
|
||||
@@ -53,6 +71,33 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "商品栏目标题不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.FilePath))
|
||||
{
|
||||
if (!model.FilePath.StartsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径请以/开头!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (model.FilePath.EndsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径结尾不用加上/";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (model.FilePath.Count(x => x == '/') > 4)
|
||||
{
|
||||
tip.Message = "最多只能四级路径!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.FilePath) && !AdminUtils.CheckFilePathIsOK(model.FilePath, 0, 1))
|
||||
{
|
||||
tip.Message = "栏目路径不可用,请重新填写!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
model.Insert();
|
||||
Core.Admin.WriteLogActions("添加商品栏目(id:" + model.Id + ");");
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
@@ -74,9 +119,25 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
//获取上级栏目
|
||||
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
||||
ViewBag.ListTree = list;
|
||||
//获取模板
|
||||
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
|
||||
//ViewBag.ListTpl = listtpl;
|
||||
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||
List<string> listTpls = new List<string>();
|
||||
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Product")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
foreach (var type in types)
|
||||
{
|
||||
string viewName = type.Name.Replace("Views_Product_", "") + ".cshtml";
|
||||
listTpls.Add(viewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewBag.ListTpl = listTpls;
|
||||
|
||||
Core.Admin.WriteLogActions("查看/编辑商品栏目(id:" + id + ")页面;");
|
||||
return View(entity);
|
||||
}
|
||||
@@ -102,6 +163,30 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "系统找不到本记录!";
|
||||
Json(tip);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.FilePath))
|
||||
{
|
||||
if (!model.FilePath.StartsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径请以/开头!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (model.FilePath.EndsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径结尾不用加上/";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (model.FilePath.Count(x => x == '/') > 4)
|
||||
{
|
||||
tip.Message = "最多只能四级路径!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.FilePath) && !AdminUtils.CheckFilePathIsOK(model.FilePath, entity.Id, 1))
|
||||
{
|
||||
tip.Message = "栏目路径不可用,请重新填写!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (entity.PId != model.PId)
|
||||
{
|
||||
@@ -147,6 +232,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
entity.KindDomain = model.KindDomain;
|
||||
entity.Rank = model.Rank;
|
||||
entity.Pic = model.Pic;
|
||||
entity.FilePath = model.FilePath;
|
||||
|
||||
|
||||
entity.Save();
|
||||
|
||||
@@ -28,6 +28,14 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
pinyin = pcategory.FilePath+"/";
|
||||
}
|
||||
}
|
||||
else if(t == "category" && pid > 0)
|
||||
{
|
||||
Category pcategory = Category.FindById(pid);
|
||||
if (pcategory != null && !string.IsNullOrEmpty(pcategory.FilePath))
|
||||
{
|
||||
pinyin = pcategory.FilePath + "/";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
|
||||
@@ -27,7 +27,13 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写栏目名称">
|
||||
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写栏目名称" onblur="aoutoTransform()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目路径:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="FilePath" name="FilePath" maxlength="100" type="text" class="form-control" aria-required="true" placeholder="填写栏目路径,SEO优化使用,最多支持4级目录,可以输入字母、数字和-">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -69,29 +75,34 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@*<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
{
|
||||
<option value="@s" >@s</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" name="DetailTemplateFile" id="DetailTemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
{
|
||||
if (s.ToLower().StartsWith("index"))
|
||||
{
|
||||
<option value="@s">@s</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>*@
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">商品详情模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="DetailTemplateFile" id="DetailTemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
{
|
||||
if (s.ToLower().StartsWith("detail"))
|
||||
{
|
||||
<option value="@s">@s</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
||||
<div class="col-sm-8">
|
||||
@@ -145,5 +156,30 @@
|
||||
DoPost("addArticleKindForm");
|
||||
CKEDITOR.replace('KindInfo');
|
||||
})
|
||||
function aoutoTransform() {
|
||||
var title = $("#KindName").val();
|
||||
var filePath = $("#FilePath").val();
|
||||
var pid = $("#PId").val();
|
||||
if (!filePath) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/AdminCP/Server/Hanzi2Pinyin",
|
||||
data: { name: title, pid: pid, t: "category" },
|
||||
dataType: "JSON",
|
||||
success: function (data) {
|
||||
if (data.status == "success") {
|
||||
if (data.message) {
|
||||
$("#FilePath").val(data.message);
|
||||
}
|
||||
} else {
|
||||
layer.alert(data.message, { icon: 2 });
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('执行错误,请联系管理员!', { icon: 2 });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
@foreach (var m in Model)
|
||||
{
|
||||
<tr class="treegrid-@m.Id @(m.PId !=0?"treegrid-parent-"+m.PId:"") ">
|
||||
<td>@m.KindName</td>
|
||||
<td><a href="@ViewsHelper.EchoURL(m)" target="_blank" title="新窗口打开栏目">@m.KindName</a></td>
|
||||
<td>
|
||||
@m.Id
|
||||
</td>
|
||||
|
||||
@@ -28,7 +28,13 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" value="@Model.KindName" required aria-required="true" placeholder="填写栏目名称">
|
||||
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" value="@Model.KindName" required aria-required="true" placeholder="填写栏目名称" onblur="aoutoTransform()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目路径:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="FilePath" name="FilePath" maxlength="100" type="text" class="form-control" aria-required="true" placeholder="填写栏目路径,SEO优化使用,最多支持4级目录,可以输入字母、数字和-" value="@Model.FilePath">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -86,28 +92,34 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@*<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" asp-for="TemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
{
|
||||
if (s.ToLower().StartsWith("index"))
|
||||
{
|
||||
<option value="@s" @(Model.TemplateFile == s?"selected":"")>@s</option>
|
||||
<option value="@s">@s</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">商品模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="DetailTemplateFile" id="DetailTemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">商品详情模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" asp-for="DetailTemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
{
|
||||
if (s.ToLower().StartsWith("detail"))
|
||||
{
|
||||
<option value="@s" @(Model.DetailTemplateFile == s?"selected":"")>@s</option>
|
||||
<option value="@s">@s</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>*@
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
||||
<div class="col-sm-8">
|
||||
@@ -162,4 +174,29 @@
|
||||
DoPost("editCategoryForm");
|
||||
CKEDITOR.replace('KindInfo');
|
||||
})
|
||||
function aoutoTransform() {
|
||||
var title = $("#KindName").val();
|
||||
var filePath = $("#FilePath").val();
|
||||
var pid = $("#PId").val();
|
||||
if (!filePath) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/AdminCP/Server/Hanzi2Pinyin",
|
||||
data: { name: title, pid: pid, t: "category" },
|
||||
dataType: "JSON",
|
||||
success: function (data) {
|
||||
if (data.status == "success") {
|
||||
if (data.message) {
|
||||
$("#FilePath").val(data.message);
|
||||
}
|
||||
} else {
|
||||
layer.alert(data.message, { icon: 2 });
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('执行错误,请联系管理员!', { icon: 2 });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -135,7 +135,10 @@
|
||||
title: '所属分类'
|
||||
}, {
|
||||
field: 'Title',
|
||||
title: '商品标题',
|
||||
title: '商品标题',
|
||||
formatter: function (value, row, index) {
|
||||
return '<a href="/Product/Detail/' + row["id"] + '" target="_blank" title="新窗口打开预览商品">' + value + '</a>'
|
||||
}
|
||||
|
||||
}, {
|
||||
field: 'Price',
|
||||
|
||||
Reference in New Issue
Block a user