228 lines
3.9 KiB
PHP
Raw Normal View History

2021-03-29 19:52:01 +08:00
<?php
namespace catcher\library\table;
class HeaderItem
{
use ComponentsTrait;
protected $attributes = [];
2021-05-16 17:23:22 +08:00
/**
* HeaderItem constructor.
* @param string $label
*/
2021-03-29 19:52:01 +08:00
public function __construct(string $label)
{
$this->attributes['label'] = $label;
2021-05-11 18:48:10 +08:00
$this->attributes['show'] = true;
2021-03-29 19:52:01 +08:00
return $this;
}
2021-05-16 17:23:22 +08:00
/**
* label
*
* @time 2021年05月15日
* @param string $label
* @return HeaderItem
*/
2021-04-03 10:35:21 +08:00
public static function label(string $label = ''): HeaderItem
2021-03-29 19:52:01 +08:00
{
return new self($label);
}
2021-05-16 17:23:22 +08:00
/**
* prop
*
* @time 2021年05月15日
* @param string $prop
* @return $this
*/
2021-03-29 19:52:01 +08:00
public function prop(string $prop): HeaderItem
{
$this->attributes['prop'] = $prop;
return $this;
}
2021-05-16 17:23:22 +08:00
/**
* 宽度
*
* @time 2021年05月15日
* @param string $width
* @return $this
*/
2021-03-29 19:52:01 +08:00
public function width(string $width): HeaderItem
{
$this->attributes['width'] = $width;
return $this;
}
2021-05-16 17:23:22 +08:00
/**
* align 宽度
*
* @time 2021年05月15日
* @param string $align
* @return $this
*/
public function align(string $align): HeaderItem
{
$this->attributes['align'] = $align;
return $this;
}
2021-03-29 19:52:01 +08:00
2021-05-16 17:23:22 +08:00
/**
* 居中
*
* @time 2021年05月15日
* @return $this
*/
public function alignCenter(): HeaderItem
{
$this->attributes['align'] = 'center';
return $this;
}
/**
* 居右
*
* @time 2021年05月15日
* @return $this
*/
public function alignRight(): HeaderItem
{
$this->attributes['align'] = 'right';
return $this;
}
/**
* 操作
*
* @time 2021年05月15日
* @param array $actions
* @return $this
*/
2021-03-29 19:52:01 +08:00
public function actions(array $actions): HeaderItem
{
foreach ($actions as $action) {
$this->attributes['action'][] = $action->render();
}
return $this;
}
2021-05-16 17:23:22 +08:00
/**
* 冒泡点击
*
* @time 2021年05月15日
* @param false $bubble
* @return $this
*/
2021-03-29 19:52:01 +08:00
public function isBubble($bubble = false): HeaderItem
{
$this->attributes['isBubble'] = $bubble;
return $this;
}
2021-03-31 20:21:16 +08:00
/**
* 可排序
*
* @time 2021年03月31日
* @return $this
*/
public function sortable(): HeaderItem
{
$this->attributes['sortable'] = true;
return $this;
}
2021-03-29 19:52:01 +08:00
/**
* selection
*
* @time 2021年03月29日
* @return mixed
*/
public function selection()
{
return $this->width(50)->type('selection');
}
2021-05-07 08:41:41 +08:00
/**
* 展开行
*
* @time 2021年05月07日
* @return mixed
*/
public function expand()
{
return $this->type('expand');
}
/**
* 固定列
*
* @time 2021年05月07日
* @param bool|string $fixed
* @return bool|mixed
*/
public function fixed($fixed = true)
{
2021-08-19 19:37:31 +08:00
$this->attributes['fixed'] = $fixed;
return $this;
2021-05-07 08:41:41 +08:00
}
2021-04-24 20:30:28 +08:00
/**
* dont export
*
* @time 2021年04月22日
* @return $this
*/
public function dontExport(): HeaderItem
{
$this->attributes['export'] = false;
return $this;
}
/**
* dont import
*
* @time 2021年04月22日
* @return $this
*/
public function dontImport(): HeaderItem
{
$this->attributes['import'] = false;
return $this;
}
2021-03-29 19:52:01 +08:00
/**
* 动态访问
*
* @time 2021年03月24日
* @param $method
* @param $params
* @return $this
*/
public function __call($method, $params): HeaderItem
{
$this->attributes[$method] = $params[0];
return $this;
}
public function __get($key)
{
return $this->{$key};
}
}