MaintrwController.class.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class MaintrwController extends ComController {
  5. public function _initialize() {
  6. parent::_initialize();
  7. $this->dbname ='maint_infolist';
  8. }
  9. public function index(){
  10. $Data=I();
  11. if(isset($Data['list'])){
  12. $UserVIew=M('maint_infolist');
  13. $GetPage=$Data['pageCurrent'];//第几页
  14. $GetSize=$Data['pageSize'];//每页条数
  15. $Page=($GetPage-1)*$GetSize;
  16. $Map=array();
  17. if(!empty($Data['name'])){
  18. $Map['comp_name']=array("LIKE",'%'.$Data['name'].'%');
  19. }
  20. if(!empty($Data['phone'])){
  21. $Map['worker']=array("LIKE",'%'.$Data['phone'].'%');
  22. }
  23. $permdata=$this->permdata();
  24. if (!empty($permdata))
  25. {
  26. $Map['editor']=$permdata;
  27. }
  28. $Count= $UserVIew->where($Map)->count();// 查询满足要求的总记录数
  29. $List = $UserVIew->field("id,owner_code,CASE WHEN `type`='fire' THEN '火系统' WHEN `type`='water' THEN '水系统'
  30. WHEN `type`='efire' THEN '电气火灾' WHEN `type`='rtu' THEN 'RTU' WHEN `type`='fume' THEN '烟感' END as type,comp_name,datetime,owner_address,editor,worker,CASE WHEN `status`='0' THEN '未分配'
  31. WHEN `status`='1' THEN '未完成' WHEN `status`='2' THEN '已完成' END as status,content")->where($Map)->order('datetime desc')
  32. ->limit($Page,$GetSize)->select();
  33. $Info = array(
  34. 'totalRow' => $Count,
  35. //'pageSize' => $count,//分页时不传
  36. 'list' => $List,
  37. );
  38. echo json_encode($Info);
  39. }
  40. else
  41. {
  42. $this->display();
  43. }
  44. }
  45. public function edit(){
  46. $Data=I();
  47. $Tab=M('maint_infolist');
  48. if(IS_POST)
  49. {
  50. $this->logcs(print_r($Data,ture));
  51. $res=$Tab->save($Data);
  52. if($res)
  53. $this->mtReturn(200,'编辑成功');
  54. else
  55. $this->mtReturn(300,'编辑失败');
  56. }
  57. else
  58. {
  59. $ResData = $Tab->field("id,owner_name,owner_code,comp_name,content,editor,worker")->where(array('id'=>$Data['id']))->select();
  60. $UserData =M('')->query('SELECT id,yw_enginer from sp_wb_yunwei');
  61. $this->assign('UserData',$UserData);
  62. $this->assign('ResData',$ResData[0]);
  63. $this->assign('action','/home/Maintrw/edit');
  64. $this->display();
  65. }
  66. }
  67. }