dbname ='wb_yunwei'; } public function yunwei(){ $Data=I(); if(isset($Data['list'])){ $UserVIew=M('wb_yunwei'); $GetPage=$Data['pageCurrent'];//第几页 $GetSize=$Data['pageSize'];//每页条数 $Page=($GetPage-1)*$GetSize; $Map=array(); if(!empty($Data['name'])){ $Map['yw_enginer']=array("LIKE",'%'.$Data['name'].'%'); } if(!empty($Data['phone'])){ $Map['yw_enphone']=array("LIKE",'%'.$Data['phone'].'%'); } $permdata=$this->permdata(); if (!empty($permdata)) { $Map['yw_editor']=$permdata; } $Count= $UserVIew->where($Map)->count();// 查询满足要求的总记录数 $List = $UserVIew->field("id,yw_enginer,yw_enphone,yw_addtime,yw_editor,yw_types")->where($Map)->order('yw_addtime desc') ->limit($Page,$GetSize)->select(); $Info = array( 'totalRow' => $Count, //'pageSize' => $count,//分页时不传 'list' => $List, ); echo json_encode($Info); } else { $this->display(); } } public function yw_add(){ if (IS_POST) { $Tab=M('wb_yunwei'); $rules = array( array('phone','','电话号码重复!',0,'unique'), ); if (!$Tab->validate($rules)->create()) { // echo json_encode(array('statusCode'=>'300','message'=> $menu->getError())); $this->mtReturn(300,$Tab->getError()); } else { /*$PhoneRes=M('')->query('SELECT openid FROM ztcrm.sp_customuser where phone='.$Data['phone']); if (empty($PhoneRes)) { $this->mtReturn(300,'该号码未关注公众号,请先关注公众号注册信息才能录入'); }*/ $Data=I(); $Data['yw_addtime']=date('Y-m-d H:i:s'); $Data['yw_editor']=session('zt_username'); $res = $Tab->add($Data); if($res) $this->mtReturn(200,'维保人员新增成功'); else $this->mtReturn(300,'维保人员新增失败'); } } else { $this->assign('action','/home/Maintyw/yw_add'); $this->display(); } } public function yw_edit(){ $Data=I(); $Tab=M('wb_yunwei'); if(IS_POST) { $this->logcs(print_r($Data,ture)); $res=$Tab->save($Data); if($res) $this->mtReturn(200,'编辑成功'); else $this->mtReturn(300,'编辑失败'); } else { $ResData = $Tab->field("id,yw_enginer,yw_enphone,yw_addtime,yw_editor,yw_types")->where(array('id'=>$Data['id']))->select(); $this->assign('ResData',$ResData[0]); $this->assign('action','/home/Maintyw/yw_edit'); $this->display(); } } }