🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
![](https://img.kancloud.cn/21/65/2165f230f3efd01ba5ed0f1adb864c39_445x65.png) ### 方法 数字控件实例: ```php $number = $toolbarFilter ->number(); ``` 设置标签文本: ```php $number->label('关键词'); ``` 设置内容提示: ```php $number->placeholder('请输入关键词'); ``` 设置默认值: ```php $number->defaultValue('张三'); ``` 设置ui类: ```php $number->uiClass(['f13']); ``` 设置style样式: ```php $number->style(); ``` 设置html属性: ```php $number->attribute(); ``` ### 链式调用 ~~~ $tableBuilder->setToolbarFilter([ 'keyword' => $this->toolbarFilter->number()->label('数字')->placeholder('请输入数字')->defaultValue()->attribute(['test' => 1])->uiClass('w-330 mr-3'), //'username' => $this->toolbarFilter->datetime()->style(['width' => '800px'])->label('注册时间')->placeholder('请选择注册时间'), //'username' => $this->toolbarFilter->datetime()->label('注册时间')->placeholder('请选择注册时间'), /*'status' => $this->toolbarFilter->select()->label('用户状态')->uiClass(['layui-col-sm12'])->placeholder('请选择用户状态')->options([ '分组1' => [ 'normal' => '正常', 'deny' => '禁用', ], '分组2' => [ 'A' => '不可以', 'B' => '可以', ], ])->disabled(['deny'])->uiClass('w-330 mr-3'),*/ 'link1' => $this->toolbarFilter->selectLink()->label('联动1')->placeholder('请选择')->route('admin/link')->initOptions([ '测试1' => [ 'a' => 'A', 'b' => 'B' ], '测试2' => [ 'c' => 'C', 'd' => 'D' ], ])->disabled(['d'])->targetLink('link2')->start()->uiClass('w-330'), 'link2' => $this->toolbarFilter->selectLink()->label('')->placeholder('请选择')->route('admin/link')->targetLink('link3')->through()->uiClass('w-330'), 'link3' => $this->toolbarFilter->selectLink()->label('')->placeholder('请选择')->end()->uiClass('w-330'), ]) ~~~ ### 代码示例 ~~~ /** * 列表 * @return string * @throws \Throwable * @throws \builder\base\InvalidInstanceException * @throws \builder\base\NotFoundParamsException */ public function actionIndex() { $viewBuilder = $this->viewBuilder; $table = $viewBuilder->table; $table->setId('_admin_list'); if ($this->isAjax) { // AJAX $table->setQuery(function () { $params = $this->filteredGet; $query = Admin::find(); $query->filterWhere([ 'like', 'username', isset($params['keyword']) ? $params['keyword'] : null, ]); return $query; }) ->setOrderBy(['id' => SORT_DESC]) ->setColumns([ 'id', 'username', 'password_hash' => function($row) { return $row['password_hash']; // return MediaList::widget([ // 'media' => [ // 'https://buerzz.damanzj.com/upload/image/goods_manager/G20230406163045884/album_images/20230411112406L0K9PC73oN.jpg', // 'https://buerzz.damanzj.com/upload/image/goods_manager/G20230720164108385/album_images/20230720164331DNcGzFHn7d.png', // 'https://buerzz.damanzj.com/upload/image/goods_manager/G20230331142909667/album_images/202303311628517pMZoWtdEd.jpg', // ], // 'mediaHeader' => '佳能g7x2微单入门相机美颜自拍旅游', // 'mediaBody' => [ // '姓名:' => '杨心怡', // '性别:' => '女', // ], // 'mediaList' => [ // '所在地:' => '河南新乡', // '微信:' => 'wx+15032785', // 'QQ:' => '654874554452', // '年龄:' => '1岁半', // '大学:' => '清华大学', // '爱好:' => '睡觉', // '成绩:' => '100分', // '班级:' => '九年级', // '理想:' => '让这个世界因为我而变得不一样!', // '信念:' => '计算机信息网络技术研究中心', // ], // ]); }, 'email', 'mobile', 'status', 'group', 'created_at', 'updated_at', 'ro_delete3' => function ($row) { return $row['id'] % 2; }, ]) ->setExtraData(function (Query $query) { return [ 'tol' => $query->count(), 'a' => 100000, ]; }); $render = $viewBuilder->render(); //return $table->data; return $render; } else { // HTML $table->setTitle('管理员列表') ->setExtraDataTpl([ 'tol' => '当前总数量', 'a' => '所在院校', ]) //->registerPointcut(H5::alert('测试一下', 'success')) //->registerPointcut(H5::alert('测试一下'), TableBuilder::POS_END) ->setAjaxRoute('admin/index') // ->setLineStyle([ // 'height' => '350px', // ]) ->setTableHead([ $this->tableHead->checkbox()->style([]), $this->tableHead->field('password_hash')->title('密码')->minWidth(300), $this->tableHead->field('username')->title('账号')->editText('admin/edit'), $this->tableHead->field('email')->title('邮箱')->maxWidth(220), $this->tableHead->field('mobile')->title('手机号'), $this->tableHead->field('created_at')->title('添加时间'), $this->tableHead->field('updated_at')->title('更新时间'), $this->tableHead->toolbar()->title('操作项')->maxWidth(180), ]) ->setRowOperation([ // 详情 $this->rowOperation->modal()->title('详情')->icon('bi bi-plus-lg f15')->route('admin/detail'), $this->rowOperation->ajax()->title('删除')->icon('bi bi-x-lg')->route('admin/delete')->method('POST')->group(), $this->rowOperation->ajax()->title('我要删除1')->icon('bi bi-x-lg')->route('admin/delete')->method('POST')->group(), $this->rowOperation->ajax()->title('我要删除2')->icon('bi bi-x-lg')->route('admin/delete')->method('POST')->group(), $this->rowOperation->ajax()->title('我要删除3')->id('ro_delete3')->icon('bi bi-x-lg')->route('admin/delete')->method('POST')->group(), ]) ->setToolbarCustom([ // 表单 $this->toolbarCustom->modal()->btnClass('layui-btn-primary layui-border')->title('表单')->icon('bi bi-plus-lg f15')->route('__upload/index')->width(916)->height(655), // 列表 $this->toolbarCustom->modal()->btnClass('layui-btn-primary layui-border-green')->title('列表')->icon('bi bi-plus-lg f15')->route('admin/detail')->closeBtn(), // 选项卡 $this->toolbarCustom->modal()->btnClass('layui-btn-primary layui-border-blue')->title('选项卡')->icon('bi bi-pencil-square f13')->route('admin/edit')->closeBtn(), // AJAX $this->toolbarCustom->page()->btnClass('layui-btn-primary layui-border-orange')->title('AJAX')->icon('bi bi-lock')->targetBlank()->params(['id'])->route('admin/add'), ]) ->setToolbarFilter([ 'keyword' => $this->toolbarFilter->text()->label('关键词')->placeholder('请输入账号/姓名')->defaultValue()->attribute(['test' => 1])->uiClass('w-330 mr-3'), //'username' => $this->toolbarFilter->datetime()->style(['width' => '800px'])->label('注册时间')->placeholder('请选择注册时间'), //'username' => $this->toolbarFilter->datetime()->label('注册时间')->placeholder('请选择注册时间'), /*'status' => $this->toolbarFilter->select()->label('用户状态')->uiClass(['layui-col-sm12'])->placeholder('请选择用户状态')->options([ '分组1' => [ 'normal' => '正常', 'deny' => '禁用', ], '分组2' => [ 'A' => '不可以', 'B' => '可以', ], ])->disabled(['deny'])->uiClass('w-330 mr-3'),*/ 'link1' => $this->toolbarFilter->selectLink()->label('联动1')->placeholder('请选择')->route('admin/link')->initOptions([ '测试1' => [ 'a' => 'A', 'b' => 'B' ], '测试2' => [ 'c' => 'C', 'd' => 'D' ], ])->disabled(['d'])->targetLink('link2')->start()->uiClass('w-330'), 'link2' => $this->toolbarFilter->selectLink()->label('')->placeholder('请选择')->route('admin/link')->targetLink('link3')->through()->uiClass('w-330'), 'link3' => $this->toolbarFilter->selectLink()->label('')->placeholder('请选择')->end()->uiClass('w-330'), ]) ->setAutoRequest(true); return $viewBuilder->render(); } } ~~~