111 lines
2.5 KiB
PHP
Raw Normal View History

2021-03-29 19:52:01 +08:00
<?php
namespace catcher\library\table;
2021-03-31 20:21:16 +08:00
use catcher\library\table\components\Button;
2021-03-29 19:52:01 +08:00
class Actions
{
2021-04-05 12:26:31 +08:00
protected static $noText = false;
2021-03-29 19:52:01 +08:00
/**
* 创建按钮
*
* @time 2021年03月23日
* @param string $text
* @param string $event
2021-05-08 07:31:41 +08:00
* @return Button
2021-03-29 19:52:01 +08:00
*/
2021-05-08 07:31:41 +08:00
public static function create(string $text = '新建', string $event = 'handleCreate'): Button
2021-03-29 19:52:01 +08:00
{
2021-04-03 10:35:21 +08:00
return self::normal($text, 'primary',$event)->icon('el-icon-plus');
2021-03-29 19:52:01 +08:00
}
/**
* 更新按钮
*
* @time 2021年03月23日
* @param string $text
* @param string $event
2021-05-08 07:31:41 +08:00
* @return Button
2021-03-29 19:52:01 +08:00
*/
2021-05-08 07:31:41 +08:00
public static function update(string $text = '更新', string $event = 'handleUpdate'): Button
2021-03-29 19:52:01 +08:00
{
2021-04-03 10:35:21 +08:00
return self::normal($text, 'primary', $event)->icon('el-icon-edit');
2021-03-29 19:52:01 +08:00
}
/**
* 删除按钮
*
* @time 2021年03月23日
* @param string $text
* @param string $event
2021-05-08 07:31:41 +08:00
* @return Button
2021-03-29 19:52:01 +08:00
*/
2021-05-08 07:31:41 +08:00
public static function delete(string $text = '删除', string $event = 'handleDel'): Button
2021-03-29 19:52:01 +08:00
{
2021-04-03 10:35:21 +08:00
return self::normal($text, 'danger', $event)->icon('el-icon-delete');
2021-03-29 19:52:01 +08:00
}
/**
* 查询按钮
*
* @time 2021年03月23日
* @param string $text
2021-04-03 12:49:55 +08:00
* @param string $type
2021-04-03 10:35:21 +08:00
* @param string|null $event
2021-05-08 07:31:41 +08:00
* @return Button
2021-03-29 19:52:01 +08:00
*/
2021-05-08 07:31:41 +08:00
public static function view(string $text = '查看', $type = 'success', string $event = 'handleView'): Button
2021-03-29 19:52:01 +08:00
{
2021-04-03 12:49:55 +08:00
return self::normal($text, $type, $event)->icon('el-icon-view');
2021-03-29 19:52:01 +08:00
}
/**
* normal
*
* @time 2021年03月23日
* @param string $text
2021-04-03 10:35:21 +08:00
* @param string $type
2021-03-29 19:52:01 +08:00
* @param string|null $event
2021-04-03 10:35:21 +08:00
* @return Button
2021-03-29 19:52:01 +08:00
*/
public static function normal(string $text, $type = '', string $event = null, string $icon = ''): Button
2021-03-29 19:52:01 +08:00
{
$button = (new Button)
->size('mini')
2021-04-03 10:35:21 +08:00
->type($type)
->icon($icon)
2021-04-05 12:26:31 +08:00
->text(self::$noText ? '' : $text);
2021-03-29 19:52:01 +08:00
if ($event) {
return $button->click($event);
}
return $button;
}
2021-04-03 10:35:21 +08:00
/**
* 导出按钮
*
* @time 2021年04月02日
2021-05-08 07:31:41 +08:00
* @return Button
2021-04-03 10:35:21 +08:00
*/
2021-05-08 07:31:41 +08:00
public static function export(): Button
2021-04-03 10:35:21 +08:00
{
return self::normal('导出', 'success','handleExport')->icon('el-icon-download');
}
/**
* 导入按钮
*
* @time 2021年04月02日
2021-05-08 07:31:41 +08:00
* @return Button
2021-04-03 10:35:21 +08:00
*/
2021-05-08 07:31:41 +08:00
public static function import(): Button
2021-04-03 10:35:21 +08:00
{
return self::normal('导入', 'warning', 'handleImport')->icon('el-icon-upload2');
}
2021-03-29 19:52:01 +08:00
}