Newer
Older
import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic-angular';
import {CommonService} from "../../../../provide/common.service";
import {ServeService} from "../../serve.service";
@Component({
selector: 'page-driver',
templateUrl: 'driver.html',
})
export class DriverPage {
@Input() applyId;
opObj = {
isOwner: <any>"1", //是否是内部车辆(1是,0否)
driverName: '',
};
checkOpObj = {
driverName: false,
carNumber: false,
carOrg: false,
};
carList = [];
driverList = [];
constructor(public navCtrl: NavController, public navParams: NavParams,
private commonSer: CommonService, private serveSer: ServeService) {
this.getList();
}
//车辆 司机
getList() {
this.serveSer.getCarList().subscribe(
(res) => {
this.carList = res.data;
}
);
this.serveSer.getDriverList().subscribe(
(res) => {
this.driverList = res.data;
}
);
}
//选择司机
chooseDriver() {
const btnArr = this.driverList.map(e => {
const data = {
text: e.name,
role: e.name,
handler: () => {
this.opObj.driverName = e.name;
this.opObj.driverNameText = e.name;
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
}
};
return data;
});
btnArr.push({
text: '取消',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
});
const actionSheet = this.actionSheetCtrl.create({
cssClass: 'cameraAction',
buttons: btnArr
});
actionSheet.present();
}
//选择车牌号
chooseNumber() {
const btnArr = this.carList.map(e => {
const data = {
text: e.carNumber,
role: e.carNumber,
handler: () => {
this.opObj.carNumber = e.carNumber;
this.opObj.carNumberText = e.carNumber;
}
};
return data;
});
btnArr.push({
text: '取消',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
});
const actionSheet = this.actionSheetCtrl.create({
cssClass: 'cameraAction',
buttons: btnArr
});
actionSheet.present();
}
//提交审核
submitOp(status) {
let data;
const data_company = {
applyId: this.applyId,
driverName: this.opObj.driverName,
carNumber: this.opObj.carNumber,
status: status,
isOwner: Number(this.opObj.isOwner)
};
const data_lease = {
applyId: this.applyId,
driverName: this.opObj.driverName,
carNumber: this.opObj.carNumber,
carOrg: this.opObj.carOrg,
status: status,
isOwner: Number(this.opObj.isOwner)
};
data = this.opObj.isOwner == "1" ? data_company : data_lease;
//校验
let checkBool = false;
if (status == 2) {
for (let i in data) {
if (!data[i]) {
checkBool = true;
this.checkOpObj[i] = true;
} else {
this.checkOpObj[i] = false;
}
if (checkBool) {
this.commonSer.toast("请输入必填项!");
return false;
}
this.commonSer.alert('确认提交?', () => {
this.serveSer.carOperate(data).subscribe(
(res) => {
if (res.errcode == 1000) {
this.commonSer.toast('审核成功');
this.navCtrl.pop();
} else {
this.commonSer.toast(res.errmsg);
}
}
)
});
}
}