DataNumber.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace UCore\DcatAdmin\Metrics\Examples;
  3. use App\Module\Order\Enums\Status;
  4. use App\Module\Order\Model\Order;
  5. use App\Module\Wallet\Guidance;
  6. use Carbon\Carbon;
  7. use Dcat\Admin\Widgets\Metrics\Line;
  8. use Dcat\Admin\Widgets\Metrics\RadialBar;
  9. use UCore\Helper\Cache;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Support\Str;
  12. /**
  13. * 显示多个数值
  14. * 两行
  15. *
  16. */
  17. class DataNumber extends RadialBar
  18. {
  19. protected $contentWidth = [12, 0];
  20. protected $chartPullRight =true;
  21. /**
  22. * 初始化卡片内容
  23. */
  24. protected function init()
  25. {
  26. $this->id('metric-card-'.Str::random(8));
  27. $this->class('card');
  28. $this->height(220);
  29. $this->dropdown([
  30. '1' => '最近 1 天',
  31. '7' => '最近 7 天',
  32. '30' => '最近 30 天',
  33. '90' => '最近 90 天',
  34. ]);
  35. }
  36. /**
  37. * 卡片内容
  38. *
  39. * @param string $count
  40. *
  41. * @return $this
  42. */
  43. public function withContent($dataList)
  44. {
  45. $string = '';
  46. foreach ($dataList as $key => $value){
  47. $string.= <<<HTML
  48. <div class="text-center" style="font-weight: 600">
  49. <h4>{$key}</h4>
  50. <span class="font-md-5" style="min-width: 90px;">{$value}</span>
  51. </div>
  52. HTML;
  53. }
  54. return $this->content(
  55. <<<HTML
  56. <div class="d-flex justify-content-between p-1 ">
  57. $string
  58. </div>
  59. HTML
  60. );
  61. }
  62. /**
  63. * 卡片底部内容.
  64. *
  65. * @param string $new
  66. * @param string $open
  67. * @param string $response
  68. *
  69. * @return $this
  70. */
  71. public function withFooter($dataList )
  72. {
  73. $string = '';
  74. foreach ($dataList as $key => $value) {
  75. $string .= <<<HTML
  76. <div class="text-center">
  77. <p>$key</p>
  78. <span class="font-md-5">{$value}</span>
  79. </div>
  80. HTML;
  81. }
  82. return $this->footer(
  83. <<<HTML
  84. <div class="d-flex justify-content-between p-1" style="padding-top: 0!important;">
  85. $string
  86. </div>
  87. HTML
  88. );
  89. }
  90. }