Newer
Older
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {CalendarComponentOptions} from "ion2-calendar";
import {monthCh, weekDay} from "../../../app/main";
import {RoomApplyPage} from "./room-apply/room-apply";
import {ServeService} from "../serve.service";
import {DatePipe} from "@angular/common";
import {AppGlobal} from "../../../service/http.service";
import {CommonService} from "../../../provide/common.service";
import {AppMainService} from "../../../app/app.service";
import {RoomDealPage} from "./room-deal/room-deal";
changeType = 1;
date = new Date();
options: CalendarComponentOptions = {
from: new Date(2000, 0, 1),
monthFormat: 'YYYY 年 MM 月 ',
weekdays: weekDay,
monthPickerFormat: monthCh,
pickMode: 'single',
color: 'danger'
};
pageNumber = 1;
pageSize = AppGlobal.pageCount;
total;
isLoad = true;
constructor(public navCtrl: NavController, public navParams: NavParams,
private commonSer: CommonService, private appMainSer: AppMainService) {
this.selectDate = this.datePipe.transform(new Date(), 'yyyy-MM-dd');
this.getApply();
//获取权限
this.appMainSer.role.subscribe(value => {
this.role = value;
}
);
//获取个人信息
this.appMainSer.mineInfo.subscribe(value => {
this.mineInfo = value;
})
this.serveSer.queryMeetingRoomByDate(data).subscribe(
(res) => {
this.room = res.data;
}
)
getDate(e) {
this.selectDate = e;
this.getApply();
}
//我的预定
myApply() {
const data = {
P_pageNumber: this.pageNumber,
P_pageSize: this.pageSize,
this.serveSer.queryMyApply(data).subscribe(
(res) => {
this.isLoad = false;
this.applyList = res.list;
this.total = res.total;
}
)
}
//取消预定
removeItem(item) {
this.serveSer.cancelApply(item.id).subscribe(
(res) => {
if (res.errcode == 1000) {
this.commonSer.toast('取消预定成功');
this.myApply();
} else {
this.commonSer.toast(res.errmsg);
}
}
)
}
if (this.changeType == 1) this.getApply();
if (this.changeType == 2) this.myApply();
if (this.role.includes(0)) return false; //普通人不可编辑
if (this.role.includes(1) && item.orgName != this.mineInfo.orgName) return false; //内勤只能编辑本处室的
goApply(item) {
if (this.role.includes(0)) return false;
let data;
if (item) {
data = {
roomId: item.id,
roomName: item.name,
startTime: this.selectDate + ' 9:00:00',
};
}
this.navCtrl.push(RoomApplyPage, {data: data});