"病人", 2=>"普通", 3=>"限时", 4=>"预约检查", 5=>"药品运送" ]; public $priority = [ 1=>"可延缓的", 2=>"常规", 3=>"紧急", 4=>"预约" ]; protected $createTime = 'create_time'; protected $updateTime = 'update_time'; public $table = 'convey_cate'; protected $validateName = 'ConveyCate'; public function updates(){ $data = request()->post(); $data['org_id'] =cur_org_id(); $result = validate($this->validateName)->check($data,[],''); if(true !== $result){ $this->error = validate($this->validateName)->getError(); return false; } $id = $data['id']; unset($data['id']); if($id > 0){ $data['update_time'] = date('Y-m-d H:i:s'); $ret = $this->allowField(true)->save($data,['id'=>$id]); }else{ $data['create_time'] = date('Y-m-d H:i:s'); $ret = $this->allowField(true)->save($data); } if(!$ret){ $this->error = '操作失败'; return false; } return true; } public function getList($orgId=0){ if($orgId==0){ $orgId = cur_org_id(); } $list = $this ->where('org_id',$orgId) ->where('enable',1) ->where('del',0) ->select(); foreach ($list as $k=>$v){ if($v['time_id'] > 0){ $time = Db::name('time') ->where('id',$v['time_id']) ->find(); $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']); }else{ $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = ''; } $ends = $v['ends']?explode(',',$v['ends']):[]; $list[$k]['ends'] = 0; if(count($ends) == 1){ $list[$k]['ends'] = $ends[0]; } } return $list; } public function getList1($orgId=0){ if($orgId==0){ $orgId = cur_org_id(); } $list = $this ->where('org_id',$orgId) ->where('enable',1) ->where('del',0) ->select(); foreach ($list as $k=>$v){ if($v['time_id'] > 0){ $time = Db::name('time') ->where('id',$v['time_id']) ->find(); $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']); }else{ $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = ''; } $ends = $v['ends']?explode(',',$v['ends']):[]; if($ends && count($ends)==1){ $list[$k]['ends'] = Db::name('address') ->where('id','in',$ends) ->field('id,title') ->select(); }else{ $list[$k]['ends'] = []; } $list[$k]['priorityName'] = $this->priority[$v['priority']]; } return $list; } public function getInfo($id){ $v = $this ->where('id',$id) ->where('enable',1) ->where('del',0) ->find(); $v = $v->toArray()?$v:[]; if($v['time_id'] > 0){ $time = Db::name('time') ->where('id',$v['time_id']) ->find(); $v['xq_time'] = date('Y-m-d H:i'); $v['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']); }else{ $v['xq_time'] = date('Y-m-d H:i'); $v['ywc_time'] = ''; } $ends = $v['ends']?explode(',',$v['ends']):[]; if($ends && count($ends)==1){ $v['ends'] = Db::name('address') ->where('id','in',$ends) ->field('id,title') ->select(); }else{ $v['ends'] = null; } $v['priorityName'] = $this->priority[$v['priority']]; return $v; } }