初始化仓库
This commit is contained in:
73
admin/components/UI/Tabs.php
Normal file
73
admin/components/UI/Tabs.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: chatfeed
|
||||
* Date: 2022/5/19
|
||||
* Time: 6:40 PM
|
||||
*/
|
||||
|
||||
namespace admin\components\UI;
|
||||
|
||||
use admin\components\UI\Components\VueComponent;
|
||||
use phpDocumentor\Reflection\Types\Boolean;
|
||||
|
||||
class Tabs extends VueComponent
|
||||
{
|
||||
public $dialog =false;
|
||||
public bool $lazyLoad = false;
|
||||
public $nodes = [];
|
||||
public function setup(string $script)
|
||||
{
|
||||
return <<<JS
|
||||
|
||||
JS;
|
||||
// TODO: Implement setup() method.
|
||||
}
|
||||
|
||||
public function addTab($title,$key,$desc,$child=null){
|
||||
$this->nodes[] = ['title'=>$title,'name'=>$title,'key'=>$key,'order'=>0,'desc'=>$desc,'child'=>$child?[$child]:[]];
|
||||
}
|
||||
public function render(): array
|
||||
{
|
||||
|
||||
$panelNodes = [];
|
||||
|
||||
$nodes = collect($this->nodes)->sortBy('order')->toArray();
|
||||
foreach ($nodes as $key => $node) {
|
||||
$child = [];
|
||||
if ($node['title']) {
|
||||
$child[] = [
|
||||
'nodeName' => 'div',
|
||||
'class' => 'pt-2',
|
||||
'child' => $node['child']
|
||||
];
|
||||
}
|
||||
|
||||
//$child[] = [
|
||||
// 'nodeName' => 'div',
|
||||
// 'class' => 'pt-2',
|
||||
// 'child' => $node['object']->render()
|
||||
//];
|
||||
$panelNodes[] = [
|
||||
'nodeName' => 'a-tab-pane',
|
||||
'title' => $node['name'],
|
||||
'key' => $key,
|
||||
'class' => !$this->dialog ? ' border-t border-gray-200 dark:border-blackgray-1 px-3 pt-4 pb-0' : '',
|
||||
'child' => [
|
||||
'nodeName' => 'div',
|
||||
'class' => '',
|
||||
'child' => $child
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'nodeName' => 'a-tabs',
|
||||
'lazy-load'=>$this->lazyLoad,
|
||||
'class' => !$this->dialog ? 'mb-4 bg-white dark:bg-blackgray-4 rounded shadow p-4 pb-1' : '',
|
||||
'type' => 'rounded',
|
||||
'child' => $panelNodes
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user