449 lines
9.5 KiB
PHP
449 lines
9.5 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
|
||
namespace Builder\View\Grid\Concerns;
|
||
|
||
use Builder\View\Grid\Table\Attributes;
|
||
|
||
trait HasGridAttributes
|
||
{
|
||
/**
|
||
* @var Attributes
|
||
*/
|
||
protected $attributes;
|
||
/***
|
||
* 设置表格主键key
|
||
* @param $key
|
||
* @return $this
|
||
*/
|
||
public function pk($key)
|
||
{
|
||
$this->attributes->pk = $key;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 表单是否排除pk字段
|
||
* @param $key
|
||
* @return $this
|
||
*/
|
||
public function formExcludePk(Boolean $pk)
|
||
{
|
||
$this->attributes->formExcludePk = $pk;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 表格的行选择器配置
|
||
* @param $row
|
||
* @return $this
|
||
*/
|
||
public function rowSelection($row)
|
||
{
|
||
$this->attributes->rowSelection = $row;
|
||
return $this;
|
||
}
|
||
|
||
|
||
/***
|
||
* 设置开启多选
|
||
* @param bool $showCheckedAll
|
||
*/
|
||
public function showCheckedAll($showCheckedAll=true){
|
||
$this->attributes->rowSelection=[
|
||
'showCheckedAll'=>$showCheckedAll
|
||
];
|
||
}
|
||
|
||
/***
|
||
* 是否显示边框
|
||
* @param $row
|
||
* @return $this
|
||
*/
|
||
public function bordered($bordered)
|
||
{
|
||
$this->attributes->bordered = $bordered;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 子节点为空隐藏节点按钮
|
||
* @param $bordered
|
||
* @return $this
|
||
*/
|
||
public function hideExpandButtonOnEmpty($bordered)
|
||
{
|
||
$this->attributes->hideExpandButtonOnEmpty = $bordered;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 每页记录数
|
||
* @param $pageSize
|
||
* @return $this
|
||
*/
|
||
public function pageSize(int $pageSize)
|
||
{
|
||
$this->attributes->pageSize = $pageSize;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 设置分页组件每页记录数
|
||
* [10, 20, 30, 50, 100]
|
||
* @param array $pageSizeOption
|
||
* @return $this
|
||
*/
|
||
public function pageSizeOption(array $pageSizeOption)
|
||
{
|
||
$this->attributes->pageSizeOption = $pageSizeOption;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 默认展开所有行
|
||
* @param Boolean $tablePagination
|
||
* @return $this
|
||
*/
|
||
public function tablePagination($tablePagination=true)
|
||
{
|
||
$this->attributes->tablePagination = $tablePagination;
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* 默认展开搜索栏
|
||
* @param Boolean $expandAllRows
|
||
* @return $this
|
||
*/
|
||
public function expandAllRows($expandAllRows=true)
|
||
{
|
||
$this->attributes->expandAllRows = $expandAllRows;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 默认展开搜索栏
|
||
* @param Boolean $expandSearch
|
||
* @return $this
|
||
*/
|
||
public function expandSearch(Boolean $expandSearch)
|
||
{
|
||
$this->attributes->expandSearch = $expandSearch;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否显示斑马线
|
||
* @param Boolean $stripe
|
||
* @return $this
|
||
*/
|
||
public function stripe(Boolean $stripe)
|
||
{
|
||
$this->attributes->stripe = $stripe;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 表格大小
|
||
* 'mini', 'small', 'medium', 'large'
|
||
* @param $size
|
||
* @return $this
|
||
*/
|
||
public function size($size)
|
||
{
|
||
$this->attributes->size = $size;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 搜索label宽度
|
||
* @param $searchLabelWidth
|
||
* @return $this
|
||
*/
|
||
public function searchLabelWidth($searchLabelWidth)
|
||
{
|
||
$this->attributes->searchLabelWidth = $searchLabelWidth;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 搜索label对齐方式
|
||
* 'left', 'center', 'right'
|
||
* @param $searchLabelAlign
|
||
* @return $this
|
||
*/
|
||
public function searchLabelAlign($searchLabelAlign)
|
||
{
|
||
$this->attributes->searchLabelAlign = $searchLabelAlign;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 搜索栏每行显示列数
|
||
* @param $searchColNumber
|
||
* @return $this
|
||
*/
|
||
public function searchColNumber($searchColNumber)
|
||
{
|
||
$this->attributes->searchColNumber = $searchColNumber;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 搜索栏搜索按钮文案
|
||
* @param $searchSubmitButtonText
|
||
* @return $this
|
||
*/
|
||
public function searchSubmitButtonText($searchSubmitButtonText)
|
||
{
|
||
$this->attributes->searchSubmitButtonText = $searchSubmitButtonText;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 搜索栏重置按钮文案
|
||
* @param $searchResetButtonText
|
||
* @return $this
|
||
*/
|
||
public function searchResetButtonText($searchResetButtonText)
|
||
{
|
||
$this->attributes->searchResetButtonText = $searchResetButtonText;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否显示折叠按钮
|
||
* @param $isExpand
|
||
* @return $this
|
||
*/
|
||
public function isExpand($isExpand)
|
||
{
|
||
$this->attributes->isExpand = $isExpand;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否显示工具栏
|
||
* @param $showTools
|
||
* @return $this
|
||
*/
|
||
public function showTools($showTools)
|
||
{
|
||
$this->attributes->showTools = $showTools;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 允许调整列宽
|
||
* @param $resizable
|
||
* @return $this
|
||
*/
|
||
public function resizable($resizable)
|
||
{
|
||
$this->attributes->resizable = $resizable;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 表头是否固定吸顶
|
||
* @param $stickyHeader
|
||
* @return $this
|
||
*/
|
||
public function stickyHeader($stickyHeader)
|
||
{
|
||
$this->attributes->stickyHeader = $stickyHeader;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 表格滚动默认宽高
|
||
* @param $scroll
|
||
* @return $this
|
||
*/
|
||
public function scroll($scroll)
|
||
{
|
||
$this->attributes->scroll = $scroll;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 统一设置列宽度
|
||
* @param $columnWidth
|
||
* @return $this
|
||
*/
|
||
public function columnWidth(int $columnWidth)
|
||
{
|
||
$this->attributes->columnWidth = $columnWidth;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否自动请求
|
||
* @param $autoRequest
|
||
* @return $this
|
||
*/
|
||
public function autoRequest($autoRequest=true)
|
||
{
|
||
$this->attributes->autoRequest = $autoRequest;
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* 新增、编辑、删除完成后是否刷新表格
|
||
* @param $dataCompleteRefresh
|
||
* @return $this
|
||
*/
|
||
public function dataCompleteRefresh($dataCompleteRefresh=true)
|
||
{
|
||
$this->attributes->dataCompleteRefresh = $dataCompleteRefresh;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否开启双击编辑数据
|
||
* @param $isDbClickEdit
|
||
* @return $this
|
||
*/
|
||
public function isDbClickEdit($isDbClickEdit=true)
|
||
{
|
||
$this->attributes->isDbClickEdit = $isDbClickEdit;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否显示自定义扩展行
|
||
* @param $showExpandRow
|
||
* @return $this
|
||
*/
|
||
public function showExpandRow($showExpandRow)
|
||
{
|
||
$this->attributes->showExpandRow = $showExpandRow;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否显示合计行
|
||
* @param $showSummary
|
||
* @return $this
|
||
*/
|
||
public function showSummary($showSummary)
|
||
{
|
||
$this->attributes->showSummary = $showSummary;
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* 自定义合计行 JS
|
||
* Function
|
||
* @return $this
|
||
*/
|
||
public function customerSummary($customerSummary){
|
||
$this->attributes->customerSummary = $customerSummary;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 是否显示索引列
|
||
* @param $showIndex
|
||
* @return $this
|
||
*/
|
||
public function showIndex($showIndex)
|
||
{
|
||
$this->attributes->showIndex = $showIndex;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 索引列名称
|
||
* @param $indexLabel
|
||
* @return $this
|
||
*/
|
||
public function indexLabel($indexLabel)
|
||
{
|
||
$this->attributes->indexLabel = $indexLabel;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 合计行,可参考
|
||
* @param $summary
|
||
* @return $this
|
||
*/
|
||
public function summary($summary)
|
||
{
|
||
$this->attributes->summary = $summary;
|
||
return $this;
|
||
}
|
||
|
||
|
||
/***
|
||
* 是否显示操作列
|
||
* @param $operationColumn
|
||
* @return $this
|
||
*/
|
||
public function operationColumn($operationColumn=true)
|
||
{
|
||
$this->attributes->operationColumn = $operationColumn;
|
||
return $this;
|
||
}
|
||
|
||
|
||
/***
|
||
* 操作列宽度
|
||
* @param $operationWidth
|
||
* @return $this
|
||
*/
|
||
public function operationWidth($operationWidth)
|
||
{
|
||
$this->attributes->operationWidth = $operationWidth;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 操作列名称
|
||
* @param $operationColumnText
|
||
* @return $this
|
||
*/
|
||
public function operationColumnText($operationColumnText)
|
||
{
|
||
$this->attributes->operationColumnText = $operationColumnText;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 搜索栏是否启用自定义布局
|
||
* @param $searchCustomerLayout
|
||
* @return $this
|
||
*/
|
||
public function searchCustomerLayout($searchCustomerLayout)
|
||
{
|
||
$this->attributes->searchCustomerLayout = $searchCustomerLayout;
|
||
return $this;
|
||
}
|
||
|
||
/***
|
||
* 组件在页面布局方式,normal为常规布局,fixed为固定模式,搜索在上部,分页沉底,表格自适应高度
|
||
* 'normal', 'fixed'
|
||
* @param $pageLayout
|
||
* @return $this
|
||
*/
|
||
public function pageLayout($pageLayout)
|
||
{
|
||
$this->attributes->pageLayout = $pageLayout;
|
||
return $this;
|
||
}
|
||
|
||
|
||
/***
|
||
* 表单布局
|
||
* @param $formOption
|
||
* @return $this
|
||
*/
|
||
public function formOption($formOption)
|
||
{
|
||
$this->attributes->formOption = $formOption;
|
||
return $this;
|
||
}
|
||
}
|