SupplierGoods.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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.supplier_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[] = ['a.supplier_id','=',$supplier_id];
  37. if($company_id)$where[] = ['a.company_id','=',$company_id];
  38. $query = $this->_query($this->table)->where($where)->like('a.name')->field('a.*,b.title supplier_name ,c.title company_name');
  39. $query->leftJoin('Supplier b','b.id = a.supplier_id')->leftJoin('Company c','c.id = a.company_id');
  40. $query->order(' sort desc , id desc')->page();
  41. }
  42. /**
  43. * 数据列表处理
  44. * @auth true
  45. * @menu true
  46. * @param array $data
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\ModelNotFoundException
  49. * @throws \think\exception\DbException
  50. */
  51. protected function _index_page_filter(&$data)
  52. {
  53. }
  54. /**
  55. * 添加供货商商品
  56. * @auth true
  57. * @menu true
  58. * @throws \think\Exception
  59. * @throws \think\db\exception\DataNotFoundException
  60. * @throws \think\db\exception\ModelNotFoundException
  61. * @throws \think\exception\DbException
  62. * @throws \think\exception\PDOException
  63. */
  64. public function add()
  65. {
  66. $this->title = '添加供货商商品';
  67. $this->supplier_id = input('supplier_id');
  68. $this->_form($this->table, 'form');
  69. }
  70. /**
  71. * 编辑供货商商品
  72. * @auth true
  73. * @menu true
  74. * @throws \think\Exception
  75. * @throws \think\db\exception\DataNotFoundException
  76. * @throws \think\db\exception\ModelNotFoundException
  77. * @throws \think\exception\DbException
  78. * @throws \think\exception\PDOException
  79. */
  80. public function edit()
  81. {
  82. $this->title = '编辑供货商商品';
  83. $this->supplier_id = input('supplier_id');
  84. $this->_form($this->table, 'form');
  85. }
  86. /**
  87. * 启用
  88. * @auth true
  89. * @menu true
  90. * @throws \think\Exception
  91. * @throws \think\exception\PDOException
  92. */
  93. public function enable()
  94. {
  95. $this->_save($this->table, ['status' => 1]);
  96. }
  97. /**
  98. * 删除
  99. * @auth true
  100. * @menu true
  101. * @throws \think\Exception
  102. * @throws \think\exception\PDOException
  103. */
  104. public function del()
  105. {
  106. $this->_save($this->table, ['is_deleted' => 1]);
  107. }
  108. /**
  109. * 表单数据处理
  110. * @auth true
  111. * @menu true
  112. * @param array $data
  113. */
  114. protected function _form_filter(&$data)
  115. {
  116. // 视频
  117. $this->video_list = \app\common\model\VideoIntro::with('videoArr')
  118. ->where(['is_deleted'=>0])->order('id desc')
  119. ->select()->toArray();
  120. // 文章列表
  121. $this->article_list = \app\common\model\ArticleIntro::with('itemChildren')
  122. ->field('id,title')
  123. ->where(['is_deleted'=>0])->order('id desc')
  124. ->select()->toArray();
  125. // 资料
  126. $this->datum_list = DatumIntro::with('urlArr')
  127. ->where(['is_deleted'=>0])->order('id desc')
  128. ->select()->toArray();
  129. $data['create_at'] = date('Y-m-d H:i:s');
  130. $this->supplier_list = \app\common\model\Supplier::getSupplierName();
  131. $this->company_list = \app\common\model\Company::getCompanyName();
  132. $this->assign('waitSecond','1');
  133. $this->assign("jumpUrl",$_SERVER["HTTP_REFERER"]);
  134. }
  135. protected function _form_result($id)
  136. {
  137. $this->success('操作成功', 'javascript:history.back()');
  138. }
  139. }