EnergyRecordWarning.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\admin\controller;
  3. class EnergyRecordWarning extends Auth
  4. {
  5. public function index(){
  6. if(request()->isAjax()){
  7. //分页参数
  8. $length = input('rows',10,'intval'); //每页条数
  9. $page = input('page',1,'intval'); //第几页
  10. $start = ($page - 1) * $length; //分页开始位置
  11. //排序
  12. $sortRow = input('sidx','sort','trim');
  13. $type = input('type','','trim');
  14. if ($type != '') {
  15. $map['type'] = $type;
  16. }
  17. $map['org_id'] = $this->orgId;
  18. //数据查询
  19. $lists = db('energy_record_warning')->where($map)->limit($start,$length)->select();
  20. $totalCount = db('energy_record_warning')->where($map)->count();
  21. $totalPage = ceil($totalCount/$length);
  22. $result['page'] = $page;
  23. $result['total'] = $totalPage;
  24. $result['records'] = $totalCount;
  25. $result['rows'] = $lists;
  26. return json($result);
  27. }else{
  28. return $this->fetch();
  29. }
  30. }
  31. }