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 @@ +
-