Meeting.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. * 租会议室
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Meeting extends Backend
  11. {
  12. /**
  13. * Meeting模型对象
  14. * @var \app\admin\model\Meeting
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Meeting;
  21. }
  22. public function import()
  23. {
  24. parent::import();
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. /**
  32. * 查看
  33. */
  34. public function index()
  35. {
  36. //当前是否为关联查询
  37. $this->relationSearch = true;
  38. //设置过滤方法
  39. $this->request->filter(['strip_tags', 'trim']);
  40. if ($this->request->isAjax()) {
  41. //如果发送的来源是Selectpage,则转发到Selectpage
  42. if ($this->request->request('keyField')) {
  43. return $this->selectpage();
  44. }
  45. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  46. $list = $this->model
  47. ->with(['city','parklists'])
  48. ->where($where)
  49. ->order($sort, $order)
  50. ->paginate($limit);
  51. foreach ($list as $row) {
  52. $row->getRelation('city')->visible(['name']);
  53. $row->getRelation('parklists')->visible(['name']);
  54. }
  55. $result = array("total" => $list->total(), "rows" => $list->items());
  56. return json($result);
  57. }
  58. return $this->view->fetch();
  59. }
  60. // 添加删除一级列表返回数据格式
  61. public function indexx()
  62. {
  63. // $data = Db::name('city')->field('id,name')->select();
  64. $res = [
  65. ['id' =>'00:00-01:00','name' =>'00:00-01:00'],
  66. ['id' =>'01:00-02:00','name' =>'01:00-02:00'],
  67. ['id' =>'02:00-03:00','name' =>'02:00-03:00'],
  68. ['id' =>'03:00-04:00','name' =>'03:00-04:00'],
  69. ['id' =>'04:00-05:00','name' =>'04:00-05:00'],
  70. ['id' =>'05:00-06:00','name' =>'05:00-06:00'],
  71. ['id' =>'06:00-07:00','name' =>'06:00-07:00'],
  72. ['id' =>'07:00-08:00','name' =>'07:00-08:00'],
  73. ['id' =>'08:00-09:00','name' =>'08:00-09:00'],
  74. ['id' =>'09:00-10:00','name' =>'09:00-10:00'],
  75. ['id' =>'10:00-11:00','name' =>'10:00-11:00'],
  76. ['id' =>'11:00-12:00','name' =>'11:00-12:00'],
  77. ['id' =>'12:00-13:00','name' =>'12:00-13:00'],
  78. ['id' =>'13:00-14:00','name' =>'13:00-14:00'],
  79. ['id' =>'14:00-15:00','name' =>'14:00-15:00'],
  80. ['id' =>'15:00-16:00','name' =>'15:00-16:00'],
  81. ['id' =>'16:00-17:00','name' =>'16:00-17:00'],
  82. ['id' =>'17:00-18:00','name' =>'17:00-18:00'],
  83. ['id' =>'18:00-19:00','name' =>'18:00-19:00'],
  84. ['id' =>'19:00-20:00','name' =>'19:00-20:00'],
  85. ['id' =>'20:00-21:00','name' =>'20:00-21:00'],
  86. ['id' =>'21:00-22:00','name' =>'21:00-22:00'],
  87. ['id' =>'22:00-23:00','name' =>'22:00-23:00'],
  88. ['id' =>'23:00-00:00','name' =>'23:00-00:00'],
  89. ];
  90. if($this->request->request("keyValue")){
  91. $keyValue = $this->request->request("keyValue");
  92. $keyValueArr = explode(',',$keyValue);
  93. foreach ($keyValueArr as $v) {
  94. foreach ($res as $m) {
  95. if ($m['id'] == $v) {
  96. $data[] = $m;
  97. }
  98. }
  99. }
  100. return ['total'=>count($data), 'list'=>$data];
  101. }
  102. return json(['list' => $res, 'total' => count($res)]);
  103. }
  104. }