Supplier.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. namespace app\operate\controller;
  3. use app\common\model\ChinaArea;
  4. use library\Controller;
  5. use think\Db;
  6. /**
  7. * 招聘
  8. * Class Supplier
  9. * @package app\operate\controller
  10. */
  11. class Supplier extends Controller
  12. {
  13. protected $table = 'Supplier';
  14. /**
  15. * 列表
  16. * @auth true
  17. * @menu true
  18. * @throws \think\Exception
  19. * @throws \think\db\exception\DataNotFoundException
  20. * @throws \think\db\exception\ModelNotFoundException
  21. * @throws \think\exception\DbException
  22. * @throws \think\exception\PDOException
  23. */
  24. public function index()
  25. {
  26. $this->title = '列表';
  27. $where = [];
  28. $where[] = ['f.is_deleted','=',0];
  29. if($title = input('title')) $where[] = ['f.title','like','%'.$title.'%'];
  30. $query = $this->_query($this->table)->alias('f')
  31. ->field('f.*')
  32. ->where($where)
  33. ->order('sort desc,f.id desc ')->page();
  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. * @auth true
  68. * @throws \think\Exception
  69. * @throws \think\exception\PDOException
  70. */
  71. public function del()
  72. {
  73. $this->_save($this->table, ['is_deleted' => '1']);
  74. }
  75. /**
  76. * 批量删除
  77. * @auth true
  78. * @throws \think\Exception
  79. * @throws \think\exception\PDOException
  80. */
  81. public function remove()
  82. {
  83. $this->_save($this->table, ['is_deleted' => '1']);
  84. }
  85. /**
  86. * 启用
  87. * @auth true
  88. * @menu true
  89. * @throws \think\Exception
  90. * @throws \think\exception\PDOException
  91. */
  92. public function enable()
  93. {
  94. $this->_save($this->table, ['status' => 1]);
  95. $this->success('已上架!');
  96. }
  97. /**
  98. * 禁用
  99. * @auth true
  100. * @menu true
  101. * @throws \think\Exception
  102. * @throws \think\db\exception\DataNotFoundException
  103. * @throws \think\db\exception\ModelNotFoundException
  104. * @throws \think\exception\DbException
  105. * @throws \think\exception\PDOException
  106. */
  107. public function forbidden()
  108. {
  109. $this->_save($this->table, ['status' => 0]);
  110. $this->success('已下架!');
  111. }
  112. /**
  113. * 表单数据处理
  114. * @param array $data
  115. */
  116. protected function _form_filter(&$data)
  117. {
  118. $all_cate = \app\common\model\SupplierCate::where(['is_deleted'=>0])->order('sort desc ,id desc')->select();
  119. $this->cate_tree = make_tree($all_cate);
  120. if ($this->request->isGet() && $this->request->action() == 'add') {
  121. $this->isAddMode = 1;
  122. }
  123. if ($this->request->isGet() && $this->request->action() == 'edit') {
  124. $this->isAddMode = 0;
  125. }
  126. if($this->request->isPost())
  127. {
  128. if($data['build_time'] == '' || $data['build_time'] == null){
  129. unset($data['build_time']);
  130. }
  131. }
  132. }
  133. protected function _form_result(&$data)
  134. {
  135. $this->success('操作成功', 'javascript:history.back()');
  136. }
  137. }