update:table组件
This commit is contained in:
parent
5ce104e820
commit
2ad466e617
@ -2,7 +2,7 @@
|
||||
|
||||
namespace catcher\library\table;
|
||||
|
||||
use catcher\library\components\Button;
|
||||
use catcher\library\table\components\Button;
|
||||
|
||||
class Actions
|
||||
{
|
||||
|
@ -12,11 +12,11 @@ trait ComponentsTrait
|
||||
* @param array $options
|
||||
* @return ComponentsTrait|HeaderItem
|
||||
*/
|
||||
public function component(string $name, string $updateField, $options = [])
|
||||
public function component(string $name, string $updateField = '', $options = [])
|
||||
{
|
||||
$this->attributes['component'][] = [
|
||||
'name' => $name,
|
||||
'field' => $updateField,
|
||||
'field' => $updateField ? : $this->attributes['prop'],
|
||||
'options' => $options
|
||||
];
|
||||
|
||||
|
@ -49,6 +49,19 @@ class HeaderItem
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 可排序
|
||||
*
|
||||
* @time 2021年03月31日
|
||||
* @return $this
|
||||
*/
|
||||
public function sortable(): HeaderItem
|
||||
{
|
||||
$this->attributes['sortable'] = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* selection
|
||||
*
|
||||
|
@ -11,7 +11,7 @@ class Table
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $header = [];
|
||||
protected $headers = [];
|
||||
|
||||
/**
|
||||
* table 操作
|
||||
@ -77,6 +77,11 @@ class Table
|
||||
*/
|
||||
protected $dialog;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $filterParams;
|
||||
|
||||
/**
|
||||
* Table constructor.
|
||||
* @param string $ref
|
||||
@ -96,7 +101,7 @@ class Table
|
||||
public function header(array $header): Table
|
||||
{
|
||||
foreach ($header as $h) {
|
||||
$this->header[] = $h->attributes;
|
||||
$this->headers[] = $h->attributes;
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -160,6 +165,20 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* filter params
|
||||
*
|
||||
* @time 2021年03月30日
|
||||
* @param array $filterParams
|
||||
* @return $this
|
||||
*/
|
||||
public function withFilterParams(array $filterParams): Table
|
||||
{
|
||||
$this->filterParams = $filterParams;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏分页
|
||||
*
|
||||
@ -266,12 +285,12 @@ class Table
|
||||
public function appendHeaders($header): Table
|
||||
{
|
||||
if ($header instanceof HeaderItem) {
|
||||
$this->header[] = $header;
|
||||
$this->headers[] = $header;
|
||||
}
|
||||
|
||||
|
||||
if (is_array($header)) {
|
||||
$this->header = array_merge($this->header, $header);
|
||||
$this->headers = array_merge($this->headers, $header);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -328,7 +347,21 @@ class Table
|
||||
*/
|
||||
public function appendHeader(array $header): Table
|
||||
{
|
||||
$this->header = array_merge($this->header, $header);
|
||||
$this->headers = array_merge($this->headers, $header);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 filter params
|
||||
*
|
||||
* @time 2021年03月30日
|
||||
* @param array $params
|
||||
* @return $this
|
||||
*/
|
||||
public function appendFilterParams(array $params): Table
|
||||
{
|
||||
$this->filterParams = array_merge($this->filterParams, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -341,7 +374,7 @@ class Table
|
||||
*/
|
||||
public function getHeader(): array
|
||||
{
|
||||
return $this->header;
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,4 +409,15 @@ class Table
|
||||
{
|
||||
return $this->defaultQueryParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* get filter params
|
||||
*
|
||||
* @time 2021年03月30日
|
||||
* @return array
|
||||
*/
|
||||
public function getFilterParams(): array
|
||||
{
|
||||
return $this->filterParams;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user