| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace App\Module\Point\AdminControllers;
- use App\Module\Point\AdminControllers\Helper\FilterHelper;
- use App\Module\Point\AdminControllers\Helper\GridHelper;
- use App\Module\Point\AdminControllers\Helper\ShowHelper;
- use App\Module\Point\Repositorys\PointCirculationRepository;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Spatie\RouteAttributes\Attributes\Resource;
- use UCore\DcatAdmin\AdminController;
- /**
- * 种植点数流转控制器
- *
- * 路由: /admin/point/point-circulation
- * 菜单: 积分管理 -> 点数流转
- * 功能: 查看用户种植点数账户间的流转记录
- */
- #[Resource('point-point-circulation', names: 'admin.point.point-circulation', except: ['create', 'store', 'edit', 'update', 'destroy'])]
- class PointCirculationController extends AdminController
- {
- /**
- * 数据仓库
- */
- protected string $repository = PointCirculationRepository::class;
- /**
- * 页面标题
- */
- protected $title = '点数流转';
- /**
- * 列表页面
- */
- protected function grid(): Grid
- {
- return Grid::make(new PointCirculationRepository(), function (Grid $grid) {
- $gridHelper = new GridHelper($grid,$this);
- $grid->column('id', 'ID')->sortable();
- $gridHelper->columnCirculationInfo();
- $gridHelper->columnPoints('amount', '流转积分');
- $grid->column('re_type', '关联类型');
- $grid->column('re_id', '关联ID');
- $gridHelper->columnStatus();
- $grid->column('remark', '备注')->limit(30);
- $gridHelper->columnTimestamp('create_time', '创建时间');
- $grid->filter(function (Grid\Filter $filter) {
- $filterHelper = new FilterHelper($filter,$this);
- $filterHelper->equalUserId();
- $filter->equal('from_point_id', '源积分类型')->select([
- 1 => '经验积分',
- 2 => '成就积分',
- 3 => '活动积分',
- 4 => '签到积分',
- 5 => '推荐积分',
- ]);
- $filter->equal('to_point_id', '目标积分类型')->select([
- 1 => '经验积分',
- 2 => '成就积分',
- 3 => '活动积分',
- 4 => '签到积分',
- 5 => '推荐积分',
- ]);
- $filterHelper->equalReType();
- $filterHelper->equalStatus();
- $filterHelper->betweenTimestamp('create_time', '创建时间');
- $filterHelper->likeRemark();
- });
- $grid->disableCreateButton();
- $grid->disableEditButton();
- $grid->disableDeleteButton();
- $grid->actions(function (Grid\Displayers\Actions $actions) {
- $actions->disableEdit();
- $actions->disableDelete();
- });
- $grid->tools(function (Grid\Tools $tools) {
- $tools->append('<a href="/admin/point/point" class="btn btn-sm btn-primary">用户积分</a>');
- });
- });
- }
- /**
- * 详情页面
- */
- protected function detail($id): Show
- {
- return Show::make($id, new PointCirculationRepository(), function (Show $show) {
- $showHelper = new ShowHelper($show,$this);
- $show->field('id', 'ID');
- $showHelper->fieldCirculationInfo();
- $showHelper->fieldPoints('amount', '流转积分');
- $show->field('re_type', '关联类型');
- $show->field('re_id', '关联ID');
- $showHelper->fieldStatus();
- $show->field('remark', '备注');
- $showHelper->fieldTimestamp('create_time', '创建时间');
- $showHelper->fieldTimestamp('update_time', '更新时间');
- $show->disableEditButton();
- $show->disableDeleteButton();
- });
- }
- /**
- * 禁用表单页面
- */
- protected function form()
- {
- return redirect()->back()->with('error', '积分流转记录不允许编辑');
- }
- }
|