SupplierGoods.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace app\operate\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 供货商商品
  7. * Class SupplierGoods
  8. * @package app\mall\controller
  9. */
  10. class SupplierGoods extends Controller
  11. {
  12. /**
  13. * 绑定数据表
  14. * @var string
  15. */
  16. protected $table = 'SupplierGoods';
  17. /**
  18. * 供货商商品列表
  19. * @auth true
  20. * @menu true
  21. * @throws \think\Exception
  22. * @throws \think\db\exception\DataNotFoundException
  23. * @throws \think\db\exception\ModelNotFoundException
  24. * @throws \think\exception\DbException
  25. * @throws \think\exception\PDOException
  26. */
  27. public function index()
  28. {
  29. $this->title = '供货商商品列表';
  30. $supplier_id = input('get.id');
  31. $this->supplier_id = $supplier_id;
  32. $query = $this->_query($this->table)->where('is_deleted',0)->where('supplier_id',$supplier_id);
  33. $query->like('name');
  34. $query->order(' sort desc , id desc')->page();
  35. }
  36. /**
  37. * 数据列表处理
  38. * @auth true
  39. * @menu true
  40. * @param array $data
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @throws \think\exception\DbException
  44. */
  45. protected function _index_page_filter(&$data)
  46. {
  47. }
  48. /**
  49. * 添加供货商商品
  50. * @auth true
  51. * @menu true
  52. * @throws \think\Exception
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\ModelNotFoundException
  55. * @throws \think\exception\DbException
  56. * @throws \think\exception\PDOException
  57. */
  58. public function add()
  59. {
  60. $this->title = '添加供货商商品';
  61. $this->_form($this->table, 'form');
  62. }
  63. /**
  64. * 编辑供货商商品
  65. * @auth true
  66. * @menu true
  67. * @throws \think\Exception
  68. * @throws \think\db\exception\DataNotFoundException
  69. * @throws \think\db\exception\ModelNotFoundException
  70. * @throws \think\exception\DbException
  71. * @throws \think\exception\PDOException
  72. */
  73. public function edit()
  74. {
  75. $this->title = '编辑供货商商品';
  76. $this->supplier_id = input('supplier_id');
  77. $this->_form($this->table, 'form');
  78. }
  79. /**
  80. * 启用
  81. * @auth true
  82. * @menu true
  83. * @throws \think\Exception
  84. * @throws \think\exception\PDOException
  85. */
  86. public function enable()
  87. {
  88. $this->_save($this->table, ['status' => 1]);
  89. }
  90. /**
  91. * 删除
  92. * @auth true
  93. * @menu true
  94. * @throws \think\Exception
  95. * @throws \think\exception\PDOException
  96. */
  97. public function del()
  98. {
  99. $this->_save($this->table, ['is_deleted' => 1]);
  100. }
  101. /**
  102. * 表单数据处理
  103. * @auth true
  104. * @menu true
  105. * @param array $data
  106. */
  107. protected function _form_filter(&$data)
  108. {
  109. $data['create_at'] = date('Y-m-d H:i:s');
  110. }
  111. }