Company.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\store\controller;
  15. use library\Controller;
  16. use library\tools\Data;
  17. use think\Db;
  18. /**
  19. * 公司信息
  20. * Class Goods
  21. * @package app\store\controller
  22. */
  23. class Company extends Controller
  24. {
  25. /**
  26. * 指定数据表
  27. * @var string
  28. */
  29. protected $table = 'StoreCompany';
  30. /**
  31. * 公司信息
  32. * @auth true
  33. * @menu true
  34. * @throws \think\Exception
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. * @throws \think\exception\DbException
  38. * @throws \think\exception\PDOException
  39. */
  40. public function index()
  41. {
  42. $this->title = '公司信息';
  43. $query = $this->_query($this->table);
  44. $query->where(['is_deleted' => '0'])->order('id desc')->page();
  45. }
  46. /**
  47. * 数据列表处理
  48. * @param array $data
  49. * @throws \think\db\exception\DataNotFoundException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. * @throws \think\exception\DbException
  52. */
  53. protected function _index_page_filter(&$data)
  54. {
  55. foreach ($data as &$vo) {
  56. $vo['brand_protection'] = image_path($vo['brand_protection']);
  57. $vo['license'] = image_path($vo['license']);
  58. }
  59. }
  60. /**
  61. * 添加公司信息
  62. * @auth true
  63. * @throws \think\Exception
  64. * @throws \think\db\exception\DataNotFoundException
  65. * @throws \think\db\exception\ModelNotFoundException
  66. * @throws \think\exception\DbException
  67. * @throws \think\exception\PDOException
  68. */
  69. public function add()
  70. {
  71. $this->title = '添加公司信息';
  72. $this->isAddMode = '1';
  73. $this->_form($this->table, 'form');
  74. }
  75. /**
  76. * 编辑公司信息
  77. * @auth true
  78. * @throws \think\Exception
  79. * @throws \think\db\exception\DataNotFoundException
  80. * @throws \think\db\exception\ModelNotFoundException
  81. * @throws \think\exception\DbException
  82. * @throws \think\exception\PDOException
  83. */
  84. public function edit()
  85. {
  86. $this->title = '编辑公司信息';
  87. $this->isAddMode = '0';
  88. $this->_form($this->table, 'form');
  89. }
  90. /**
  91. * 表单数据处理
  92. * @param array $data
  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. protected function _form_filter(&$data)
  100. {
  101. // 生成公司信息ID
  102. if(empty($data['id'])){
  103. $goods_id = Db::name('store_company')->order('id desc')->value('id');
  104. $data['id'] = $goods_id + 1;
  105. }
  106. if ($this->request->isGet()) {
  107. } elseif ($this->request->isPost()) {
  108. }
  109. }
  110. /**
  111. * 表单结果处理
  112. * @param boolean $result
  113. */
  114. protected function _form_result($result)
  115. {
  116. if ($result && $this->request->isPost()) {
  117. $this->success('公司信息编辑成功!', 'javascript:history.back()');
  118. }
  119. }
  120. /**
  121. * 禁用公司信息
  122. * @auth true
  123. * @throws \think\Exception
  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. * @throws \think\Exception
  134. * @throws \think\exception\PDOException
  135. */
  136. public function resume()
  137. {
  138. $this->_save($this->table, ['status' => '1']);
  139. }
  140. /**
  141. * 删除公司信息
  142. * @auth true
  143. * @throws \think\Exception
  144. * @throws \think\exception\PDOException
  145. */
  146. public function remove()
  147. {
  148. $this->_delete($this->table);
  149. }
  150. }