139 lines
5.0 KiB
PHP
139 lines
5.0 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace App\Mall\Controller\Agent;
|
|
use Hyperf\HttpServer\Annotation\Controller;
|
|
use Hyperf\HttpServer\Annotation\GetMapping;
|
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
|
|
|
|
|
use Builder\BaseController;
|
|
use Builder\View\Layout\Content;
|
|
use Builder\View\Layout\Row;
|
|
|
|
use Builder\View\Components\Grid\Avatar;
|
|
use Builder\View\Components\Widgets\Alert;
|
|
use Builder\View\Components\Widgets\Button;
|
|
use Builder\View\Components\Widgets\Dialog;
|
|
use Builder\View\Components\Widgets\Card;
|
|
use Builder\View\Components\Widgets\Html;
|
|
use Builder\View;
|
|
use Builder\Entity\MenuEntity;
|
|
use Builder\Entity\MenuItemEntity;
|
|
|
|
use Builder\Entity\UISettingEntity;
|
|
use Builder\Entity\UserEntity;
|
|
use Hyperf\HttpServer\Response;
|
|
use Hyperf\HttpServer\Annotation\AutoController;
|
|
|
|
use Builder\View\Grid;
|
|
use Builder\View\Form;
|
|
//use Builder\View\Grid;
|
|
/**
|
|
* Class IndexController
|
|
* @package App\Mall\Controller
|
|
*/
|
|
#[Controller(prefix: "mall/agent")]
|
|
class IndexController extends BaseController
|
|
{
|
|
#[GetMapping("index")]
|
|
public function index()
|
|
{
|
|
$content = new Content();
|
|
$content->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 = <<<JS
|
|
self.attrs.type='success'
|
|
self.\$message.success("获取成功,请在浏览器调试器查看打印数据")
|
|
console.log(ref)
|
|
JS;
|
|
$toolbars->addLeft(Button::make("动态获取已选择的项目")->refData("top250", $js));
|
|
$js = <<<JS
|
|
ref.\$refs.top250.clearSelection();
|
|
JS;
|
|
$toolbars->addLeft(Button::make("调用表格事件,清除全选")->refData("top250", $js)->className('ml-10'));
|
|
$js = <<<JS
|
|
ref.\$bus.emit("tableReload");
|
|
JS;
|
|
|
|
$toolbars->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 = <<<JS
|
|
let table = ref.\$refs.top250
|
|
table.stripe=false;
|
|
table['rowClassName'] = ({row, rowIndex})=>{
|
|
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();
|
|
}
|
|
} |