作者 郭文星

123

@@ -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,58 @@ class Car extends Backend @@ -74,6 +74,58 @@ 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 + $res=$this->model
  91 + ->alias("a")
  92 + ->join("driver b","a.driver_id=b.id")
  93 + ->field("b.id,name,license_plate")
  94 + ->select();
  95 + $count=$this->model
  96 + ->alias("a")
  97 + ->join("driver b","a.driver_id=b.id")
  98 + ->count();
  99 + foreach ($res as $k=>$v){
  100 + $res[$k]['pid']=0;
  101 + }
  102 + $data=['list'=>$res,'total'=>$count];
  103 + return $data;
  104 + }
  105 + list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  106 +
  107 + $list = $this->model
  108 + ->with(['route','seat','driver'])
  109 + ->where($where)
  110 + ->order($sort, $order)
  111 + ->paginate($limit);
  112 +
  113 + foreach ($list as $row) {
  114 + $row->visible(['id','car_model','license_plate','seat','colour','driving_license','driver_license','reservation_time','start_time','create_time','status','carmodel_id']);
  115 + $row->visible(['route']);
  116 + $row->getRelation('route')->visible(['name']);
  117 + $row->visible(['seat']);
  118 + $row->getRelation('seat')->visible(['name']);
  119 + $row->visible(['driver']);
  120 + $row->getRelation('driver')->visible(['name']);
  121 + }
  122 +
  123 + $result = array("total" => $list->total(), "rows" => $list->items());
  124 +
  125 + return json($result);
  126 + }
  127 + return $this->view->fetch();
  128 + }
77 /** 129 /**
78 * 添加 130 * 添加
79 * 131 *
@@ -230,7 +282,7 @@ class Car extends Backend @@ -230,7 +282,7 @@ class Car extends Backend
230 } 282 }
231 283
232 function createMiniProgramQRCode($accessToken, $path, $width = 430) { 284 function createMiniProgramQRCode($accessToken, $path, $width = 430) {
233 - $path = 'pages/module/intercityOrder?url='.$path; // 小程序内的页面路径 285 + $path = 'pages/module/intercityOrder?'.$path; // 小程序内的页面路径
234 $url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}"; 286 $url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
235 $data = json_encode([ 287 $data = json_encode([
236 'path' => $path, 288 'path' => $path,
@@ -275,6 +275,7 @@ class Order extends Backend @@ -275,6 +275,7 @@ class Order extends Backend
275 275
276 public function orderinfo($ids){ 276 public function orderinfo($ids){
277 $row = Db::name("order")->field("id,passengers,driver_id,starting_point,end_point,order_no,pay_type,price,route_id,is_pay,phone,type")->find(['id' => $ids]); 277 $row = Db::name("order")->field("id,passengers,driver_id,starting_point,end_point,order_no,pay_type,price,route_id,is_pay,phone,type")->find(['id' => $ids]);
  278 +
278 $res=Db::name("passenger")->where("id","in",$row['passengers'])->select(); 279 $res=Db::name("passenger")->where("id","in",$row['passengers'])->select();
279 $row['passenger']=""; 280 $row['passenger']="";
280 foreach ($res as $k=>$v) { 281 foreach ($res as $k=>$v) {
@@ -304,10 +305,14 @@ class Order extends Backend @@ -304,10 +305,14 @@ class Order extends Backend
304 }elseif($row['pay_type']=="background"){ 305 }elseif($row['pay_type']=="background"){
305 $row['pay_type']="后台下单"; 306 $row['pay_type']="后台下单";
306 } 307 }
  308 + $row['license_plate']="";
  309 + $row['driver_name']="";
  310 + if($row['driver_id']){
307 $driver=Db::name("driver")->find($row['driver_id']); 311 $driver=Db::name("driver")->find($row['driver_id']);
308 $car=Db::name("car")->where("driver_id",$row['driver_id'])->find(); 312 $car=Db::name("car")->where("driver_id",$row['driver_id'])->find();
309 $row['license_plate']=$car['license_plate']; 313 $row['license_plate']=$car['license_plate'];
310 $row['driver_name']=$driver['name']; 314 $row['driver_name']=$driver['name'];
  315 + }
311 $route=Db::name("route")->find($row['route_id']); 316 $route=Db::name("route")->find($row['route_id']);
312 $row['route_name']=$route['name']; 317 $row['route_name']=$route['name'];
313 unset($row['driver_id']); 318 unset($row['driver_id']);
@@ -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-field="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>