Dcat 中的选项卡Tab使用方法

1. 运行环境

1). 当前使用的 Laravel 版本?

9.0
//: <> (使用 php artisan --version 命令查看)

2). 当前使用的 php/php-fpm 版本?

PHP 版本:

php-fpm 版本:

3). 当前系统

CentOS 8
//: <> (期待数值 Windows 10 / Ubuntu 20.4 / CentOS 8 )

4). 业务环境

开发环境
//: <> (期待信息 开发环境生产环境)
//: <> (是否使用负载均衡?请提供相关信息)

5). 相关软件版本

2. 问题描述?

大家有没有在详情页面使用Tab选项卡的案例,最在在研究这块,我想把一个详情页面改成Tab来做,但是研究好久没有找到想法。

3. 您期望得到的结果?

4. 您实际得到的结果?

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 4
mouyong
<?php

namespace App\Domain\ContentCenter\Admin\Controllers;

use App\Domain\ContentCenter\Admin\Repositories\Watcher;
use App\Domain\ContentCenter\Models\Watcher as ModelsWatcher;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class WatcherController extends AdminController
{
    public function index(\Dcat\Admin\Layout\Content $content)
    {
        $tab = \Dcat\Admin\Widgets\Tab::make();

        foreach (ModelsWatcher::TYPE_MAP as $key => $value) {
            $tab->add($value, $this->grid($key));
        }

        return $content
            ->translation($this->translation())
            ->title($this->title())
            ->description($this->description()['index'] ?? trans('admin.list'))
            ->body($tab);
    }

    protected function grid($type = ModelsWatcher::TYPE_USER)
    {
        $grid = Grid::make(new Watcher(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('name', '关注者/称谓')->display(function () {
                if ($this->name === $this->appellation) {
                    return $this->name;
                }

                return "{$this->name}/{$this->appellation}";
            });
            $grid->column('state')->switch();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
            });
        });


        $grid->model()
            ->where('type', $type ?? ModelsWatcher::TYPE_USER);

        return $grid;
    }
}


<?php

namespace App\Domain\ContentCenter\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Watcher extends Model
{
    const TYPE_USER = 'friend';
    const TYPE_USER_EMAIL = 'user_email';
    const TYPE_WEWORK_GROUP = 'wework_group';
    const TYPE_MAP = [
        Watcher::TYPE_USER => '好友',
        Watcher::TYPE_USER_EMAIL => '用户邮箱',
        Watcher::TYPE_WEWORK_GROUP => '企业微信群',
    ];
}
3年前 评论

详情页的tab方式目前还没有案例。表单页的是可以的。详情页尤其是扩展的关联数据,很多情况下需要tab展示。 这种效果 preview.pro.antdv.com/profile/adva...

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!