SupplierClassify.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 SupplierClassify
  10. * @package app\operate\controller
  11. */
  12. class SupplierClassify extends Controller
  13. {
  14. /**
  15. * 绑定数据表
  16. * @var string
  17. */
  18. protected $table = 'SupplierCate';
  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. $this->title = '分类列表';
  32. $query = $this->_query($this->table)->where('is_deleted',0)->like('title')
  33. ->where('pid',0)
  34. ->order('sort desc,id asc')->page();
  35. }
  36. /**
  37. * 添加分类
  38. * @auth true
  39. * @menu true
  40. * @throws \think\Exception
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @throws \think\exception\DbException
  44. * @throws \think\exception\PDOException
  45. */
  46. public function add()
  47. {
  48. $this->title = '添加分类';
  49. $this->_form($this->table, 'form');
  50. }
  51. /**
  52. * 编辑分类
  53. * @auth true
  54. * @menu true
  55. * @throws \think\Exception
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. * @throws \think\exception\DbException
  59. * @throws \think\exception\PDOException
  60. */
  61. public function edit()
  62. {
  63. $this->title = '编辑分类';
  64. $this->_form($this->table, 'form');
  65. }
  66. /**
  67. * 表单数据处理
  68. * @param array $vo
  69. * @throws \ReflectionException
  70. * @throws \think\db\exception\DataNotFoundException
  71. * @throws \think\db\exception\ModelNotFoundException
  72. * @throws \think\exception\DbException
  73. */
  74. protected function _form_filter(&$data)
  75. {
  76. if($this->request->action() == 'edit') unset($data['pid']);
  77. }
  78. /**
  79. * 启用
  80. * @auth true
  81. * @menu true
  82. * @throws \think\Exception
  83. * @throws \think\exception\PDOException
  84. */
  85. public function resume()
  86. {
  87. $this->_save($this->table, ['status' => '1']);
  88. }
  89. /**
  90. * 禁用
  91. * @auth true
  92. * @menu true
  93. * @throws \think\Exception
  94. * @throws \think\db\exception\DataNotFoundException
  95. * @throws \think\db\exception\ModelNotFoundException
  96. * @throws \think\exception\DbException
  97. * @throws \think\exception\PDOException
  98. */
  99. public function forbid()
  100. {
  101. $this->_save($this->table, ['status' => '0']);
  102. }
  103. /**
  104. * 删除
  105. * @auth true
  106. * @menu true
  107. * @throws \think\Exception
  108. * @throws \think\exception\PDOException
  109. */
  110. public function remove()
  111. {
  112. $this->_save($this->table, ['is_deleted' => 1]);
  113. }
  114. /**
  115. * 二级分类列表
  116. * @auth true
  117. * @menu true
  118. * @throws \think\Exception
  119. * @throws \think\exception\PDOException
  120. */
  121. public function second(){
  122. $this->title ='二级分类';
  123. $pid = input('pid');
  124. $list = $this->_query('SupplierCate')
  125. ->where(['is_deleted'=>0,'pid'=>$pid])
  126. ->like('title')
  127. ->order('id desc')->page();
  128. $this->assign('list',$list);
  129. $this->fetch('');
  130. }
  131. /**
  132. * 三级分类列表
  133. * @auth true
  134. * @menu true
  135. * @throws \think\Exception
  136. * @throws \think\exception\PDOException
  137. */
  138. public function third(){
  139. $this->title ='三级分类';
  140. $pid = input('pid');
  141. $list = $this->_query('SupplierCate')
  142. ->where(['is_deleted'=>0,'pid'=>$pid])
  143. ->like('title')
  144. ->order('id desc')->page();
  145. $this->assign('list',$list);
  146. $this->fetch('');
  147. }
  148. }