chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user