...
|
...
|
@@ -19,7 +19,7 @@ class Car extends Backend |
|
|
* @var \app\admin\model\Car
|
|
|
*/
|
|
|
protected $model = null;
|
|
|
|
|
|
protected $selectpageFields = "id,license_plate,seat,driver_id,name";
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
...
|
...
|
@@ -74,6 +74,61 @@ class Car extends Backend |
|
|
}
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看
|
|
|
*/
|
|
|
public function select_driver()
|
|
|
{
|
|
|
//当前是否为关联查询
|
|
|
$this->relationSearch = true;
|
|
|
//设置过滤方法
|
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
|
if ($this->request->isAjax()) {
|
|
|
//如果发送的来源是Selectpage,则转发到Selectpage
|
|
|
if ($this->request->request('keyField')) {
|
|
|
$keyField=$this->request->request();
|
|
|
$res=$this->model
|
|
|
->where("(license_plate like %".$keyField['q_word'][0]."% or name like %".$keyField['q_word'][0]."%) ")
|
|
|
->alias("a")
|
|
|
->join("driver b","a.driver_id=b.id")
|
|
|
->field("b.id,name,license_plate")
|
|
|
->select();
|
|
|
print_r($res);return;
|
|
|
$count=$this->model
|
|
|
->alias("a")
|
|
|
->join("driver b","a.driver_id=b.id")
|
|
|
->count();
|
|
|
foreach ($res as $k=>$v){
|
|
|
$res[$k]['pid']=0;
|
|
|
}
|
|
|
$data=['list'=>$res,'total'=>$count];
|
|
|
return $data;
|
|
|
}
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
|
|
$list = $this->model
|
|
|
->with(['route','seat','driver'])
|
|
|
->where($where)
|
|
|
->order($sort, $order)
|
|
|
->paginate($limit);
|
|
|
|
|
|
foreach ($list as $row) {
|
|
|
$row->visible(['id','car_model','license_plate','seat','colour','driving_license','driver_license','reservation_time','start_time','create_time','status','carmodel_id']);
|
|
|
$row->visible(['route']);
|
|
|
$row->getRelation('route')->visible(['name']);
|
|
|
$row->visible(['seat']);
|
|
|
$row->getRelation('seat')->visible(['name']);
|
|
|
$row->visible(['driver']);
|
|
|
$row->getRelation('driver')->visible(['name']);
|
|
|
}
|
|
|
|
|
|
$result = array("total" => $list->total(), "rows" => $list->items());
|
|
|
|
|
|
return json($result);
|
|
|
}
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
...
|
...
|
|