0
0

TransformerTemp.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\Db;
  5. use think\Exception;
  6. class TransformerTemp extends Auth
  7. {
  8. protected function initialize()
  9. {
  10. parent::initialize(); // TODO: Change the autogenerated stub
  11. }
  12. public function index(){
  13. if(request()->isAjax()){
  14. //分页参数
  15. $length = input('rows',10,'intval'); //每页条数
  16. $page = input('page',1,'intval'); //第几页
  17. $start = ($page - 1) * $length; //分页开始位置
  18. //排序
  19. $sortRow = input('sidx','sort','trim'); //排序列
  20. $sort = input('sord','asc','trim'); //排序方式
  21. $order = $sortRow.' '.$sort.' ,id desc';
  22. $map[] = ['del','=',0];
  23. $map[] = ['org_id','=',$this->orgId];
  24. $map= empty($map) ? true: $map;
  25. //数据查询
  26. $lists = Db::name('transformer_temp')
  27. ->where($map)
  28. ->limit($start,$length)
  29. ->order('id desc')
  30. ->select();
  31. //数据返回
  32. $totalCount = Db::name('transformer_temp')->where($map)->count();
  33. $totalPage = ceil($totalCount/$length);
  34. $result['page'] = $page;
  35. $result['total'] = $totalPage;
  36. $result['records'] = $totalCount;
  37. $result['rows'] = $lists;
  38. return json($result);
  39. }else{
  40. $this->assign('meta_title','变压器温度列表');
  41. return $this->fetch();
  42. }
  43. }
  44. }