链街Dcat后台
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.

62 lines
1.4 KiB

5 years ago
  1. <?php
  2. namespace App\Admin\Actions\Tools;
  3. use Dcat\Admin\Admin;
  4. use Dcat\Admin\Grid\Tools\AbstractTool;
  5. class DataReportTime extends AbstractTool
  6. {
  7. protected $url;
  8. protected $option;
  9. protected $route;
  10. public function __construct($route)
  11. {
  12. $this->route = $route;
  13. parent::__construct();
  14. }
  15. protected function script()
  16. {
  17. return <<<JS
  18. $("#{$this->option}").change(function () {
  19. var url = "{$this->url}"
  20. Dcat.reload(url)
  21. });
  22. JS;
  23. }
  24. public function render()
  25. {
  26. $options = [
  27. 'all'=>'全部',
  28. 'today' => '今日',
  29. 'yesterday' => '昨日',
  30. 'week' => '本周',
  31. 'last_week' => '上周',
  32. 'month' => '本月',
  33. 'last_month' => '上月',
  34. ];
  35. $data = [
  36. 'all'=>'0',
  37. 'today' => '1',
  38. 'yesterday' => '-1',
  39. 'week' => 'w',
  40. 'last_week' => 'lw',
  41. 'month' => '30',
  42. 'last_month' => '-30',
  43. ];
  44. foreach ($data as $key=>$value){
  45. $this->url = "{$this->route}?type={$key}&option={$value}&&name={$options[$key]}";
  46. $this->option = $key;
  47. Admin::script($this->script());
  48. }
  49. return view('admin.tools.data_report_time', compact('options'));
  50. }
  51. }