Newer
Older
import {ActionSheetController, IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {FilterComponent} from "../../../../components/filter/filter";
import {PersonMulComponent} from "../../../../components/person-mul/person-mul";
participantAmount: false,
personList: false,
orgId: false
};
{id: '1', name: '工作会议'},
{id: '2', name: '座谈会'},
{id: '3', name: '中心组学习'},
{id: '4', name: '访谈'},
{id: '1', name: '投影仪'},
{id: '2', name: '互联网'},
{id: '3', name: '政务外网'},
{id: '4', name: '话筒'},
{id: '5', name: '茶水'},
{id: '6', name: '矿泉水'},
{id: '7', name: '毛巾'},
{id: '8', name: '水果'},
constructor(public navCtrl: NavController, public navParams: NavParams, private actionSheetCtrl: ActionSheetController,
private serveSer: ServeService, public _modalCtrl: ModalController, private appMainSer: AppMainService,
this.appMainSer.mineInfo.subscribe(value => {
this.mineInfo = value;
})
this.applyId = this.navParams.get('id');
if (this.applyId) {
this.meetDetail();
}
}
//时间和会议室初始化
initParams() {
const data = this.navParams.get('data');
if (data) {
this.obj.startTime = this.datePipe.transform(data.startTime, 'yyyy-MM-ddTHH:mm');
this.obj.roomId = data.roomId;
this.obj.roomText = data.roomName;
} else {
const now = this.datePipe.transform(new Date(), 'yyyy-MM-dd') + ' 9:00';
this.obj.startTime = this.datePipe.transform(now, 'yyyy-MM-ddTHH:mm');
//会议详情
meetDetail() {
this.serveSer.meetDetail(this.applyId).subscribe(
(res) => {
if (res) {
this.personList = res.participants.map(e => {
const m = {
id: e.userId,
userName: e.userName
};
return m;
});
this.obj.startTime = this.datePipe.transform(res.startTime, 'yyyy-MM-ddTHH:mm');
this.obj.endTime = this.datePipe.transform(res.endTime, 'yyyy-MM-ddTHH:mm');
getList() {
this.serveSer.getLeaders().subscribe(
(res) => {
this.leaderList = res.data;
}
);
this.serveSer.getRoomList().subscribe(
(res) => {
this.roomList = res.data;
}
);
const data = {order: 0};
this.serveSer.getAllOrganization(data).subscribe(
(res) => {
this.orgList = res;
const org = <any>this.orgList.filter(e => e.name == this.mineInfo.orgName);
if (org && org.length > 0) {
this.obj.orgText = org[0].name;
this.obj.orgId = org[0].id;
}
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//选择会议类型
chooseRoomType() {
const btnArr = this.meetTypeList.map(e => {
const data = {
text: e.name,
role: e.id,
handler: () => {
this.obj.meetingType = e.id;
this.obj.meetingTypeText = e.name;
}
};
return data;
});
btnArr.push({
text: '取消',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
});
const actionSheet = this.actionSheetCtrl.create({
cssClass: 'cameraAction',
buttons: btnArr
});
actionSheet.present();
}
//选择会议室
chooseRoom() {
const btnArr = this.roomList.map(e => {
const data = {
text: e.name,
role: e.id,
handler: () => {
this.obj.roomId = e.id;
this.obj.roomText = e.name;
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
}
};
return data;
});
btnArr.push({
text: '取消',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
});
const actionSheet = this.actionSheetCtrl.create({
cssClass: 'cameraAction',
buttons: btnArr
});
actionSheet.present();
}
//选择处室
chooseOrg() {
const btnArr = this.orgList.map(e => {
const data = {
text: e.name,
role: e.id,
handler: () => {
this.obj.orgId = e.id;
this.obj.orgText = e.name;
}
};
return data;
});
btnArr.push({
text: '取消',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
});
const actionSheet = this.actionSheetCtrl.create({
cssClass: 'cameraAction',
buttons: btnArr
});
actionSheet.present();
}
chooseLeader(item) {
const index = this.obj.orgLeader.indexOf(item.id);
if (index > -1) {
chooseEquip(item) {
const index = this.obj.equipmervice.indexOf(item.id);
if (index > -1) {
this.obj.equipmervice.splice(index, 1);
} else {
this.obj.equipmervice.push(item.id);
}
enterAnimation: 'modal-scale-enter',
leaveAnimation: 'modal-scale-leave'
});
modal.onDidDismiss(data => {
if (data) {
this.personList = data;
}
});
modal.present();
}
//移除人员
removePerson(index) {
console.log(index);
this.personList.splice(index, 1);
}
submit() {
const max = this.roomMax.replace(/[^0-9]/ig, "");
console.log(max);
if (isNaN(this.obj.participantAmount) || this.obj.participantAmount > max) {
console.log(this.obj.participantAmount);
this.check.participantAmount = true;
return false;
}
//校验
let checkBool = false;
for (let i in this.check) {
if (!this.obj[i] || this.personList.length == 0) {
checkBool = true;
this.check[i] = true;
} else {
this.check[i] = false;
}
}
if (checkBool) return false;
let orgName = this.orgList.filter(e => this.obj.orgId == e.id)[0].name;
roomId: this.obj.roomId,
orgId: this.obj.orgId,
orgName: orgName,
startTime: new Date(this.obj.startTime).getTime(),
endTime: new Date(this.obj.endTime).getTime(),
orgLeader: this.obj.orgLeader.join(','),
remark: this.obj.remark,
participant: this.personList.map(e => {
return e.id
}).join(','),
participantAmount: this.obj.participantAmount,
equipmervice: this.obj.equipmervice.join(','),
this.commonSer.alert('确定提交申请?', () => {
this.serveSer.saveApply(data).subscribe(
(res) => {
if (res.errcode == 1000) {
this.navCtrl.pop()
this.commonSer.toast('会议室申请成功');
} else {
this.commonSer.toast(res.errmsg);
}
}
)
});