redirect('/h5/index/errortxt'); } $arr = get_qrcode_arr($nCode); if($arr['type'] != 'address'){ $this->redirect('/h5/index/errortxt'); } $this->addrId = $arr['id']; } public function index(){ $addr = Db::name('address')->where('id',$this->addrId)->find(); $org = Db::name('org')->where('id',$addr['org_id'])->find(); $orgPhone = model('Config')->getConfig('org_phone',$addr['org_id']); $this->assign('orgPhone',explode(',',$orgPhone)); $this->assign('orgName',$org['name']); return $this->fetch(); } public function add(){ $mode = input('mode',0); $addr = Db::name('address')->where('id',$this->addrId)->find(); if(request()->isPost()){ if(in_array($mode,[1,2,4])){ $json = [ 'user_id'=>input('user_id',0), 'org_id'=>$addr['org_id'], 'dep_id'=>input('depId/d',0), 'images'=>input('images',''), 'videos'=>input('videos',''), 'voices'=>input('voices',''), 'content'=>input('content',''), 'work_type_mode'=>input('mode/d',1), 'source_type'=>input('sourceType/d',1), 'type_id'=>input('typeId/d',0), 'address_id'=>$this->addrId, 'start'=>input('start',''), 'end'=>input('end',''), 'xq_time'=>input('xqTime',''), 'ywc_time'=>input('ywcTime',''), 'type'=>input('type',''), 'device_id'=>input('deviceId',''), 'priority'=>input('priority',''), 'bed_number'=>input('bedNumber',''), 'ba_number'=>input('baNumber',''), 'p_name'=>input('pName',''), 'gender'=>input('gender',''), 'back'=>input('back',''), 'name'=>input('name',''), 'phone'=>input('phone',''), 'address'=>input('address',''), 'isSpontaneous'=>input('isSpontaneous',0), 'house_type_id'=>input('houseTypeId',0), 'sxType'=>1 ]; $json['images'] = $json['images'] ? implode(',',$json['images']):''; $res = model('Orders')->addSave($json); if($res){ $this->success('操作成功',url('addSuccess')); }else{ $this->error(model('Orders')->getError()); } }else{ $info = [ 'orgId'=>$addr['org_id'], 'depId'=>input('depId/d',0), 'createUserId'=>0, 'hide'=>input('hide',''), 'content'=>input('content',''), 'images'=>input('images',''), 'voices'=>input('voices',''), 'videos'=>input('videos',''), 'name'=>input('name',''), 'phone'=>input('phone',''), ]; $info['images'] = $info['images'] ? implode(',',$info['images']):''; $res = model('Complain')->addSave($info); if($res){ $this->success('操作成功',url('addSuccess')); }else{ $this->error(model('Complain')->getError()); } } }else{ $list = Db::name('patrol_record') ->where('org_id',$addr['org_id']) ->where('patrol_mode',4) ->where('patrol_addr_id',$addr['id']) ->order('id desc') ->limit(5) ->select(); foreach ($list as $k=>$v){ $list[$k]['addrName'] = Db::name('address')->where('id',$v['patrol_addr_id'])->value('title'); $list[$k]['userName'] = Db::name('user')->where('id',$v['user_id'])->value('real_name'); $status = Db::name('patrol_task')->where('id',$v['patrol_task_id'])->value('status'); $statusTxt = ''; if($status == 0){ $statusTxt = '待完成'; }elseif ($status == 1){ $statusTxt = '执行中'; }elseif ($status == 2){ $statusTxt = '已完成'; }elseif ($status == 3){ $statusTxt = '未完成'; }elseif ($status == 5){ $statusTxt = '中断'; }elseif ($status == 6){ $statusTxt = '已关闭'; } $list[$k]['statusTxt'] = $statusTxt; $list[$k]['status'] = $status; $list[$k]['create_time'] = date('m-d H:i:s',strtotime($v['create_time'])); } $this->assign('list',$list); } $title = ''; if($mode == 1){ $title = '维修'; }elseif ($mode == 2){ $title = '保洁'; }elseif ($mode == 4){ $title = '安保'; }elseif($mode == 0){ $title = '投诉'; } $this->assign('mode',$mode); $this->assign('title',$title); return $this->fetch(); } public function questionnaire(){ $addr = Db::name('address')->where('id',$this->addrId)->find(); $list = Db::name('questionnaire') ->where('org_id',$addr['org_id']) ->where('enable',1) ->where('del',0) ->order('id desc') ->select(); $strs = aes_encrypt('wj',config('app.encryption_key')); foreach ($list as $k=>$v){ $url = getSite().'/h5/Wj/index?id='.$v['id'].'&code='.$strs.'&orgId='.$addr['org_id']; $list[$k]['url'] = $url; } $this->assign('list',$list); return $this->fetch(); } public function video(){ $addr = Db::name('address')->where('id',$this->addrId)->find(); $orgId = $addr['org_id']; $list = Db::name('video') ->where(function ($query) use ($orgId) { $query->where('org_id',$orgId) ->whereOr('org_id',0); }) // ->where('org_id',$addr['org_id']) ->where('enable',1) ->where('del',0) ->order('id desc') ->select(); $this->assign('list',$list); return $this->fetch(); } public function addSuccess(){ return $this->fetch(); } public function record() { $addr = Db::name('address')->where('id',$this->addrId)->find(); $list = Db::name('patrol_record') ->where('org_id',$addr['org_id']) ->where('patrol_mode',4) ->where('patrol_addr_id',$addr['id']) ->order('id desc') ->paginate(10) ->each(function($item,$key){ $item['addrName'] = Db::name('address')->where('id',$item['patrol_addr_id'])->value('title'); $item['userName'] = Db::name('user')->where('id',$item['user_id'])->value('real_name'); $item['create_time'] = date('m-d H:i:s',strtotime($item['create_time'])); $status = Db::name('patrol_task')->where('id',$item['patrol_task_id'])->value('status'); $item['status'] = $status; $statusTxt = ''; if($status == 0){ $statusTxt = '待完成'; }elseif ($status == 1){ $statusTxt = '执行中'; }elseif ($status == 2){ $statusTxt = '已完成'; }elseif ($status == 3){ $statusTxt = '未完成'; }elseif ($status == 5){ $statusTxt = '中断'; }elseif ($status == 6){ $statusTxt = '已关闭'; } $item['statusTxt'] = $statusTxt; return $item; }); $this->assign('list',$list); $this->assign('currentPage',$list->currentPage()); $this->assign('lastPage',$list->lastPage()); $this->assign('total',$list->total()); $this->assign('title','巡检记录'); return $this->fetch(); } public function recordDetail() { $id = input('id', 0, 'intval'); if (!$id) { $this->error('参数错误'); } $info = Db::name('patrol_record')->where('id', $id)->find(); if (!$info) { $this->error('记录不存在'); } $info['addr'] = Db::name('address')->where('id', $info['patrol_addr_id'])->value('title'); $info['task_name'] = Db::name('patrol_task')->where('id', $info['patrol_task_id'])->value('title'); $info['in_order'] = Db::name('patrol_task')->where('id', $info['patrol_task_id'])->value('in_order'); $info['task_addr_form'] = Db::name('patrol_addr_form') ->alias('a') ->join('patrol_task_addr b', 'a.id = b.patrol_form_id') ->where('b.id', $info['patrol_addr_form_id'])->value('a.title'); $info['task_user'] = Db::name('user')->where('id', $info['user_id'])->value('real_name'); $info['check_json'] = json_decode($info['check_json'], true); $info['images'] = $info['images'] ? array_filter(explode(',', $info['images'])) : []; // 整改状态:关联工单是否存在 $zgType = 0; if ($info['order_id'] > 0) { $order = Db::name('orders') ->where('id', $info['order_id']) ->where('quality_type', $info['patrol_mode'] + 1) ->whereIn('order_mode', [5, 6]) ->where('del', 0) ->find(); $zgType = $order ? 2 : 1; } $info['zg_type'] = $zgType; // 任务状态(与列表页保持一致) $taskStatus = Db::name('patrol_task')->where('id', $info['patrol_task_id'])->value('status'); $statusTxt = ''; if ($taskStatus == 0) { $statusTxt = '待完成'; } elseif ($taskStatus == 1) { $statusTxt = '执行中'; } elseif ($taskStatus == 2) { $statusTxt = '已完成'; } elseif ($taskStatus == 3) { $statusTxt = '未完成'; } elseif ($taskStatus == 5) { $statusTxt = '中断'; } elseif ($taskStatus == 6) { $statusTxt = '已关闭'; } $info['statusTxt'] = $statusTxt; $info['status'] = $taskStatus; $info['create_time'] = date('Y-m-d H:i:s', strtotime($info['create_time'])); $this->assign('info', $info); $this->assign('title', '记录详情'); return $this->fetch(); } }