SupplierGoods.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. $this->supplier_id = $supplier_id;
  33. $query = $this->_query($this->table)->where('is_deleted',0)->where('supplier_id',$supplier_id);
  34. $query->like('name');
  35. $query->order(' sort desc , id desc')->page();
  36. }
  37. /**
  38. * 数据列表处理
  39. * @auth true
  40. * @menu true
  41. * @param array $data
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @throws \think\exception\DbException
  45. */
  46. protected function _index_page_filter(&$data)
  47. {
  48. }
  49. /**
  50. * 添加供货商商品
  51. * @auth true
  52. * @menu true
  53. * @throws \think\Exception
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @throws \think\exception\DbException
  57. * @throws \think\exception\PDOException
  58. */
  59. public function add()
  60. {
  61. $this->title = '添加供货商商品';
  62. $this->supplier_id = input('supplier_id');
  63. $this->_form($this->table, 'form');
  64. }
  65. /**
  66. * 编辑供货商商品
  67. * @auth true
  68. * @menu true
  69. * @throws \think\Exception
  70. * @throws \think\db\exception\DataNotFoundException
  71. * @throws \think\db\exception\ModelNotFoundException
  72. * @throws \think\exception\DbException
  73. * @throws \think\exception\PDOException
  74. */
  75. public function edit()
  76. {
  77. $this->title = '编辑供货商商品';
  78. $this->supplier_id = input('supplier_id');
  79. $this->_form($this->table, 'form');
  80. }
  81. /**
  82. * 启用
  83. * @auth true
  84. * @menu true
  85. * @throws \think\Exception
  86. * @throws \think\exception\PDOException
  87. */
  88. public function enable()
  89. {
  90. $this->_save($this->table, ['status' => 1]);
  91. }
  92. /**
  93. * 删除
  94. * @auth true
  95. * @menu true
  96. * @throws \think\Exception
  97. * @throws \think\exception\PDOException
  98. */
  99. public function del()
  100. {
  101. $this->_save($this->table, ['is_deleted' => 1]);
  102. }
  103. /**
  104. * 表单数据处理
  105. * @auth true
  106. * @menu true
  107. * @param array $data
  108. */
  109. protected function _form_filter(&$data)
  110. {
  111. // 视频
  112. $this->video_list = \app\common\model\VideoIntro::with('videoArr')
  113. ->where(['is_deleted'=>0])->order('id desc')
  114. ->select()->toArray();
  115. // 文章列表
  116. $this->article_list = \app\common\model\ArticleIntro::with('itemList')
  117. ->where(['is_deleted'=>0])->order('id desc')
  118. ->select()->toArray();
  119. // 资料
  120. $this->datum_list = DatumIntro::with('urlArr')
  121. ->where(['is_deleted'=>0])->order('id desc')
  122. ->select()->toArray();
  123. $data['create_at'] = date('Y-m-d H:i:s');
  124. }
  125. protected function _form_result($id)
  126. {
  127. // $supplier_id = \app\common\model\SupplierGoods::where('id',$id)->value('supplier_id');
  128. // $this->redirect('@operate/supplier_goods/index',['id'=>$supplier_id,'spm'=>'m-277-294-296']);
  129. // $this->redirect('/operate/supplier_goods/index.html?id='.$supplier_id.'&spm=m-277-294-296');
  130. }
  131. }