10 changed files with 15037 additions and 0 deletions
-
72app/Admin/Actions/Tools/DataReportDate.php
-
62app/Admin/Actions/Tools/DataReportOption.php
-
62app/Admin/Actions/Tools/DataReportTime.php
-
37app/Admin/Controllers/v3/DataReport.php
-
1app/Admin/routes.php
-
3public/css/data_report.css
-
14765public/js/moment-with-locales.js
-
18resources/views/admin/tools/data_report_date.blade.php
-
10resources/views/admin/tools/data_report_option.blade.php
-
7resources/views/admin/tools/data_report_time.blade.php
@ -0,0 +1,72 @@ |
|||||
|
<?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() |
||||
|
{ |
||||
|
return <<<JS |
||||
|
var app= new Vue({ |
||||
|
el:"#date_time", |
||||
|
data:{ |
||||
|
value1: '', |
||||
|
value2: '', |
||||
|
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); |
||||
|
} |
||||
|
}] |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
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'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,62 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\Admin\Actions\Tools; |
||||
|
|
||||
|
|
||||
|
use App\Admin\Common\LinkUrl; |
||||
|
use Dcat\Admin\Admin; |
||||
|
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
|
|
||||
|
class DataReportOption extends AbstractTool |
||||
|
{ |
||||
|
|
||||
|
protected $route; |
||||
|
|
||||
|
public function __construct($route) |
||||
|
{ |
||||
|
$this->route = $route; |
||||
|
parent::__construct(); |
||||
|
} |
||||
|
|
||||
|
protected function script() |
||||
|
{ |
||||
|
return <<<JS |
||||
|
var app= new Vue({ |
||||
|
el:"#option", |
||||
|
data:{ |
||||
|
options: [{ |
||||
|
value: '选项1', |
||||
|
label: '黄金糕' |
||||
|
}, { |
||||
|
value: '选项2', |
||||
|
label: '双皮奶' |
||||
|
}, { |
||||
|
value: '选项3', |
||||
|
label: '蚵仔煎' |
||||
|
}, { |
||||
|
value: '选项4', |
||||
|
label: '龙须面' |
||||
|
}, { |
||||
|
value: '选项5', |
||||
|
label: '北京烤鸭' |
||||
|
}], |
||||
|
value: '' |
||||
|
}, |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
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_option'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,62 @@ |
|||||
|
<?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')); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\Admin\Controllers\v3; |
||||
|
|
||||
|
|
||||
|
|
||||
|
use App\Admin\Actions\Tools\DataReportDate; |
||||
|
use App\Admin\Actions\Tools\DataReportOption; |
||||
|
use App\Models\LanzuStore; |
||||
|
use Dcat\Admin\Form; |
||||
|
use Dcat\Admin\Grid; |
||||
|
use Dcat\Admin\Layout\Column; |
||||
|
use Dcat\Admin\Layout\Content; |
||||
|
use Dcat\Admin\Layout\Row; |
||||
|
|
||||
|
class DataReport |
||||
|
{ |
||||
|
public function index(Content $content) |
||||
|
{ |
||||
|
return $content |
||||
|
->header('数据统计') |
||||
|
->body(function (Row $row){ |
||||
|
$row->column(4,function (Column $column){ |
||||
|
$column->row(new \App\Admin\Actions\Tools\DataReportTime('data_report')); |
||||
|
}); |
||||
|
$row->column(2,function (Column $column){ |
||||
|
$column->row(new DataReportOption('data_report')); |
||||
|
}); |
||||
|
|
||||
|
$row->column(6,function (Column $column){ |
||||
|
$column->row(new DataReportDate('data_report')); |
||||
|
}); |
||||
|
|
||||
|
})->body('<hr />'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
.el-input__inner { |
||||
|
height: 37px; |
||||
|
} |
||||
14765
public/js/moment-with-locales.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,18 @@ |
|||||
|
<div id="date_time"> |
||||
|
<div class="block"> |
||||
|
<el-date-picker |
||||
|
class="v1" |
||||
|
v-model="value1" |
||||
|
type="date" |
||||
|
placeholder="选择日期"> |
||||
|
</el-date-picker> |
||||
|
- |
||||
|
<el-date-picker |
||||
|
v-model="value2" |
||||
|
type="date" |
||||
|
placeholder="选择日期"> |
||||
|
</el-date-picker> |
||||
|
<button type="button" class="btn btn-primary">查询</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
@ -0,0 +1,10 @@ |
|||||
|
<div id="option"> |
||||
|
<el-select v-model="value" filterable placeholder="请选择"> |
||||
|
<el-option |
||||
|
v-for="item in options" |
||||
|
:key="item.value" |
||||
|
:label="item.label" |
||||
|
:value="item.value"> |
||||
|
</el-option> |
||||
|
</el-select> |
||||
|
</div> |
||||
@ -0,0 +1,7 @@ |
|||||
|
<div class="btn-group btn-group-toggle" data-toggle="buttons"> |
||||
|
@foreach($options as $option => $label) |
||||
|
<label class="btn btn-primary {{request()->get('type','all')==$option? 'active':''}}"> |
||||
|
<input type="radio" name="options" id="{{$option}}"> {{$label}} |
||||
|
</label> |
||||
|
@endforeach |
||||
|
</div> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue