作者 郭文星

123

... ... @@ -102,10 +102,10 @@ class Car extends Backend
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
// $istrue=$this->model->where("driver_id",$params['driver_id'])->find();
// if($istrue){
// $this->error("该司机添加车辆");
// }
$istrue=$this->model->where("driver_id",$params['driver_id'])->find();
if($istrue){
$this->error("该司机添加车辆");
}
$route=Db::name("route")->where("id",$params['route_id'])->find();
$driver=Db::name("driver")->where("id",$params['driver_id'])->find();
$result = $this->model->allowField(true)->save($params);
... ... @@ -164,6 +164,23 @@ class Car extends Backend
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$car=Db::name('car')->where("id",$ids)->find();
$driver=Db::name('driver')->where("id",$car['driver_id'])->find();
if(!$driver['place_image']){
$index=new Index();
$route=Db::name("route")->where("id",$params['route_id'])->find();
$driver=Db::name("driver")->where("id",$params['driver_id'])->find();
$data=[
"start_address"=>$route["start_address"],
"end_address"=>$route["end_address"],
"name"=>$driver["name"],
"driver_id"=>$driver["id"],
];
$place_image=$index->build(json_encode($data));
$result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image['fileurl']]);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
... ...
... ... @@ -10,7 +10,7 @@ return [
'Colour' => '车辆颜色',
'Driving_license' => '行驶证',
'Driver_license' => '驾照',
'Seat_id' => '座位id',
'Seat_id' => '座位价格',
'Reservation_time' => '预约时间',
'Start_time' => '发车时间',
'Create_time' => '创建时间',
... ...
... ... @@ -3,5 +3,6 @@
return [
'Id' => 'ID',
'Name' => '车型名称',
'Price' => '包车价格'
'Price' => '包车价格',
'Intercity_price' => '城际价格'
];
... ...
... ... @@ -73,13 +73,13 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Reservation_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-reservation_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[reservation_time]" type="text" value="{:$row.reservation_time?datetime($row.reservation_time):''}">
<input id="c-reservation_time" class="form-control datetimepicker" data-date-format=" HH:mm" data-use-current="true" name="row[reservation_time]" type="text" value="{:$row.reservation_time?datetime($row.reservation_time):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Start_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-start_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[start_time]" type="text" value="{:$row.start_time?datetime($row.start_time):''}">
<input id="c-start_time" class="form-control datetimepicker" data-date-format=" HH:mm" data-use-current="true" name="row[start_time]" type="text" value="{:$row.start_time?datetime($row.start_time):''}">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -12,6 +12,12 @@
<input id="c-price" class="form-control" step="0.01" name="row[price]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Intercity_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-intercity_price" class="form-control" step="0.01" name="row[intercity_price]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -12,6 +12,12 @@
<input id="c-price" class="form-control" step="0.01" name="row[price]" type="number" value="{$row.price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Intercity_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-intercity_price" class="form-control" step="0.01" name="row[intercity_price]" type="number" value="{$row.intercity_price|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -976,7 +976,8 @@ class Car extends Base
* @return void
*/
public function qrcode(){
$driver=Db::name("driver")->where('user_id',$this->auth->id)->field("place_image")->find();
$driver=Db::name("driver")->where('user_id',7)->field("place_image")->find();
$driver['place_image']=full_image($driver['place_image']);
$this->success("请求成功",$driver);
}
... ...
... ... @@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'price', title: __('Price'), operate:'BETWEEN'},
{field: 'intercity_price', title: __('Intercity_price'), operate:'BETWEEN'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...