From 96f2c438a244e1c30397d412810c92969d8cc85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sat, 16 Apr 2022 23:01:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E9=97=BB=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/news/Item.php | 41 +++--- app/data/model/DataNewsMark.php | 13 ++ app/data/view/base/slider/form.html | 2 +- app/data/view/news/item/form.html | 36 ++--- app/data/view/news/item/index.html | 154 ++++++++++++--------- app/data/view/news/item/index_search.html | 26 ++-- app/data/view/news/item/select.html | 96 +++++++++---- app/data/view/news/item/select_search.html | 36 ----- 8 files changed, 223 insertions(+), 181 deletions(-) delete mode 100644 app/data/view/news/item/select_search.html diff --git a/app/data/controller/news/Item.php b/app/data/controller/news/Item.php index d2db1f3a2..5882665e4 100644 --- a/app/data/controller/news/Item.php +++ b/app/data/controller/news/Item.php @@ -7,6 +7,8 @@ use app\data\model\DataNewsMark; use app\data\service\NewsService; use think\admin\Controller; use think\admin\extend\CodeExtend; +use think\admin\helper\QueryHelper; +use think\admin\model\SystemBase; /** * 文章内容管理 @@ -25,24 +27,14 @@ class Item extends Controller */ public function index() { - $this->title = '文章内容管理'; - $query = DataNewsItem::mQuery(); - $query->like('mark,name')->dateBetween('create_at'); - $query->where(['deleted' => 0])->order('sort desc,id desc')->page(); - } - - /** - * 文章内容选择器 - * @login true - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function select() - { - $query = DataNewsItem::mQuery(); - $query->equal('status')->like('name')->dateBetween('create_at'); - $query->where(['deleted' => 0])->order('sort desc,id desc')->page(); + $this->type = input('get.type', 'index'); + DataNewsItem::mQuery($this->get)->layTable(function () { + $this->title = '文章内容管理'; + $this->marks = DataNewsMark::items(); + }, function (QueryHelper $query) { + $query->where(['status' => intval($this->type === 'index'), 'deleted' => 0]); + $query->like('name')->like('mark', ',')->dateBetween('create_at'); + }); } /** @@ -126,4 +118,17 @@ class Item extends Controller { DataNewsItem::mDelete(); } + + /** + * 文章内容选择 + * @login true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function select() + { + $this->get['status'] = 1; + $this->index(); + } } \ No newline at end of file diff --git a/app/data/model/DataNewsMark.php b/app/data/model/DataNewsMark.php index f99d91ccb..674f6fb3f 100644 --- a/app/data/model/DataNewsMark.php +++ b/app/data/model/DataNewsMark.php @@ -10,6 +10,19 @@ use think\admin\Model; */ class DataNewsMark extends Model { + /** + * 获取标签数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function items(): array + { + $query = static::mk()->where(['status' => 1, 'deleted' => 0]); + return $query->field('id,name,remark')->order('sort desc,id desc')->select()->toArray(); + } + /** * 格式化创建时间 * @param string $value diff --git a/app/data/view/base/slider/form.html b/app/data/view/base/slider/form.html index 61b6ff0f2..5c2549c42 100644 --- a/app/data/view/base/slider/form.html +++ b/app/data/view/base/slider/form.html @@ -86,7 +86,7 @@ }; if (data.value === '#') return input.val('#'); if (data.value === 'LK') return /^https?:\/\//.test(input.val()) || input.val('#').focus(); - if (data.value === 'NS') return this.openModel('{:url("data/base.news/select")}'); + if (data.value === 'NS') return this.openModel('{:url("data/news.item/select")}'); return window.setItemValue(); }); diff --git a/app/data/view/news/item/form.html b/app/data/view/news/item/form.html index 1065d374c..5318546da 100644 --- a/app/data/view/news/item/form.html +++ b/app/data/view/news/item/form.html @@ -1,12 +1,12 @@ {extend name="../../admin/view/main"} {block name='content'} -
+
- {notempty name='marks'} -
- 文章标签Mark Name + +
+ 资讯标签News Mark
{foreach $marks as $tag}{if isset($vo.mark) && is_array($vo.mark) && in_array($tag.name, $vo.mark)} @@ -15,37 +15,30 @@ {/if}{/foreach}
- {/notempty} +
- 文章封面Conver Image + 资讯封面News Conver
- - - + +
- -
- 富文本内容Article Content + 资讯内容News Content
{notempty name='vo.id'}{/notempty} - {notempty name='vo.code'}{/notempty}
@@ -57,7 +50,8 @@ -{/block} \ No newline at end of file +{/block} diff --git a/app/data/view/news/item/index.html b/app/data/view/news/item/index.html index a8fe47a8c..926e5f1a2 100644 --- a/app/data/view/news/item/index.html +++ b/app/data/view/news/item/index.html @@ -1,78 +1,98 @@ -{extend name="../../admin/view/main"} +{extend name='../../admin/view/table'} {block name="button"} - + - - - - - + {/block} -{block name='content'} -
- {include file='news/item/index_search'} - - {notempty name='list'} - - - - - - - - - - - - - {/notempty} - - {foreach $list as $key=>$vo} - - - - - - - - - - - {/foreach} - -
- - - - 文章编号文章名称搜索标签文章状态创建时间
- - - - {$vo.code|default=''}{$vo.name|default=''}{notempty name='vo.mark'}{foreach $vo.mark as $tag}{$tag}{/foreach}{/notempty}
{if $vo.status eq 0}已禁用{elseif $vo.status eq 1}已激活{/if}{$vo.create_at|format_datetime} - - - 编 辑 - - - - 禁 用 - - - - 激 活 - - - - 删 除 - - -
- {empty name='list'}没有记录哦{else}{$pagehtml|raw|default=''}{/empty} +{block name="content"} +
+
    + {foreach ['index'=>'资讯管理','recycle'=>'回 收 站'] as $k=>$v}{if isset($type) and $type eq $k} +
  • {$v}
  • + {else} +
  • {$v}
  • + {/if}{/foreach} +
+
+ {include file='news/item/index_search'} +
+
+{/block} + +{block name='script'} + + + + + + + + + + {/block} \ No newline at end of file diff --git a/app/data/view/news/item/index_search.html b/app/data/view/news/item/index_search.html index 0b066d4e3..91284e5b6 100644 --- a/app/data/view/news/item/index_search.html +++ b/app/data/view/news/item/index_search.html @@ -1,17 +1,27 @@
条件搜索 + +
- - + +
+ +
+
- +
@@ -20,8 +30,8 @@
+ + {foreach $marks as $mark}{if isset($get.mark) and $mark.code eq $get.mark} + + {else} + + {/if}{/foreach} + +
+
+ +
+ + +
+ +
+ + +
+ +
+ +
+ + +
{/block} {block name='script'} + + + + + + + {/block} diff --git a/app/data/view/news/item/select_search.html b/app/data/view/news/item/select_search.html deleted file mode 100644 index 688c26dd2..000000000 --- a/app/data/view/news/item/select_search.html +++ /dev/null @@ -1,36 +0,0 @@ -
- 条件搜索 - -
\ No newline at end of file