Dashboard.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * ----------------------------------------------------------------------------
  4. * 行到水穷处,坐看云起时
  5. * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
  6. * ----------------------------------------------------------------------------
  7. * Author: 老成
  8. * email:85556713@qq.com
  9. */
  10. declare (strict_types = 1);
  11. namespace app\admin\controller;
  12. use app\common\model\Admin;
  13. use app\common\model\delivery\Text;
  14. use app\common\model\User;
  15. use app\common\model\StockDetail;
  16. use app\common\model\StockConfig;
  17. use app\common\library\Date;
  18. use app\common\controller\Backend;
  19. use think\annotation\route\Route;
  20. use think\facade\Db;
  21. /**
  22. * 控制台
  23. */
  24. class Dashboard extends Backend
  25. {
  26. public function _initialize()
  27. {
  28. parent::_initialize();
  29. }
  30. /**
  31. * 查看
  32. */
  33. #[Route('GET','dashboard/index')]
  34. public function index(StockConfig $stockConfig, StockDetail $stockDetail)
  35. {
  36. if($this->request->isAjax()){
  37. //模拟数据面板
  38. $panel=[
  39. rand(100,1000),
  40. rand(100,1000),
  41. rand(100,1000),
  42. rand(100,1000),
  43. ];
  44. $variety = [];
  45. $box = [];
  46. $material = [];
  47. $list = $stockConfig->where('status', $stockConfig::StatusNormal)->field('id,type_id,title')->orderRaw("field('variety_name','packing_box','material')")->select();
  48. foreach ($list as $item) {
  49. switch ($item['type_id']) {
  50. case $stockConfig::VarietyName:
  51. $variety[] = [
  52. 'name' => $item->title,
  53. 'num' => $stockDetail->where('key', $item['id'])->value('num')
  54. ];
  55. break;
  56. case $stockConfig::PackingBox:
  57. $box[] = [
  58. 'name' => $item->title,
  59. 'num' => $stockDetail->where('key', $item['id'])->value('num')
  60. ];
  61. break;
  62. case $stockConfig::Material:
  63. $material[] = [
  64. 'name' => $item->title,
  65. 'num' => $stockDetail->where('key', $item['id'])->value('num')
  66. ];
  67. break;
  68. }
  69. }
  70. $this->success('',compact('panel','variety','box','material'));
  71. }
  72. return $this->fetch();
  73. }
  74. #[Route('GET','dashboard/platform1')]
  75. public function platform1()
  76. {
  77. return $this->fetch();
  78. }
  79. #[Route('GET','dashboard/platform2')]
  80. public function platform2()
  81. {
  82. return $this->fetch();
  83. }
  84. }