海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.9 KiB

4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\AdminSupplier\Controllers;
  3. use App\AdminSupplier\Extensions\Grid\IndustryOrderStatus;
  4. use App\AdminSupplier\Repositories\IndustryOrder;
  5. use App\Common\OrderStatus;
  6. use Dcat\Admin\Admin;
  7. use Dcat\Admin\Form;
  8. use Dcat\Admin\Grid;
  9. use Dcat\Admin\Show;
  10. use Dcat\Admin\Http\Controllers\AdminController;
  11. use Dcat\Admin\Widgets\Table;
  12. class IndustryOrderController extends AdminController
  13. {
  14. /**
  15. * Make a grid builder.
  16. *
  17. * @return Grid
  18. */
  19. protected function grid()
  20. {
  21. return Grid::make(new IndustryOrder(['agent:id,company_name']), function (Grid $grid) {
  22. $grid->disableCreateButton();
  23. $grid->disableRowSelector();
  24. $grid->disableActions();
  25. $grid->model()->where('supplier_id', Admin::user()->id);
  26. $grid->column('id')->sortable();
  27. $grid->column('agent.company_name', '代理商名称')->limit(10);
  28. $grid->column('order_no')->limit(10);
  29. $grid->column('num');
  30. $grid->column('price');
  31. $grid->column('name');
  32. $grid->column('mobile');
  33. $grid->column('info', '信息收集')
  34. ->display('查看')
  35. ->modal('信息收集', function ($modal) {
  36. $info = $this->info ?? [];
  37. $info = array_map(function($v) {
  38. if (isset($v['value'], $v['type'])) {
  39. if ($v['type'] == 'image') {
  40. if (is_array($v['value'])) {
  41. return array_reduce($v['value'], fn($v2, $v3) => $v2 . '<img data-action="preview-img" src="' . $v3 . '" style="max-width:120px;max-height:200px;cursor:pointer" class="img img-thumbnail"> &nbsp;');
  42. } else {
  43. return '<img data-action="preview-img" src="' . $v['value'] . '" style="max-width:120px;max-height:200px;cursor:pointer" class="img img-thumbnail">';
  44. }
  45. } else {
  46. return is_string($v['value']) ? $v['value'] : join(',', $v['value']);
  47. }
  48. }
  49. return is_string($v) ? $v : json_encode($v);
  50. }, $info);
  51. return Table::make([], $info);
  52. })->xl();
  53. $grid->column('industry_product_id', '产品ID');
  54. $grid->column('title')->limit(15);
  55. $grid->column('picture')->image('', 60, 60);
  56. $grid->column('status')
  57. ->using(OrderStatus::array())
  58. ->if(fn() => $this->status == OrderStatus::OFFLINE_UNPAID)
  59. ->action(new IndustryOrderStatus);
  60. $grid->column('paid_at');
  61. // $grid->column('timeout');
  62. $grid->column('created_at');
  63. $grid->filter(function (Grid\Filter $filter) {
  64. $filter->equal('id')->width(2);
  65. $filter->equal('order_no')->width(3);
  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 IndustryOrder(), function (Show $show) {
  79. $show->field('id');
  80. $show->field('agent_id');
  81. $show->field('supplier_id');
  82. $show->field('order_no');
  83. $show->field('industry_product_id');
  84. $show->field('num');
  85. $show->field('price');
  86. $show->field('name');
  87. $show->field('mobile');
  88. $show->field('title');
  89. $show->field('picture');
  90. $show->field('status');
  91. $show->field('paid_at');
  92. $show->field('verify_code');
  93. $show->field('timeout');
  94. $show->field('created_at');
  95. $show->field('updated_at');
  96. });*/
  97. }
  98. /**
  99. * Make a form builder.
  100. *
  101. * @return Form
  102. */
  103. protected function form()
  104. {
  105. return Form::make(new IndustryOrder(), function (Form $form) {
  106. $form->display('id');
  107. // $form->select('status')->options([OrderStatus::OFFLINE_PAID => '已付款']);
  108. })->saving(function(Form $form) {
  109. return $form->response()->error('操作禁止');
  110. })->deleting(function(Form $form) {
  111. return $form->response()->error('操作禁止');
  112. });
  113. }
  114. }