From a553ac81865f56edacf4551c9599fe47d09f4143 Mon Sep 17 00:00:00 2001 From: livisky <262248861@qq.com> Date: Fri, 1 Jul 2016 17:36:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E7=AB=A0=E6=90=9C=E7=B4=A2=E5=8F=8A?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E7=AD=9B=E9=80=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/controller/content.js | 37 +++++- view/admin/content_article.html | 10 +- view/admin/content_index.html | 122 ++---------------- .../css/business/admin/article/article.css | 8 ++ www/static/src/js/business/admin/content.js | 5 - .../src/js/business/admin/contentList.js | 56 ++++++++ 6 files changed, 106 insertions(+), 132 deletions(-) create mode 100644 www/static/src/css/business/admin/article/article.css create mode 100644 www/static/src/js/business/admin/contentList.js diff --git a/src/admin/controller/content.js b/src/admin/controller/content.js index 399e37b..b09d031 100644 --- a/src/admin/controller/content.js +++ b/src/admin/controller/content.js @@ -12,17 +12,42 @@ export default class extends Base */ async indexAction() { - let articlelist ={},result={} + let articlelist ={},result={},list={}; + let selval=this.get('type'); + let searchtxt=this.get('search'); // 设置分页 - if(this.post('marksel')){ - + if(selval){ + //文章筛选 let map={}; - map[this.post('marksel')]=1; - articlelist = await this.model("article").field("*,li_article.id as aid").join("li_tags ON li_article.tag=li_tags.id").where(map).page(this.get("page"), this.get("pagesize")).order("createtime DESC").select(); + map[this.get('type')]=1; + articlelist = await this.model("article").join({ + tags: {on: "tag, id"}, + item: {on: ["item", "id"]}, + }).where(map).page(this.get("page"), this.get("pagesize")).order("createtime DESC").select(); + result = await this.model("article").where(map).page(this.get('page'), this.get('pagesize')).order("createtime DESC").countSelect(); + this.assign("type", selval); + }else if(searchtxt){ + //文章搜索 + let map={title: ["like", "%"+searchtxt+"%"]}; + articlelist = await this.model("article").join({ + tags: {on: "tag, id"}, + item: {on: ["item", "id"]}, + }).where(map).page(this.get("page"), this.get("pagesize")).order("createtime DESC").select(); result = await this.model("article").where(map).page(this.get('page'), this.get('pagesize')).order("createtime DESC").countSelect(); + if(articlelist.length==0){ + let map={id:searchtxt*1}; + articlelist = await this.model("article").where(map).page(this.get("page"), this.get("pagesize")).order("createtime DESC").select(); + result = await this.model("article").where(map).page(this.get('page'), this.get('pagesize')).order("createtime DESC").countSelect(); + } + this.assign("type", ''); }else{ - articlelist = await this.model("article").field("*,li_article.id as aid").join("li_tags ON li_article.tag=li_tags.id").page(this.get("page"), this.get("pagesize")).order("createtime DESC").select(); + let map={}; + articlelist = await this.model("article").join({ + tags: {on: "tag, id"}, + item: {on: ["item", "id"]}, + }).where(map).page(this.get("page"), this.get("pagesize")).order("createtime DESC").select(); result = await this.model("article").page(this.get('page'), this.get('pagesize')).order("createtime DESC").countSelect(); + this.assign("type", ''); } let Page = think.adapter("template", "page"); let page = new Page(this.http); diff --git a/view/admin/content_article.html b/view/admin/content_article.html index a294f20..1e52005 100644 --- a/view/admin/content_article.html +++ b/view/admin/content_article.html @@ -5,16 +5,8 @@ + -
diff --git a/view/admin/content_index.html b/view/admin/content_index.html index 21674e6..32ffdcd 100644 --- a/view/admin/content_index.html +++ b/view/admin/content_index.html @@ -4,16 +4,14 @@ - +
<% if(!isdraft){ %>
- - + +
<%}%>
@@ -28,15 +26,16 @@ 批量删除 - 标记筛选  +  
@@ -69,7 +68,7 @@ <%=item.title%> <% }%> - <%=item.item%> + <%=item.itemname%> <%=item.tagname%> <%=liFormatDate(think.datetime(item.cteatetime))%> <%=item.view%> @@ -107,107 +106,6 @@
- - + \ No newline at end of file diff --git a/www/static/src/css/business/admin/article/article.css b/www/static/src/css/business/admin/article/article.css new file mode 100644 index 0000000..fa8b0cb --- /dev/null +++ b/www/static/src/css/business/admin/article/article.css @@ -0,0 +1,8 @@ +#filepick a{padding: 55px 15px;} +#filepick{text-align: center;vertical-align: middle; width: 140px; height: 130px} +.webuploader-pick{padding: 50px 50px; background: #fff; } +#uploader-demo{margin-top:20px;width: 142px; border: 1px dashed #ccc} +.flag span{margin-right: 10px;} +input[type=checkbox], input[type=radio]{margin:0px;} +.row {margin-top: 15px;} +.modal-backdrop{background-color: #fff;} \ No newline at end of file diff --git a/www/static/src/js/business/admin/content.js b/www/static/src/js/business/admin/content.js index ac3c5c2..875d8b1 100644 --- a/www/static/src/js/business/admin/content.js +++ b/www/static/src/js/business/admin/content.js @@ -1,11 +1,6 @@ /** * Created by livi on 16/4/19. */ - - //生成编辑器 - // var editor = new wangEditor('editor'); - // editor.create(); - //上传markdown文件,返回html解析并赋值 $('.add-img-btn2 input[type="file"]').on('change', function () { var $this = $(this); var addimgBtn=$this.parent(); diff --git a/www/static/src/js/business/admin/contentList.js b/www/static/src/js/business/admin/contentList.js new file mode 100644 index 0000000..2bbb1f1 --- /dev/null +++ b/www/static/src/js/business/admin/contentList.js @@ -0,0 +1,56 @@ +/** + * Created by livi on 16/4/19. + */ + //文章搜索 + $("#search_article").on('click',function(){ + var searchTxt=$("#searchText").val(); + window.location.href="/admin/content/index?page=1&pagesize=10&search="+searchTxt; + }) + $("#markselect").on('change',function(){ + var filter=$(this).val(); + window.location.href="/admin/content/index?page=1&pagesize=10&type="+filter; + }) + $('.delete').bind('click', function () { + var delId = $(this).attr("del-id"); + var delids = []; + delids.push(delId); + var r = confirm("确定删除?"); + if (r) { + $.ajax({ + url: '/admin/content/delsome', + data: {delarr: delids, __CSRF__: G_csrf}, + type: 'POST', + success: function (json) { + if (json.errno === 0) { + alert("删除成功!"); + window.location.href = "/admin/content"; + } + } + }) + } else { + } + }) + var delsome = function () { + var delids = []; + $.each($('input[type="checkbox"]', 'tbody'), function (i, item) { + if ($(item).is(':checked')) { + delids.push($(this).val()); + } + }) + var r = confirm("确定删除?"); + if (r) { + $.ajax({ + url: '/admin/content/delsome', + data: {delarr: delids, __CSRF__: G_csrf}, + type: 'POST', + success: function (json) { + if (json.errno === 0) { + alert("删除成功!"); + window.location.href = "/admin/content"; + } + } + }) + } else { + return false + } + }