From f9222e1b7fa81a881809005e7c4d6808fde417d4 Mon Sep 17 00:00:00 2001 From: 15090180611 <215509543@qq.com> Date: Tue, 31 Dec 2024 14:10:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/manystore/Index.php | 2 +- .../admin/controller/school/help/Article.php | 42 +++++++++ .../admin/controller/school/help/Cate.php | 13 ++- .../admin/lang/zh-cn/school/help/article.php | 2 +- .../admin/lang/zh-cn/school/help/cate.php | 16 +++- .../admin/model/school/help/Article.php | 19 ++++- .../admin/view/school/help/article/add.html | 14 +-- .../admin/view/school/help/article/edit.html | 14 +-- .../admin/view/school/help/cate/index.html | 4 +- application/common/controller/Backend.php | 5 +- .../common/listener/manystore/ShopHook.php | 5 +- public/assets/js/backend/school/help/cate.js | 85 ++++++++++++++----- 12 files changed, 175 insertions(+), 46 deletions(-) diff --git a/application/admin/controller/manystore/Index.php b/application/admin/controller/manystore/Index.php index ef5af57..2af08ea 100644 --- a/application/admin/controller/manystore/Index.php +++ b/application/admin/controller/manystore/Index.php @@ -483,7 +483,7 @@ class Index extends Backend //调用事件 - $data = ['shop' => $shop]; + $data = ['shop' => $this->shopModel]; \think\Hook::listen('shop_create_after', $data); db()->commit(); diff --git a/application/admin/controller/school/help/Article.php b/application/admin/controller/school/help/Article.php index 89b2f05..0504a80 100644 --- a/application/admin/controller/school/help/Article.php +++ b/application/admin/controller/school/help/Article.php @@ -3,6 +3,8 @@ namespace app\admin\controller\school\help; use app\common\controller\Backend; +use think\exception\DbException; +use think\response\Json; /** * 帮助文章 @@ -28,6 +30,9 @@ class Article extends Backend $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("hotList", $this->model->getHotList()); + + $this->view->assign("cateList", $this->model->getCateList()); + $this->view->assign("cateListJson", json_encode($this->model->getCateList(), JSON_UNESCAPED_UNICODE)); } @@ -39,4 +44,41 @@ class Article extends Backend */ + + /** + * 查看 + * + * @return string|Json + * @throws \think\Exception + * @throws DbException + */ + public function index() + { + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if (false === $this->request->isAjax()) { + return $this->view->fetch(); + } + //如果发送的来源是 Selectpage,则转发到 Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit, $page, $alias, $bind, $excludearray) = $this->buildparams(null, null, ["cate_title"]); + + if (isset($excludearray['cate_title']['value']) && $excludearray['cate_title']['value']) { + $help_cate_ids = $excludearray['cate_title']['value']; + $help_cate_ids = implode("|",explode(',',$help_cate_ids)); + $expireWhere = ["help_cate_ids REGEXP '({$help_cate_ids})'"]; + } else { + $expireWhere = ["1=1"]; + } + $list = $this->model + ->where($where) + ->whereRaw(...$expireWhere) + ->order($sort, $order) + ->paginate($limit); + $result = ['total' => $list->total(), 'rows' => $list->items()]; + return json($result); + } + } diff --git a/application/admin/controller/school/help/Cate.php b/application/admin/controller/school/help/Cate.php index d4fc7c6..b9e7583 100644 --- a/application/admin/controller/school/help/Cate.php +++ b/application/admin/controller/school/help/Cate.php @@ -33,15 +33,20 @@ class Cate extends Backend $this->view->assign("statusList", $this->model->getStatusList()); - Tree::instance()->init(collection($this->model->order('weigh DESC,id ASC')->select())->toArray())->icon = [' ', ' ', ' ']; + Tree::instance()->init(collection($this->model->order('weigh DESC,id ASC')->select())->toArray())->icon = array(' │', ' ├', ' └'); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name'); $ruledata = [0 => __('None')]; foreach ($this->rulelist as $k => &$v) { +// $v['name'] = str_replace(' ', ' ', $v['name']); $ruledata[$v['id']] = $v['name']; + } unset($v); $this->view->assign('ruledata', $ruledata); + $this->view->assign("cateList", (new \app\admin\model\school\help\Article)->getCateList()); + $this->view->assign("cateListJson", json_encode((new \app\admin\model\school\help\Article)->getCateList(), JSON_UNESCAPED_UNICODE)); + } @@ -60,6 +65,12 @@ class Cate extends Backend public function index() { if ($this->request->isAjax()) { + //如果发送的来源是 Selectpage,则转发到 Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + + $list = $this->rulelist; $total = count($this->rulelist); $result = array("total" => $total, "rows" => $list); diff --git a/application/admin/lang/zh-cn/school/help/article.php b/application/admin/lang/zh-cn/school/help/article.php index ac6957e..f472a1a 100644 --- a/application/admin/lang/zh-cn/school/help/article.php +++ b/application/admin/lang/zh-cn/school/help/article.php @@ -1,7 +1,7 @@ '平台帮助分类ids', + 'Help_cate_ids' => '平台帮助分类', 'Title' => '标题', 'Content' => '文章详情', 'Status' => '状态', diff --git a/application/admin/lang/zh-cn/school/help/cate.php b/application/admin/lang/zh-cn/school/help/cate.php index d7c75b1..bf35fd9 100644 --- a/application/admin/lang/zh-cn/school/help/cate.php +++ b/application/admin/lang/zh-cn/school/help/cate.php @@ -1,7 +1,7 @@ 'pid', + 'Pid' => '上级分类', 'Name' => '帮助分类名', 'Status' => '状态', 'Status 1' => '上架', @@ -11,5 +11,17 @@ return [ 'Weigh' => '权重', 'Createtime' => '创建时间', 'Updatetime' => '修改时间', - 'Deletetime' => '删除时间' + 'Deletetime' => '删除时间', + + 'Help_cate_ids' => '平台帮助分类', + 'Title' => '标题', + 'Content' => '文章详情', + + 'Hot' => '平台热门', + 'Hot 0' => '否', + 'Hot 1' => '是', + 'Start_time' => '更新时间', + 'Toggle all' => '展开', + 'Views' => '浏览量', + ]; diff --git a/application/admin/model/school/help/Article.php b/application/admin/model/school/help/Article.php index bfd5dd9..477a214 100644 --- a/application/admin/model/school/help/Article.php +++ b/application/admin/model/school/help/Article.php @@ -27,9 +27,20 @@ class Article extends Model protected $append = [ 'status_text', 'hot_text', - 'start_time_text' + 'start_time_text', + 'cate_title', ]; - + + public function getCateTitleAttr($value, $data) + { + $classes_cate_ids = (isset($data['help_cate_ids']) ? $data['help_cate_ids'] : ''); + if(!$classes_cate_ids) return ''; + //$classes_cate_ids 查询分类表 names 已逗号拼接返回 + $classes_cate_title = Cate::where('id','in',$classes_cate_ids)->column('name'); + return implode(',',$classes_cate_title); + } + + protected static function init() { @@ -80,5 +91,9 @@ class Article extends Model return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } + public function getCateList(){ + return Cate::column("name", 'id'); + } + } diff --git a/application/admin/view/school/help/article/add.html b/application/admin/view/school/help/article/add.html index c38c373..a452e73 100644 --- a/application/admin/view/school/help/article/add.html +++ b/application/admin/view/school/help/article/add.html @@ -3,7 +3,7 @@