TemplateItem.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. namespace app\operate\controller;
  3. use library\Controller;
  4. use library\service\MenuService;
  5. use library\tools\Data;
  6. use think\Db;
  7. /**
  8. * 活动报名模板详情
  9. * Class TemplateItem
  10. * @package app\operate\controller
  11. */
  12. class TemplateItem extends Controller
  13. {
  14. /**
  15. * 绑定数据表
  16. * @var string
  17. */
  18. protected $table = 'ActivityTemplateItem';
  19. /**
  20. * 模板列表
  21. * @auth true
  22. * @menu true
  23. * @throws \think\Exception
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. * @throws \think\exception\PDOException
  28. */
  29. public function index()
  30. {
  31. $template = input('template_id');
  32. $this->title = '列表';
  33. $query = $this->_query($this->table)
  34. ->where('is_deleted',0)
  35. ->where('template_id',$template)
  36. ->order('id asc')->page();
  37. }
  38. /**
  39. * 数据列表处理
  40. * @auth true
  41. * @menu true
  42. * @param array $data
  43. * @throws \think\db\exception\DataNotFoundException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. * @throws \think\exception\DbException
  46. */
  47. protected function _index_page_filter(&$data)
  48. {
  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 add()
  61. {
  62. $this->title = '添加';
  63. $this->_form($this->table, 'form');
  64. }
  65. /**
  66. * 编辑
  67. * @auth true
  68. * @menu true
  69. * @throws \think\Exception
  70. * @throws \think\db\exception\DataNotFoundException
  71. * @throws \think\db\exception\ModelNotFoundException
  72. * @throws \think\exception\DbException
  73. * @throws \think\exception\PDOException
  74. */
  75. public function edit()
  76. {
  77. $this->title = '编辑';
  78. $this->_form($this->table, 'form');
  79. }
  80. /**
  81. * 表单数据处理
  82. * @param array $vo
  83. * @throws \ReflectionException
  84. * @throws \think\db\exception\DataNotFoundException
  85. * @throws \think\db\exception\ModelNotFoundException
  86. * @throws \think\exception\DbException
  87. */
  88. protected function _form_filter(&$vo)
  89. {
  90. if($this->request->isGet()) {
  91. $this->param_set = !empty($vo['extend']) ? json_decode($vo['extend'],true) : [['title'=>'']];
  92. }
  93. if($this->request->isPost())
  94. {
  95. list($post,$item_arr) = [$this->request->post(),[]];
  96. foreach ($post['item_title'] as $v) {
  97. $item_arr[] = [
  98. 'item_title'=>$v,
  99. 'value'=>0,
  100. ];
  101. }
  102. $vo['extend'] = $vo['type'] == 3 ? json_encode($item_arr) : null;
  103. }
  104. }
  105. /**
  106. * 启用
  107. * @auth true
  108. * @menu true
  109. * @throws \think\Exception
  110. * @throws \think\exception\PDOException
  111. */
  112. public function resume()
  113. {
  114. $this->_save($this->table, ['status' => '1']);
  115. }
  116. /**
  117. * 禁用
  118. * @auth true
  119. * @menu true
  120. * @throws \think\Exception
  121. * @throws \think\db\exception\DataNotFoundException
  122. * @throws \think\db\exception\ModelNotFoundException
  123. * @throws \think\exception\DbException
  124. * @throws \think\exception\PDOException
  125. */
  126. public function forbid()
  127. {
  128. $this->_save($this->table, ['status' => '0']);
  129. }
  130. /**
  131. * 删除
  132. * @auth true
  133. * @menu true
  134. * @throws \think\Exception
  135. * @throws \think\exception\PDOException
  136. */
  137. public function remove()
  138. {
  139. $this->_save($this->table, ['is_deleted' => 1]);
  140. }
  141. }