140 lines
3.5 KiB
PHP
Raw Normal View History

2021-03-29 19:52:01 +08:00
<?php
namespace catcher\library\table;
2021-04-10 21:57:51 +08:00
use catcher\base\CatchModel;
2021-04-05 12:26:31 +08:00
use FormBuilder\UI\Elm\Components\Input;
use FormBuilder\UI\Elm\Components\Select;
use FormBuilder\UI\Elm\Components\DatePicker;
2021-03-29 19:52:01 +08:00
use catcher\library\form\Form;
class Search
{
2021-04-05 12:26:31 +08:00
protected static $label = '';
public static function label(string $label): Search
{
self::$label = $label;
return new self();
}
2021-03-29 19:52:01 +08:00
/**
* 名称
*
* @time 2021年03月23日
* @param $placeholder
* @return \FormBuilder\UI\Elm\Components\Input
*/
2021-04-10 21:57:51 +08:00
public static function name(string $placeholder): Input
2021-03-29 19:52:01 +08:00
{
2021-04-05 12:26:31 +08:00
return Form::input('name', self::$label)->placeholder($placeholder);
2021-03-29 19:52:01 +08:00
}
/**
* 状态
*
* @time 2021年03月23日
* @param $placeholder
* @return \FormBuilder\UI\Elm\Components\Select
*/
2021-04-10 21:57:51 +08:00
public static function status(string $placeholder = '请选择状态'): Select
2021-03-29 19:52:01 +08:00
{
return self::select('status', $placeholder, [
2021-04-10 21:57:51 +08:00
[ 'value' => CatchModel::ENABLE, 'label'=> ' 正常'],
[ 'value' => CatchModel::DISABLE, 'label'=> ' 禁用']
2021-03-29 19:52:01 +08:00
]);
}
/**
* 开始时间
*
* @time 2021年03月23日
* @param string $placeholder
* @return \FormBuilder\UI\Elm\Components\DatePicker
*/
2021-04-10 21:57:51 +08:00
public static function startAt(string $placeholder = '请选择开始时间'): DatePicker
2021-03-29 19:52:01 +08:00
{
2021-04-10 21:57:51 +08:00
return self::label(self::$label ? : '开始时间')->datetime('start_at', $placeholder);
2021-03-29 19:52:01 +08:00
}
/**
* 结束时间
*
* @time 2021年03月23日
* @param string $placeholder
* @return \FormBuilder\UI\Elm\Components\DatePicker
*/
2021-04-10 21:57:51 +08:00
public static function endAt(string $placeholder = '请选择结束时间'): DatePicker
2021-03-29 19:52:01 +08:00
{
2021-04-10 21:57:51 +08:00
return self::label(self::$label ? : '结束时间')->datetime('end_at', $placeholder);
2021-03-29 19:52:01 +08:00
}
/**
* 文本
*
* @time 2021年03月23日
* @param $name
* @param $placeholder
* @return \FormBuilder\UI\Elm\Components\Input
*/
2021-04-10 21:57:51 +08:00
public static function text(string $name, string $placeholder): Input
2021-03-29 19:52:01 +08:00
{
2021-04-05 12:26:31 +08:00
return Form::input($name, self::$label)->placeholder($placeholder);
2021-03-29 19:52:01 +08:00
}
/**
* 选择
*
* @time 2021年03月23日
* @param $name
* @param $placeholder
* @param $options
* @return \FormBuilder\UI\Elm\Components\Select
*/
2021-04-10 21:57:51 +08:00
public static function select(string $name, string $placeholder, array $options): Select
2021-03-29 19:52:01 +08:00
{
2021-04-05 12:26:31 +08:00
return Form::select($name, self::$label)->placeholder($placeholder)->options($options);
2021-03-29 19:52:01 +08:00
}
/**
* 选择时间
*
* @time 2021年03月23日
* @param $name
* @param $placeholder
* @return \FormBuilder\UI\Elm\Components\DatePicker
*/
2021-04-10 21:57:51 +08:00
public static function datetime(string $name, string $placeholder): DatePicker
2021-03-29 19:52:01 +08:00
{
2021-04-05 12:26:31 +08:00
return Form::dateTime($name, self::$label)
2021-03-29 19:52:01 +08:00
->placeholder($placeholder)
2021-04-10 21:57:51 +08:00
->format('yyyy-MM-dd HH:mm:ss')
->valueFormat('yyyy-MM-dd HH:mm:ss');
2021-03-29 19:52:01 +08:00
}
2021-04-05 12:26:31 +08:00
2021-04-10 21:57:51 +08:00
/**
* 代理方法
*
* @time 2021年04月06日
* @param $method
* @param $params
* @return mixed
*/
2021-04-05 12:26:31 +08:00
public static function __callStatic($method, $params)
{
return Form::{$method}(...$params);
}
2021-05-09 17:09:18 +08:00
/**
* 代理方法
*
* @time 2021年04月06日
* @param $method
* @param $params
* @return mixed
*/
public function __call($method, $params)
{
return Form::{$method}(...$params);
}
2021-03-29 19:52:01 +08:00
}