1、后台增加文章管理;2、更新CKeditor到最新,并修复最新版本上传文件接口错误问题;3、其他细节更新

This commit is contained in:
2018-04-18 20:43:33 +08:00
parent 309b696266
commit 13ab681205
194 changed files with 4160 additions and 2048 deletions
@@ -0,0 +1,424 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using COMCMS.Common;
using COMCMS.Core;
using XCode;
using Newtonsoft.Json;
using COMCMS.Web.Common;
using Microsoft.AspNetCore.Http;
namespace COMCMS.Web.Areas.AdminCP.Controllers
{
public class ArticleController : AdminBaseController
{
#region 文章栏目
/// <summary>
/// 文章栏目列表
/// </summary>
/// <returns></returns>
[MyAuthorize( "viewlist", "articlecategory")]
public IActionResult ArticleCategoryList()
{
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, false, true);
Core.Admin.WriteLogActions("查看文章栏目列表页面;");
return View(list);
}
[MyAuthorize( "add", "articlecategory")]
public IActionResult AddArticleCategory()
{
//获取上级栏目
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
ViewBag.ListTree = list;
//获取模板
Core.Admin.WriteLogActions("查看添加文章栏目页面;");
return View();
}
[HttpPost]
[MyAuthorize( "add", "articlecategory", "JSON")]
public IActionResult AddArticleCategory(ArticleCategory model)
{
//获取上级栏目
if (string.IsNullOrWhiteSpace(model.KindName))
{
tip.Message = "文章栏目标题不能为空!";
return Json(tip);
}
model.Insert();
Core.Admin.WriteLogActions("添加文章栏目(id:" + model.Id + ");");
tip.Status = JsonTip.SUCCESS;
tip.Message = "添加文章栏目成功";
tip.ReturnUrl = "close";
return Json(tip);
}
//编辑栏目
[MyAuthorize( "edit", "articlecategory")]
public IActionResult EditArticleCategory(int id)
{
ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == id);
if (entity == null)
{
return EchoTipPage("系统找不到本记录!");
}
//获取上级栏目
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
ViewBag.ListTree = list;
//获取模板
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
//ViewBag.ListTpl = listtpl;
Core.Admin.WriteLogActions("查看/编辑文章栏目(id:" + id + ")页面;");
return View(entity);
}
[HttpPost]
[MyAuthorize( "edit", "articlecategory", "JSON")]
public IActionResult EditArticleCategory(ArticleCategory model)
{
if (model.Id <= 0)
{
tip.Message = "错误参数传递!";
Json(tip);
}
if (string.IsNullOrWhiteSpace(model.KindName))
{
tip.Message = "文章栏目标题不能为空!";
return Json(tip);
}
ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == model.Id);
if (entity == null)
{
tip.Message = "系统找不到本记录!";
Json(tip);
}
if (entity.PId != model.PId)
{
if (entity.Id == model.PId)
{
tip.Message = "上级栏目不能选择本身!";
return Json(tip);
}
entity.PId = model.PId;
entity.Location = ArticleCategory.GetNewLocation(model.PId);
entity.Level = ArticleCategory.GetNewLevel(model.PId);
//修改文章的location
IList<Article> alist = Article.FindAll(Article._.KId == model.Id, null, null, 0, 0);
if (alist != null && alist.Count > 0)
{
foreach (var a in alist)
{
a.Location = entity.Location + "," + entity.Id;
//a.FilePath = entity.FilePath;
}
alist.Save();
}
}
//赋值
entity.PId = model.PId;
entity.KindName = model.KindName;
entity.SubTitle = model.SubTitle;
entity.KindTitle = model.KindTitle;
entity.Keyword = model.Keyword;
entity.Description = model.Description;
entity.LinkURL = model.LinkURL;
entity.TitleColor = model.TitleColor;
entity.TemplateFile = model.TemplateFile;
entity.DetailTemplateFile = model.DetailTemplateFile;
entity.IsList = model.IsList;
entity.PageSize = model.PageSize <= 0 ? 15 : model.PageSize;
entity.IsLock = model.IsLock;
entity.IsHide = model.IsHide;
entity.IsShowSubDetail = model.IsShowSubDetail;
entity.BannerImg = model.BannerImg;
entity.Pic = model.Pic;
entity.KindInfo = model.KindInfo;
entity.KindDomain = model.KindDomain;
entity.Rank = model.Rank;
entity.Pic = model.Pic;
entity.Save();
Core.Admin.WriteLogActions("修改文章栏目(id:" + entity.Id + ");");
tip.Status = JsonTip.SUCCESS;
tip.Message = "修改文章栏目成功";
tip.ReturnUrl = "close";
return Json(tip);
}
//删除栏目
[HttpPost]
[MyAuthorize( "del", "articlecategory", "JSON")]
public JsonResult DelArticleCategory(int id)
{
ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == id);
if (entity == null)
{
tip.Message = "系统找不到本文章栏目!";
return Json(tip);
}
if (ArticleCategory.FindCount(ArticleCategory._.PId == entity.Id, null, null, 0, 0) > 0)
{
tip.Message = "本栏目有下级栏目,不允许删除!";
return Json(tip);
}
//删除文章
IList<Article> list = Article.FindAll(Article._.KId == entity.Id, null, null, 0, 0);
if (list != null && list.Count > 0)
{
list.Delete();
}
Core.Admin.WriteLogActions("删除文章栏目(id:" + entity.Id + ");");
entity.Delete();
tip.Status = JsonTip.SUCCESS;
tip.Message = "删除文章栏目成功";
return Json(tip);
}
#endregion
#region 文章
[MyAuthorize("viewlist", "article")]
public IActionResult ArticleList()
{
//获取上级栏目
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
ViewBag.ListKinds = list;
Core.Admin.WriteLogActions("查看文章列表;");
return View();
}
[MyAuthorize("viewlist", "article", "JSON")]
public IActionResult GetArticleList(string keyword, int page = 1, int limit = 20)
{
int numPerPage, currentPage, startRowIndex;
numPerPage = limit;
currentPage = page;
startRowIndex = (currentPage - 1) * numPerPage;
Expression ex = Article._.Id > 0;
if (!string.IsNullOrWhiteSpace(keyword))
{
if (Utils.IsInt(keyword))
{
ex &= (Article._.Id == int.Parse(keyword) | Article._.Title.Contains(keyword));
}
else
{
ex &= Article._.Title.Contains(keyword);
}
}
string kid = Request.Query["kid"];
string isshowsub = Request.Query["isshowsub"];
if (Utils.IsInt(kid) && int.Parse(kid) > 0)
{
//获取栏目
if (isshowsub == "1")
{
List<int> kids = new List<int>();
kids.Add(int.Parse(kid));
IList<ArticleCategory> subkinds = ArticleCategory.FindByParentID(int.Parse(kid));
if (subkinds != null && subkinds.Count > 0)
{
foreach (var item in subkinds)
{
kids.Add(item.Id);
}
ex &= Article._.KId.In(kids);
}
}
else
{
ex &= Article._.KId == int.Parse(kid);
}
}
IList<Article> list = Article.FindAll(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage);
long totalCount = Article.FindCount(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage);
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
}
//添加文章
[HttpGet]
[MyAuthorize("add", "article")]
public IActionResult AddArticle()
{
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
ViewBag.ListKinds = list;
string lastkid = SessionHelper.GetSession("com_add_article_kid").ToString();
ViewBag.lastkid = lastkid;
Core.Admin.WriteLogActions("查看添加文章页面;");
return View();
}
//执行添加文章
[HttpPost]
[MyAuthorize("add", "article", "JSON")]
public IActionResult AddArticle(Article model)
{
if (model.KId <= 0)
{
tip.Message = "请选择一个文章栏目";
return Json(tip);
}
if (string.IsNullOrWhiteSpace(model.Title))
{
tip.Message = "请填写文章标题";
return Json(tip);
}
if (string.IsNullOrWhiteSpace(model.Content))
{
tip.Message = "请填写文章内容";
return Json(tip);
}
if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic))
{
tip.Message = "文章图片填写的不是图片格式!";
return Json(tip);
}
//处理文章更多图片
string[] moreImgSrc = Request.Form["nImgUrl"];
string morIMG = string.Empty;//更多图片的时候用到
if (moreImgSrc != null && moreImgSrc.Length > 0)
{
foreach (string s in moreImgSrc)
{
if (Utils.IsImgFilename(s))
{
morIMG += s + "|||";//使用“|||”分隔图片
}
}
}
model.ItemImg = morIMG;
model.AuthorId = Core.Admin.GetMyInfo().Id;
model.Insert();
ArticleCategory.UpdateDetailCount(model.KId);
SessionHelper.WriteSession("com_add_article_kid", model.KId);
//添加TAG
//Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title);
Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");");
tip.Status = JsonTip.SUCCESS;
tip.Message = "添加文章成功";
tip.ReturnUrl = "close";
return Json(tip);
}
//编辑文章
[HttpGet]
[MyAuthorize("edit", "article")]
public IActionResult EditArticle(int id)
{
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
ViewBag.ListKinds = list;
Article entity = Article.Find(Article._.Id == id);
if (entity == null)
{
return EchoTipPage("系统找不到本记录!");
}
Core.Admin.WriteLogActions("查看文章(" + id + ");");
return View(entity);
}
[HttpPost]
[MyAuthorize("edit", "article", "JSON")]
public IActionResult EditArticle(Article model)
{
if (model.Id <= 0)
{
tip.Message = "错误参数传递!";
Json(tip);
}
Article entity = Article.Find(Article._.Id == model.Id);
if (entity == null)
{
tip.Message = "系统找不到本记录!";
return Json(tip);
}
if (string.IsNullOrWhiteSpace(model.Title))
{
tip.Message = "文章标题不能为空!";
return Json(tip);
}
if (string.IsNullOrWhiteSpace(model.Content))
{
tip.Message = "请填写文章内容";
return Json(tip);
}
if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic))
{
tip.Message = "文章图片填写的不是图片格式!";
return Json(tip);
}
//处理文章更多图片
string[] moreImgSrc = Request.Form["nImgUrl"];
string morIMG = string.Empty;//更多图片的时候用到
if (moreImgSrc != null && moreImgSrc.Length > 0)
{
foreach (string s in moreImgSrc)
{
if (Utils.IsImgFilename(s))
{
morIMG += s + "|||";//使用“|||”分隔图片
}
}
}
//处理三个勾选属性的
string isnew = Request.Form["IsNew"];
model.IsNew = isnew == "1" ? 1 : 0;
string IsRecommend = Request.Form["IsRecommend"];
model.IsRecommend = IsRecommend == "1" ? 1 : 0;
string IsHide = Request.Form["IsHide"];
model.IsHide = IsHide == "1" ? 1 : 0;
model.Hits = entity.Hits;
model.UpdateTime = DateTime.Now;
model.ItemImg = morIMG;
//model.AuthorId = Core.Admin.GetMyInfo().Id;
model.Save();
//Tag.ModifyTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title);
Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");");
tip.Status = JsonTip.SUCCESS;
tip.Message = "编辑文章详情成功";
tip.ReturnUrl = "close";
return Json(tip);
}
//删除文章
[HttpPost]
[MyAuthorize("del", "article", "JSON")]
public JsonResult DelArtice(int id)
{
Article entity = Article.Find(Article._.Id == id);
if (entity == null)
{
tip.Message = "系统找不到本文章!";
return Json(tip);
}
int kid = entity.Id;
//删除TAG
//Tag.DeleteTag(RTType.RatuoModule.Article, entity.Id);
Core.Admin.WriteLogActions("删除文章(id:" + entity.Id + ");");
entity.Delete();
ArticleCategory.UpdateDetailCount(kid);
tip.Status = JsonTip.SUCCESS;
tip.Message = "删除文章成功";
return Json(tip);
}
#endregion
}
}
@@ -135,8 +135,9 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
{
if (!string.IsNullOrWhiteSpace(model.WaterMarkImg))
{
if (!System.IO.File.Exists(Path.Combine(_env.WebRootPath, model.WaterMarkImg)))
string imgPath = _env.WebRootPath + model.WaterMarkImg.Replace("/", "\\");
NewLife.Log.XTrace.WriteLine(_env.WebRootPath + "|" + Path.Combine(_env.WebRootPath, model.WaterMarkImg) + "|" + imgPath);
if (!System.IO.File.Exists(imgPath))
{
tip.Message = "水印图片不存在,请重新上传!";
return Json(tip);
@@ -18,6 +18,26 @@ using Microsoft.AspNetCore.Http.Internal;
namespace COMCMS.Web.Areas.AdminCP.Controllers
{
#region CKEditor错误返回实体类
/// <summary>
/// CKEditor错误返回实体类
/// </summary>
public class CKFileUploadError
{
public CKFileUploadErrorMessage error { get; set; } = new CKFileUploadErrorMessage();
}
public class CKFileUploadErrorMessage
{
/// <summary>
/// 错误代码
/// </summary>
public int number { get; set; } = 100;
/// <summary>
/// 错误信息
/// </summary>
public string message { get; set; }
}
#endregion
/// <summary>
/// 后台上传文件帮助类
/// </summary>
@@ -32,7 +52,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
_env = env;
_attachsetting = attachsetting.Value;
}
#region CKEditor 上传图片
/// <summary>
/// ckeditor 上传图片
@@ -43,14 +63,21 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
string callback = Request.Query["CKEditorFuncNum"];//要求返回值
var upload = Request.Form.Files[0];
string tpl = "<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction(\"{1}\", \"{0}\", \"{2}\");</script>";
//string tpl = "<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction(\"{1}\", \"{0}\", \"{2}\");</script>";
CKFileUploadError errorJson = new CKFileUploadError();
if (upload == null)
return Content(string.Format(tpl, "", callback, "请选择一张图片!"), "text/html");
{
errorJson.error.message = "请选择一张图片!";
return Json(errorJson);
}
//判断是否是图片类型
List<string> imgtypelist = new List<string> { "image/pjpeg", "image/png", "image/x-png", "image/gif", "image/bmp", "image/jpeg" };
if (imgtypelist.FindIndex(x => x == upload.ContentType) == -1)
{
return Content(string.Format(tpl, "", callback, "请上传一张图片!"), "text/html");
errorJson.error.message = "请选择一张图片!";
return Json(errorJson);
//return Content(string.Format(tpl, "", callback, "请上传一张图片!"), "text/html");
}
var data = Request.Form.Files["upload"];
string filepath = $"{_env.WebRootPath}\\{attach.AttachPatch}\\images\\";
@@ -157,9 +184,19 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
}
catch (Exception ex)
{
return Content(string.Format(tpl, "", callback, "图片上传失败:" + ex.Message), "text/html");
errorJson.error.message = "图片上传失败," + ex.Message + "!";
return Json(errorJson);
//return Content(string.Format(tpl, "", callback, "图片上传失败:" + ex.Message), "text/html");
}
return Content(string.Format(tpl, $"/{attach.AttachPatch}/images/{imgPath.Replace("\\", "/")}/" + imgname, callback, ""), "text/html");
dynamic successJson = new
{
fileName = imgname,
uploaded = 1,
url = $"/{attach.AttachPatch}/images/{imgPath.Replace("\\", "/")}/" + imgname
};
return Json(successJson);
//{"fileName":"20180413145904.png","uploaded":1,"url":"\/userfiles\/files\/Public%20Folder\/20180413145904.png"}
//return Content(string.Format(tpl, $"/{attach.AttachPatch}/images/{imgPath.Replace("\\", "/")}/" + imgname, callback, ""), "text/html");
}
#endregion
@@ -169,13 +206,20 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
string callback = Request.Query["CKEditorFuncNum"];//要求返回值
var upload = Request.Form.Files[0];
string tpl = "<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction(\"{1}\", \"{0}\", \"{2}\");</script>";
CKFileUploadError errorJson = new CKFileUploadError();
if (upload == null)
return Content(string.Format(tpl, "", callback, "请选择一个文件!"), "text/html");
{
errorJson.error.message = "请选择一个文件!";
return Json(errorJson);
}
//return Content(string.Format(tpl, "", callback, "请选择一个文件!"), "text/html");
string sFileNameNoExt = Utils.GetFileNameWithoutExtension(upload.FileName);//文件名字,不带扩展名
string sFullExtension = Utils.GetFileExtName(upload.FileName);//扩展名
if (string.IsNullOrEmpty(sFullExtension))
{
return Content(string.Format(tpl, "", callback, $"错误的文件类型!"), "text/html");
errorJson.error.message = "错误的文件类型!";
return Json(errorJson);
//return Content(string.Format(tpl, "", callback, $"错误的文件类型!"), "text/html");
}
//判断是否是允许文件扩展名
string sAllowedExtensions = _attachsetting.FileAllowedExtensions;
@@ -190,7 +234,9 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
}
if (listAllowedExtensions.Find(x => x == sFullExtension.ToLower().Replace(".", "")) == null)
{
return Content(string.Format(tpl, "", callback, $"{sFullExtension}的文件类型,不允许上传!"), "text/html");
errorJson.error.message = $"{sFullExtension}的文件类型,不允许上传!";
return Json(errorJson);
//return Content(string.Format(tpl, "", callback, $"{sFullExtension}的文件类型,不允许上传!"), "text/html");
}
//判断是否是图片,如果是图片,后面需要生成缩略图并可能的话,就加上水印
bool isImage = false;
@@ -299,9 +345,18 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
}
catch (Exception ex)
{
return Content(string.Format(tpl, "", callback, "文件上传失败:" + ex.Message), "text/html");
errorJson.error.message = "文件上传失败:" + ex.Message;
return Json(errorJson);
//return Content(string.Format(tpl, "", callback, "文件上传失败:" + ex.Message), "text/html");
}
return Content(string.Format(tpl, $"/{attach.AttachPatch}/fales/{imgPath.Replace("\\", "/")}/" + imgname, callback, ""), "text/html");
dynamic successJson = new
{
fileName = imgname,
uploaded = 1,
url = $"/{attach.AttachPatch}/images/{imgPath.Replace("\\", "/")}/" + imgname
};
return Json(successJson);
//return Content(string.Format(tpl, $"/{attach.AttachPatch}/fales/{imgPath.Replace("\\", "/")}/" + imgname, callback, ""), "text/html");
}
#endregion
@@ -0,0 +1,186 @@
@{
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 = "addArticleForm", @class = "form-horizontal m-t" }))
{
<div class="form-group">
<label class="col-sm-3 control-label">文章栏目:</label>
<div class="col-sm-8">
<select class="form-control m-b" name="KId" id="KId">
@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">
<input id="Title" name="Title" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写文章标题">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">副标题:</label>
<div class="col-sm-8">
<input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="文章副标题,非必填" data-title="文章副标题" maxlength="200">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">标题颜色:</label>
<div class="col-sm-8">
<input id="TitleColor" type="text" class="form-control" name="TitleColor" placeholder="标题颜色,可以填写一个如:#FF0000等" maxlength="20">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章来源:</label>
<div class="col-sm-8">
<input id="Origin" type="text" class="form-control" name="Origin" placeholder="文章来源,不填前台显示:网络" data-title="文章来源,不填前台显示:网络" maxlength="50">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">添加时间:</label>
<div class="col-sm-8">
<input id="AddTime" type="text" class="form-control" name="AddTime" placeholder="文章来源,不填前台显示:网络" required onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" value="@DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">排序:</label>
<div class="col-sm-8">
<input id="Sequence" type="number" class="form-control" name="Sequence" value="999" maxlength="20" placeholder="越小排得越前" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">关键字:</label>
<div class="col-sm-8">
<input id="Keyword" type="text" class="form-control" name="Keyword" value="" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">描述:</label>
<div class="col-sm-8">
<input id="Description" type="text" class="form-control" name="Description" value="" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">TAG:</label>
<div class="col-sm-8">
<input id="Tags" type="text" class="form-control" name="Tags" value="" maxlength="250" placeholder="TAG关键字,不同关键字请用“,”(英文逗号)隔开" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章点击数量:</label>
<div class="col-sm-8">
<input id="Hits" type="number" class="form-control" name="Hits" value="0" maxlength="20" placeholder="文章点击数量,仅对文章列表页面有效" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">跳转链接:</label>
<div class="col-sm-8">
<input id="LinkURL" type="text" class="form-control" name="LinkURL" value="" maxlength="200" placeholder="填写则点击该类别自动跳转到该地址" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">其他属性:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsNew" id="IsNew"> 最新文章
</label>
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsRecommend" id="IsRecommend"> 推荐文章
</label>
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsHide" id="IsHide"> 隐藏文章
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章图片:</label>
<div class="col-sm-8">
<div class="input-group">
<input id="Pic" name="Pic" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="">
<span class="input-group-addon my-upload-span upload-img"></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章内容:</label>
<div class="col-sm-8">
<textarea id="Content" name="Content" class="form-control" placeholder="可以输入文章内容" required></textarea>
</div>
</div>
<div id="MoreImages">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">更多图片(相册):</label>
<div class="col-sm-8">
<button class="btn btn-info" type="button" onclick="addImagesrow();"><i class="fa fa-plus"></i> 添加图片 </button>
</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>
var htmlText = '<div class="form-group" id="nImgRow{0}">';
htmlText += '<label class="col-sm-3 control-label"><button type="button" class="btn btn-danger btn-sm" onclick="delmyImgRow(\'nImgRow{0}\')"> <i class="fa fa-close"></i> 删除</button></label>';
htmlText += '<div class="col-sm-8">';
htmlText += '<div class="input-group">';
htmlText += '<input id="nImgUrlnImgRow{0}" name="nImgUrl" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="">';
htmlText += '<span class="input-group-addon my-upload-span upload-img" id="newimg_{0}"></span>';
htmlText += '</div></div></div>';
var items = 1;
function addImagesrow() {
var newHtmlTr = htmlText.replace(/\{0\}/g, "new" + items);
$('#MoreImages').append(newHtmlTr);
$("#newimg_new" + items).InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp,jpeg", notwater: true });
items += 1;
}
function delmyImgRow(id) {
$("#" + id).remove();
}
$(function () {
//初始化上传控件
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp,jpeg", notwater: true });
DoPost("addArticleForm");
//
$("#TitleColor").colorpicker();
CKEDITOR.replace('Content');
})
</script>
@if (!string.IsNullOrEmpty(ViewBag.lastkid))
{
<script>
$(function () {
$("#KId").val(@ViewBag.lastkid);
})
</script>
}
@@ -0,0 +1,151 @@
@{
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 = "addArticleKindForm", @class = "form-horizontal m-t" }))
{
<div class="form-group">
<label class="col-sm-3 control-label">上级栏目:</label>
<div class="col-sm-8">
<select class="form-control m-b" name="PId" id="PId">
<option value="0">一级栏目</option>
@foreach (var m in ViewBag.ListTree)
{
<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">
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写栏目名称">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">副标题:</label>
<div class="col-sm-8">
<input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="栏目副标题,非必填" maxlength="200">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Banner图片:</label>
<div class="col-sm-8">
<div class="input-group">
<input id="BannerImg" name="BannerImg" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个Banner图片" value="">
<span class="input-group-addon my-upload-span upload-img"></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">排序:</label>
<div class="col-sm-8">
<input id="Rank" type="number" class="form-control" name="Rank" value="0" maxlength="20" placeholder="越小排得越前" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章列表:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsList" id="IsList" checked> 文章列表页(勾上则该栏目为文章列表页面。)
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">列表文章数量:</label>
<div class="col-sm-8">
<input id="PageSize" type="number" class="form-control" name="PageSize" value="15" maxlength="20" placeholder="文章列表页面每页文章显示条数,仅对文章列表页面有效" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">显示下级栏目文章:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsShowSubDetail" id="IsShowSubDetail" checked> 显示下级栏目文章(勾选则该栏目列表,显示下级栏目文章。)
</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)
{
<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">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsHide" id="IsHide"> 隐藏栏目(栏目在前台不显示)
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">栏目关键字:</label>
<div class="col-sm-8">
<input id="Keyword" type="text" class="form-control" name="Keyword" value="" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">栏目描述:</label>
<div class="col-sm-8">
<input id="Description" type="text" class="form-control" name="Description" value="" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">跳转链接:</label>
<div class="col-sm-8">
<input id="LinkURL" type="text" class="form-control" name="LinkURL" value="" maxlength="200" placeholder="填写则点击该类别自动跳转到该地址" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">栏目介绍:</label>
<div class="col-sm-8">
<textarea id="KindInfo" name="KindInfo" class="form-control" placeholder="可以输入栏目的详细介绍"></textarea>
</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 () {
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true });
DoPost("addArticleKindForm");
CKEDITOR.replace('KindInfo');
})
</script>
@@ -0,0 +1,69 @@
@model IList<COMCMS.Core.ArticleCategory>
@{
ViewBag.title = "文章栏目管理";
}
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>@ViewBag.Title</h5>
</div>
<div class="ibox-content">
<div id="toolbar" class="btn-group">
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="showDialog('addarticlekind','添加文章栏目','/AdminCP/Article/AddArticleCategory',0,0);">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
</button>
</div>
<div id="toolbar2" class="btn-group pull-right">
<button id="btn_refresh" type="button" class="btn btn-outline btn-default" onclick="refresh();">
<span class="fa fa-refresh" aria-hidden="true"></span>刷新
</button>
</div>
<table class="tree table table-striped table-bordered">
<thead>
<tr>
<th>栏目名称</th>
<th>ID</th>
<th class="text-center">排序</th>
<th class="text-center">文章数量</th>
<th class="text-center">隐藏</th>
<th width="200">操作</th>
</tr>
</thead>
@if (Model.Count == 0)
{
<tr><td colspan="6" class="text-center">暂无记录...</td></tr>
}
@foreach (var m in Model)
{
<tr class="treegrid-@m.Id @(m.PId !=0?"treegrid-parent-"+m.PId:"") ">
<td>@m.KindName</td>
<td>
@m.Id
</td>
<td class="text-center">@m.Rank</td>
<td class="text-center">@m.Counts</td>
<td class="text-center">
@if (m.IsHide == 1)
{
<i class="fa fa-eye-slash"></i>
}
</td>
<td>
<a href="javascript:;" class="btn btn-xs btn-primary" title="编辑" onclick="top.showDialog('eidtarticlekind', '编辑文章栏目详情', '/AdminCP/Article/EditArticleCategory/@m.Id', 0, 0)"><i class="fa fa-edit"></i> 编辑</a>
<a href="javascript:;" class="btn btn-xs btn-danger" title="删除" onclick="doDel('/AdminCP/Article/DelArticleCategory',@m.Id);"><i class="fa fa-close"></i> 删除</a>
</td>
</tr>
}
</table>
<script type="text/javascript">
$(document).ready(function() {
$('.tree').treegrid();
});
</script>
</div>
</div>
</div>
@@ -0,0 +1,209 @@
@{
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="return doSearch(); return false;">
<div>
<label class="control-label">文章栏目:</label>
<select class="form-control" name="kid" id="kid">
<option value="0">所有栏目</option>
@foreach (var m in ViewBag.ListKinds)
{
<option value="@m.Id">@m.KindName</option>
}
</select>
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="isshowsub" id="isshowsub" /> 显示下级栏目文章
</label>
<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>
<div id="toolbar" class="btn-group">
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addarticle','添加文章','/AdminCP/Article/AddArticle',0,0)">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
</button>
@*<button id="btn_edit" type="button" class="btn btn-outline btn-default">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
</button>
<button id="btn_delete" type="button" class="btn btn-outline btn-default">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
</button>*@
</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(),
isshowsub: $("#isshowsub").prop("checked") ? 1:0
};
return temp;
}
$('#tb_departments').bootstrapTable('refresh', params);
}
var TableInit = function () {
var oTableInit = new Object();
//初始化Table
oTableInit.Init = function () {
$('#tb_departments').bootstrapTable({
url: '/AdminCP/Article/GetArticleList', //请求后台的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: true, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
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: 'ArticleKind.KindName',
title: '所属栏目'
}, {
field: 'Title',
title: '文章标题'
}, {
field: 'Sequence',
title: '排序'
}, {
field: 'AddTime',
title: '添加时间'
}, {
field: 'IsNew',
title: '最新',
align: 'center',
formatter: 'newFormatter'
}, {
field: 'IsRecommend',
title: '推荐',
align: 'center',
formatter: 'recommendFormatter'
}, {
field: 'IsHide',
title: '隐藏',
align: 'center',
formatter: 'hideFormatter'
},
{
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(\'eidtarticle\', \'编辑文章详情\', \'/AdminCP/Article/EditArticle/' + value + '\', 0, 0)"><i class="fa fa-edit"></i> 编辑</a>',
'<a href="javascript:;" class="btn btn-xs btn-danger m-l-xs" title="删除" onclick="doDel(\'/AdminCP/Article/DelArtice\',' + value + ');"><i class="fa fa-close"></i> 删除</a>',
].join('');
}
function newFormatter(value, row, index) {
if (value == 1) {
return '<i class="fa fa-circle-o"></i>';
} else {
return '';
}
}
function recommendFormatter(value, row, index) {
if (value == 1) {
return '<i class="fa fa-star"></i>';
} else {
return '';
}
}
function hideFormatter(value, row, index) {
if (value == 1) {
return '<i class="fa fa-eye-slash"></i>';
} else {
return '';
}
}
var ButtonInit = function () {
var oInit = new Object();
var postdata = {};
oInit.Init = function () {
//初始化页面上面的按钮事件
};
return oInit;
};
</script>
</div>
</div>
</div>
@@ -0,0 +1,201 @@
@model COMCMS.Core.Article
@{
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 = "editArticleForm", @class = "form-horizontal m-t" }))
{
<div class="form-group">
<label class="col-sm-3 control-label">文章栏目:</label>
<div class="col-sm-8">
<select class="form-control m-b" asp-for="KId">
@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">
<input id="Title" name="Title" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写文章标题" value="@Model.Title">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">副标题:</label>
<div class="col-sm-8">
<input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="栏目副标题,非必填" maxlength="200" value="@Model.SubTitle">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">标题颜色:</label>
<div class="col-sm-8">
<input id="TitleColor" type="text" class="form-control" name="TitleColor" placeholder="标题颜色,可以填写一个如:#FF0000等" maxlength="20" value="@Model.TitleColor">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章来源:</label>
<div class="col-sm-8">
<input id="Origin" type="text" class="form-control" name="Origin" placeholder="文章来源,不填前台显示:网络" maxlength="50" value="@Model.Origin">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">添加时间:</label>
<div class="col-sm-8">
<input id="AddTime" type="text" class="form-control" name="AddTime" placeholder="文章来源,不填前台显示:网络" required onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" value="@Model.AddTime.ToString("yyyy-MM-dd HH:mm:ss")">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">排序:</label>
<div class="col-sm-8">
<input id="Sequence" type="number" class="form-control" name="Sequence" value="@Model.Sequence" maxlength="20" placeholder="越小排得越前" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">关键字:</label>
<div class="col-sm-8">
<input id="Keyword" type="text" class="form-control" name="Keyword" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true" value="@Model.Keyword">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">描述:</label>
<div class="col-sm-8">
<input id="Description" type="text" class="form-control" name="Description" value="@Model.Description" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">TAG:</label>
<div class="col-sm-8">
<input id="Tags" type="text" class="form-control" name="Tags" value="@Model.Tags" maxlength="250" placeholder="TAG关键字,不同关键字请用“,”(英文逗号)隔开" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章点击数量:</label>
<div class="col-sm-8">
<input id="Hits" type="number" class="form-control" name="Hits" value="@Model.Hits" maxlength="20" placeholder="文章点击数量,仅对文章列表页面有效" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">跳转链接:</label>
<div class="col-sm-8">
<input id="LinkURL" type="text" class="form-control" name="LinkURL" value="@Model.LinkURL" maxlength="200" placeholder="填写则点击该类别自动跳转到该地址" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">其他属性:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsNew" id="IsNew" @(Model.IsNew == 1 ? "checked" : "")> 最新文章
</label>
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsRecommend" id="IsRecommend" @(Model.IsRecommend == 1 ? "checked" : "")> 推荐文章
</label>
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsHide" id="IsHide" @(Model.IsHide == 1 ? "checked" : "")> 隐藏文章
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章图片:</label>
<div class="col-sm-8">
<div class="input-group">
<input id="Pic" name="Pic" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="@Model.Pic">
<span class="input-group-addon my-upload-span upload-img"></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章内容:</label>
<div class="col-sm-8">
<textarea id="Content" name="Content" class="form-control" placeholder="可以输入栏目的详细介绍" required>@Model.Content</textarea>
</div>
</div>
<div id="MoreImages">
@if (!string.IsNullOrEmpty(Model.ItemImg))
{
string[] arrimg = Model.ItemImg.Split(new string[] { "|||" }, StringSplitOptions.None);
int i = 1;
foreach (string s in arrimg)
{
if (!string.IsNullOrEmpty(s) && COMCMS.Common.Utils.IsImgFilename(s))
{
<div class="form-group" id="ImgRow@(i)">
<label class="col-sm-3 control-label"><button type="button" class="btn btn-danger btn-sm" onclick="delmyImgRow('ImgRow@(i)')"> <i class="fa fa-close"></i> 删除</button></label>
<div class="col-sm-8">
<div class="input-group">
<input id="ImgUrlnImgRow@(i)" name="nImgUrl" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="@s">
<span class="input-group-btn">
<span class="input-group-addon my-upload-span upload-img"></span>
</span>
</div>
</div>
</div>
i++;
}
}
}
</div>
<div class="form-group">
<label class="col-sm-3 control-label">更多图片(相册):</label>
<div class="col-sm-8">
<button class="btn btn-info" type="button" onclick="addImagesrow();"><i class="fa fa-plus"></i> 添加图片 </button>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
<input type="hidden" id="Id" name="Id" value="@Model.Id" />
<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("editArticleForm");
//初始化上传控件
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp,jpeg", notwater: true });
CKEDITOR.replace('Content');
$("#TitleColor").colorpicker();
})
var htmlText = '<div class="form-group" id="nImgRow{0}">';
htmlText += '<label class="col-sm-3 control-label"><button type="button" class="btn btn-danger btn-sm" onclick="delmyImgRow(\'nImgRow{0}\')"> <i class="fa fa-close"></i> 删除</button></label>';
htmlText += '<div class="col-sm-8">';
htmlText += '<div class="input-group">';
htmlText += '<input id="nImgUrlnImgRow{0}" name="nImgUrl" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="">';
htmlText += '<span class="input-group-addon my-upload-span upload-img" id="newimg_{0}"></span>';
htmlText += '</div></div></div>';
var items = 1;
function addImagesrow() {
var newHtmlTr = htmlText.replace(/\{0\}/g, "new" + items);
$('#MoreImages').append(newHtmlTr);
$("#newimg_new" + items).InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp,jpeg", notwater: true });
items += 1;
}
function delmyImgRow(id) {
$("#" + id).remove();
}
</script>
@@ -0,0 +1,155 @@
@model COMCMS.Core.ArticleCategory
@{
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 = "editArticleKindForm", @class = "form-horizontal m-t" }))
{
<div class="form-group">
<label class="col-sm-3 control-label">上级栏目:</label>
<div class="col-sm-8">
<select class="form-control m-b" asp-for="PId">
<option value="0">一级栏目</option>
@foreach (var m in ViewBag.ListTree)
{
<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">
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" value="@Model.KindName" required aria-required="true" placeholder="填写栏目名称">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">副标题:</label>
<div class="col-sm-8">
<input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="栏目副标题,非必填" value="@Model.SubTitle" maxlength="200">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Banner图片:</label>
<div class="col-sm-8">
<div class="input-group">
<input id="BannerImg" name="BannerImg" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个Banner图片" value="@Model.BannerImg">
<span class="input-group-addon my-upload-span upload-img"></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">排序:</label>
<div class="col-sm-8">
<input id="Rank" type="number" class="form-control" name="Rank" value="@Model.Rank" maxlength="20" placeholder="越小排得越前" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章列表:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsList" id="IsList" @(Model.IsList == 1 ? "checked" : "")> 文章列表页(勾上则该栏目为文章列表页面。)
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">列表文章数量:</label>
<div class="col-sm-8">
<input id="PageSize" type="number" class="form-control" name="PageSize" value="@Model.PageSize" maxlength="20" placeholder="文章列表页面每页文章显示条数,仅对文章列表页面有效" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">显示下级栏目文章:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsShowSubDetail" id="IsShowSubDetail" @(Model.IsShowSubDetail == 1 ? "checked" : "")> 显示下级栏目文章(勾选则该栏目列表,显示下级栏目文章。)
</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" @(Model.TemplateFile == s?"selected":"")>@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)
{
<option value="@s" @(Model.DetailTemplateFile == s?"selected":"")>@s</option>
}
</select>
</div>
</div>*@
<div class="form-group">
<label class="col-sm-3 control-label">隐藏栏目:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsHide" id="IsHide" @(Model.IsHide == 1 ? "checked" : "")> 隐藏栏目(栏目在前台不显示)
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">栏目关键字:</label>
<div class="col-sm-8">
<input id="Keyword" type="text" class="form-control" name="Keyword" value="@Model.Keyword" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">栏目描述:</label>
<div class="col-sm-8">
<input id="Description" type="text" class="form-control" name="Description" value="@Model.Description" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">跳转链接:</label>
<div class="col-sm-8">
<input id="LinkURL" type="text" class="form-control" name="LinkURL" value="@Model.LinkURL" maxlength="200" placeholder="填写则点击该类别自动跳转到该地址" aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">栏目介绍:</label>
<div class="col-sm-8">
<textarea id="KindInfo" name="KindInfo" class="form-control" placeholder="可以输入栏目的详细介绍">@Model.KindInfo</textarea>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
<input type="hidden" value="@Model.Id" id="Id" name="Id" />
<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 () {
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true });
DoPost("editArticleKindForm");
CKEDITOR.replace('KindInfo');
})
</script>
@@ -13,6 +13,7 @@
<link href="~/hplus/css/plugins/iCheck/custom.css" rel="stylesheet" />
<link href="~/js/treegrid/jquery.treegrid.css" rel="stylesheet" />
<link href="~/js/webuploader/webuploader.css" rel="stylesheet" />
<link href="~/js/bootstrap-colorpicker/css/bootstrap-colorpicker.css" rel="stylesheet" />
<environment names="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
@@ -32,6 +33,8 @@
<script src="~/hplus/js/plugins/iCheck/icheck.min.js"></script>
<script src="~/js/webuploader/webuploader.min.js"></script>
<script src="~/js/uploader.js"></script>
<script src="~/editor/ckeditor/ckeditor.js"></script>
<script src="~/js/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
@@ -61,6 +64,8 @@
<script src="~/hplus/js/plugins/iCheck/icheck.min.js"></script>
<script src="~/js/webuploader/webuploader.min.js"></script>
<script src="~/js/uploader.js"></script>
<script src="~/editor/ckeditor/ckeditor.js"></script>
<script src="~/js/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
</environment>
</head>
<body class="gray-bg">