update:table组件

This commit is contained in:
JaguarJack 2021-03-31 20:21:16 +08:00
parent 5ce104e820
commit 2ad466e617
4 changed files with 66 additions and 9 deletions

View File

@ -2,7 +2,7 @@
namespace catcher\library\table; namespace catcher\library\table;
use catcher\library\components\Button; use catcher\library\table\components\Button;
class Actions class Actions
{ {

View File

@ -12,11 +12,11 @@ trait ComponentsTrait
* @param array $options * @param array $options
* @return ComponentsTrait|HeaderItem * @return ComponentsTrait|HeaderItem
*/ */
public function component(string $name, string $updateField, $options = []) public function component(string $name, string $updateField = '', $options = [])
{ {
$this->attributes['component'][] = [ $this->attributes['component'][] = [
'name' => $name, 'name' => $name,
'field' => $updateField, 'field' => $updateField ? : $this->attributes['prop'],
'options' => $options 'options' => $options
]; ];

View File

@ -49,6 +49,19 @@ class HeaderItem
return $this; return $this;
} }
/**
* 可排序
*
* @time 2021年03月31日
* @return $this
*/
public function sortable(): HeaderItem
{
$this->attributes['sortable'] = true;
return $this;
}
/** /**
* selection * selection
* *

View File

@ -11,7 +11,7 @@ class Table
* *
* @var array * @var array
*/ */
protected $header = []; protected $headers = [];
/** /**
* table 操作 * table 操作
@ -77,6 +77,11 @@ class Table
*/ */
protected $dialog; protected $dialog;
/**
* @var array
*/
protected $filterParams;
/** /**
* Table constructor. * Table constructor.
* @param string $ref * @param string $ref
@ -96,7 +101,7 @@ class Table
public function header(array $header): Table public function header(array $header): Table
{ {
foreach ($header as $h) { foreach ($header as $h) {
$this->header[] = $h->attributes; $this->headers[] = $h->attributes;
} }
return $this; return $this;
@ -160,6 +165,20 @@ class Table
return $this; 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 public function appendHeaders($header): Table
{ {
if ($header instanceof HeaderItem) { if ($header instanceof HeaderItem) {
$this->header[] = $header; $this->headers[] = $header;
} }
if (is_array($header)) { if (is_array($header)) {
$this->header = array_merge($this->header, $header); $this->headers = array_merge($this->headers, $header);
} }
return $this; return $this;
@ -328,7 +347,21 @@ class Table
*/ */
public function appendHeader(array $header): 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; return $this;
} }
@ -341,7 +374,7 @@ class Table
*/ */
public function getHeader(): array public function getHeader(): array
{ {
return $this->header; return $this->headers;
} }
/** /**
@ -376,4 +409,15 @@ class Table
{ {
return $this->defaultQueryParams; return $this->defaultQueryParams;
} }
/**
* get filter params
*
* @time 2021年03月30日
* @return array
*/
public function getFilterParams(): array
{
return $this->filterParams;
}
} }