FundCirculationController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace App\Module\Fund\AdminControllers;
  3. use App\Module\Fund\Admin\Actions\UserCirculationsAction;
  4. use App\Module\Fund\Services\AccountService;
  5. use Spatie\RouteAttributes\Attributes\Resource;
  6. use UCore\DcatAdmin\AdminController;
  7. use App\Module\Fund\AdminControllers\Helper\FilterHelper;
  8. use App\Module\Fund\AdminControllers\Helper\GridHelper;
  9. use App\Module\Fund\AdminControllers\Helper\ShowHelper;
  10. use App\Module\Fund\AdminControllers\Helper\FormHelper;
  11. use Dcat\Admin\Form;
  12. use Dcat\Admin\Grid;
  13. use Dcat\Admin\Show;
  14. use App\Module\Fund\Models\FundModel;
  15. use App\Module\Fund\Repositorys\FundCirculationRepository as FundCirculation;
  16. use UCore\DcatAdmin\Metrics\Examples\Link;
  17. /**
  18. * 资金流转
  19. *
  20. *
  21. */
  22. #[Resource('fund-circulation', names: 'dcat.admin.fund-circulation')]
  23. class FundCirculationController extends AdminController
  24. {
  25. protected $title='资金流转';
  26. /**
  27. * Make a grid builder.
  28. *
  29. * @return Grid
  30. */
  31. protected function grid()
  32. {
  33. return Grid::make(new FundCirculation(), function (Grid $grid) {
  34. // $grid->model()->with('user');
  35. $helper = new GridHelper($grid,$this);
  36. $helper->disableAll();
  37. $helper->columnIdDesc();
  38. $helper->columnUserID();
  39. $helper->columnUsingkv('fund_id', AccountService::getFundsDesc(),'来源账户');
  40. $helper->columnUsingkv('to_fund_id', AccountService::getFundsDesc(),'目标账户');
  41. $helper->columnc1000('total_fee','数额');
  42. $helper->columnAt('create_time');
  43. $grid->column('re_type','关联')->expand(function(){
  44. $url = admin_url('404');
  45. $title = '未知';
  46. $link = new Link($title,$url);
  47. return $link;
  48. });
  49. // $helper->columnAt('ok_time');
  50. // * @property string $re_type 关联类型
  51. // * @property int $re_id 关联类型
  52. // $helper-
  53. //
  54. $grid->filter(function (Grid\Filter $filter) {
  55. $helper= new FilterHelper($filter,$this);
  56. $filter->equal('id', 'ID');
  57. $filter->equal('user_id', '用户ID');
  58. $helper->equalRadio('fund_id', AccountService::getFundsDesc(), '来源账户');
  59. $helper->equalRadio('to_fund_id', AccountService::getFundsDesc(), '目标账户');
  60. $helper->betweenAmount('total_fee', '金额范围'); // 添加金额范围筛选
  61. $helper->betweenTimestamp('create_time', '创建时间');
  62. });
  63. $grid->disableCreateButton();
  64. $grid->actions(function (Grid\Displayers\Actions $actions) {
  65. // $actions->disableDelete();
  66. $actions->disableView();
  67. $actions->append(new UserCirculationsAction());
  68. });
  69. });
  70. }
  71. /**
  72. * Make a show builder.
  73. *
  74. * @param mixed $id
  75. *
  76. * @return Show
  77. */
  78. protected function detail($id)
  79. {
  80. return Show::make($id, new FundCirculation(), function (Show $show) {
  81. $show->field('id');
  82. $show->field('service_id');
  83. $show->field('title');
  84. $show->field('title_i18n');
  85. });
  86. }
  87. /**
  88. * Make a form builder.
  89. *
  90. * @return Form
  91. */
  92. protected function form()
  93. {
  94. return Form::make(new FundCirculation(), function (Form $form) {
  95. });
  96. }
  97. }