作者 郭文星

123131

@@ -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 - protected $selectpageFields = "id,license_plate,seat,driver_id,name"; 22 +
23 public function _initialize() 23 public function _initialize()
24 { 24 {
25 parent::_initialize(); 25 parent::_initialize();
@@ -74,58 +74,6 @@ class Car extends Backend @@ -74,58 +74,6 @@ 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 - }  
129 /** 77 /**
130 * 添加 78 * 添加
131 * 79 *
@@ -12,12 +12,6 @@ @@ -12,12 +12,6 @@
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>  
21 15
22 <div class="form-group layer-footer"> 16 <div class="form-group layer-footer">
23 <label class="control-label col-xs-12 col-sm-2"></label> 17 <label class="control-label col-xs-12 col-sm-2"></label>