链街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.

126 lines
3.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Actions\Tools;
  3. use App\Admin\Common\LinkUrl;
  4. use Dcat\Admin\Admin;
  5. use Dcat\Admin\Grid\Tools\AbstractTool;
  6. class DataReportDate extends AbstractTool
  7. {
  8. protected $route;
  9. public function __construct($route)
  10. {
  11. $this->route = $route;
  12. parent::__construct();
  13. }
  14. protected function script()
  15. {
  16. $url = $path = request()->url();
  17. $fullUrl = request()->fullUrl();
  18. $date = request()->input('created_at');
  19. $start = $date?$date['start']:'';
  20. $end = $date?$date['end']:'';
  21. if(!(request()->server('QUERY_STRING'))){
  22. $fullUrl = $url .= "?type=today&option=1";
  23. }
  24. return <<<JS
  25. var app= new Vue({
  26. el:"#date_time",
  27. data:{
  28. start: "$start",
  29. end: "$end",
  30. url:"$url",
  31. full_url:"$fullUrl",
  32. path:"$path",
  33. pickerOptions: {
  34. disabledDate(time) {
  35. return time.getTime() > Date.now();
  36. },
  37. shortcuts: [{
  38. text: '今天',
  39. onClick(picker) {
  40. picker.\$emit('pick', new Date());
  41. }
  42. }, {
  43. text: '昨天',
  44. onClick(picker) {
  45. const date = new Date();
  46. date.setTime(date.getTime() - 3600 * 1000 * 24);
  47. picker.\$emit('pick', date);
  48. }
  49. }, {
  50. text: '一周前',
  51. onClick(picker) {
  52. const date = new Date();
  53. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
  54. picker.\$emit('pick', date);
  55. }
  56. }]
  57. },
  58. },
  59. methods:{
  60. doSearch(){
  61. var market_id = sessionStorage.getItem('market_id');
  62. if (market_id==0&&!this.start&&!this.end){
  63. this.\$message({message:'请选择查询市场或时间',type:"error"})
  64. return false;
  65. }
  66. var url = this.url;
  67. if (this.start){
  68. url = url+"?type=date&option=0&created_at[start]="+this.start;
  69. }
  70. if (this.end){
  71. if (!this.start){
  72. this.\$message({message:'请选择起始时间',type:"error"})
  73. return false;
  74. }
  75. url = url+"&created_at[end]="+this.end;
  76. }else {
  77. if (this.start){
  78. this.\$message({message:'请选择截止时间',type:"error"})
  79. return false;
  80. }
  81. }
  82. if (this.start&&this.end&&(this.start>this.end)){
  83. this.\$message({message:'截止时间不能小于起始时间',type:"error"})
  84. return false;
  85. }
  86. if (market_id>0&&!this.start&&!this.end){
  87. url = this.full_url+"&market_id="+market_id;
  88. }else {
  89. url = url+"&market_id="+market_id;
  90. }
  91. window.location.href=url;
  92. },
  93. reset(){
  94. window.location.href=this.path;
  95. }
  96. }
  97. });
  98. JS;
  99. }
  100. public function render()
  101. {
  102. Admin::js(LinkUrl::VUE_JS);
  103. Admin::js(LinkUrl::ELEMENT_UI_JS);
  104. Admin::css(LinkUrl::ELEMENT_UI_CSS);
  105. Admin::css('css/data_report.css');
  106. Admin::script($this->script());
  107. return view('admin.tools.data_report_date');
  108. }
  109. }