ShopList.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\controller\shop;
  4. use app\common\controller\Backend;
  5. use think\annotation\route\Group;
  6. use think\annotation\route\Route;
  7. use app\admin\traits\Actions;
  8. use app\common\model\Customer;
  9. use app\common\model\User;
  10. use app\common\model\ShopList as ShopListModel;
  11. #[Group("shop/shop_list")]
  12. class ShopList extends Backend
  13. {
  14. use Actions{
  15. add as protected _add;
  16. edit as protected _edit;
  17. }
  18. protected function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = new ShopListModel();
  22. $this->assign('customerList', Customer::where('status',Customer::STATUS_NORMAL)->column('name','id'));
  23. $this->assign('platformList', config("app.platform_list"));
  24. $this->assign('userList', User::where('status',Customer::STATUS_NORMAL)->column('nickname','id'));
  25. $this->relationField=['customer','staff'];
  26. }
  27. #[Route('GET,POST','add')]
  28. public function add()
  29. {
  30. if($this->request->isPost()){
  31. }
  32. return $this->_add();
  33. }
  34. #[Route('GET,POST','edit')]
  35. public function edit()
  36. {
  37. $ids = $this->request->get('ids');
  38. $row = $this->model->find($ids);
  39. //...可以对row进行一些前置的操作
  40. if($this->request->isPost()){
  41. //通过postParams属性可以增加或者覆盖前端row/a传过来的参数
  42. //$this->postParams['属性名']='属性的值';
  43. }
  44. //注意这里传入已经修改过的$row
  45. return $this->_edit($row);
  46. }
  47. //删除
  48. #[Route("GET","del")]
  49. public function del()
  50. {
  51. return "删除";
  52. }
  53. //导入
  54. #[Route("GET","import")]
  55. public function import()
  56. {
  57. return "导入";
  58. }
  59. }