1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace Home\Controller;
- use Think\Controller;
- class MaintrwController extends ComController {
-
- public function _initialize() {
- parent::_initialize();
- $this->dbname ='maint_infolist';
- }
- public function index(){
- $Data=I();
- if(isset($Data['list'])){
- $UserVIew=M('maint_infolist');
- $GetPage=$Data['pageCurrent'];//第几页
- $GetSize=$Data['pageSize'];//每页条数
- $Page=($GetPage-1)*$GetSize;
- $Map=array();
- if(!empty($Data['name'])){
- $Map['comp_name']=array("LIKE",'%'.$Data['name'].'%');
- }
- if(!empty($Data['phone'])){
- $Map['worker']=array("LIKE",'%'.$Data['phone'].'%');
- }
- $permdata=$this->permdata();
- if (!empty($permdata))
- {
- $Map['editor']=$permdata;
- }
- $Count= $UserVIew->where($Map)->count();// 查询满足要求的总记录数
- $List = $UserVIew->field("id,owner_code,CASE WHEN `type`='fire' THEN '火系统' WHEN `type`='water' THEN '水系统'
- 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 '未分配'
- WHEN `status`='1' THEN '未完成' WHEN `status`='2' THEN '已完成' END as status,content")->where($Map)->order('datetime desc')
- ->limit($Page,$GetSize)->select();
- $Info = array(
- 'totalRow' => $Count,
- //'pageSize' => $count,//分页时不传
- 'list' => $List,
- );
- echo json_encode($Info);
- }
- else
- {
- $this->display();
- }
-
- }
- public function edit(){
- $Data=I();
- $Tab=M('maint_infolist');
- 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,owner_name,owner_code,comp_name,content,editor,worker")->where(array('id'=>$Data['id']))->select();
- $UserData =M('')->query('SELECT id,yw_enginer from sp_wb_yunwei');
- $this->assign('UserData',$UserData);
- $this->assign('ResData',$ResData[0]);
- $this->assign('action','/home/Maintrw/edit');
- $this->display();
- }
- }
-
-
- }
|