FundController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace App\Module\Fund\AdminControllers;
  3. use App\Module\Fund\Admin\Actions\Circulation;
  4. use App\Module\Fund\Admin\Actions\FundAdminAction;
  5. use App\Module\Fund\Repositorys\FundRepository;
  6. use App\Module\Fund\Services\AccountService;
  7. use Spatie\RouteAttributes\Attributes\Resource;
  8. use UCore\DcatAdmin\AdminController;
  9. use UCore\DcatAdmin\FilterHelper;
  10. use UCore\DcatAdmin\GridHelper;
  11. use Dcat\Admin\Form;
  12. use Dcat\Admin\Grid;
  13. use Dcat\Admin\Layout\Content;
  14. use Dcat\Admin\Show;
  15. use App\Module\Fund\Models\FundModel;
  16. use App\Module\Fund\Repositorys\FundRepository as Fund;
  17. /**
  18. * 资金账户
  19. */
  20. #[Resource('fund', names: 'dcat.admin.fund')]
  21. class FundController extends AdminController
  22. {
  23. protected $title='资金账户';
  24. /**
  25. * Make a grid builder.
  26. *
  27. * @return Grid
  28. */
  29. protected function grid()
  30. {
  31. return Grid::make(new Fund(['user']), function (Grid $grid) {
  32. $helper = new GridHelper($grid, $this);
  33. $helper->columnIdDesc();
  34. $helper->columnUserIDInfo();
  35. $grid->column('fund_id', '账户')->using(AccountService::getFundsDesc());
  36. $helper->columnc1000('balance')->sortable();
  37. $helper->columnAt('create_time');
  38. $helper->columnAt('update_time');
  39. $helper->disableAll();
  40. $grid->filter(function (Grid\Filter $filter) {
  41. $helper= new FilterHelper($filter,$this);
  42. $filter->equal('user_id');
  43. $helper->equalRadio('fund_id',AccountService::getFundsDesc(),'账户');
  44. $helper->gtas('user_idgt','user_id','最小');
  45. $filter->expand();
  46. $filter->panel();
  47. });
  48. $grid->actions(function (Grid\Displayers\Actions $actions) {
  49. // $actions->disableDelete();
  50. // $actions->disableView();
  51. $actions->append(new FundAdminAction());
  52. $actions->append(new Circulation());
  53. });
  54. });
  55. }
  56. /**
  57. * Make a show builder.
  58. *
  59. * @param mixed $id
  60. *
  61. * @return Show
  62. */
  63. protected function detail($id)
  64. {
  65. return Show::make($id, new FundRepository(), function (Show $show) {
  66. $show->field('id');
  67. $show->field('service_id');
  68. $show->field('title');
  69. $show->field('title_i18n');
  70. });
  71. }
  72. /**
  73. * Make a form builder.
  74. *
  75. * @return Form
  76. */
  77. protected function form()
  78. {
  79. return Form::make(new Fund(), function (Form $form) {
  80. });
  81. }
  82. public function circulation(Content $content)
  83. {
  84. return $content
  85. ->title('流转')
  86. ->body(new CirculationForm());
  87. }
  88. }