链街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.

104 lines
2.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Metrics\Examples\Order;
  3. use App\Admin\Common\Order;
  4. use App\Models\ImsCjdcOrder;
  5. use App\Models\ImsCjdcOrderMain;
  6. use Dcat\Admin\Widgets\Metrics\Card;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Support\Facades\DB;
  9. class OrderData extends Card
  10. {
  11. protected $params;
  12. public function __construct($title=null,$data=[])
  13. {
  14. $this->params = $data;
  15. parent::__construct($title, null);
  16. }
  17. public function init()
  18. {
  19. parent::init(); // TODO: Change the autogenerated stub
  20. $this->dropdown([
  21. '1' => '今日',
  22. '-1' => '昨日',
  23. '7' => '最近7天',
  24. 'w' => '本周',
  25. 'lw' => '上周',
  26. '30' => '本月',
  27. '-30' => '上月'
  28. ]);
  29. }
  30. public function handle(Request $request)
  31. {
  32. $params = $request->get('params');//参数选项
  33. $option = $request->get('option',1);//数据选项
  34. //获取订单数据
  35. $result = $this->getOrderData($params,$option);
  36. $this->content($result);
  37. }
  38. /**
  39. * 查询结果
  40. * @param $params
  41. * @param $option
  42. * @return int
  43. */
  44. public function getOrderData($params,$option)
  45. {
  46. $result = Order::getOrderData($params,$option);
  47. return $result;
  48. }
  49. /**
  50. * 查询时间范围
  51. * @param $option
  52. * @return array
  53. */
  54. public function beginAndEnd($option)
  55. {
  56. list($beginTime,$endTime) = Order::beginAndEnd($option);
  57. return [$beginTime,$endTime];
  58. }
  59. /**
  60. * 构建数据模型
  61. * @param $condition
  62. * @return mixed
  63. */
  64. public function buildData()
  65. {
  66. $build = Order::buildData();
  67. return $build;
  68. }
  69. // 传递自定义参数到 handle 方法
  70. public function parameters(): array
  71. {
  72. return [
  73. 'params'=>$this->params
  74. ];
  75. }
  76. /**
  77. * 渲染卡片内容
  78. * @return string
  79. */
  80. public function renderContent()
  81. {
  82. $content = parent::renderContent();
  83. return <<<HTML
  84. <div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
  85. <h2 class="ml-1 font-large-1 text-primary">{$content}</h2>
  86. </div>
  87. HTML;
  88. }
  89. }