From 908f84ee9fd4d14fe3186f737f5973b174ceab81 Mon Sep 17 00:00:00 2001 From: augushong Date: Sat, 25 Jul 2026 22:39:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor(timer):=20TimerLog=20=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8=E8=BF=81=E7=A7=BB=E5=88=B0=20Base=20?= =?UTF-8?q?=E5=B1=82=20+=20toolbar=20=E4=B8=8E=E4=BA=8B=E4=BB=B6=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 控制器逻辑移入 extend/base/admin/controller/system/TimerLogBase.php,app 层改为空壳继承。index.js 补 toolbar:[] + defaultToolbar:['filter'](B 类只读页面),修正 ua.table.on → layui.table.on。 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- app/admin/controller/system/TimerLog.php | 104 +---------------- .../admin/controller/system/TimerLogBase.php | 109 ++++++++++++++++++ .../base/admin/view/system/timer_log/index.js | 4 +- 3 files changed, 114 insertions(+), 103 deletions(-) create mode 100644 extend/base/admin/controller/system/TimerLogBase.php diff --git a/app/admin/controller/system/TimerLog.php b/app/admin/controller/system/TimerLog.php index 820a37b..33f28a5 100644 --- a/app/admin/controller/system/TimerLog.php +++ b/app/admin/controller/system/TimerLog.php @@ -2,108 +2,8 @@ namespace app\admin\controller\system; -use app\common\controller\AdminController; -use app\admin\service\annotation\ControllerAnnotation; -use app\admin\service\annotation\NodeAnotation; -use think\App; +use base\admin\controller\system\TimerLogBase; -/** - * @ControllerAnnotation(title="定时器执行日志") - */ -class TimerLog extends AdminController +class TimerLog extends TimerLogBase { - - use \app\admin\traits\Curd; - - protected $sort = [ - 'id' => 'desc', - ]; - - public function __construct(App $app) - { - parent::__construct($app); - - $this->model = new \app\admin\model\SystemTimerLog(); - } - - /** - * @NodeAnotation(title="列表") - */ - public function index() - { - if ($this->request->isAjax()) { - if (input('selectFields')) { - return $this->selectList(); - } - list($page, $limit, $where, $excludes, $request_options, $group) = $this->buildTableParames(); - $count = $this->model - ->where($where) - ->group($group) - ->count(); - $list = $this->model - ->where($where) - ->page($page, $limit) - ->order($this->sort) - ->group($group) - ->select(); - $data = [ - 'code' => 0, - 'msg' => '', - 'count' => $count, - 'data' => $list, - ]; - - return json($data); - } - - return $this->fetch(); - } - - /** - * @NodeAnotation(title="详情") - */ - public function read($id) - { - $row = $this->model->find($id); - empty($row) && $this->error('数据不存在'); - - $title = $row->title; - - $this->assign('row', $row); - $this->assign('title', $title); - - return $this->fetch(); - } - - /** - * @NodeAnotation(title="添加") - */ - public function add() - { - $this->error('日志表不允许手动添加'); - } - - /** - * @NodeAnotation(title="编辑") - */ - public function edit($id) - { - $this->error('日志表不允许编辑'); - } - - /** - * @NodeAnotation(title="删除") - */ - public function delete($id) - { - $this->error('日志表不允许删除'); - } - - /** - * @NodeAnotation(title="属性修改") - */ - public function modify() - { - $this->error('日志表不允许修改'); - } } diff --git a/extend/base/admin/controller/system/TimerLogBase.php b/extend/base/admin/controller/system/TimerLogBase.php new file mode 100644 index 0000000..4d6cfff --- /dev/null +++ b/extend/base/admin/controller/system/TimerLogBase.php @@ -0,0 +1,109 @@ + 'desc', + ]; + + public function __construct(App $app) + { + parent::__construct($app); + + $this->model = new \app\admin\model\SystemTimerLog(); + } + + /** + * @NodeAnotation(title="列表") + */ + public function index() + { + if ($this->request->isAjax()) { + if (input('selectFields')) { + return $this->selectList(); + } + list($page, $limit, $where, $excludes, $request_options, $group) = $this->buildTableParames(); + $count = $this->model + ->where($where) + ->group($group) + ->count(); + $list = $this->model + ->where($where) + ->page($page, $limit) + ->order($this->sort) + ->group($group) + ->select(); + $data = [ + 'code' => 0, + 'msg' => '', + 'count' => $count, + 'data' => $list, + ]; + + return json($data); + } + + return $this->fetch(); + } + + /** + * @NodeAnotation(title="详情") + */ + public function read($id) + { + $row = $this->model->find($id); + empty($row) && $this->error('数据不存在'); + + $title = $row->title; + + $this->assign('row', $row); + $this->assign('title', $title); + + return $this->fetch(); + } + + /** + * @NodeAnotation(title="添加") + */ + public function add() + { + $this->error('日志表不允许手动添加'); + } + + /** + * @NodeAnotation(title="编辑") + */ + public function edit($id) + { + $this->error('日志表不允许编辑'); + } + + /** + * @NodeAnotation(title="删除") + */ + public function delete($id) + { + $this->error('日志表不允许删除'); + } + + /** + * @NodeAnotation(title="属性修改") + */ + public function modify() + { + $this->error('日志表不允许修改'); + } +} diff --git a/extend/base/admin/view/system/timer_log/index.js b/extend/base/admin/view/system/timer_log/index.js index af6f874..b58ce85 100644 --- a/extend/base/admin/view/system/timer_log/index.js +++ b/extend/base/admin/view/system/timer_log/index.js @@ -56,6 +56,8 @@ $(function(){ ua.table.render({ init: init, + toolbar: [], + defaultToolbar: ['filter'], cols: [[ {type: 'checkbox'}, {field: 'id', title: 'ID', width: 80, sort: true}, @@ -85,7 +87,7 @@ $(function(){ }); // 点击错误信息查看完整内容 - ua.table.on('tool(currentTable)', function(obj) { + layui.table.on('tool(currentTable)', function(obj) { if (obj.event === 'showError') { var text = obj.data.error_message || ''; layer.alert('
'+text.replace(//g,'>')+'
', {