0
0

MeetingDevice.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\admin\controller;
  3. class MeetingDevice 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','id','trim'); //排序列
  13. $sort = input('sord','desc','trim'); //排序方式
  14. $order = $sortRow.' '.$sort;
  15. $title = input('title','','trim');
  16. if($title){
  17. $map[] = ['title','like','%'.$title.'%'];
  18. }
  19. $map[] = ['org_id','=',cur_org_id()];
  20. $map[] = ['del','=',0];
  21. $map= empty($map) ? true: $map;
  22. //数据查询
  23. $lists = db('meeting_device')->where($map)->limit($start,$length)->order('id desc')->select();
  24. //数据返回
  25. $totalCount = db('meeting_device')->where($map)->count();
  26. $totalPage = ceil($totalCount/$length);
  27. $result['page'] = $page;
  28. $result['total'] = $totalPage;
  29. $result['records'] = $totalCount;
  30. $result['rows'] = $lists;
  31. return json($result);
  32. }else{
  33. return $this->fetch();
  34. }
  35. }
  36. /**
  37. * 新增/编辑
  38. */
  39. public function add($id=0){
  40. if(request()->isPost()){
  41. $res = model('MeetingDevice')->updates();
  42. if($res){
  43. $this->success('操作成功',url('index'));
  44. }else{
  45. $this->error(model('NewsCate')->getError());
  46. }
  47. }else{
  48. if($id){
  49. $info = db('MeetingDevice')->where('id',$id)->find();
  50. $this->assign('info',$info);
  51. }
  52. return $this->fetch();
  53. }
  54. }
  55. /**
  56. * 删除记录
  57. * @param int $id
  58. */
  59. public function del($id=0){
  60. if(!$id){
  61. $this->error('参数错误');
  62. }
  63. $res = db('MeetingDevice')->where('id',$id)->update(['del'=>1]);
  64. if($res){
  65. $this->success('删除成功');
  66. }else{
  67. $this->error('删除失败');
  68. }
  69. }
  70. }