From 7585ec761484b795cc212599f2af44d03a441da1 Mon Sep 17 00:00:00 2001 From: lemon <15040771@qq.com> Date: Fri, 3 Sep 2021 16:34:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A2=E5=8A=A1=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinanceStatisticsController.php | 80 +++++++++++++ .../Metrics/Examples/FinanceStatistics.php | 112 ++++++++++++++++++ app/AdminAgent/routes.php | 2 +- resources/lang/zh_CN/global.php | 1 + 4 files changed, 194 insertions(+), 1 deletion(-) create mode 100755 app/AdminAgent/Controllers/FinanceStatisticsController.php create mode 100644 app/AdminAgent/Metrics/Examples/FinanceStatistics.php diff --git a/app/AdminAgent/Controllers/FinanceStatisticsController.php b/app/AdminAgent/Controllers/FinanceStatisticsController.php new file mode 100755 index 0000000..78b3929 --- /dev/null +++ b/app/AdminAgent/Controllers/FinanceStatisticsController.php @@ -0,0 +1,80 @@ +body( + << + + + HTML + + ) + ->body(function (Row $row) use ($count, $total, $totalNon) { + + $row->column(4, function (Column $column) use ($count) { + $column->row(Card::make('金额', function () use ($count) { + return << +

$count

+ +HTML; + })); + }); + + $row->column(4, function (Column $column) use ($total) { + $column->row(Card::make('利润', function () use ($total) { + return << +

$total

+ +HTML; + })); + + }); + + $row->column(4, function (Column $column) use ($totalNon) { + $column->row(Card::make('已完成订单', function () use ($totalNon) { + return << +

$totalNon

+ +HTML; + })); + + }); + + }) + ->body(function (Row $row){ + $row->column(12,new FinanceStatistics()); + }); + } +} diff --git a/app/AdminAgent/Metrics/Examples/FinanceStatistics.php b/app/AdminAgent/Metrics/Examples/FinanceStatistics.php new file mode 100644 index 0000000..fb7b1f5 --- /dev/null +++ b/app/AdminAgent/Metrics/Examples/FinanceStatistics.php @@ -0,0 +1,112 @@ +contentWidth(0, 12); + // 标题 + //$this->title('财务统计'); + $this->chartHeight = 500; + // 设置下拉选项 + $this->dropdown([ + '7' => '日', + '30' => '月', + '365' => '年', + ]); + // 设置图表颜色 + $this->chartColors([ + $color->green(), + ]); + } + + /** + * 处理请求 + * + * @param Request $request + * + * @return mixed|void + */ + public function handle(Request $request) + { + switch ($request->get('option')) { + case '7': + default: + + + // 图表数据 + $this->withChart( + [75, 125, 225, 175, 125, 75, 25] + ); + } + } + + /** + * 设置图表数据. + * + * @param array $data + * + * @return $this + */ + public function withChart(array $data) + { + return $this->chart([ + 'series' => [[ + 'name' => '金额', + 'data' => $data + ]], + 'chart' => [ + //'width' => '180%', + 'type' => 'bar', + 'events' => [ + ], + 'toolbar' => ['show' => false], + ], + 'colors' => $this->colors, + 'plotOptions' => [ + 'bar' => [ + //'columnWidth' => '45%', + 'distributed' => true, + ] + ], + 'dataLabels' => [ + 'enabled' => false + ], + 'legend' => [ + 'show' => false + ], + 'xaxis' => [ + 'categories' => + [75, 125, 225, 175, 125, 75, 25] + , + 'labels' => [ + 'show' => true, + 'style' => [ + 'colors' => $this->colors, + 'fontSize' => '12px' + ] + ], + ], + 'yaxis' => [ + 'show' => true + ], + 'tooltip' => [ + 'x' => ['show' => true], + ], + + ]); + } +} diff --git a/app/AdminAgent/routes.php b/app/AdminAgent/routes.php index 33fe648..9983702 100644 --- a/app/AdminAgent/routes.php +++ b/app/AdminAgent/routes.php @@ -36,5 +36,5 @@ Route::group([ $router->resource('article/list', 'ArticleController'); $router->resource('setting', 'SettingController'); $router->resource('channel/list', 'ChannelController'); - + $router->resource('/finance_statistics', 'FinanceStatisticsController'); }); diff --git a/resources/lang/zh_CN/global.php b/resources/lang/zh_CN/global.php index 9f9af97..80bd8c7 100644 --- a/resources/lang/zh_CN/global.php +++ b/resources/lang/zh_CN/global.php @@ -30,6 +30,7 @@ return [ 'create' => '创建', 'root' => '顶级', 'scaffold' => '代码生成器', + 'finance_statistics'=> '财务统计', ], 'options' => [ //