ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(10)之素材管理

news/2024/5/20 4:35:58/文章来源:https://blog.csdn.net/weixin_30954265/article/details/99507375

 

源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 

素材管理模块也是我们这个项目的核心模块,里面的增删查改都跟文章管理模块相同或者相似,唯一不同点可能是对附件的上传处理,但没有涉及到复杂的文件上传,所以我们采用了原生的文件流的形式上传,同时在做了文件在编辑的时候,如果重新上传文件,我们将旧文件删除,这样可以释放更多的服务器空间,以免造成大量垃圾文件堆积。

在创建之前,我们需要在表现层的SystemExtension下创建一个公共类BaseCommon.cs:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;namespace IA.WebApp.SystemExtension
{/// <summary>/// 通用方法/// </summary>public class BaseCommon{#region 解压ZIP文件/// <summary>   /// 解压功能(解压压缩文件到指定目录)   /// </summary>   /// <param name="fileToUnZip">待解压的文件</param>   /// <param name="zipedFolder">指定解压目标目录</param>   /// <param name="password">密码</param>   /// <returns>解压结果</returns>   public static bool UnZip(string fileToUnZip, string zipedFolder, string password){bool result = true;FileStream fs = null;ICSharpCode.SharpZipLib.Zip.ZipInputStream zipStream = null;ICSharpCode.SharpZipLib.Zip.ZipEntry ent = null;string fileName;if (!File.Exists(fileToUnZip))return false;if (!Directory.Exists(zipedFolder))Directory.CreateDirectory(zipedFolder);try{zipStream = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(fileToUnZip));if (!string.IsNullOrEmpty(password)) zipStream.Password = password;while ((ent = zipStream.GetNextEntry()) != null){if (!string.IsNullOrEmpty(ent.Name)){fileName = Path.Combine(zipedFolder, ent.Name);fileName = fileName.Replace('/', '\\');//change by Mr.HopeGi   if (fileName.EndsWith("\\")){Directory.CreateDirectory(fileName);continue;}fs = File.Create(fileName);int size = 2048;byte[] data = new byte[size];while (true){size = zipStream.Read(data, 0, data.Length);if (size > 0)fs.Write(data, 0, size);elsebreak;}}}}catch{result = false;}finally{if (fs != null){fs.Close();fs.Dispose();}if (zipStream != null){zipStream.Close();zipStream.Dispose();}if (ent != null){ent = null;}GC.Collect();GC.Collect(1);}return result;}#endregion#region 搜索引擎自动推送/// <summary>/// 搜索引擎链接推送/// </summary>/// <param name="urls"></param>/// <returns></returns>public static string PostUrl(string[] urls){try{string formUrl = "http://data.zz.baidu.com/urls?site=www.yealuo.com&token=nvLhHxq4HKwgKoCQ";string formData = "";foreach (string url in urls){formData += url + "\n";}byte[] postData = System.Text.Encoding.UTF8.GetBytes(formData);// 设置提交的相关参数 System.Net.HttpWebRequest request = System.Net.WebRequest.Create(formUrl) as System.Net.HttpWebRequest;System.Text.Encoding myEncoding = System.Text.Encoding.UTF8;request.Method = "POST";request.KeepAlive = false;request.AllowAutoRedirect = true;request.ContentType = "text/plain";request.UserAgent = "curl/7.12.1";request.ContentLength = postData.Length;// 提交请求数据 System.IO.Stream outputStream = request.GetRequestStream();outputStream.Write(postData, 0, postData.Length);outputStream.Close();System.Net.HttpWebResponse response;System.IO.Stream responseStream;System.IO.StreamReader reader;string srcString;response = request.GetResponse() as System.Net.HttpWebResponse;responseStream = response.GetResponseStream();reader = new System.IO.StreamReader(responseStream, System.Text.Encoding.GetEncoding("UTF-8"));srcString = reader.ReadToEnd();string result = srcString;   //返回值赋值reader.Close();return result;}catch (Exception ex){return ex.Message;}}#endregion}
}

同样的步骤,首先我们创建一个名为AttachmentMangeController的控制器、Index.cshtml视图,以及业务类Com_AttachmentBll.cs

(1)AttachmentMangeController.cs

using Bobo.Utilities;
using IA.Business;
using IA.Business.SystemBusiness;
using IA.Entity;
using IA.WebApp.SystemExtension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml;namespace IA.WebApp.Areas.BackstageModule.Controllers
{/// <summary>/// 素材管理控制器/// </summary>[LoginAuthorize("~/BackstageModule/Login/Index")]public class AttachmentMangeController : PublicController<Com_Attachment>{//// GET: /BackstageModule/AttachmentMange//// <summary>/// 获取分页数据/// </summary>/// <param name="ArticleTitle"></param>/// <param name="jgp"></param>/// <returns></returns>public ActionResult GetTable(string FileTitle, JqGridParam jgp){FileTitle = FileTitle.Replace("&nbsp;", "");Com_AttachmentBll bll = new Com_AttachmentBll();DataTable model = bll.GetTablePage(FileTitle, ref jgp);//构建分页数据var JsonData = new{success = true,pageData = jgp,message = "",data = model};return Content(JsonData.ToJson());}/// <summary>/// 添加编辑 /// </summary>/// <param name="entity"></param>/// <param name="KeyValue"></param>/// <returns></returns>public ActionResult SubmitFormData(Com_Attachment entity, string KeyValue){HttpPostedFileBase FileCover = Request.Files["FileCover"];HttpPostedFileBase FileUrl = Request.Files["FileUrl"];Com_AttachmentBll bll = new Com_AttachmentBll();try{int IsOk = 0;string Message = KeyValue == "" ? "新增成功。" : "编辑成功。";#region 附件处理bool FileHasCover = FileCover != null && FileCover.ContentLength > 0;bool FileHasUrl = FileUrl != null && FileUrl.ContentLength > 0;List<string> fileType = ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageType").ToLower().Split('|').ToList();string PicName = "";string FileUrName = "";if (FileHasCover){PicName = Path.GetFileName(FileCover.FileName);}if (FileHasUrl){FileUrName = Path.GetFileName(FileUrl.FileName);}if ((FileHasCover && !fileType.Contains(Path.GetExtension(PicName).ToLower()))){return Content(new JsonMessage { Code = "-1", Success = false, Message = "封面只能上传" + ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageType").ToLower() + "类型的文件!" }.ToString());}var ssssl = FileCover.ContentLength;var ssss = CommonHelper.GetInt(SizeHelper.CountSizeNum(FileCover.ContentLength));if (FileHasCover && CommonHelper.GetInt(SizeHelper.CountSizeNum(FileCover.ContentLength)) > CommonHelper.GetInt(ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageSize"))){return Content(new JsonMessage { Code = "-1", Success = false, Message = "文件大小不能超过" + ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageSize") + "M!" }.ToString());}string strLower = Path.GetExtension(FileUrName).ToLower();if (FileHasUrl && (strLower != ".zip" && strLower != ".ZIP")){return Content(new JsonMessage { Code = "-1", Success = false, Message = "附件只能上传ZIP类型的文件!" }.ToString());}if (FileHasUrl && CommonHelper.GetInt(SizeHelper.CountSizeNum(FileUrl.ContentLength)) > CommonHelper.GetInt(ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "BigSize"))){return Content(new JsonMessage { Code = "-1", Success = false, Message = "文件大小不能超过" + ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "BigSize") + "M!" }.ToString());}string AllPath = "";//ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "AllFilePath");string PicPath = "/Resource/Journal/FileCover/";string PicMinPath = "/Resource/Journal/FileMinCover/";DirFileHelper.CreateDirectory(Server.MapPath(AllPath + PicPath));DirFileHelper.CreateDirectory(Server.MapPath(AllPath + PicMinPath));//上传FileCoverif (FileHasCover){string fileName = CommonHelper.GetGuidNotLine() + Path.GetExtension(PicName).ToLower();FileCover.SaveAs(Server.MapPath(AllPath + PicPath + fileName));entity.FileCover = PicPath + fileName;Image titleImg = Image.FromStream(FileCover.InputStream);PictureHelp.MakeThumbnail(titleImg,Server.MapPath(AllPath + PicMinPath) + fileName, 260, 0, "W");entity.FileMinCover = PicMinPath + fileName;}//上传FileUrlstring FileUrlPath = "/Resource/Journal/FileUrl/";string guid = CommonHelper.GetGuid();DirFileHelper.CreateDirectory(Server.MapPath(AllPath + FileUrlPath + guid));if (FileHasUrl){string fileName = CommonHelper.GetGuidNotLine() + Path.GetFileName(FileUrl.FileName);FileUrl.SaveAs(Server.MapPath(AllPath + FileUrlPath + fileName));entity.FileUrl = FileUrlPath + fileName;if (entity.FileType == "FLASH" || entity.FileType == "PIC" || entity.FileType == "SYS"){entity.FileIndexUrl = "";}else{entity.FileIndexUrl = AllPath + FileUrlPath + guid + "/Index.html";BaseCommon.UnZip(Server.MapPath(AllPath + FileUrlPath + fileName), Server.MapPath(AllPath + FileUrlPath + guid), null);//压缩包解压}}#endregionif (!string.IsNullOrEmpty(KeyValue)){Com_Attachment Oldentity = bll.Factory.FindEntity(KeyValue);//获取没更新之前实体对象if (FileHasCover){ //修改的时候判断是否有新上传图,有就删除原图片if (!StringHelper.IsNullOrEmpty(Oldentity.FileCover)){string path = Server.MapPath(Oldentity.FileCover);string path1 = Server.MapPath(Oldentity.FileMinCover);if (System.IO.File.Exists(path)){System.IO.File.Delete(path);}if (System.IO.File.Exists(path1)){System.IO.File.Delete(path1);}}}if (FileHasUrl){ //修改的时候判断是否有新上文件,有就删除原文件if (!StringHelper.IsNullOrEmpty(Oldentity.FileUrl)){string path = Server.MapPath(Oldentity.FileUrl);if (System.IO.File.Exists(path)){System.IO.File.Delete(path);}}if (!StringHelper.IsNullOrEmpty(Oldentity.FileIndexUrl)){string path = Path.GetDirectoryName(Server.MapPath(Oldentity.FileIndexUrl));if (Directory.Exists(path)){Directory.Delete(path, true);//删除文件夹及子文件}}}entity.Modify(KeyValue);IsOk = bll.Factory.Update(entity);this.WriteLog(IsOk, entity, Oldentity, KeyValue, Message);}else{entity.Create();IsOk = bll.Factory.Insert(entity);if (IsOk > 0){KeyValue = entity.FileID;SetWebMapFile();BaseCommon.PostUrl(new string[] { KeyValue });}this.WriteLog(IsOk, entity, null, KeyValue, Message);}if (IsOk < 1){Message = "操作失败";}new Base_DataDictionaryDetailBll().SubContentKey(entity.ContentKey);return Content(new JsonMessage { Success = true, Code = IsOk.ToString(), Message = Message }.ToString());}catch (Exception ex){this.WriteLog(-1, entity, null, KeyValue, "操作失败:" + ex.Message);return Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString());}}/// <summary>/// 制造站长地图文档/// </summary>/// <returns></returns>public int SetWebMapFile(){try{//创建XmlDocument对象XmlDocument xmlDoc = new XmlDocument();//XML的声明<?xml version="1.0" encoding="gb2312"?> XmlDeclaration xmlSM = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);//追加xmldecl位置xmlDoc.AppendChild(xmlSM);//添加一个名为Gen的根节点XmlElement xml = xmlDoc.CreateElement("", "urlset", "");//追加Gen的根节点位置 xmlDoc.AppendChild(xml);//添加另一个节点,与Gen所匹配,查找<Gen>XmlNode urlset = xmlDoc.SelectSingleNode("urlset");Com_AttachmentBll bll = new Com_AttachmentBll();List<Com_Attachment> alist = bll.GetAttachmentList(null, null, null);foreach (var item in alist){XmlElement url = xmlDoc.CreateElement("url");XmlElement loc = xmlDoc.CreateElement("loc");//必填,定义某一个链接的入口,每一条数据必须要用<url>和</url>来标示//必填,URL长度限制在256字节内XmlElement lastmod = xmlDoc.CreateElement("lastmod");//更新时间标签,非必填,用来表示最后更新时间XmlElement changefreq = xmlDoc.CreateElement("changefreq");//更新频率标签,非必填,用来告知引擎页面的更新频率XmlElement priority = xmlDoc.CreateElement("priority");//优先权标签,优先权值0.0-1.0,用来告知引擎该条url的优先级string ul = "http://www.yealuo.com/Home/Detail";loc.InnerText = ul + "?" + item.FileID;lastmod.InnerText = DateTime.Now.ToString("yyy-MM-dd");changefreq.InnerText = "daily";priority.InnerText = "0.8";url.AppendChild(loc);url.AppendChild(lastmod);url.AppendChild(changefreq);url.AppendChild(priority);urlset.AppendChild(url);}DirFileHelper.CreateDirectory(Server.MapPath("~/Resource/360Map/"));xmlDoc.Save(Server.MapPath("~/Resource/360Map/Sitemap.xml"));return 1;}catch (Exception ex){return 0;}}/// <summary>/// 假删方法(会刊)/// </summary>/// <param name="KeyValue"></param>/// <returns></returns>public ActionResult DeleteOther(string KeyValue){Com_AttachmentBll bll = new Com_AttachmentBll();try{int IsOk = 1;string Message = "删除成功";if (!string.IsNullOrEmpty(KeyValue)){string[] array = KeyValue.Split(',');foreach (var item in array){Com_Attachment Oldentity = bll.Factory.FindEntity(item);//获取没更新之前实体对象Oldentity.DeleteMark = 1;Oldentity.Modify(item);IsOk = bll.Factory.Update(Oldentity);this.WriteLog(IsOk, Oldentity, Oldentity, item, Message);}}else{Message = "删除失败";IsOk = 1;}return Content(new JsonMessage { Success = true, Code = IsOk.ToString(), Message = Message }.ToString());}catch (Exception ex){this.WriteLog(-1, null, null, KeyValue, "操作失败:" + ex.Message);return Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString());}}/// <summary>/// 获取关键字/// </summary>/// <param name="title"></param>/// <returns></returns>public ActionResult GetContentKey(string title){Base_DataDictionaryDetailBll bll = new Base_DataDictionaryDetailBll();List<Base_DataDictionaryDetail> dlist = bll.GetDataDictionaryList(title, "ContentKey");return Content(dlist.ToJson());}}
}

