showHeader() ->title('测试') ->body( Alert::make() ->type('error') ->title('这里是警告信息') ->description('我是提示消息哈哈哈') ); return $content->toJson(); } #[RequestMapping(methods: "get,post")] public function grid(){ $page = request('page'); $pre = 10; $grid = new Grid(); if ($grid->isGetData()) { // $start = ($page - 1) * $pre; // $data = file_get_contents('http://web.peakchao.top:250/music/getMusicBanner'); // $data = json_decode($data, true); // $lsat_page = 10; // $grid->customData($data['result'], $page, $pre, $lsat_page, 100); } $grid->dataUrl('/ui/grid'); $grid->autoHeight(); $grid->column('name')->width(180); $grid->column('img1', 'Image')->defaultValue('https://wx.qlogo.cn/mmopen/vi_32/ajNVdqHZLLBpqXMk6kUC4PeB5VrIVtHyUqrcPg65sjKdPxlkBINiaQ1NG6nZC9iaWOh9qdO6VaApJzgWA1wu5h8Q/132')->component(Avatar::make())->width(80); $grid->column('singer')->width(80); $grid->batchActions(function (Grid\BatchActions $actions) { $actions->hideDeleteAction(); }); $grid->ref("top250"); $grid->toolbars(function (Grid\Toolbars $toolbars) { $toolbars->createButton()->disabled(); $js = <<addLeft(Button::make("动态获取已选择的项目")->refData("top250", $js)); $js = <<addLeft(Button::make("调用表格事件,清除全选")->refData("top250", $js)->className('ml-10')); $js = <<addLeft(Button::make("手动发送emit")->refData("top250", $js)->className('ml-10')); $toolbars->addLeft(Button::make("表格交互")->ref('gButton')->className('ml-10')->dialog(function (Dialog $dialog) { $dialog->width('40%'); $dialog->ref("gDialog")->showClose(false); // $dialog->slot(function (Content $content) { // $this->dialogGrid($content); // }); $dialog->title("表格交互"); })); $js = <<{ if (rowIndex === 1) { return 'warning-row'; } else if (rowIndex === 3) { return 'success-row'; } return ''; } JS; $toolbars->addLeft(Button::make("设置表格row-class-name")->refData("top250", $js)->className('ml-10')); }); // $grid->top(function (Content $content) { // $content->row($this->code())->className('mb-10'); // }); $grid->selection(); $grid->actions(function (Grid\Actions $actions) { $actions->hideEditAction(); $actions->hideDeleteAction(); $title = $actions->getRow()['name'] ?? ''; $actions->add(Grid\Actions\ActionButton::make("操作:$title")); }); return $grid->toJson(); } }