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'} -