108 lines
2.4 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
{
/**
* 创建按钮
*
* @time 2021年03月23日
* @param string $text
* @param string $event
* @return mixed
*/
public static function create(string $text = '新建', string $event = 'handleCreate')
{
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
* @return mixed
*/
public static function update(string $text = '更新', string $event = 'handleUpdate')
{
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
* @return mixed
*/
public static function delete(string $text = '删除', string $event = 'handleDel')
{
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-03-29 19:52:01 +08:00
* @return mixed
*/
2021-04-03 12:49:55 +08:00
public static function view(string $text = '查看', $type = 'success', string $event = 'handleView')
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
*/
2021-04-03 10:35:21 +08:00
public static function normal(string $text, $type = '', string $event = null): Button
2021-03-29 19:52:01 +08:00
{
$button = (new Button)
->size('mini')
2021-04-03 10:35:21 +08:00
->type($type)
2021-03-29 19:52:01 +08:00
->text($text);
if ($event) {
return $button->click($event);
}
return $button;
}
2021-04-03 10:35:21 +08:00
/**
* 导出按钮
*
* @time 2021年04月02日
* @return mixed
*/
public static function export()
{
return self::normal('导出', 'success','handleExport')->icon('el-icon-download');
}
/**
* 导入按钮
*
* @time 2021年04月02日
* @return mixed
*/
public static function import()
{
return self::normal('导入', 'warning', 'handleImport')->icon('el-icon-upload2');
}
2021-03-29 19:52:01 +08:00
}