FundCirculationController.php 3.3 KB

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