链街Dcat后台
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.
 
 
 
 

84 lines
1.7 KiB

<?php
namespace App\Admin\Widgets\Charts;
use Dcat\Admin\Widgets\Metrics\Card;
use Illuminate\Http\Request;
class OrderGoodsActivityTotalChart extends Card
{
/**
* 活动商品总数
*/
protected $data = [];
protected $id;
protected $option;
public function __construct($data = [])
{
$this->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 <<<HTML
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
<h2 class="ml-1 font-large-1">{$total}</h2>
</div>
HTML;
}
}