From 64a4df2400f07212cf9bb2f018ca0723d912752c Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Wed, 21 Oct 2020 18:23:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=95=86=E5=93=81=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1--=E6=B7=BB=E5=8A=A0=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/GoodsActivityReportController.php | 4 + .../Charts/OrderGoodsActivityTotalChart.php | 84 +++++++++++++++++++ app/Admin/routes.php | 2 +- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 app/Admin/Widgets/Charts/OrderGoodsActivityTotalChart.php diff --git a/app/Admin/Controllers/v3/GoodsActivityReportController.php b/app/Admin/Controllers/v3/GoodsActivityReportController.php index d534c72..a0e4042 100644 --- a/app/Admin/Controllers/v3/GoodsActivityReportController.php +++ b/app/Admin/Controllers/v3/GoodsActivityReportController.php @@ -6,6 +6,7 @@ use App\Admin\Actions\Grid\v3\DataReportOption; use App\Admin\Repositories\v3\GoodsActivityReport; use App\Admin\Widgets\Charts\OrderGoodsActivityColumnChart; +use App\Admin\Widgets\Charts\OrderGoodsActivityTotalChart; use Dcat\Admin\Grid; use Dcat\Admin\Controllers\AdminController; use App\Models\v3\Market as MarketModel; @@ -90,6 +91,9 @@ class GoodsActivityReportController extends AdminController public function index(Content $content) { return $content->title('活动商品统计') + ->body(function(Row $row){ + $row->column(4,new OrderGoodsActivityTotalChart()); + }) ->body(function(Row $row){ $row->column(12,$this->grid()); }) diff --git a/app/Admin/Widgets/Charts/OrderGoodsActivityTotalChart.php b/app/Admin/Widgets/Charts/OrderGoodsActivityTotalChart.php new file mode 100644 index 0000000..3592a17 --- /dev/null +++ b/app/Admin/Widgets/Charts/OrderGoodsActivityTotalChart.php @@ -0,0 +1,84 @@ +option = $this->id = 7; + $this->data = $data; + parent::__construct(); + } + + protected function init() + { + parent::init(); + + // 设置标题 + $this->title('销售总数量'); + // 设置下拉菜单 + // $this->dropdown([]); + } + + /** + * 处理请求 + * 如果你的图表类中包含此方法,则可以通过此方法处理前端通过ajax提交的获取图表数据的请求 + * + * @param Request $request + * @return mixed|void + */ + public function handle(Request $request) + { + // dd($request); + // 数据查询逻辑 + $data = ['total' => $this->data['total'] ?? 0 ]; + + $this->withData($data); + } + + /** + * 这里返回需要异步传递到 handler 方法的参数 + * + * @return array + */ + public function parameters(): array + { + return [ + 'id' => $this->id, + 'option' => $this->option, + ]; + } + + public function withData($data) + { + $this->data = $data; + } + + /** + * 渲染卡片内容. + * + * @return string + */ + public function renderContent() + { + $total = $this->data['total'] ?? 0 ; + + return << +