6 changed files with 200 additions and 1 deletions
-
0app/Admin/Actions/Exporter/SalesMan.php
-
55app/Admin/Actions/Tools/DataReportOrder.php
-
22app/Admin/Controllers/v3/DataReport.php
-
115app/Admin/Extensions/Chart/Bar/OrderBar.php
-
7resources/views/admin/tools/data_report_order.blade.php
-
2resources/views/admin/tools/data_report_time.blade.php
@ -0,0 +1,55 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Actions\Tools; |
|||
|
|||
|
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Grid\Tools\AbstractTool; |
|||
|
|||
class DataReportOrder 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 = [ |
|||
'al'=>'全部', |
|||
'online' => '外卖', |
|||
'offline' => '当面付', |
|||
|
|||
|
|||
]; |
|||
|
|||
$data = [ |
|||
'al'=>'0', |
|||
'online' => '1', |
|||
'offline' => '2', |
|||
|
|||
]; |
|||
|
|||
foreach ($data as $key=>$value){ |
|||
$this->url = "{$this->route}?order_type={$key}&option={$value}&&name={$options[$key]}"; |
|||
$this->option = $key; |
|||
Admin::script($this->script()); |
|||
} |
|||
return view('admin.tools.data_report_order', compact('options')); |
|||
} |
|||
} |
|||
@ -0,0 +1,115 @@ |
|||
<?php |
|||
namespace App\Admin\Extensions\Chart\Bar; |
|||
|
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Widgets\ApexCharts\Chart; |
|||
use Dcat\Admin\Widgets\Metrics\Bar; |
|||
|
|||
class OrderBar extends Chart |
|||
{ |
|||
public function __construct($containerSelector = null, $options = []) |
|||
{ |
|||
parent::__construct($containerSelector, $options); |
|||
|
|||
$this->setUpOptions(); |
|||
} |
|||
|
|||
/** |
|||
* 初始化图表配置 |
|||
*/ |
|||
protected function setUpOptions() |
|||
{ |
|||
$color = Admin::color(); |
|||
|
|||
$colors = [$color->primary(), $color->primaryDarker()]; |
|||
|
|||
$this->options([ |
|||
'colors' => $colors, |
|||
'chart' => [ |
|||
'type' => 'bar', |
|||
'height' => 430 |
|||
], |
|||
'plotOptions' => [ |
|||
'bar' => [ |
|||
'horizontal' => false, |
|||
'dataLabels' => [ |
|||
'position' => 'top', |
|||
], |
|||
] |
|||
], |
|||
'dataLabels' => [ |
|||
'enabled' => true, |
|||
'offsetX' => -6, |
|||
'style' => [ |
|||
'fontSize' => '12px', |
|||
'colors' => ['#fff'] |
|||
] |
|||
], |
|||
'stroke' => [ |
|||
'show' => true, |
|||
'width' => 1, |
|||
'colors' => ['#fff'] |
|||
], |
|||
'xaxis' => [ |
|||
'categories' => [], |
|||
], |
|||
]); |
|||
} |
|||
|
|||
/** |
|||
* 处理图表数据 |
|||
*/ |
|||
protected function buildData() |
|||
{ |
|||
// 执行你的数据查询逻辑
|
|||
$data = [ |
|||
[ |
|||
'data' => [44, 55, 41, 64, 22, 43, 21] |
|||
], |
|||
[ |
|||
'data' => [53, 32, 33, 52, 13, 44, 32] |
|||
] |
|||
]; |
|||
$categories = [2001, 2002, 2003, 2004, 2005, 2006, 2007]; |
|||
|
|||
$this->withData($data); |
|||
$this->withCategories($categories); |
|||
} |
|||
|
|||
/** |
|||
* 设置图表数据 |
|||
* |
|||
* @param array $data |
|||
* |
|||
* @return $this |
|||
*/ |
|||
public function withData(array $data) |
|||
{ |
|||
return $this->option('series', $data); |
|||
} |
|||
|
|||
/** |
|||
* 设置图表类别. |
|||
* |
|||
* @param array $data |
|||
* |
|||
* @return $this |
|||
*/ |
|||
public function withCategories(array $data) |
|||
{ |
|||
return $this->option('xaxis.categories', $data); |
|||
} |
|||
|
|||
/** |
|||
* 渲染图表 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function render() |
|||
{ |
|||
$this->buildData(); |
|||
|
|||
return parent::render(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<div class="btn-group btn-group-toggle" data-toggle="buttons"> |
|||
@foreach($options as $option => $label) |
|||
<label class="btn btn-outline-primary {{request()->get('order_type','al')==$option? 'active':''}}"> |
|||
<input type="radio" name="options" id="{{$option}}"> {{$label}} |
|||
</label> |
|||
@endforeach |
|||
</div> |
|||
@ -1,6 +1,6 @@ |
|||
<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':''}}"> |
|||
<label class="btn btn-outline-primary {{request()->get('t','all')==$option? 'active':''}}"> |
|||
<input type="radio" name="options" id="{{$option}}"> {{$label}} |
|||
</label> |
|||
@endforeach |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue