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

<?php
namespace App\Admin\Actions\Tools;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid\Tools\AbstractTool;
class DataReportTime extends AbstractTool
{
protected $url;
protected $option;
protected $route;
public function __construct($route)
{
$this->route = $route;
parent::__construct();
}
protected function script()
{
return <<<JS
$("#{$this->option}").change(function () {
var url = "{$this->url}"
Dcat.reload(url)
});
JS;
}
public function render()
{
$options = [
'all'=>'全部',
'today' => '今日',
'yesterday' => '昨日',
'week' => '本周',
'last_week' => '上周',
'month' => '本月',
'last_month' => '上月',
];
$data = [
'all'=>'0',
'today' => '1',
'yesterday' => '-1',
'week' => 'w',
'last_week' => 'lw',
'month' => '30',
'last_month' => '-30',
];
foreach ($data as $key=>$value){
$this->url = "{$this->route}?type={$key}&option={$value}&&name={$options[$key]}";
$this->option = $key;
Admin::script($this->script());
}
return view('admin.tools.data_report_time', compact('options'));
}
}