ActivitySchedule.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. namespace app\operate\controller;
  3. use library\Controller;
  4. /**
  5. * 日程
  6. * Class ActivitySchedule
  7. * @package app\operate\controller
  8. */
  9. class ActivitySchedule extends Controller
  10. {
  11. /**
  12. * 绑定数据表
  13. * @var string
  14. */
  15. protected $table = 'ActivitySchedule';
  16. /**
  17. * 日程列表
  18. * @auth true
  19. * @menu true
  20. * @throws \think\Exception
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. * @throws \think\exception\DbException
  24. * @throws \think\exception\PDOException
  25. */
  26. public function index()
  27. {
  28. $this->title = '日程列表';
  29. $act_id = input('get.act_id');
  30. $query = $this->_query($this->table)->where('is_deleted',0)->like('title')
  31. ->where('pid',0)
  32. ->where('act_id',$act_id)
  33. ->order('sort desc,id asc')->page(false);
  34. }
  35. /**
  36. * 添加日程
  37. * @auth true
  38. * @menu true
  39. * @throws \think\Exception
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. * @throws \think\exception\DbException
  43. * @throws \think\exception\PDOException
  44. */
  45. public function add()
  46. {
  47. $this->title = '添加日程';
  48. $this->_form($this->table, 'form');
  49. }
  50. /**
  51. * 编辑日程
  52. * @auth true
  53. * @menu true
  54. * @throws \think\Exception
  55. * @throws \think\db\exception\DataNotFoundException
  56. * @throws \think\db\exception\ModelNotFoundException
  57. * @throws \think\exception\DbException
  58. * @throws \think\exception\PDOException
  59. */
  60. public function edit()
  61. {
  62. $this->title = '编辑日程';
  63. $this->_form($this->table, 'form');
  64. }
  65. /**
  66. * 表单数据处理
  67. * @param array $vo
  68. * @throws \ReflectionException
  69. * @throws \think\db\exception\DataNotFoundException
  70. * @throws \think\db\exception\ModelNotFoundException
  71. * @throws \think\exception\DbException
  72. */
  73. protected function _form_filter(&$data)
  74. {
  75. if($this->request->isGet()) {
  76. $this->schedule_list = !empty($data['schedule_list']) ? json_decode($data['schedule_list'],true):[];
  77. $pid = isset($data['pid']) ? $data['pid'] : 0;
  78. if(input('get.pid')) $pid = input('get.pid');
  79. $this->pid = $pid;
  80. }
  81. if($this->request->isPost()) {
  82. $theme_arr= input('post.theme');
  83. $theme_time= input('post.theme_time');
  84. $schedule_list = [];
  85. if(!empty($theme_arr)){
  86. foreach ($theme_arr as $k=>$t){
  87. if($t) $schedule_list[] = ['theme'=>$t,'theme_time'=>$theme_time[$k]];
  88. }
  89. }
  90. if($data['pid']) {
  91. $data['date_time'] =\app\common\model\ActivitySchedule::where('id',$data['pid'])->value('date_time');
  92. }
  93. if(!empty($data)) $data['schedule_list'] = json_encode($schedule_list);
  94. }
  95. }
  96. /**
  97. * 启用
  98. * @auth true
  99. * @menu true
  100. * @throws \think\Exception
  101. * @throws \think\exception\PDOException
  102. */
  103. public function resume()
  104. {
  105. $this->_save($this->table, ['status' => '1']);
  106. }
  107. /**
  108. * 禁用
  109. * @auth true
  110. * @menu true
  111. * @throws \think\Exception
  112. * @throws \think\db\exception\DataNotFoundException
  113. * @throws \think\db\exception\ModelNotFoundException
  114. * @throws \think\exception\DbException
  115. * @throws \think\exception\PDOException
  116. */
  117. public function forbid()
  118. {
  119. $this->_save($this->table, ['status' => '0']);
  120. }
  121. /**
  122. * 删除
  123. * @auth true
  124. * @menu true
  125. * @throws \think\Exception
  126. * @throws \think\exception\PDOException
  127. */
  128. public function remove()
  129. {
  130. $this->_save($this->table, ['is_deleted' => 1]);
  131. }
  132. /**
  133. * 二级日程列表
  134. * @auth true
  135. * @menu true
  136. * @throws \think\Exception
  137. * @throws \think\exception\PDOException
  138. */
  139. public function second(){
  140. $this->title ='二级日程';
  141. $pid = input('pid');
  142. $list = $this->_query('ActivitySchedule')
  143. ->where(['is_deleted'=>0,'pid'=>$pid])
  144. ->like('title')
  145. ->order('id desc')->page();
  146. $this->assign('list',$list);
  147. $this->fetch('');
  148. }
  149. }