update:更新table&form组件
This commit is contained in:
parent
246d2caf44
commit
f321a71677
@ -14,6 +14,7 @@
|
||||
namespace catcher\library\form;
|
||||
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\library\form\components\Editor;
|
||||
use FormBuilder\Exception\FormBuilderException;
|
||||
use FormBuilder\Factory\Elm;
|
||||
use FormBuilder\UI\Elm\Components\Upload;
|
||||
@ -317,4 +318,18 @@ abstract class Form
|
||||
return ['span' => $col];
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑器
|
||||
*
|
||||
* @time 2021年04月08日
|
||||
* @param $field
|
||||
* @param $title
|
||||
* @param string $value
|
||||
* @return Editor
|
||||
*/
|
||||
public static function editor(string $field, string $title, string $value = ''): Editor
|
||||
{
|
||||
return new Editor($field, $title, $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace catcher\library\form;
|
||||
|
||||
use FormBuilder\UI\Elm\Validate;
|
||||
|
||||
trait FormValidates
|
||||
{
|
||||
/**
|
||||
@ -8,9 +10,9 @@ trait FormValidates
|
||||
*
|
||||
* @time 2021年03月06日
|
||||
* @param string $pattern
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validatePattern(string $pattern): \FormBuilder\UI\Elm\Validate
|
||||
public static function validatePattern(string $pattern): Validate
|
||||
{
|
||||
return self::validateStr()->pattern($pattern);
|
||||
}
|
||||
@ -19,120 +21,120 @@ trait FormValidates
|
||||
* 纯数字验证
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateAlpha(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateAlpha(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('^[A-Za-z]+$')->message('必须为纯字母');
|
||||
return self::validatePattern('^[A-Za-z]+$')->message('必须为纯字母');
|
||||
}
|
||||
|
||||
/**
|
||||
* 字母和数字
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateAlphaNum(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateAlphaNum(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('^[A-Za-z0-9]+$')->message('必须为字母和数字');
|
||||
return self::validatePattern('^[A-Za-z0-9]+$')->message('必须为字母和数字');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateAlphaDash(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateAlphaDash(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('^[A-Za-z0-9\-\_]+$')->message('必须为字母和数字,下划线_及破折号-');
|
||||
return self::validatePattern('^[A-Za-z0-9\-\_]+$')->message('必须为字母和数字,下划线_及破折号-');
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateMobile(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateMobile(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('^1[3-9]\d{9}$')->message('请输入正确的手机号格式');
|
||||
return self::validatePattern('^1[3-9]\d{9}$')->message('请输入正确的手机号格式');
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateIdCard(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateIdCard(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)')->message('身份证输入格式不正确');
|
||||
return self::validatePattern('(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)')->message('身份证输入格式不正确');
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮政编码
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateZip(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateZip(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('\d{6}')->message('请输入有效的邮政编码');
|
||||
return self::validatePattern('\d{6}')->message('请输入有效的邮政编码');
|
||||
}
|
||||
|
||||
/**
|
||||
* IP 地址
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateIp(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateIp(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))')->message('请输入正确的 IP 地址');
|
||||
return self::validatePattern('((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))')->message('请输入正确的 IP 地址');
|
||||
}
|
||||
|
||||
/**
|
||||
* 座机
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateLandLine(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateLandLine(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('\d{3}-\d{8}|\d{4}-\d{7}')->message('请输入正确的座机格式');
|
||||
return self::validatePattern('\d{3}-\d{8}|\d{4}-\d{7}')->message('请输入正确的座机格式');
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validatePassword(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validatePassword(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('^[a-zA-Z]\w{5,18}$')->message('以字母开头,长度在6~18之间,只能包含字母、数字和下划线');
|
||||
return self::validatePattern('^[a-zA-Z]\w{5,18}$')->message('以字母开头,长度在6~18之间,只能包含字母、数字和下划线');
|
||||
}
|
||||
|
||||
/**
|
||||
* 强密码
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateStrongPassword(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateStrongPassword(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,20}$')->message('必须包含大小写字母和数字的组合,不能使用特殊字符,长度在8-20之间');
|
||||
return self::validatePattern('^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,20}$')->message('必须包含大小写字母和数字的组合,不能使用特殊字符,长度在8-20之间');
|
||||
}
|
||||
|
||||
/**
|
||||
* 纯汉字
|
||||
*
|
||||
* @time 2021年03月12日
|
||||
* @return \FormBuilder\UI\Elm\Validate
|
||||
* @return Validate
|
||||
*/
|
||||
public static function validateChineseCharacter(): \FormBuilder\UI\Elm\Validate
|
||||
public static function validateChineseCharacter(): Validate
|
||||
{
|
||||
return Form::validateStr()->pattern('^[\u4e00-\u9fa5]{0,}$')->message('必须为纯汉字');
|
||||
return self::validatePattern('^[\u4e00-\u9fa5]{0,}$')->message('必须为纯汉字');
|
||||
}
|
||||
}
|
18
extend/catcher/library/form/components/Editor.php
Normal file
18
extend/catcher/library/form/components/Editor.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace catcher\library\form\components;
|
||||
|
||||
use FormBuilder\Driver\FormComponent;
|
||||
use FormBuilder\Factory\Elm;
|
||||
|
||||
class Editor extends FormComponent
|
||||
{
|
||||
protected $defaultProps = [
|
||||
'type' => 'editor'
|
||||
];
|
||||
|
||||
public function createValidate()
|
||||
{
|
||||
// TODO: Implement createValidate() method.
|
||||
return Elm::validateStr();
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace catcher\library\table;
|
||||
|
||||
use catcher\base\CatchModel;
|
||||
use FormBuilder\UI\Elm\Components\Input;
|
||||
use FormBuilder\UI\Elm\Components\Select;
|
||||
use FormBuilder\UI\Elm\Components\DatePicker;
|
||||
@ -24,7 +25,7 @@ class Search
|
||||
* @param $placeholder
|
||||
* @return \FormBuilder\UI\Elm\Components\Input
|
||||
*/
|
||||
public static function name($placeholder): Input
|
||||
public static function name(string $placeholder): Input
|
||||
{
|
||||
return Form::input('name', self::$label)->placeholder($placeholder);
|
||||
}
|
||||
@ -36,11 +37,11 @@ class Search
|
||||
* @param $placeholder
|
||||
* @return \FormBuilder\UI\Elm\Components\Select
|
||||
*/
|
||||
public static function status($placeholder = '请选择状态'): Select
|
||||
public static function status(string $placeholder = '请选择状态'): Select
|
||||
{
|
||||
return self::select('status', $placeholder, [
|
||||
[ 'value' => 1, 'label'=> ' 正常'],
|
||||
[ 'value' => 2, 'label'=> ' 禁用']
|
||||
[ 'value' => CatchModel::ENABLE, 'label'=> ' 正常'],
|
||||
[ 'value' => CatchModel::DISABLE, 'label'=> ' 禁用']
|
||||
]);
|
||||
}
|
||||
|
||||
@ -51,11 +52,9 @@ class Search
|
||||
* @param string $placeholder
|
||||
* @return \FormBuilder\UI\Elm\Components\DatePicker
|
||||
*/
|
||||
public static function startAt($placeholder = '开始时间'): DatePicker
|
||||
public static function startAt(string $placeholder = '请选择开始时间'): DatePicker
|
||||
{
|
||||
return self::label(self::$label ? : '开始时间')->datetime('start_at', $placeholder)
|
||||
->placeholder($placeholder)
|
||||
->format('yy-MM-DD HH:i:s');
|
||||
return self::label(self::$label ? : '开始时间')->datetime('start_at', $placeholder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,11 +64,9 @@ class Search
|
||||
* @param string $placeholder
|
||||
* @return \FormBuilder\UI\Elm\Components\DatePicker
|
||||
*/
|
||||
public static function endAt($placeholder = '结束时间'): DatePicker
|
||||
public static function endAt(string $placeholder = '请选择结束时间'): DatePicker
|
||||
{
|
||||
return self::label(self::$label ? : '结束时间')->datetime('end_at', $placeholder)
|
||||
->placeholder($placeholder)
|
||||
->format('yy-MM-DD HH:i:s');
|
||||
return self::label(self::$label ? : '结束时间')->datetime('end_at', $placeholder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +77,7 @@ class Search
|
||||
* @param $placeholder
|
||||
* @return \FormBuilder\UI\Elm\Components\Input
|
||||
*/
|
||||
public static function text($name, $placeholder): Input
|
||||
public static function text(string $name, string $placeholder): Input
|
||||
{
|
||||
return Form::input($name, self::$label)->placeholder($placeholder);
|
||||
}
|
||||
@ -94,7 +91,7 @@ class Search
|
||||
* @param $options
|
||||
* @return \FormBuilder\UI\Elm\Components\Select
|
||||
*/
|
||||
public static function select($name, $placeholder, $options): Select
|
||||
public static function select(string $name, string $placeholder, array $options): Select
|
||||
{
|
||||
return Form::select($name, self::$label)->placeholder($placeholder)->options($options);
|
||||
}
|
||||
@ -107,14 +104,22 @@ class Search
|
||||
* @param $placeholder
|
||||
* @return \FormBuilder\UI\Elm\Components\DatePicker
|
||||
*/
|
||||
public static function datetime($name, $placeholder): DatePicker
|
||||
public static function datetime(string $name, string $placeholder): DatePicker
|
||||
{
|
||||
return Form::dateTime($name, self::$label)
|
||||
->placeholder($placeholder)
|
||||
->format('yyyy-MM-dd HH:i:s');
|
||||
->format('yyyy-MM-dd HH:mm:ss')
|
||||
->valueFormat('yyyy-MM-dd HH:mm:ss');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 代理方法
|
||||
*
|
||||
* @time 2021年04月06日
|
||||
* @param $method
|
||||
* @param $params
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($method, $params)
|
||||
{
|
||||
return Form::{$method}(...$params);
|
||||
|
Loading…
x
Reference in New Issue
Block a user