SupplierGoods.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace app\operate\controller;
  3. use app\common\model\DatumIntro;
  4. use library\Controller;
  5. use think\Db;
  6. /**
  7. * 供货商商品
  8. * Class SupplierGoods
  9. * @package app\mall\controller
  10. */
  11. class SupplierGoods extends Controller
  12. {
  13. /**
  14. * 绑定数据表
  15. * @var string
  16. */
  17. protected $table = 'SupplierGoods';
  18. /**
  19. * 供货商商品列表
  20. * @auth true
  21. * @menu true
  22. * @throws \think\Exception
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @throws \think\exception\PDOException
  27. */
  28. public function index()
  29. {
  30. $this->title = '供货商商品列表';
  31. $supplier_id = input('get.id');
  32. $company_id = input('get.company_id');
  33. $this->supplier_id = $supplier_id;
  34. $where = [];
  35. $where[] = ['is_deleted','=',0];
  36. if($supplier_id)$where[] = ['supplier_id','=',$supplier_id];
  37. if($company_id)$where[] = ['company_id','=',$company_id];
  38. $query = $this->_query($this->table)->where($where)->like('name');
  39. $query->order(' sort desc , id desc')->page();
  40. }
  41. /**
  42. * 数据列表处理
  43. * @auth true
  44. * @menu true
  45. * @param array $data
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @throws \think\exception\DbException
  49. */
  50. protected function _index_page_filter(&$data)
  51. {
  52. }
  53. /**
  54. * 添加供货商商品
  55. * @auth true
  56. * @menu true
  57. * @throws \think\Exception
  58. * @throws \think\db\exception\DataNotFoundException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. * @throws \think\exception\DbException
  61. * @throws \think\exception\PDOException
  62. */
  63. public function add()
  64. {
  65. $this->title = '添加供货商商品';
  66. $this->supplier_id = input('supplier_id');
  67. $this->_form($this->table, 'form');
  68. }
  69. /**
  70. * 编辑供货商商品
  71. * @auth true
  72. * @menu true
  73. * @throws \think\Exception
  74. * @throws \think\db\exception\DataNotFoundException
  75. * @throws \think\db\exception\ModelNotFoundException
  76. * @throws \think\exception\DbException
  77. * @throws \think\exception\PDOException
  78. */
  79. public function edit()
  80. {
  81. $this->title = '编辑供货商商品';
  82. $this->supplier_id = input('supplier_id');
  83. $this->_form($this->table, 'form');
  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. }
  96. /**
  97. * 删除
  98. * @auth true
  99. * @menu true
  100. * @throws \think\Exception
  101. * @throws \think\exception\PDOException
  102. */
  103. public function del()
  104. {
  105. $this->_save($this->table, ['is_deleted' => 1]);
  106. }
  107. /**
  108. * 表单数据处理
  109. * @auth true
  110. * @menu true
  111. * @param array $data
  112. */
  113. protected function _form_filter(&$data)
  114. {
  115. // 视频
  116. $this->video_list = \app\common\model\VideoIntro::with('videoArr')
  117. ->where(['is_deleted'=>0])->order('id desc')
  118. ->select()->toArray();
  119. // 文章列表
  120. $this->article_list = \app\common\model\ArticleIntro::with('itemChildren')
  121. ->field('id,title')
  122. ->where(['is_deleted'=>0])->order('id desc')
  123. ->select()->toArray();
  124. // 资料
  125. $this->datum_list = DatumIntro::with('urlArr')
  126. ->where(['is_deleted'=>0])->order('id desc')
  127. ->select()->toArray();
  128. $data['create_at'] = date('Y-m-d H:i:s');
  129. $this->assign('waitSecond','1');
  130. $this->assign("jumpUrl",$_SERVER["HTTP_REFERER"]);
  131. }
  132. protected function _form_result($id)
  133. {
  134. $this->success('操作成功', 'javascript:history.back()');
  135. }
  136. }