chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
121
crmeb/form/BaseComponent.php
Normal file
121
crmeb/form/BaseComponent.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form;
|
||||
|
||||
/**
|
||||
* 基础组件集成
|
||||
* Class BaseComponent
|
||||
* @package crmeb\form
|
||||
*/
|
||||
abstract class BaseComponent
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $init = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [];
|
||||
|
||||
/**
|
||||
* 数据库验证
|
||||
* @var array
|
||||
*/
|
||||
protected $validate = [];
|
||||
|
||||
/**
|
||||
* @var CommonRule
|
||||
*/
|
||||
protected $validataRule;
|
||||
|
||||
/**
|
||||
* 是否实例化
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->init) {
|
||||
$this->validataRule = new CommonRule;
|
||||
$this->init = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个验证规则
|
||||
* @param array $validate
|
||||
* @return $this
|
||||
*/
|
||||
public function validates(array $validate)
|
||||
{
|
||||
$this->validate = $validate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个验证规则
|
||||
* @param CommonRule $validate
|
||||
* @return $this
|
||||
*/
|
||||
public function validate(CommonRule $validate)
|
||||
{
|
||||
$this->validate[] = $validate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
* @return $this
|
||||
*/
|
||||
public function required()
|
||||
{
|
||||
$this->init();
|
||||
$this->validataRule->required();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置提示消息
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function message(string $message)
|
||||
{
|
||||
$this->init();
|
||||
$this->validataRule->message($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据写入
|
||||
*/
|
||||
protected function before()
|
||||
{
|
||||
if (!$this->validate && $this->validataRule instanceof CommonRule) {
|
||||
if (!$this->validataRule->getMessage() && $this->rule['title']) {
|
||||
$this->validataRule->message('请输入' . $this->rule['title']);
|
||||
}
|
||||
$this->validate[] = $this->validataRule->toArray();
|
||||
}
|
||||
$validate = [];
|
||||
foreach ($this->validate as $item) {
|
||||
if ($item instanceof CommonRule) {
|
||||
$validate[] = $item->toArray();
|
||||
} else {
|
||||
$validate[] = $item;
|
||||
}
|
||||
}
|
||||
$this->rule['validate'] = $validate;
|
||||
}
|
||||
}
|
||||
262
crmeb/form/Build.php
Normal file
262
crmeb/form/Build.php
Normal file
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form;
|
||||
|
||||
|
||||
use crmeb\form\components\Address;
|
||||
use crmeb\form\components\Alert;
|
||||
use crmeb\form\components\Card;
|
||||
use crmeb\form\components\CheckBox;use crmeb\form\components\DiyTable;
|
||||
use crmeb\form\components\Input;
|
||||
use crmeb\form\components\InputNumber;
|
||||
use crmeb\form\components\Map;
|
||||
use crmeb\form\components\Radio;
|
||||
use crmeb\form\components\Select;
|
||||
use crmeb\form\components\Switchs;
|
||||
use crmeb\form\components\Tabs;
|
||||
use crmeb\form\components\Time;
|
||||
use crmeb\form\components\UploadFrame;
|
||||
use crmeb\form\components\UploadImage;
|
||||
|
||||
/**
|
||||
* Class Build
|
||||
* @package crmeb\form
|
||||
* @method Input input(string $field, string $title, $value = null)
|
||||
* @method Tabs tabs(array $options = [])
|
||||
* @method Card card(string $title)
|
||||
* @method InputNumber inputNum(string $field, string $title, $value = null)
|
||||
* @method Select select(string $field, string $title, $value = null)
|
||||
* @method UploadFrame uploadFrame(string $field, string $title, $value = null)
|
||||
* @method UploadImage uploadImage(string $field, string $title, $value = null)
|
||||
* @method Radio radio(string $field, string $title, $value = null)
|
||||
* @method CheckBox checkbox(string $field, string $title, $value = null)
|
||||
* @method Switchs switch (string $field, string $title, $value = null)
|
||||
* @method Alert alert (string $title, string $type = '', bool $closable = false, bool $showIcon = false)
|
||||
* @method DiyTable diyTable(string $field, string $title, array $value = [], array $options = [])
|
||||
* @method Map map(string $field, string $title, $value = null)
|
||||
* @method Address address(string $field, string $title, $value = null)
|
||||
* @method Time time(string $field, string $title, $value = null)
|
||||
*/
|
||||
class Build
|
||||
{
|
||||
|
||||
/**
|
||||
* 挂载组件
|
||||
* @var string[]
|
||||
*/
|
||||
protected static array $components = [
|
||||
'input' => Input::class,
|
||||
'tabs' => Tabs::class,
|
||||
'card' => Card::class,
|
||||
'inputNum' => InputNumber::class,
|
||||
'select' => Select::class,
|
||||
'uploadFrame' => UploadFrame::class,
|
||||
'uploadImage' => UploadImage::class,
|
||||
'radio' => Radio::class,
|
||||
'switch' => Switchs::class,
|
||||
'alert' => Alert::class,
|
||||
'diyTable' => DiyTable::class,
|
||||
'address' => Address::class,
|
||||
'map' => Map::class,
|
||||
'time' => Time::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $rule = [];
|
||||
|
||||
/**
|
||||
* 请求地址
|
||||
* @var
|
||||
*/
|
||||
protected ?string $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $method = 'POST';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $data = [];
|
||||
|
||||
/**
|
||||
* Build constructor.
|
||||
* @param string|null $url
|
||||
* @param array $rule
|
||||
* @param string|null $method
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(string $url = null, array $rule = [], string $method = null, array $data = [])
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->rule = $rule;
|
||||
$this->method = $method ?: 'POST';
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rule
|
||||
* @return $this
|
||||
*/
|
||||
public function rule(array $rule = [])
|
||||
{
|
||||
$this->rule = $rule;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function url(string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @return $this
|
||||
*/
|
||||
public function method(string $method)
|
||||
{
|
||||
$this->method = $method;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Build
|
||||
*/
|
||||
public function data(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置数据
|
||||
* @param $rule
|
||||
* @return mixed
|
||||
*/
|
||||
public function setValue($rule)
|
||||
{
|
||||
if (!$this->data) {
|
||||
return $rule;
|
||||
}
|
||||
foreach ($rule as &$value) {
|
||||
if (isset($value['value']) && $value['value'] !== '' && isset($value['field'])) {
|
||||
$value['value'] = $this->data[$value['field']];
|
||||
}
|
||||
if (isset($value['options']) && $value['options']) {
|
||||
foreach ($value['options'] as $i => $option) {
|
||||
if (isset($option['componentsModel']) && $option['componentsModel']) {
|
||||
$value['options'][$i] = $this->setValue($option['componentsModel']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($value['control']) && $value['control']) {
|
||||
foreach ($value['control'] as $ii => $control) {
|
||||
if (isset($control['componentsModel']) && $control['componentsModel']) {
|
||||
$value['control'][$ii] = $this->setValue($control['componentsModel']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($value['componentsModel']) && $value['componentsModel']) {
|
||||
$value['componentsModel'] = $this->setValue($value['componentsModel']);
|
||||
}
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取验证值
|
||||
* @param $rule
|
||||
* @return array
|
||||
*/
|
||||
protected function getValidate($rule)
|
||||
{
|
||||
$validate = [];
|
||||
foreach ($rule as $value) {
|
||||
if (isset($value['field']) && isset($value['validate']) && $value['validate']) {
|
||||
$validate[$value['field']] = $value['validate'];
|
||||
}
|
||||
if (isset($value['options']) && $value['options']) {
|
||||
foreach ($value['options'] as $option) {
|
||||
if (isset($option['componentsModel']) && $option['componentsModel']) {
|
||||
$validate = array_merge($validate, $this->getValidate($option['componentsModel']));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($value['control']) && $value['control']) {
|
||||
foreach ($value['control'] as $control) {
|
||||
if (isset($control['componentsModel']) && $control['componentsModel']) {
|
||||
$validate = array_merge($validate, $this->getValidate($control['componentsModel']));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($value['componentsModel']) && $value['componentsModel']) {
|
||||
$validate = array_merge($validate, $this->getValidate($value['componentsModel']));
|
||||
}
|
||||
}
|
||||
return $validate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$rule = [];
|
||||
foreach ($this->rule as $item) {
|
||||
if ($item instanceof BuildInterface) {
|
||||
$rule[] = $item->toArray();
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'rules' => $this->setValue($rule),
|
||||
'validate' => $this->getValidate($rule),
|
||||
'url' => $this->url,
|
||||
'method' => $this->method
|
||||
];
|
||||
$data['validate'] = $data['validate'] ?: (object)[];
|
||||
$this->url = null;
|
||||
$this->rule = [];
|
||||
$this->method = 'POST';
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
$compKeys = array_keys(self::$components);
|
||||
if (in_array($name, $compKeys)) {
|
||||
return new self::$components[$name](...$arguments);
|
||||
}
|
||||
throw new BuildException('Method does not exist');
|
||||
}
|
||||
}
|
||||
27
crmeb/form/BuildException.php
Normal file
27
crmeb/form/BuildException.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form;
|
||||
|
||||
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BuildException
|
||||
* @package crmeb\form
|
||||
*/
|
||||
class BuildException extends \RuntimeException
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
24
crmeb/form/BuildInterface.php
Normal file
24
crmeb/form/BuildInterface.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form;
|
||||
|
||||
|
||||
/**
|
||||
* Interface BuildInterface
|
||||
* @package crmeb\form
|
||||
*/
|
||||
interface BuildInterface
|
||||
{
|
||||
|
||||
public function toArray(): array;
|
||||
|
||||
}
|
||||
180
crmeb/form/CommonRule.php
Normal file
180
crmeb/form/CommonRule.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form;
|
||||
|
||||
/**
|
||||
* Class CommonRule
|
||||
* @package crmeb\form
|
||||
*/
|
||||
class CommonRule implements BuildInterface
|
||||
{
|
||||
/**
|
||||
* 验证类型
|
||||
*/
|
||||
const VALIDATE_TYPE = ['string', 'number', 'boolean', 'method', 'regexp', 'integer', 'float', 'array', 'object', 'enum', 'date', 'url', 'hex', 'email'];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $required = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $pattern = '';
|
||||
|
||||
/**
|
||||
* 枚举值
|
||||
* @var array
|
||||
*/
|
||||
protected $enum = [];
|
||||
|
||||
/**
|
||||
* 提示语
|
||||
* @var string
|
||||
*/
|
||||
protected $message = '';
|
||||
|
||||
/**
|
||||
* 深度验证对象
|
||||
* @var array
|
||||
*/
|
||||
protected $fields = [];
|
||||
|
||||
/**
|
||||
* 验证触发方式
|
||||
* @var string
|
||||
*/
|
||||
protected $trigger = 'blur';
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function type(string $type)
|
||||
{
|
||||
$this->type = in_array($type, self::VALIDATE_TYPE) ? $type : null;
|
||||
if (!$this->type) {
|
||||
throw new FormValidate('验证类型错误');
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
* @return $this
|
||||
*/
|
||||
public function required()
|
||||
{
|
||||
$this->required = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置错误提示
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function message(string $message)
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提示语
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 枚举数据
|
||||
* @param array $enum
|
||||
* @return $this
|
||||
*/
|
||||
public function enum(array $enum)
|
||||
{
|
||||
$this->enum = $enum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 正则表达式
|
||||
* @param string $pattern
|
||||
* @return $this
|
||||
*/
|
||||
public function pattern(string $pattern)
|
||||
{
|
||||
$this->pattern = $pattern;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证规则
|
||||
* @param string|array|BuildInterface $field
|
||||
* @param array $rule
|
||||
* @return $this
|
||||
*/
|
||||
public function field($field, array $rule = [])
|
||||
{
|
||||
if (!in_array($this->type, ['array', 'object'])) {
|
||||
throw new BuildException('无效规则,类型只能在array或者object情况下才可设置');
|
||||
}
|
||||
if ($this->type === 'array') {
|
||||
$rules = [];
|
||||
if ($field instanceof BuildInterface) {
|
||||
$rules = $field->toArray();
|
||||
}
|
||||
$this->fields[] = $rules;
|
||||
} else {
|
||||
$rules = [];
|
||||
foreach ($rule as $item) {
|
||||
if ($item instanceof BuildInterface) {
|
||||
$rules[] = $item->toArray();
|
||||
}
|
||||
}
|
||||
$this->fields[$field] = $rules;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据转换
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$data = [
|
||||
'required' => $this->required,
|
||||
'message' => $this->message,
|
||||
'trigger' => $this->trigger,
|
||||
'pattern' => $this->pattern,
|
||||
'enum' => $this->enum,
|
||||
'type' => $this->type
|
||||
];
|
||||
$res = [];
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_bool($value) || $value) {
|
||||
$res[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
25
crmeb/form/FormValidate.php
Normal file
25
crmeb/form/FormValidate.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form;
|
||||
|
||||
|
||||
/**
|
||||
* Class FormValidate
|
||||
* @package crmeb\form
|
||||
*/
|
||||
class FormValidate extends \RuntimeException
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
70
crmeb/form/components/Address.php
Normal file
70
crmeb/form/components/Address.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 选择地址
|
||||
* Class Addres
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class Address extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
const NAME = 'address';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'field' => '',
|
||||
'value' => '',
|
||||
'info' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* Map constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param array $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, array $value = null)
|
||||
{
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['value'] = empty($value) ? '' : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
102
crmeb/form/components/Alert.php
Normal file
102
crmeb/form/components/Alert.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 警告框
|
||||
* Class Alert
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class Alert implements BuildInterface
|
||||
{
|
||||
|
||||
//组件名
|
||||
const NAME = 'alert';
|
||||
//提示类型
|
||||
const INFO = 'info';
|
||||
//成功类型
|
||||
const SUCCESS = 'success';
|
||||
//警告类型
|
||||
const WARNING = 'warning';
|
||||
//错误类型
|
||||
const ERROR = 'error';
|
||||
//组件类型
|
||||
const TYPE = [self::INFO, self::SUCCESS, self::WARNING, self::ERROR];
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'type' => '',
|
||||
'closable' => false,
|
||||
'showIcon' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* Alert constructor.
|
||||
* @param string $title
|
||||
* @param string $type
|
||||
* @param bool $closable
|
||||
* @param bool $showIcon
|
||||
*/
|
||||
public function __construct(string $title, string $type = '', bool $closable = false, bool $showIcon = false)
|
||||
{
|
||||
$this->rule['type'] = in_array($type, self::TYPE) ? $type : '';
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['closable'] = $closable;
|
||||
$this->rule['showIcon'] = $showIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function type(string $type)
|
||||
{
|
||||
$this->rule['type'] = in_array($type, self::TYPE) ? $type : '';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可关闭
|
||||
* @param bool $closable
|
||||
* @return $this
|
||||
*/
|
||||
public function closable(bool $closable = false)
|
||||
{
|
||||
$this->rule['closable'] = $closable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否展示图标
|
||||
* @param bool $showIcon
|
||||
* @return $this
|
||||
*/
|
||||
public function showIcon(bool $showIcon = false)
|
||||
{
|
||||
$this->rule['showIcon'] = $showIcon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
74
crmeb/form/components/Card.php
Normal file
74
crmeb/form/components/Card.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 卡片组件
|
||||
* Class Card
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class Card implements BuildInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
const NAME = 'card';
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'componentsModel' => [],
|
||||
'title' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* Card constructor.
|
||||
* @param string $title
|
||||
*/
|
||||
public function __construct(string $title)
|
||||
{
|
||||
$this->rule['title'] = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加组件群
|
||||
* @param array $components
|
||||
* @return $this
|
||||
*/
|
||||
public function components(array $components = [])
|
||||
{
|
||||
$this->rule['componentsModel'] = $components;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$componentsModel = [];
|
||||
foreach ($this->rule['componentsModel'] as $item) {
|
||||
if ($item instanceof BuildInterface) {
|
||||
$componentsModel[] = $item->toArray();
|
||||
}
|
||||
}
|
||||
$this->rule['componentsModel'] = $componentsModel;
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
90
crmeb/form/components/CheckBox.php
Normal file
90
crmeb/form/components/CheckBox.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 多选组件
|
||||
* Class CheckBox
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class CheckBox extends BaseComponent implements BuildInterface
|
||||
{
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
const NAME = 'checkbox';
|
||||
|
||||
/**
|
||||
* 组件规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'field' => '',
|
||||
'value' => [],
|
||||
'info' => '',
|
||||
'options' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* Radio constructor.
|
||||
* @param string $title
|
||||
* @param string $field
|
||||
* @param null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, array $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = !is_null($value) ? $value : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* options数据 ['label'=>'确定','value'=>1]
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options(array $options = [])
|
||||
{
|
||||
$this->rule['options'] = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置提示语
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据转换
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
91
crmeb/form/components/DiyTable.php
Normal file
91
crmeb/form/components/DiyTable.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 自定义表格
|
||||
* Class DiyTable
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class DiyTable extends BaseComponent implements BuildInterface
|
||||
{
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
const NAME = 'diyTable';
|
||||
|
||||
//内部表格自定义类型
|
||||
const TYPE = ['input', 'select', 'inputNumber', 'switch'];
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'value' => [],
|
||||
'type' => '',
|
||||
'field' => '',
|
||||
'options' => [],
|
||||
'info' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* DiyTable constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param array $value
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(string $field, string $title, array $value = [], array $options = [])
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['options'] = $options;
|
||||
$this->rule['value'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置列
|
||||
* @param string $name
|
||||
* @param string $key
|
||||
* @param string $type
|
||||
* @param array $props
|
||||
* @return $this
|
||||
*/
|
||||
public function column(string $name, string $key, string $type = 'input', array $props = [])
|
||||
{
|
||||
$this->rule['options'][] = ['name' => $name, 'key' => $key, 'type' => $type, 'props' => $props];
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
132
crmeb/form/components/Input.php
Normal file
132
crmeb/form/components/Input.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 输入框组件
|
||||
* Class Input
|
||||
* @package crmeb\form\components
|
||||
* @method Input info(string $info) 设置info
|
||||
* @method Input placeholder(string $placeholder) 设置placeholder
|
||||
* @method Input suffix(string $suffix) 输入框头部图标
|
||||
* @method Input prefix(string $prefix) 输入框尾部图标
|
||||
* @method Input value($value) 设置value
|
||||
* @method Input rows(int $rows) 设置rows
|
||||
* @method Input type(string $type) 设置type
|
||||
* @method Input maxlength(int $maxlength) 设置maxlength
|
||||
*/
|
||||
class Input extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
const NAME = 'input';
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'value' => '',
|
||||
'type' => '',
|
||||
'field' => '',
|
||||
'info' => '',
|
||||
'disabled' => false,
|
||||
'placeholder' => '',
|
||||
'suffix' => '',
|
||||
'prefix' => '',
|
||||
'rows' => 2,
|
||||
'copy' => false,
|
||||
'copyText' => '',
|
||||
'randToken' => 0,
|
||||
'maxlength' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Input constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = empty($value) ? '' : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* @param bool $disabled
|
||||
* @return $this
|
||||
*/
|
||||
public function disabled(bool $disabled = true)
|
||||
{
|
||||
$this->rule['disabled'] = $disabled;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机token
|
||||
* @return $this
|
||||
*/
|
||||
public function randToken()
|
||||
{
|
||||
$this->rule['randToken'] = 1;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机encodingAESKeyGen
|
||||
* @return $this
|
||||
*/
|
||||
public function randAESK()
|
||||
{
|
||||
$this->rule['randToken'] = 2;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制按钮
|
||||
* @param string $copyText
|
||||
* @return $this
|
||||
*/
|
||||
public function copy(string $copyText = '复制')
|
||||
{
|
||||
$this->rule['copy'] = true;
|
||||
$this->rule['copyText'] = $copyText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return $this
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (in_array($name, ['title', 'field', 'disabled', 'copyText'])) {
|
||||
return $this;
|
||||
}
|
||||
$keys = array_keys($this->rule);
|
||||
if (in_array($name, $keys)) {
|
||||
$this->rule[$name] = $arguments[0] ?? null;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
118
crmeb/form/components/InputNumber.php
Normal file
118
crmeb/form/components/InputNumber.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 数字输入框
|
||||
* Class InputNumber
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class InputNumber extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
const NAME = 'inputNumber';
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'value' => '',
|
||||
'type' => '',
|
||||
'field' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'info' => '',
|
||||
'min' => null,
|
||||
'max' => 99999999
|
||||
];
|
||||
|
||||
/**
|
||||
* InputNumber constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = floatval($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提示语
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 最小值
|
||||
* @param int $min
|
||||
* @return $this
|
||||
*/
|
||||
public function min(int $min)
|
||||
{
|
||||
$this->rule['min'] = $min;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 最大值
|
||||
* @param int $max
|
||||
* @return $this
|
||||
*/
|
||||
public function max(int $max)
|
||||
{
|
||||
$this->rule['max'] = $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return $this
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (in_array($name, ['title', 'field'])) {
|
||||
return $this;
|
||||
}
|
||||
$keys = array_keys($this->rule);
|
||||
if (in_array($name, $keys)) {
|
||||
$this->rule[$name] = $arguments[0] ?? null;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
crmeb/form/components/Map.php
Normal file
70
crmeb/form/components/Map.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 地图组件
|
||||
* Class Map
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class Map extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
const NAME = 'map';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'field' => '',
|
||||
'value' => '',
|
||||
'info' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* Map constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, string $value = null)
|
||||
{
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['value'] = empty($value) ? '' : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
134
crmeb/form/components/Radio.php
Normal file
134
crmeb/form/components/Radio.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 单选框组件
|
||||
* Class Radio
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class Radio extends BaseComponent implements BuildInterface
|
||||
{
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
const NAME = 'radio';
|
||||
|
||||
/**
|
||||
* 组件规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'field' => '',
|
||||
'value' => 0,
|
||||
'info' => '',
|
||||
'vertical' => false,
|
||||
'control' => [],
|
||||
'options' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* Radio constructor.
|
||||
* @param string $title
|
||||
* @param string $field
|
||||
* @param null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = !is_null($value) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个组件联动
|
||||
* @param array $controls
|
||||
* @return $this
|
||||
*/
|
||||
public function controls(array $controls = [])
|
||||
{
|
||||
$this->rule['control'] = $controls;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* options数据 ['label'=>'确定','value'=>1]
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options(array $options = [])
|
||||
{
|
||||
$this->rule['options'] = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件联动
|
||||
* @param $value
|
||||
* @param array $components
|
||||
* @return $this
|
||||
*/
|
||||
public function control($value, array $components = [])
|
||||
{
|
||||
$this->rule['control'][] = ['value' => $value, 'componentsModel' => $components];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置提示语
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否垂直展示
|
||||
* @param bool $vertical
|
||||
* @return $this
|
||||
*/
|
||||
public function vertical(bool $vertical)
|
||||
{
|
||||
$this->rule['vertical'] = $vertical;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据转换
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$control = [];
|
||||
foreach ($this->rule['control'] as $item) {
|
||||
$data = ['value' => $item['value'], 'componentsModel' => []];
|
||||
foreach ($item['componentsModel'] as $value) {
|
||||
if ($value instanceof BuildInterface) {
|
||||
$data['componentsModel'][] = $value->toArray();
|
||||
}
|
||||
}
|
||||
$control[] = $data;
|
||||
}
|
||||
$this->rule['control'] = $control;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
90
crmeb/form/components/Select.php
Normal file
90
crmeb/form/components/Select.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 多选组件
|
||||
* Class Select
|
||||
* @package crmeb\form\components
|
||||
* @method placeholder(string $placeholder)
|
||||
* @method options(array $options = [])
|
||||
* @method info(string $info)
|
||||
*/
|
||||
class Select extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
const NAME = 'select';
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'value' => '',
|
||||
'type' => '',
|
||||
'field' => '',
|
||||
'info' => '',
|
||||
'placeholder' => '',
|
||||
'options' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* Radio constructor.
|
||||
* @param string $title
|
||||
* @param string $field
|
||||
* @param null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = !is_null($value) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换数据
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return $this
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (in_array($name, ['title', 'field'])) {
|
||||
return $this;
|
||||
}
|
||||
$keys = array_keys($this->rule);
|
||||
if (in_array($name, $keys)) {
|
||||
$this->rule[$name] = $arguments[0] ?? null;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
135
crmeb/form/components/Switchs.php
Normal file
135
crmeb/form/components/Switchs.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 开关组件
|
||||
* Class Switchs
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class Switchs extends BaseComponent implements BuildInterface
|
||||
{
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
const NAME = 'switch';
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'field' => '',
|
||||
'value' => '',
|
||||
'info' => '',
|
||||
'control' => [],
|
||||
'options' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* Switchs constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param int $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, int $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = !is_null($value) ? intval($value) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多组件群添加
|
||||
* @param array $controls
|
||||
* @return $this
|
||||
*/
|
||||
public function controls(array $controls = [])
|
||||
{
|
||||
$this->rule['control'] = $controls;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件联动添加
|
||||
* @param $value
|
||||
* @param array $components
|
||||
* @return $this
|
||||
*/
|
||||
public function control(int $value, array $components = [])
|
||||
{
|
||||
$this->rule['control'][] = ['value' => $value, 'componentsModel' => $components];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启值和名称设置
|
||||
* @param string $label
|
||||
* @param int $value
|
||||
* @return $this
|
||||
*/
|
||||
public function trueValue(string $label, int $value)
|
||||
{
|
||||
$this->rule['options'][] = ['trueValue' => $value, 'label' => $label];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭值和名称设置
|
||||
* @param string $label
|
||||
* @param int $value
|
||||
* @return $this
|
||||
*/
|
||||
public function falseValue(string $label, int $value)
|
||||
{
|
||||
$this->rule['options'][] = ['falseValue' => $value, 'label' => $label];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置提示信息
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据转换
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$control = [];
|
||||
foreach ($this->rule['control'] as $item) {
|
||||
$data = ['value' => $item['value'], 'componentsModel' => []];
|
||||
foreach ($item['componentsModel'] as $value) {
|
||||
if ($value instanceof BuildInterface) {
|
||||
$data['componentsModel'][] = $value->toArray();
|
||||
}
|
||||
}
|
||||
$control[] = $data;
|
||||
}
|
||||
$this->rule['control'] = $control;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
76
crmeb/form/components/Tabs.php
Normal file
76
crmeb/form/components/Tabs.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* Tabs 组件
|
||||
* Class Tabs
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class Tabs implements BuildInterface
|
||||
{
|
||||
|
||||
//组件名
|
||||
const NAME = 'tabs';
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var array[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'options' => []
|
||||
];
|
||||
|
||||
/**
|
||||
* Tabs constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->rule['options'] = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加单个选项卡组件群
|
||||
* @param string $label
|
||||
* @param array $components
|
||||
* @return $this
|
||||
*/
|
||||
public function option(string $label, array $components = [])
|
||||
{
|
||||
$this->rule['options'][] = ['label' => $label, 'componentsModel' => $components];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|array[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$options = [];
|
||||
foreach ($this->rule['options'] as $option) {
|
||||
$data = ['label' => $option['label'], 'componentsModel' => []];
|
||||
foreach ($option['componentsModel'] as $item) {
|
||||
if ($item instanceof BuildInterface) {
|
||||
$data['componentsModel'][] = $item->toArray();
|
||||
}
|
||||
}
|
||||
$options[] = $data;
|
||||
}
|
||||
$this->rule['options'] = $options;
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
85
crmeb/form/components/Time.php
Normal file
85
crmeb/form/components/Time.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 时间组件
|
||||
* Class Time
|
||||
* @package crmeb\form\components
|
||||
* @method Time info(string $info) 设置info
|
||||
* @method Time value($value) 设置value
|
||||
* @method Time type(string $type) 设置type
|
||||
* @method Time placeholder(string $placeholder) 设置placeholder
|
||||
*/
|
||||
class Time extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
const NAME = 'time';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => '',
|
||||
'value' => '',
|
||||
'field' => '',
|
||||
'info' => '',
|
||||
'placeholder' => '',
|
||||
'format' => 'HH:mm:ss',
|
||||
'type' => 'timerange'
|
||||
];
|
||||
|
||||
/**
|
||||
* Time constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param array|null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, array $value = null)
|
||||
{
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['value'] = empty($value) ? '' : $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return $this
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (in_array($name, ['title', 'field', 'disabled', 'copyText'])) {
|
||||
return $this;
|
||||
}
|
||||
$keys = array_keys($this->rule);
|
||||
if (in_array($name, $keys)) {
|
||||
$this->rule[$name] = $arguments[0] ?? null;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
140
crmeb/form/components/UploadFrame.php
Normal file
140
crmeb/form/components/UploadFrame.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 图片选择组件
|
||||
* Class UploadFrame
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class UploadFrame extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
const NAME = 'uploadFrame';
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'upload' => [
|
||||
'url' => '',
|
||||
'width' => '960px',
|
||||
'height' => '505px',
|
||||
'field' => 'att_dir',
|
||||
'maxNum' => 1,
|
||||
],
|
||||
'field' => '',
|
||||
'title' => '',
|
||||
'value' => '',
|
||||
'info' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* UploadFrame constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = !is_null($value) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置iframe跳转地址
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function url(string $url)
|
||||
{
|
||||
$this->rule['upload']['url'] = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置iframe宽
|
||||
* @param string $width
|
||||
* @return $this
|
||||
*/
|
||||
public function width(string $width = '960px')
|
||||
{
|
||||
$this->rule['upload']['width'] = $width;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置iframe高
|
||||
* @param string $height
|
||||
* @return $this
|
||||
*/
|
||||
public function height(string $height = '505px')
|
||||
{
|
||||
$this->rule['upload']['height'] = $height;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置提取字段
|
||||
* @param string $field
|
||||
* @return $this
|
||||
*/
|
||||
public function field(string $field)
|
||||
{
|
||||
$this->rule['upload']['field'] = $field;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多图单图选择
|
||||
* @param int $maxNum
|
||||
* @return $this
|
||||
*/
|
||||
public function maxNum(int $maxNum = 1)
|
||||
{
|
||||
$this->rule['upload']['maxNum'] = $maxNum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置提示
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
if ($this->rule['upload']['maxNum'] > 1 && $this->rule['value'] && !is_array($this->rule['value'])) {
|
||||
$this->rule['value'] = [];
|
||||
}
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
156
crmeb/form/components/UploadImage.php
Normal file
156
crmeb/form/components/UploadImage.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\components;
|
||||
|
||||
|
||||
use crmeb\form\BaseComponent;
|
||||
use crmeb\form\BuildInterface;
|
||||
|
||||
/**
|
||||
* 文件上传组件
|
||||
* Class UploadImage
|
||||
* @package crmeb\form\components
|
||||
*/
|
||||
class UploadImage extends BaseComponent implements BuildInterface
|
||||
{
|
||||
|
||||
// 组件名
|
||||
const NAME = 'uploadImage';
|
||||
//图片类型
|
||||
const IMAGE = 'image';
|
||||
//文件类型
|
||||
const FILE = 'file';
|
||||
//上传支持类型
|
||||
const TYPE = [self::IMAGE, self::FILE];
|
||||
|
||||
/**
|
||||
* 规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'upload' => [
|
||||
'url' => '',
|
||||
'size' => 2097152,
|
||||
'format' => [],
|
||||
'headers' => [],
|
||||
'maxNum' => 1,
|
||||
],
|
||||
'field' => '',
|
||||
'type' => '',
|
||||
'title' => '',
|
||||
'icon' => '',
|
||||
'info' => '',
|
||||
'value' => ''
|
||||
];
|
||||
|
||||
/**
|
||||
* UploadImage constructor.
|
||||
* @param string $field
|
||||
* @param string $title
|
||||
* @param null $value
|
||||
*/
|
||||
public function __construct(string $field, string $title, $value = null)
|
||||
{
|
||||
$this->rule['title'] = $title . ':';
|
||||
$this->rule['field'] = $field;
|
||||
$this->rule['value'] = !is_null($value) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传地址
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function url(string $url)
|
||||
{
|
||||
$this->rule['upload']['url'] = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传类型
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function type(string $type)
|
||||
{
|
||||
$this->rule['type'] = in_array($type, self::TYPE) ? $type : '';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传展示icon
|
||||
* @param string $icon
|
||||
* @return $this
|
||||
*/
|
||||
public function icon(string $icon)
|
||||
{
|
||||
$this->rule['icon'] = $icon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件headers
|
||||
* @param array $headers
|
||||
* @return $this
|
||||
*/
|
||||
public function headers(array $headers = [])
|
||||
{
|
||||
$this->rule['upload']['headers'] = (object)$headers;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件大小
|
||||
* @param string $size
|
||||
* @return $this
|
||||
*/
|
||||
public function size(string $size)
|
||||
{
|
||||
$this->rule['upload']['size'] = $size;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件类型
|
||||
* @param array $format
|
||||
* @return $this
|
||||
*/
|
||||
public function format(array $format = [])
|
||||
{
|
||||
$this->rule['upload']['format'] = $format;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件提示
|
||||
* @param string $info
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
{
|
||||
$this->rule['info'] = $info;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$this->rule['name'] = self::NAME;
|
||||
$this->before();
|
||||
return $this->rule;
|
||||
}
|
||||
}
|
||||
30
crmeb/form/validate/ArrRules.php
Normal file
30
crmeb/form/validate/ArrRules.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
|
||||
/**
|
||||
* 数组
|
||||
* Class ArrRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class ArrRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'array';
|
||||
}
|
||||
}
|
||||
72
crmeb/form/validate/BaseRules.php
Normal file
72
crmeb/form/validate/BaseRules.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
|
||||
use crmeb\form\CommonRule;
|
||||
|
||||
/**
|
||||
* Class BaseRules
|
||||
* @package crmeb\form\validate
|
||||
* @method CommonRule required() 是否必填
|
||||
* @method CommonRule message(string $message) 设置错误提示
|
||||
* @method CommonRule enum(array $enum) 枚举
|
||||
* @method CommonRule pattern(string $pattern) 正则表达式
|
||||
* @method CommonRule field($field, array $rule = []) 验证规则
|
||||
*/
|
||||
abstract class BaseRules
|
||||
{
|
||||
/**
|
||||
* 是否初始化
|
||||
* @var bool
|
||||
*/
|
||||
protected static $init = false;
|
||||
|
||||
/**
|
||||
* @var CommonRule
|
||||
*/
|
||||
protected static $rule;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
public static function init()
|
||||
{
|
||||
if (!self::$init) {
|
||||
self::$rule = new CommonRule();
|
||||
self::$rule->type(static::getType());
|
||||
self::$init = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
self::init();
|
||||
if (method_exists(self::$rule, $name)) {
|
||||
return self::$rule->{$name}(...$arguments);
|
||||
}
|
||||
throw new FormValidate(__CLASS__ . ' Method does not exist' . $name . '()');
|
||||
}
|
||||
}
|
||||
29
crmeb/form/validate/BoolRules.php
Normal file
29
crmeb/form/validate/BoolRules.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* 布尔
|
||||
* Class BoolRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class BoolRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'boolean';
|
||||
}
|
||||
}
|
||||
29
crmeb/form/validate/DateRules.php
Normal file
29
crmeb/form/validate/DateRules.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
* Class DateRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class DateRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'date';
|
||||
}
|
||||
}
|
||||
29
crmeb/form/validate/EmailRules.php
Normal file
29
crmeb/form/validate/EmailRules.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
* Class EmailRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class EmailRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'email';
|
||||
}
|
||||
}
|
||||
29
crmeb/form/validate/EnumRules.php
Normal file
29
crmeb/form/validate/EnumRules.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* 枚举
|
||||
* Class EnumRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class EnumRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'enum';
|
||||
}
|
||||
}
|
||||
29
crmeb/form/validate/FloatRules.php
Normal file
29
crmeb/form/validate/FloatRules.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* 浮点
|
||||
* Class FloatRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class FloatRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'float';
|
||||
}
|
||||
}
|
||||
28
crmeb/form/validate/FunRules.php
Normal file
28
crmeb/form/validate/FunRules.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class FunRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class FunRules extends BaseRules
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'method';
|
||||
}
|
||||
}
|
||||
29
crmeb/form/validate/HexRules.php
Normal file
29
crmeb/form/validate/HexRules.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* 16进制
|
||||
* Class HexRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class HexRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'hex';
|
||||
}
|
||||
}
|
||||
28
crmeb/form/validate/IntRules.php
Normal file
28
crmeb/form/validate/IntRules.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* Class IntRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class IntRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'integer';
|
||||
}
|
||||
}
|
||||
28
crmeb/form/validate/NumRules.php
Normal file
28
crmeb/form/validate/NumRules.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* Class NumRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class NumRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'number';
|
||||
}
|
||||
}
|
||||
27
crmeb/form/validate/ObjRules.php
Normal file
27
crmeb/form/validate/ObjRules.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* Class ObjRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class ObjRules extends BaseRules
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'object';
|
||||
}
|
||||
}
|
||||
27
crmeb/form/validate/RegRules.php
Normal file
27
crmeb/form/validate/RegRules.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* Class RegRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class RegRules extends BaseRules
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'regexp';
|
||||
}
|
||||
}
|
||||
37
crmeb/form/validate/StrRules.php
Normal file
37
crmeb/form/validate/StrRules.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
use crmeb\form\FormValidate;
|
||||
|
||||
/**
|
||||
* Class StrRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class StrRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* 手机号正则
|
||||
*/
|
||||
const PHONE_NUMBER = '/((\d{3,4}-)?[0-9]{7,8}$)|(^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])[0-9]{8}$)/';
|
||||
|
||||
/**
|
||||
* 设置类型
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'string';
|
||||
}
|
||||
|
||||
}
|
||||
28
crmeb/form/validate/UrlRules.php
Normal file
28
crmeb/form/validate/UrlRules.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\form\validate;
|
||||
|
||||
/**
|
||||
* Class UrlRules
|
||||
* @package crmeb\form\validate
|
||||
*/
|
||||
class UrlRules extends BaseRules
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'url';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user