ProductOrders.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. * @return mixed|void
  26. */
  27. public function handle(Request $request)
  28. {
  29. switch ($request->get('option')) {
  30. case '365':
  31. case '30':
  32. case '28':
  33. case '7':
  34. default:
  35. // 卡片内容
  36. $this->withContent(23043, 14658, 4758);
  37. // 图表数据
  38. $this->withChart([70, 52, 26]);
  39. // 总数
  40. $this->chartTotal('Total', 344);
  41. }
  42. }
  43. /**
  44. * 设置图表数据.
  45. *
  46. * @return $this
  47. */
  48. public function withChart(array $data)
  49. {
  50. return $this->chart([
  51. 'series' => $data,
  52. ]);
  53. }
  54. /**
  55. * 卡片内容.
  56. *
  57. * @param int $finished
  58. * @param int $pending
  59. * @param int $rejected
  60. *
  61. * @return $this
  62. */
  63. public function withContent($finished, $pending, $rejected)
  64. {
  65. return $this->content(
  66. <<<HTML
  67. <div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
  68. <div class="chart-info d-flex justify-content-between mb-1 mt-2" >
  69. <div class="series-info d-flex align-items-center">
  70. <i class="fa fa-circle-o text-bold-700 text-primary"></i>
  71. <span class="text-bold-600 ml-50">Finished</span>
  72. </div>
  73. <div class="product-result">
  74. <span>{$finished}</span>
  75. </div>
  76. </div>
  77. <div class="chart-info d-flex justify-content-between mb-1">
  78. <div class="series-info d-flex align-items-center">
  79. <i class="fa fa-circle-o text-bold-700 text-warning"></i>
  80. <span class="text-bold-600 ml-50">Pending</span>
  81. </div>
  82. <div class="product-result">
  83. <span>{$pending}</span>
  84. </div>
  85. </div>
  86. <div class="chart-info d-flex justify-content-between mb-1">
  87. <div class="series-info d-flex align-items-center">
  88. <i class="fa fa-circle-o text-bold-700 text-danger"></i>
  89. <span class="text-bold-600 ml-50">Rejected</span>
  90. </div>
  91. <div class="product-result">
  92. <span>{$rejected}</span>
  93. </div>
  94. </div>
  95. </div>
  96. HTML
  97. );
  98. }
  99. }