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.
|
|
<?php
namespace App\AdminSupplier\Tools;
use App\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 = $path = request()->url(); $fullUrl = request()->fullUrl(); $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", full_url:"$fullUrl", 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+"?type=date&option=0&created_at[start]="+this.start; } if (this.end){ if (!this.start){ this.\$message({message:'请选择起始时间',type:"error"}) return false; } url = url+"&created_at[end]="+this.end; }else { if (this.start){ this.\$message({message:'请选择截止时间',type:"error"}) return false; } }
if (this.start&&this.end&&(this.start>this.end)){ this.\$message({message:'截止时间不能小于起始时间',type:"error"}) return false; }
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'); }}
|