ProductOrders.stub 3.0 KB

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