正在显示
3 个修改的文件
包含
64 行增加
和
3 行删除
| @@ -19,7 +19,7 @@ class Car extends Backend | @@ -19,7 +19,7 @@ class Car extends Backend | ||
| 19 | * @var \app\admin\model\Car | 19 | * @var \app\admin\model\Car |
| 20 | */ | 20 | */ |
| 21 | protected $model = null; | 21 | protected $model = null; |
| 22 | - | 22 | + protected $selectpageFields = "id,license_plate,seat,driver_id,name"; |
| 23 | public function _initialize() | 23 | public function _initialize() |
| 24 | { | 24 | { |
| 25 | parent::_initialize(); | 25 | parent::_initialize(); |
| @@ -74,6 +74,61 @@ class Car extends Backend | @@ -74,6 +74,61 @@ class Car extends Backend | ||
| 74 | } | 74 | } |
| 75 | return $this->view->fetch(); | 75 | return $this->view->fetch(); |
| 76 | } | 76 | } |
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 查看 | ||
| 80 | + */ | ||
| 81 | + public function select_driver() | ||
| 82 | + { | ||
| 83 | + //当前是否为关联查询 | ||
| 84 | + $this->relationSearch = true; | ||
| 85 | + //设置过滤方法 | ||
| 86 | + $this->request->filter(['strip_tags', 'trim']); | ||
| 87 | + if ($this->request->isAjax()) { | ||
| 88 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
| 89 | + if ($this->request->request('keyField')) { | ||
| 90 | + $keyField=$this->request->request(); | ||
| 91 | + $res=$this->model | ||
| 92 | + ->where("(license_plate like %".$keyField['q_word'][0]."% or name like %".$keyField['q_word'][0]."%) ") | ||
| 93 | + ->alias("a") | ||
| 94 | + ->join("driver b","a.driver_id=b.id") | ||
| 95 | + ->field("b.id,name,license_plate") | ||
| 96 | + ->select(); | ||
| 97 | + print_r($res);return; | ||
| 98 | + $count=$this->model | ||
| 99 | + ->alias("a") | ||
| 100 | + ->join("driver b","a.driver_id=b.id") | ||
| 101 | + ->count(); | ||
| 102 | + foreach ($res as $k=>$v){ | ||
| 103 | + $res[$k]['pid']=0; | ||
| 104 | + } | ||
| 105 | + $data=['list'=>$res,'total'=>$count]; | ||
| 106 | + return $data; | ||
| 107 | + } | ||
| 108 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
| 109 | + | ||
| 110 | + $list = $this->model | ||
| 111 | + ->with(['route','seat','driver']) | ||
| 112 | + ->where($where) | ||
| 113 | + ->order($sort, $order) | ||
| 114 | + ->paginate($limit); | ||
| 115 | + | ||
| 116 | + foreach ($list as $row) { | ||
| 117 | + $row->visible(['id','car_model','license_plate','seat','colour','driving_license','driver_license','reservation_time','start_time','create_time','status','carmodel_id']); | ||
| 118 | + $row->visible(['route']); | ||
| 119 | + $row->getRelation('route')->visible(['name']); | ||
| 120 | + $row->visible(['seat']); | ||
| 121 | + $row->getRelation('seat')->visible(['name']); | ||
| 122 | + $row->visible(['driver']); | ||
| 123 | + $row->getRelation('driver')->visible(['name']); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + $result = array("total" => $list->total(), "rows" => $list->items()); | ||
| 127 | + | ||
| 128 | + return json($result); | ||
| 129 | + } | ||
| 130 | + return $this->view->fetch(); | ||
| 131 | + } | ||
| 77 | /** | 132 | /** |
| 78 | * 添加 | 133 | * 添加 |
| 79 | * | 134 | * |
| @@ -12,6 +12,12 @@ | @@ -12,6 +12,12 @@ | ||
| 12 | 12 | ||
| 13 | </div> | 13 | </div> |
| 14 | </div> | 14 | </div> |
| 15 | + <div class="form-group"> | ||
| 16 | + <label class="control-label col-xs-12 col-sm-2">{:__('Driver_id')}:</label> | ||
| 17 | + <div class="col-xs-12 col-sm-8"> | ||
| 18 | + <input id="c-driver_id" data-source="car/select_driver" data-format-item="{name} - {license_plate}" class="form-control selectpage" name="row[driver_id]" type="text" value=""> | ||
| 19 | + </div> | ||
| 20 | + </div> | ||
| 15 | 21 | ||
| 16 | <div class="form-group layer-footer"> | 22 | <div class="form-group layer-footer"> |
| 17 | <label class="control-label col-xs-12 col-sm-2"></label> | 23 | <label class="control-label col-xs-12 col-sm-2"></label> |
| @@ -1188,7 +1188,7 @@ class Car extends Base | @@ -1188,7 +1188,7 @@ class Car extends Base | ||
| 1188 | $number = $this->request->param("number");//乘车人数 | 1188 | $number = $this->request->param("number");//乘车人数 |
| 1189 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 | 1189 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 |
| 1190 | $reservation_time = $this->request->param("reservation_time");//预约时间 | 1190 | $reservation_time = $this->request->param("reservation_time");//预约时间 |
| 1191 | - $departure_time=strstr($reservation_time,"-",true); | 1191 | + $departure_time=substr($reservation_time,0,16); |
| 1192 | $departure_time = strtotime($departure_time); | 1192 | $departure_time = strtotime($departure_time); |
| 1193 | $phone = $this->request->param("phone");//联系电话 | 1193 | $phone = $this->request->param("phone");//联系电话 |
| 1194 | $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 | 1194 | $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 |
| @@ -1313,7 +1313,7 @@ class Car extends Base | @@ -1313,7 +1313,7 @@ class Car extends Base | ||
| 1313 | $number = $this->request->param("number");//乘车人数 | 1313 | $number = $this->request->param("number");//乘车人数 |
| 1314 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 | 1314 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 |
| 1315 | $reservation_time = $this->request->param("reservation_time");//预约时间 | 1315 | $reservation_time = $this->request->param("reservation_time");//预约时间 |
| 1316 | - $departure_time=strstr($reservation_time,"-",true); | 1316 | + $departure_time=substr($reservation_time,0,16); |
| 1317 | $departure_time = strtotime($departure_time); | 1317 | $departure_time = strtotime($departure_time); |
| 1318 | $phone = $this->request->param("phone");//联系电话 | 1318 | $phone = $this->request->param("phone");//联系电话 |
| 1319 | $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 | 1319 | $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 |
-
请 注册 或 登录 后发表评论