💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 方法 异步实例: ```php $ajax = $toolbarCustom->ajax(); ``` 按钮class样式: ```php $ajax->btnClass('layui-btn-primary layui-border'); ``` 工具栏居右: ```php $ajax->positionRight(); ``` 行操作按钮和页标题: ```php $ajax->title('详情'); ``` 行操作按钮`icon`: ```php $ajax->icon('bi bi-plus-lg f15'); ``` 页面路由: ```php $ajax->route('user/detail'); ``` 路由参数: ```php // 直接指定query中的字段 $ajax->params(['id']); ``` ```php // key-value, 字段指定值 $ajax->params(['id' => 1]); ``` ```php // key-占位符, 字段+字段占位符 $ajax->params(['action' => ':status']); ``` 询问标题: ```php $ajax->questionTitle('是否删除?'); ``` 询问描述: ```php $ajax->questionDescription('删除数据后,将无法恢复,是否确定操作???'); ``` HTTP请求动作, `目前支持GET(助手默认)和POST`: ```php $ajax->method('POST'); ``` ### 链式调用 ~~~ $tableBuilder->setRowOperation([ // 详情 $this->rowOperation->modal()->title('详情')->icon('bi bi-plus-lg f15')->route('admin/detail'), $this->rowOperation->page()->title('测试')->icon('bi bi-x')->route('admin/detail')->params(['id' => 1])->targetBlank(), $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(), ]) ~~~ ### 代码示例 ~~~ /** * 列表 * @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(); } } ~~~