From c40b03a222f0820f0d9a68bebbd05e978e374d7d Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Sat, 8 May 2021 07:31:41 +0800 Subject: [PATCH] =?UTF-8?q?button=20=E6=96=B0=E5=A2=9E=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/library/table/Actions.php | 24 +++++------ .../library/table/components/Button.php | 43 ++++++++++++++++++- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/extend/catcher/library/table/Actions.php b/extend/catcher/library/table/Actions.php index 45808f1..3d449e0 100644 --- a/extend/catcher/library/table/Actions.php +++ b/extend/catcher/library/table/Actions.php @@ -14,9 +14,9 @@ class Actions * @time 2021年03月23日 * @param string $text * @param string $event - * @return mixed + * @return Button */ - public static function create(string $text = '新建', string $event = 'handleCreate') + public static function create(string $text = '新建', string $event = 'handleCreate'): Button { return self::normal($text, 'primary',$event)->icon('el-icon-plus'); } @@ -27,9 +27,9 @@ class Actions * @time 2021年03月23日 * @param string $text * @param string $event - * @return mixed + * @return Button */ - public static function update(string $text = '更新', string $event = 'handleUpdate') + public static function update(string $text = '更新', string $event = 'handleUpdate'): Button { return self::normal($text, 'primary', $event)->icon('el-icon-edit'); } @@ -40,9 +40,9 @@ class Actions * @time 2021年03月23日 * @param string $text * @param string $event - * @return mixed + * @return Button */ - public static function delete(string $text = '删除', string $event = 'handleDel') + public static function delete(string $text = '删除', string $event = 'handleDel'): Button { return self::normal($text, 'danger', $event)->icon('el-icon-delete'); } @@ -54,9 +54,9 @@ class Actions * @param string $text * @param string $type * @param string|null $event - * @return mixed + * @return Button */ - public static function view(string $text = '查看', $type = 'success', string $event = 'handleView') + public static function view(string $text = '查看', $type = 'success', string $event = 'handleView'): Button { return self::normal($text, $type, $event)->icon('el-icon-view'); } @@ -89,9 +89,9 @@ class Actions * 导出按钮 * * @time 2021年04月02日 - * @return mixed + * @return Button */ - public static function export() + public static function export(): Button { return self::normal('导出', 'success','handleExport')->icon('el-icon-download'); } @@ -100,9 +100,9 @@ class Actions * 导入按钮 * * @time 2021年04月02日 - * @return mixed + * @return Button */ - public static function import() + public static function import(): Button { return self::normal('导入', 'warning', 'handleImport')->icon('el-icon-upload2'); } diff --git a/extend/catcher/library/table/components/Button.php b/extend/catcher/library/table/components/Button.php index bae0580..49b3428 100644 --- a/extend/catcher/library/table/components/Button.php +++ b/extend/catcher/library/table/components/Button.php @@ -5,7 +5,13 @@ class Button extends Component { protected $el = 'button'; - + /** + * icon + * + * @time 2021年05月07日 + * @param string $icon + * @return $this + */ public function icon(string $icon): Button { $this->attributes['icon'] = $icon; @@ -13,6 +19,13 @@ class Button extends Component return $this; } + /** + * 文字 + * + * @time 2021年05月07日 + * @param string $text + * @return $this + */ public function text(string $text): Button { $this->attributes['label'] = $text; @@ -20,6 +33,13 @@ class Button extends Component return $this; } + /** + * 样式 + * + * @time 2021年05月07日 + * @param string $style + * @return $this + */ public function style(string $style): Button { $this->attributes['class'] = $style; @@ -27,6 +47,13 @@ class Button extends Component return $this; } + /** + * 点击事件 + * + * @time 2021年05月07日 + * @param string $click + * @return $this + */ public function click(string $click): Button { $this->attributes['click'] = $click; @@ -34,6 +61,20 @@ class Button extends Component return $this; } + /** + * 权限 action 指令 + * + * @time 2021年05月07日 + * @param string $action + * @return $this + */ + public function permission(string $permission): Button + { + $this->attributes['permission'] = $permission; + + return $this; + } + /** * 支持路由跳转 *