StockLog.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\controller\user;
  4. use app\common\controller\Backend;
  5. use app\admin\traits\Actions;
  6. use think\annotation\route\Group;
  7. use think\annotation\route\Route;
  8. use app\common\model\StockConfig;
  9. use app\common\model\StockLog as StockLogModel;
  10. #[Group("user/stock_log")]
  11. class StockLog extends Backend
  12. {
  13. use Actions{
  14. index as private _index;
  15. add as private _add;
  16. edit as private _edit;
  17. }
  18. protected function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = new StockLogModel();
  22. $this->assign('typeList', StockConfig::getTypeList());
  23. $this->relationField=['stockconfig'];
  24. }
  25. //查看
  26. #[Route("GET,JSON","index")]
  27. public function index()
  28. {
  29. return $this->_index();
  30. }
  31. //添加
  32. #[Route("GET,POST","add")]
  33. public function add()
  34. {
  35. //通过定义postParams来增加或覆盖post提交的表单
  36. $this->postParams=[];
  37. //通过定义callback回调函数来执行添加后的操作
  38. $this->callback=function ($model){};
  39. return $this->_add();
  40. }
  41. //修改
  42. #[Route("GET,POST","edit")]
  43. public function edit()
  44. {
  45. //通过定义postParams来增加或覆盖post提交的表单
  46. $this->postParams=[];
  47. //通过定义callback回调函数来执行修改后的操作
  48. $this->callback=function ($model){};
  49. return $this->_edit();
  50. }
  51. }