diff --git a/extend/catcher/library/table/Actions.php b/extend/catcher/library/table/Actions.php index 1e582e4..7c29b71 100644 --- a/extend/catcher/library/table/Actions.php +++ b/extend/catcher/library/table/Actions.php @@ -2,7 +2,7 @@ namespace catcher\library\table; -use catcher\library\components\Button; +use catcher\library\table\components\Button; class Actions { diff --git a/extend/catcher/library/table/ComponentsTrait.php b/extend/catcher/library/table/ComponentsTrait.php index eed4487..b708b48 100644 --- a/extend/catcher/library/table/ComponentsTrait.php +++ b/extend/catcher/library/table/ComponentsTrait.php @@ -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 ]; diff --git a/extend/catcher/library/table/HeaderItem.php b/extend/catcher/library/table/HeaderItem.php index a2d24f4..cd8527f 100644 --- a/extend/catcher/library/table/HeaderItem.php +++ b/extend/catcher/library/table/HeaderItem.php @@ -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 * diff --git a/extend/catcher/library/table/Table.php b/extend/catcher/library/table/Table.php index 6283254..b74b249 100644 --- a/extend/catcher/library/table/Table.php +++ b/extend/catcher/library/table/Table.php @@ -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; + } } \ No newline at end of file