controllerindex.stub 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * 查看
  3. */
  4. public function index()
  5. {
  6. //当前是否为关联查询
  7. $this->relationSearch = {%relationSearch%};
  8. //设置过滤方法
  9. $this->request->filter(['strip_tags', 'trim']);
  10. if ($this->request->isAjax()) {
  11. //如果发送的来源是Selectpage,则转发到Selectpage
  12. if ($this->request->request('keyField')) {
  13. return $this->selectpage();
  14. }
  15. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  16. $list = $this->model
  17. {%relationWithList%}
  18. ->where($where)
  19. ->order($sort, $order)
  20. ->paginate($limit);
  21. foreach ($list as $row) {
  22. {%visibleFieldList%}
  23. {%relationVisibleFieldList%}
  24. }
  25. $result = array("total" => $list->total(), "rows" => $list->items());
  26. return json($result);
  27. }
  28. return $this->view->fetch();
  29. }