Company.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 Company
  9. * @package app\operate\controller
  10. */
  11. class Company extends Controller
  12. {
  13. protected $table = 'Company';
  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. * @menu true
  79. * @throws \think\Exception
  80. * @throws \think\exception\PDOException
  81. */
  82. public function enable()
  83. {
  84. $this->_save($this->table, ['status' => 1]);
  85. $this->success('已启用!');
  86. }
  87. /**
  88. * 禁用
  89. * @auth true
  90. * @menu true
  91. * @throws \think\Exception
  92. * @throws \think\db\exception\DataNotFoundException
  93. * @throws \think\db\exception\ModelNotFoundException
  94. * @throws \think\exception\DbException
  95. * @throws \think\exception\PDOException
  96. */
  97. public function forbidden()
  98. {
  99. $this->_save($this->table, ['status' => 0]);
  100. $this->success('已禁用!');
  101. }
  102. /**
  103. * 表单数据处理
  104. * @param array $data
  105. */
  106. protected function _form_filter(&$data)
  107. {
  108. $all_cate = \app\common\model\SupplierCate::where(['is_deleted'=>0])->order('sort desc ,id desc')->select();
  109. $this->cate_tree = make_tree($all_cate);
  110. if ($this->request->isGet() && $this->request->action() == 'add') {
  111. $this->isAddMode = 1;
  112. }
  113. if ($this->request->isGet() && $this->request->action() == 'edit') {
  114. $this->isAddMode = 0;
  115. }
  116. if($this->request->isPost())
  117. {
  118. }
  119. }
  120. protected function _form_result(&$data)
  121. {
  122. $this->success('操作成功', 'javascript:history.back()');
  123. }
  124. }