Equipmentcate.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\admin\controller\qingdongams\customer;
  3. use app\common\controller\Backend;
  4. /**
  5. * 系统管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Equipmentcate extends Backend
  10. {
  11. /**
  12. * Equipmentcate模型对象
  13. * @var \app\admin\model\qingdongams\customer\Equipmentcate
  14. */
  15. protected $model = null;
  16. protected $searchFields = 'name,gongneng,remark';
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\qingdongams\customer\Equipmentcate;
  21. }
  22. /**
  23. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  24. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  25. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  26. */
  27. public function index() {
  28. //设置过滤方法
  29. $this->request->filter(['strip_tags', 'trim']);
  30. if (false === $this->request->isAjax()) {
  31. return $this->view->fetch();
  32. }
  33. //如果发送的来源是 Selectpage,则转发到 Selectpage
  34. if ($this->request->request('keyField')) {
  35. return $this->selectpage();
  36. }
  37. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  38. $list = $this->model
  39. ->where($where)
  40. ->order('sort', "DESC")
  41. ->paginate($limit);
  42. $result = ['total' => $list->total(), 'rows' => $list->items()];
  43. return json($result);
  44. }
  45. }