catchAdmin/extend/catcher/library/table/ComponentsTrait.php

124 lines
3.0 KiB
PHP
Raw Normal View History

2021-03-29 19:52:01 +08:00
<?php
namespace catcher\library\table;
trait ComponentsTrait
{
/**
* component
*
* @time 2021年03月24日
* @param string $name
* @param string $updateField
* @param array $options
* @return ComponentsTrait|HeaderItem
*/
2021-03-31 20:21:16 +08:00
public function component(string $name, string $updateField = '', $options = [])
2021-03-29 19:52:01 +08:00
{
$this->attributes['component'][] = [
'name' => $name,
2021-03-31 20:21:16 +08:00
'field' => $updateField ? : $this->attributes['prop'],
2021-03-29 19:52:01 +08:00
'options' => $options
];
return $this;
}
/**
* switch
*
* @time 2021年03月23日
* @param null $updateFields
* @return HeaderItem
*/
2021-04-24 20:30:28 +08:00
public function withSwitchComponent(array $options = [], $updateFields = null): HeaderItem
2021-03-29 19:52:01 +08:00
{
2021-04-24 20:30:28 +08:00
return $this->component('switch_', $updateFields ? : $this->attributes['prop'], $options);
2021-03-29 19:52:01 +08:00
}
/**
* edit
*
* @time 2021年03月23日
* @param null $updateFields
* @return HeaderItem
*/
public function withEditComponent($updateFields = null): HeaderItem
{
return $this->component('edit', $updateFields ? : $this->attributes['prop']);
}
/**
* Edit Number
*
* @time 2021年03月23日
* @param null $updateFields
* @return HeaderItem
*/
public function withEditNumberComponent($updateFields = null): HeaderItem
{
return $this->component('editNumber', $updateFields ? : $this->attributes['prop']);
}
/**
* 多选组件
*
* @time 2021年05月03日
* @param array $options
* @param null $updateFields
* @return HeaderItem
*/
2021-03-29 19:52:01 +08:00
public function withSelectComponent(array $options, $updateFields = null): HeaderItem
{
return $this->component('select_', $updateFields ? : $this->attributes['prop'], $options);
}
/**
* 预览组件
*
* @time 2021年05月03日
* @param null $field
* @return ComponentsTrait|HeaderItem
*/
public function withPreviewComponent($field = null)
{
return $this->component('preview', $field ? : $this->attributes['prop']);
}
2021-05-07 08:41:41 +08:00
2021-05-09 17:09:53 +08:00
/**
* 链接跳转
*
* @time 2021年05月09日
* @param null $field
* @return ComponentsTrait|HeaderItem
*/
public function withUrlComponent($field = null)
{
return $this->component('url', $field ? : $this->attributes['prop']);
}
2021-05-13 08:46:17 +08:00
/**
* 复制组件
*
* @time 2021年05月12日
* @param null $field
* @return ComponentsTrait|HeaderItem
*/
public function withCopyComponent($field = null)
{
return $this->component('copy', $field ? : $this->attributes['prop']);
}
2021-05-07 08:41:41 +08:00
/**
* download 组件
*
* @time 2021年05月05日
* @param null $field
* @return ComponentsTrait|HeaderItem
*/
public function withDownloadComponent($field = null)
{
return $this->component('download', $field ? : $this->attributes['prop']);
}
}