初始化仓库
This commit is contained in:
55
admin/components/UI/Table/Column/Input.php
Normal file
55
admin/components/UI/Table/Column/Input.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace admin\components\UI\Table\Column;
|
||||
|
||||
use admin\components\UI\Tools;
|
||||
|
||||
/**
|
||||
* Class Input
|
||||
*/
|
||||
class Input implements Component
|
||||
{
|
||||
|
||||
private string $route;
|
||||
private array $params;
|
||||
private string $field;
|
||||
private array $fields;
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param string $route
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(string $field, string $route, array $params = [])
|
||||
{
|
||||
$this->field = $field;
|
||||
$this->params = $params;
|
||||
$this->route = $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
* @return $this
|
||||
*/
|
||||
public function fields(array $fields = []): Input
|
||||
{
|
||||
$this->fields = $fields;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $label
|
||||
* @return array
|
||||
*/
|
||||
public function render($label): array
|
||||
{
|
||||
$url = app_route($this->route, $this->params, false, 'rowData.record', $this->fields);
|
||||
return [
|
||||
'nodeName' => 'n-input',
|
||||
'class' => 'shadow-sm',
|
||||
'vModel:value' => "rowData.record['$label']",
|
||||
'vOn:blur' => "editValue($url, {'field': '$this->field', '$this->field': rowData.record['$label']})",
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user