Newer
Older
import {Component} from '@angular/core';
import {ActionSheetController, IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {ServeService} from "../../serve.service";
import {CommonService} from "../../../../provide/common.service";
import {DatePipe} from "@angular/common";
import {PersonMulComponent} from "../../../../components/person-mul/person-mul";
obj = {
startTime: null,
endTime: null,
carUser: '',
useReason: '',
useText: '请选择',
passengerCount: '',
fromTo: ''
};
checkObj = {
startTime: false,
endTime: false,
carUser: false,
useReason: false,
passengerCount: false,
fromTo: false,
constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, public modalCtrl: ModalController,
private commonSer: CommonService, private datePipe: DatePipe,
//初始化参数
initParams() {
const data = this.navParams.get('data');
console.log(data);
if (data) {
} else {
this.obj.startTime = this.datePipe.transform(new Date(), 'yyyy-MM-ddTHH:mm');
}
}
this.obj.useReason = res.data.useReason;
this.obj.passengerCount = res.data.passengerCount;
this.obj.fromTo = res.data.fromTo;
this.obj.startTime = this.datePipe.transform(res.data.startTime, "yyyy-MM-ddTHH:mm");
this.obj.endTime = this.datePipe.transform(res.data.endTime, "yyyy-MM-ddTHH:mm");
this.personList = res.data.carUserList.map(e => {
const m = {
id: e.id,
userName: e.name
};
return m;
});
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const buttonsArr = [
{
text: '参加市委市政府有市领导参加的重要会议及活动',
handler: () => {
this.obj.useReason = '1';
this.obj.useText = '参加市委市政府有市领导参加的重要会议及活动';
}
},
{
text: '有中央领导部委及外省市主要部门负责人来访的重要公务接待活动',
handler: () => {
this.obj.useReason = '2';
this.obj.useText = '有中央领导部委及外省市主要部门负责人来访的重要公务接待活动';
}
},
{
text: '有部领导参加的郊区调研。范围包括浦东新区(中环线以外)、宝山区、嘉定区、松江区、闵行区、青浦区、奉贤区、金山区、崇明区。(同乘一辆车)',
handler: () => {
this.obj.useReason = '3';
this.obj.useText = '有部领导参加的郊区调研。范围包括浦东新区(中环线以外)、宝山区、嘉定区、松江区、闵行区、青浦区、奉贤区、金山区、崇明区。(同乘一辆车)';
}
},
{
text: '携带保密文件出席本市重要会议或向市领导汇报工作',
handler: () => {
this.obj.useReason = '4';
this.obj.useText = '携带保密文件出席本市重要会议或向市领导汇报工作';
}
},
{
text: '集中群体性上访人员紧急分流安置',
handler: () => {
this.obj.useReason = '5';
this.obj.useText = '集中群体性上访人员紧急分流安置';
}
},
{
text: '老同志用车',
handler: () => {
this.obj.useReason = '6';
this.obj.useText = '老同志用车';
}
},
{
text: '机要交通',
handler: () => {
this.obj.useReason = '7';
this.obj.useText = '机要交通';
}
}, {
text: '取消',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}
];
const actionSheet = this.actionSheetCtrl.create({
buttons: buttonsArr
});
actionSheet.present();
}
//选择人员
choose() {
let modal = this.modalCtrl.create(PersonMulComponent, {
enterAnimation: 'modal-scale-enter',
leaveAnimation: 'modal-scale-leave'
});
modal.onDidDismiss(data => {
if (data) {
this.personList = data;
}
});
modal.present();
}
//移除人员
removePerson(index) {
this.personList.splice(index, 1);
}
//校验
let checkBool = false;
for (let i in this.checkObj) {
checkBool = true;
this.checkObj[i] = true;
} else {
this.checkObj[i] = false;
}
}
if (checkBool){
this.commonSer.toast("请输入必填项!");
return false;
}
let carUser = [];
this.personList.forEach(e => {
carUser.push(e.id);
});
const data = {
startTime: new Date(this.obj.startTime).getTime(),
endTime: new Date(this.obj.endTime).getTime(),
passengerCount: this.obj.passengerCount,
carUser: carUser.join(","),
useReason: this.obj.useReason,
fromTo: this.obj.fromTo
this.commonSer.alert('确认提交?',()=>{
this.serveSer.saveCarApply(data).subscribe(
(res) => {
if (res.errcode == 1000) {
this.commonSer.toast('提交申请成功');
this.navCtrl.pop();
} else {
this.commonSer.toast(res.errmsg);
}