ProductOrders.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace App\Admin\Metrics\Examples;
  3. use Dcat\Admin\Widgets\Metrics\Round;
  4. use Illuminate\Http\Request;
  5. class ProductOrders extends Round
  6. {
  7. /**
  8. * 初始化卡片内容
  9. */
  10. protected function init()
  11. {
  12. parent::init();
  13. $this->title('Product Orders');
  14. $this->chartLabels(['Finished', 'Pending', 'Rejected']);
  15. $this->dropdown([
  16. '7' => 'Last 7 Days',
  17. '28' => 'Last 28 Days',
  18. '30' => 'Last Month',
  19. '365' => 'Last Year',
  20. ]);
  21. }
  22. /**
  23. * 处理请求
  24. *
  25. * @param Request $request
  26. *
  27. * @return mixed|void
  28. */
  29. public function handle(Request $request)
  30. {
  31. switch ($request->get('option')) {
  32. case '365':
  33. case '30':
  34. case '28':
  35. case '7':
  36. default:
  37. // 卡片内容
  38. $this->withContent(23043, 14658, 4758);
  39. // 图表数据
  40. $this->withChart([70, 52, 26]);
  41. // 总数
  42. $this->chartTotal('Total', 344);
  43. }
  44. }
  45. /**
  46. * 设置图表数据.
  47. *
  48. * @param array $data
  49. *
  50. * @return $this
  51. */
  52. public function withChart(array $data)
  53. {
  54. return $this->chart([
  55. 'series' => $data,
  56. ]);
  57. }
  58. /**
  59. * 卡片内容.
  60. *
  61. * @param int $finished
  62. * @param int $pending
  63. * @param int $rejected
  64. *
  65. * @return $this
  66. */
  67. public function withContent($finished, $pending, $rejected)
  68. {
  69. return $this->content(
  70. <<<HTML
  71. <div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
  72. <div class="chart-info d-flex justify-content-between mb-1 mt-2" >
  73. <div class="series-info d-flex align-items-center">
  74. <i class="fa fa-circle-o text-bold-700 text-primary"></i>
  75. <span class="text-bold-600 ml-50">Finished</span>
  76. </div>
  77. <div class="product-result">
  78. <span>{$finished}</span>
  79. </div>
  80. </div>
  81. <div class="chart-info d-flex justify-content-between mb-1">
  82. <div class="series-info d-flex align-items-center">
  83. <i class="fa fa-circle-o text-bold-700 text-warning"></i>
  84. <span class="text-bold-600 ml-50">Pending</span>
  85. </div>
  86. <div class="product-result">
  87. <span>{$pending}</span>
  88. </div>
  89. </div>
  90. <div class="chart-info d-flex justify-content-between mb-1">
  91. <div class="series-info d-flex align-items-center">
  92. <i class="fa fa-circle-o text-bold-700 text-danger"></i>
  93. <span class="text-bold-600 ml-50">Rejected</span>
  94. </div>
  95. <div class="product-result">
  96. <span>{$rejected}</span>
  97. </div>
  98. </div>
  99. </div>
  100. HTML
  101. );
  102. }
  103. }