(2)Index.cshtml

@{ViewBag.Title = "素材管理";Layout = "~/Views/Shared/_LayoutMange.cshtml";
}
<style>html {background-color: #f3f4f4;}.w_header .header-nav .nav-item li a.wzgl {border-bottom: 2px solid #2D81E0;background-color: #E8F4FF;color: #2D81E0;font-weight: bold;}.ContentKeyBox {padding-left: 85px;padding-top: 15px;line-height: 25px;}.ContentKeyBox a {margin: 5px;color: #666;display: inline-block;cursor: pointer;}.ContentKeyBox a:hover, .ContentKeyBox a.on {background-color: #0b234e;color: #fff;}.w_center .center-nav-item a.scgl {color: #156cd1;}
</style>
<div class="w_center clear mAuto">@Html.Partial("_PartialNav")<div class="center-main font-yahei R"><div class="center-main-nav"><a href="javascript:;" class="center-main-tag action" style="border-left:0 none;">素材编辑</a></div><div class="center-main-box" style="margin-top:0;"><div class="toolbarBox clear"><div id="searchForm" class="L searchForm"><span class="seachTit">素材标题:</span><input type="text" id="FileTitle" name="FileTitle" class="seachText" value="" /><a id="searchBtn" class="searchBtn" href="javascript:;" title="搜索"></a></div><div class="toolbar R"><input type="button" value="新增素材" class="addBtn greenBtn" οnclick="AddEditBtn(0,$(this))" /></div></div><ul class="list-ui clear" id="list-ui"></ul><div id="listPage" class="m_pageBar com_pageBar" style="padding:0 30px;"></div></div></div>
</div>@*分页数据模版*@
<script id="tempBody" type="text/template">{#each data as item}<li class="list-item"><div class="img-box"><img src="!{item.FileMinCover}" width="135" height="185" /><div class="list-mask"><a href="javascript:;" οnclick="AddEditBtn(1,$(this))" data-id="!{item.FileID}" class="list-btn list-edit L"><img src="/Content/Images/slice/edit.png" /> <span>编辑</span></a><a href="javascript:;" οnclick="delBtn($(this))" class="list-btn list-close R" data-id="!{item.FileID}"><img src="/Content/Images/slice/close.png" /> <span>删除</span></a><a href="!{item.FileIndexUrl}" target="_blank" class="list-btn list-show L"><img src="/Content/Images/slice/show.png" /> <span>预览</span></a></div></div><div class="list-title" title="!{item.FileTitle}">!{subString(item.FileTitle, 15)}</div></li>{#/each}
</script>@*隐藏弹窗模版*@
<script id="ReplyEdit" type="text/template"><div style="margin:20px 20px;"><form id="form1" action="/BackstageModule/AttachmentMange/SubmitFormData" method="post" enctype="multipart/form-data" style="margin: 1px"><input type="hidden" id="KeyValue" name="KeyValue" /><table class="layer-table-form"><tr><td><span class="layer-form-tit">标题:</span><input type="text" name="FileTitle" class="layer-form-txt" id="FileTitle" datacol="yes" err="标题" checkexpession="NotNull" /></td></tr><tr><td><span class="layer-form-tit">金币:</span><input type="text" name="Integral" class="layer-form-txt" id="Integral" datacol="yes" err="金币" checkexpession="NumOrNull" /></td></tr><tr><td><span class="layer-form-tit">类型:</span><select name="FileType" class="layer-form-select" id="FileType" datacol="yes" err="类型" checkexpession="NotNull"><option value="">==请选择==</option><option value="WEB">网站模板</option><option value="WAP">手机端</option><option value="H5C3">HTML5 CSS3</option><option value="WJS">网页特效</option><option value="FLASH">flash素材</option><option value="PIC">网页素材</option><option value="SYS">网站源码</option></select></td></tr><tr><td><div class="layer-form-tit L">封面:</div><input type="text" name="FileCoverSet" id="FileCoverSet" class="layer-form-txt url1 L" readonly="readonly" style="display:none;" placeholder="请上传.JPG|.JPEG|.PNG|.GIF|.BMP格式的图片" datacol="yes" err="封面" /><input type="text" name="FileCover" id="FileCover" class="layer-form-txt url2 L" readonly="readonly" placeholder="请上传.JPG|.JPEG|.PNG|.GIF|.BMP格式的图片" datacol="yes" err="封面" /><div class="FileBox L"><input class="file upFile" type="file" name="FileCover" value="" οnchange="SetFileVal($(this))" /></div></td></tr><tr><td><div class="layer-form-tit L">附件:</div><input type="text" name="FileUrlSet" id="FileUrlSet" class="layer-form-txt url1 L" readonly="readonly" style="display:none;" placeholder="请上传.zip格式的文件" datacol="yes" err="附件" /><input type="text" name="FileUrl" id="FileUrl" class="layer-form-txt url2 L" readonly="readonly" placeholder="请上传.PDF|.DOC|.DOCX格式的文件" datacol="yes" err="封面" /><div class="FileBox L"><input class="file upFile" type="file" name="FileUrl" value="" οnchange="SetFileVal($(this))" /></div></td></tr><tr><td style="height:auto;vertical-align:top;"><div><span class="layer-form-tit">关键字:</span><input style="background-color:#efefef;border:0 none;width:405px;" type="text" name="ContentKey" class="layer-form-txt" id="ContentKey" datacol="yes" err="关键字" checkexpession="NotNull" readonly="readonly" /></div><div><span class="layer-form-tit">输入关键字:</span><input type="text" class="layer-form-txt" id="SetContentKey" /><a style="display:inline-block;" class="addBtn yellowBtn" οnclick="SetContentKey($('#SetContentKey').val()); $('#SetContentKey').val('')">加入</a></div><div class="ContentKeyBox"></div></td></tr><tr><td><span class="layer-form-tit">介绍:</span><textarea name="Remarks" class="layer-form-txt" style="height:70px;" id="Remarks" datacol="yes" err="介绍" checkexpession="NotNull"></textarea></td></tr></table></form></div>
</script>@*隐藏下载弹窗模版*@
<script id="DownList" type="text/template"><div style="margin:20px 20px;"><input type="hidden" id="KeyValue" name="KeyValue" /><table class="layer-table-form DownList"></table></div>
</script>
@section scripts{<script type="text/javascript">var KeyValue = "";$(function () {juicer.register('formatDate', formatDate);juicer.register('subString', subString);TagNavSet();getPageData();searchEvent();//getPageData2();});//菜单切换function TagNavSet() {$(".center-main-tag").on("click", function () {if (!$(this).hasClass("action")) {$(this).addClass("action").siblings(".center-main-tag").removeClass("action");$(".center-main-box").hide();$(".center-main-box").eq($(this).index()).show();}})}//初始化分页函数function getPageData() {var param = {rows: 10,url: "/BackstageModule/AttachmentMange/GetTable",sidx: "CreateDate",sord: "DESC",searchForm: "#searchForm",infoPanel: '#list-ui',barPanel: '#listPage',template: '#tempBody',callback: handleSuccess}Pager.init(param);}//查询按钮绑定事件function searchEvent() {$("#searchBtn").on("click", function () {getPageData();});}//添加编辑弹窗function AddEditBtn(num, elem) {var allVal = "";if (num > 0) {allVal = elem.attr("data-id");}layer.open({title: "添加/编辑",type: 1,skin: 'layui-layer-rim', //加上边框area: ['650px', '600px'], //宽高content: $("#ReplyEdit").html(),btn: ['保存', '取消'], //只是为了演示yes: function () {AcceptClick();}});InitControl(allVal);GetContentKey("");}//保存按钮function AcceptClick() {if (!CheckDataValid('#form1', true)) {return false;}//提交表单$("#form1").ajaxSubmit({dataType: "json",beforeSubmit: function () {layer.msg('正在提交信息,请稍后…', { icon: 16, shade: 0.2, time: 0 });},success: function (data) {if (data.Success) {layer.msg(data.Message, { icon: data.Code, time: 1000 }, function () {layer.closeAll();getPageData();});}else {layer.alert(data.Message, { icon: data.Code });}}});}//删除function delBtn(elem) {var allVal = elem.attr("data-id");layer.confirm("是否删除这" + allVal.split(",").length + "条数据?", { icon: 0 }, function () {AjaxJson("/BackstageModule/AttachmentMange/DeleteOther", { KeyValue: allVal }, function (data) {layer.msg(data.Message, { icon: data.Code, time: 1000 }, function () {getPageData();});});});}//文件域选择设置function SetFileVal(elem) {var part = elem.parents("td");if (!!elem.val()) {part.find(".url1").val(elem.val()).show().attr("checkexpession", "NotNull");part.find(".url2").hide().removeAttr("checkexpession");}else {part.find(".url1").show().attr("checkexpession", "NotNull");part.find(".url2").hide().removeAttr("checkexpession");}}//得到一个对象实体function InitControl(allVal) {AjaxJson("/BackstageModule/AttachmentMange/SetForm", { KeyValue: allVal }, function (data) {SetWebControls(data, "#form1");$("#KeyValue").val(data.FileID);$("#FileCover").attr("checkexpession", "NotNull");$("#FileUrl").attr("checkexpession", "NotNull");});}//分页数据加载后绑定的函数function handleSuccess() {checkAll();}//全选(包括)function checkAll() {//全选按钮$(".dataTable thead").find(".ckbAll").change(function () {var chkAll = $(this);var chkVal = chkAll.prop("checked");if (chkVal == "checked" || chkVal == true) {$(".dataTable tbody tr").each(function () {var chk = $(this).find(":checkbox");chk.prop("checked", "checked");});}else {$(".dataTable tbody tr").each(function () {var chk = $(this).find(":checkbox");chk.removeAttr("checked");});}});}//关键字设置function SetContentKey(val) {var _thisVal = $("#ContentKey").val();if (_thisVal.indexOf(val) > 0) {layer.msg("已包含该关键字", { icon: "-1", time: 2000 });}else if (!!val) {(!_thisVal) ? $("#ContentKey").val(val) : $("#ContentKey").val(_thisVal + "," + val);}}//获取关键字function GetContentKey(title) {$.post("/BackstageModule/AttachmentMange/GetContentKey", { title: title }, function (data) {var strHtml = "";for (var i = 0; i < data.length; i++) {strHtml += "<a οnclick=\"SetContentKey('" + data[i].DataDictionaryTitle + "');$(this).addClass('on');\">" + data[i].DataDictionaryTitle + "</a>";}$(".ContentKeyBox").html(strHtml);}, "json")}</script>}

(3)Com_AttachmentBll.css

using Bobo.DataAccess;
using Bobo.Repository;
using Bobo.Utilities;
using IA.Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;namespace IA.Business
{// <summary> /// 素材表 /// <author> ///     <name>YHB</name> ///      <date>2018.10.18</date> /// </author> /// </summary> public class Com_AttachmentBll : RepositoryFactory<Com_Attachment>{/// <summary>/// 获取附件数据/// </summary>/// <param name="ArticleTitle"></param>/// <param name="jgp"></param>/// <returns></returns>public DataTable GetTablePage(string FileTitle, ref JqGridParam jgp){StringBuilder whereSql = new StringBuilder();List<DbParameter> param = new List<DbParameter>();whereSql.Append(@" AND DeleteMark<>1");if (!StringHelper.IsNullOrEmpty(FileTitle)){whereSql.Append(@" AND FileTitle LIKE @FileTitle");param.Add(DbFactory.CreateDbParameter("@FileTitle", '%' + FileTitle + '%'));}return Factory.FindTablePage(whereSql.ToString(), param.ToArray(), ref jgp);}/// <summary>/// 获取附件列表/// </summary>/// <param name="DataID"></param>/// <returns></returns>public List<Com_Attachment> GetAttachmentList(string DataID, int? topNum, string ByType){StringBuilder Sql = new StringBuilder();List<DbParameter> param = new List<DbParameter>();string where = "*";if (!StringHelper.IsNullOrEmpty(topNum) && topNum > 0){where = "TOP(" + topNum + ") *";}Sql.Append(@"SELECT " + where + " FROM  Com_Attachment WHERE DeleteMark<>1");if (!StringHelper.IsNullOrEmpty(DataID)){Sql.Append(@" AND DataID=@DataID");param.Add(DbFactory.CreateDbParameter("@DataID", DataID));}if (!StringHelper.IsNullOrEmpty(ByType)){Sql.Append(@" ORDER BY " + ByType + " DESC");}return Factory.FindListBySql(Sql.ToString(), param.ToArray());}}
}

(4)效果预览:

素材管理.png

素材管理2.png

转载于:https://www.cnblogs.com/boyzi/p/9963797.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_706908.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ccentos 7下安装php5.6并使用nginx + php-fpm部署多个不同端口网站

作为一个的勤杂工&#xff0c;近期因公司内部信息化的需求&#xff0c;给新进员工提供基础的知识培训和介绍&#xff0c;也为了给公司内部建立一个沟通交流的平台&#xff0c;百度找了开源的百科系统HDwiki和开源的问答系统Tipask问答系统&#xff0c;蛋痛的这两套系统均是phpm…

VS2017 网站打包发布生成的文件中包含.pdb文件,解决办法

右键点击项目属性&#xff0c;选择打包/发布 Web&#xff0c;勾选 排除生成的调试符号&#xff1a; 再次发布&#xff0c;就不会再生成.pdb文件 转载于:https://www.cnblogs.com/JoinLet/p/10297254.html

网站性能优化--CRP

网站性能优化–CRP 为了把HTML、CSS和JavaScript转化成活灵活现、绚丽多彩的网页&#xff0c;浏览器需要处理一系列的中间过程&#xff0c;优化性能其实就是了解这个过程中发生了什么-即CRP(Critical Rendering Path&#xff0c;关键渲染路径)。首先&#xff0c;我们从头开始快…

【PHP】xampp配置多个监听端口和不同的网站目录(转)

转自&#xff1a;https://blog.csdn.net/cc1314_/article/details/75646344 windows下使用xampp配置多个监听端口和不同的网站目录 一&#xff1a;配置Apache文件httpd.conf打开Apache的配置文件httpd.conf&#xff0c;可以通过点击xampp的Apache的config下的Apache(httpd.conf…

学习网站大汇集

一.综合类学习网站&#xff08;中文&#xff09; 1.网易公开课&#xff1a;https://open.163.com/。上面有TED、可汗学院、国内外高校公开课的免费资源。站内内容完全免费&#xff0c;良心推荐。 2.网易云课堂&#xff1a;http://study.163.com/。网易旗下付费学习平台&#…

【一些网站的收集】包含机器学习深度学习大牛主页等

数学概念部分 旋转矩阵、欧拉角、四元数的比较 欧拉角和四元数的表示 四元数与旋转 B样条曲线 非常好的概率统计学习的主页 误差方差偏差 编程语言学习 C#编程视频 OpenGL编程NeHe OpenGL官网 OpenGL“我叫MT“纯手工3D动画制作之1——基础介绍 【强大】非常好的Op…

Catlike Coding网站文章解析 -- 1.Procedural Grid

原文英文版链接https://catlikecoding.com/unity/tutorials/procedural-grid/&#xff0c;里面有每一部分的untiy工程链接&#xff0c;文章内容也更详实。 本章内容&#xff1a; 创建一系列点使用协程实现他们的摆放位置定义一个由三角形组成的平面自动生成法线添加纹理坐标和…

Catlike Coding网站文章解析 -- 2.Procedural Grid

本章内容 创建一个闭合的cube mesh给cube添加带弧度平滑的边缘定义法线使用sub-meshes&#xff08;子mesh&#xff09;创建一个常规shader合并碰撞体1.合成一个cube 上一章https://mp.csdn.net/postedit/89474068我们已经实现了一个平面mesh。一个cube由6个平面组成&#xff…

linux location root访问文件夹404_如何使网站支持https访问?nginx配置https证书

购买SSL证书要想使用https访问你的网址&#xff0c;首先得拥有颁发的SSL证书。我使用的是免费版&#xff0c;有效期为一年&#xff0c;过期后再重新申请。申请SSL证书购买后&#xff0c;可在搜索框输入证书关键字进入到控制台。点击证书申请&#xff0c;按照提示填写完相关信息…

mysql查询网址_bootstrap+flask+mysql实现网站查询

之前那篇文章是flaskredis的&#xff0c;如果用flaskmysql怎么实现呢&#xff1f;创建数据库&#xff1a;CREATE DATABASE web12306 DEFAULT CHARACTER SET utf8;创建表&#xff1a;CREATE TABLE web12306 (user_email varchar(100) NOT NULL DEFAULT ,user_pass varchar(100)…

网络连接异常、网站服务器失去响应_网站常见故障解决办法

网站在运行过程中&#xff0c;常常遇到各种服务器问题&#xff0c;虽然有服务器厂商的维护&#xff0c;但是往往耗时耗工小编对常见的服务器问题&#xff0c;进行了归纳整理&#xff0c;下面跟各位分享一下。常见故障分析一、恶意攻击在我平时管理网站时&#xff0c;可能会遭到…

搜索引擎提交软件_增加SEO超级外链须知的高权重网站目录提交方法

做SEO的朋友对开放式网站目录应该不陌生吧。网站目录就是按一定的分类方法把收录的网站进行分类归档。网站目录本身是不主动抓取网页的&#xff0c;一般只记录网站的名称&#xff0c;网址和有限的说明文字。和网址站、导航站、酷站网址大全等如同一辙。一般高质量的聚合目录网站…

c主线程如何等待子线程结束 linux_使用互斥量进行同步 - Linux C进程与多线程入门_Linux编程_Linux公社-Linux系统门户网站...

互斥简单地理解就是&#xff0c;一个线程进入工作区后&#xff0c;如果有其他线程想要进入工作区&#xff0c;它就会进入等待状态&#xff0c;要等待工作区内的线程结束后才可以进入。基本函数(1) pthread_mutex_init函数原型&#xff1a;int pthread_mutex_init ( pthread_mut…

xshell搭建宝塔没有远程命令密码框框弹出来_服务器安装宝塔控制面板+wordpress搭建个人网站...

准备工作服务器一台&#xff1a;服务器购买域名一个&#xff1a;随便买一个就行软件环境&#xff1a;宝塔面板第1步&#xff1a;SSH远程连接服务器通过ssh远程连接工具进行服务器主机连接&#xff08;Xshell、Putty等&#xff0c;百度下载&#xff09;需要更加详细的关于ssh远程…

php教育网站设计案例_酒店装修,精品酒店设计装修案例,酒店设计网站

酒店设计需要考虑&#xff1a;设计酒店的时候也要顺应市场潮流&#xff0c;不再单一的提供休息、洗漱、睡觉的空间&#xff0c;还要能提供社交、商务等功能&#xff0c;同顾客产生情况共鸣。这样能够引领生活方式的、能够互动&#xff0c;有仪式感的酒店&#xff0c;是很吸引人…

html5手机电商网页设计代码_Html5网站制作,干货!20个视觉体验和内容俱佳的优秀网页设计...

如何创建一个网页&#xff1f;“Html5网站制作”和“灵感干货&#xff01;20个视觉、体验和内容俱佳的优秀网页设计”有什么关系和内在关联&#xff1f;在图片方面&#xff0c;有三个具体方案&#xff1a;图片地图、Css Sprites、内联图片三种&#xff0c;最值得关注的是 Css S…

asp网站本地测试服务器,小旋风asp服务器,asp本地环境调试必备

学习asp&#xff0c;要在本地搭建一个asp服务器调试环境吧&#xff0c;那么必不可少的要找asp本地调试环境软件&#xff0c;超级小旋风AspWebServer是一个不错的选择。超级小旋风AspWebServer系统基于NetBox开发&#xff0c;可以跟IIS媲美的服务器。小旋风asp服务器 该软件是由…

将虚拟主机加入到netskills.net域环境_网站建设阿里云虚拟主机、ECS服务器、企业邮箱选择购买指南...

对于刚接触阿里云的人来说可能看到阿里云的产品介绍页面会比较头晕&#xff0c;各种产品分类&#xff0c;而且同一个产品在不同的分类目录下都能看到&#xff0c;下面简单介绍一下制作网站过程中常用的阿里云的产品。阿里云在网站建设方面常用的服务主要有云虚拟主机、ECS云服务…

seo黑帽劫持用的php,黑帽seo 论坛:黑帽seo防止网站被k的js劫持跳转代码

由于目前百度搜索百度搜索引擎对于js代码还没有办法完全辨别&#xff0c;因此也就出现了运用js代码跳转的黑帽优化提升手法。现如今在网络上有关js跳转代码不计其数&#xff0c;但是作为黑帽优化提升的seo手法之一&#xff0c;如何确保有效降低跳转的网址被k危害性&#xff0c;…

本机用域名不能访问_域名注册申请网站域名注意事项

互联网用户越来越多&#xff0c;也有越来越多人搭建网站&#xff0c;做个人博客也好、搭建企业官网也好&#xff0c;数量都在逐步上升。做网站的数量在上升&#xff0c;域名注册量肯定也在上升。有的朋友头一次注册域名&#xff0c;对域名不了解也不知道申请网站域名该注意哪些…