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.
107 lines
3.1 KiB
107 lines
3.1 KiB
<?php
|
|
|
|
|
|
namespace App\Admin\Actions\Tools;
|
|
|
|
|
|
use App\Admin\Common\LinkUrl;
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Grid\Tools\AbstractTool;
|
|
|
|
class DataReportDate extends AbstractTool
|
|
{
|
|
|
|
protected $route;
|
|
|
|
public function __construct($route)
|
|
{
|
|
$this->route = $route;
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function script()
|
|
{
|
|
$url = request()->fullUrl();
|
|
$path = request()->url();
|
|
if(!(request()->server('QUERY_STRING'))){
|
|
$url .= "?type=date&option=0";
|
|
}
|
|
$date = request()->input('created_at');
|
|
$start = $date?$date['start']:'';
|
|
$end = $date?$date['end']:'';
|
|
return <<<JS
|
|
var app= new Vue({
|
|
el:"#date_time",
|
|
data:{
|
|
start: "$start",
|
|
end: "$end",
|
|
url:"$url",
|
|
path:"$path",
|
|
pickerOptions: {
|
|
disabledDate(time) {
|
|
return time.getTime() > Date.now();
|
|
},
|
|
shortcuts: [{
|
|
text: '今天',
|
|
onClick(picker) {
|
|
picker.\$emit('pick', new Date());
|
|
}
|
|
}, {
|
|
text: '昨天',
|
|
onClick(picker) {
|
|
const date = new Date();
|
|
date.setTime(date.getTime() - 3600 * 1000 * 24);
|
|
picker.\$emit('pick', date);
|
|
}
|
|
}, {
|
|
text: '一周前',
|
|
onClick(picker) {
|
|
const date = new Date();
|
|
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
|
picker.\$emit('pick', date);
|
|
}
|
|
}]
|
|
},
|
|
},
|
|
methods:{
|
|
doSearch(){
|
|
var url = this.url;
|
|
if (this.start){
|
|
url = url+"&created_at[start]="+this.start;
|
|
}else {
|
|
this.\$message({message:'请选择起始日期',type:'error'});
|
|
return false;
|
|
}
|
|
if (this.end){
|
|
url = url+"&created_at[end]="+this.end;
|
|
}else {
|
|
this.\$message({message:'请选择截止日期',type:'error'});
|
|
return false;
|
|
}
|
|
var market_id = sessionStorage.getItem('market_id');
|
|
if (market_id>0){
|
|
url = url+"&market_id="+market_id;
|
|
}
|
|
window.location.href=url;
|
|
},
|
|
reset(){
|
|
window.location.href=this.path;
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
JS;
|
|
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
Admin::js(LinkUrl::VUE_JS);
|
|
Admin::js(LinkUrl::ELEMENT_UI_JS);
|
|
Admin::css(LinkUrl::ELEMENT_UI_CSS);
|
|
Admin::css('css/data_report.css');
|
|
Admin::script($this->script());
|
|
return view('admin.tools.data_report_date');
|
|
}
|
|
}
|