You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
202 lines
5.7 KiB
TypeScript
202 lines
5.7 KiB
TypeScript
import { ReplacementServiceRequest } from './../model/replacement-Service.request';
|
|
import { Component, OnInit } from '@angular/core';
|
|
import { VacationRuleServiceService } from '../service/vacation-rule-service.service';
|
|
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
|
|
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
|
|
import { ModalController } from '@ionic/angular';
|
|
|
|
|
|
|
|
@Component({
|
|
selector: 'app-replacement-list',
|
|
templateUrl: './replacement-list.component.html',
|
|
styleUrls: ['./replacement-list.component.scss'],
|
|
})
|
|
export class ReplacementListComponent implements OnInit {
|
|
|
|
P_SEARCH_USER_NAME: string = "";
|
|
P_SEARCH_EMPLOYEE_DISPLAY_NAME: string = "";
|
|
P_SEARCH_EMAIL_ADDRESS: string = "";
|
|
P_PAGE_NUM: number = 1;
|
|
P_PAGE_LIMIT: number = 50;
|
|
ReplacementList: any = [];
|
|
IsReachEnd: boolean = false;
|
|
selEmp: string = null;
|
|
callback: any;
|
|
searchKey: any = "";
|
|
searchKeySelect: string = "";
|
|
replacmentRequest: any = "";
|
|
isAbs: boolean = false;
|
|
isSave: boolean = false;
|
|
active: any;
|
|
|
|
constructor(public vacationRuleService: VacationRuleServiceService, public ts: TranslatorService, public cs: CommonService, public modalController: ModalController) { }
|
|
|
|
ngOnInit() { }
|
|
|
|
SearchReplacementList() {
|
|
this.ReplacementList = [];
|
|
this.IsReachEnd = false;
|
|
this.P_PAGE_NUM = 1;
|
|
if (this.searchKey) {
|
|
switch (this.searchKeySelect) {
|
|
case '1': {
|
|
|
|
this.P_SEARCH_EMPLOYEE_DISPLAY_NAME = this.searchKey;
|
|
this.P_SEARCH_USER_NAME = "";
|
|
this.P_SEARCH_EMAIL_ADDRESS = "";
|
|
|
|
break;
|
|
}
|
|
case '2': {
|
|
this.P_SEARCH_USER_NAME = this.searchKey;
|
|
this.P_SEARCH_EMPLOYEE_DISPLAY_NAME = "";
|
|
this.P_SEARCH_EMAIL_ADDRESS = "";
|
|
break;
|
|
}
|
|
case '3': {
|
|
this.P_SEARCH_EMAIL_ADDRESS = this.searchKey;
|
|
this.P_SEARCH_USER_NAME = "";
|
|
this.P_SEARCH_EMPLOYEE_DISPLAY_NAME = "";
|
|
break;
|
|
}
|
|
default: {
|
|
this.P_SEARCH_USER_NAME = "";
|
|
this.P_SEARCH_EMPLOYEE_DISPLAY_NAME = "";
|
|
this.P_SEARCH_EMAIL_ADDRESS = "";
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
this.P_SEARCH_USER_NAME = "";
|
|
this.P_SEARCH_EMPLOYEE_DISPLAY_NAME = "";
|
|
this.P_SEARCH_EMAIL_ADDRESS = "";
|
|
}
|
|
|
|
const request = new ReplacementServiceRequest();
|
|
request.P_SEARCH_USER_NAME = this.P_SEARCH_USER_NAME;
|
|
request.P_SEARCH_EMPLOYEE_DISPLAY_NAME = this.P_SEARCH_EMPLOYEE_DISPLAY_NAME;
|
|
request.P_SEARCH_EMAIL_ADDRESS = this.P_SEARCH_EMAIL_ADDRESS;
|
|
request.P_PAGE_NUM = this.P_PAGE_NUM;
|
|
request.P_PAGE_LIMIT = this.P_PAGE_LIMIT;
|
|
request.P_SELECTED_EMPLOYEE_NUMBER = this.selEmp;
|
|
|
|
this.vacationRuleService.getReplacementList(request).
|
|
subscribe((result: any) => {
|
|
this.handleReplacment(result);
|
|
});
|
|
}
|
|
|
|
handleReplacment(result) {
|
|
if (this.cs.validResponse(result)) {
|
|
if (this.cs.hasData(result.ReplacementList)) {
|
|
this.ReplacementList = result.ReplacementList;
|
|
this.P_PAGE_NUM++;
|
|
let lastItemIndex = this.ReplacementList.length - 1;
|
|
if (result.ReplacementList[lastItemIndex]) {
|
|
let lastitem = result.ReplacementList[lastItemIndex];
|
|
if (lastitem.NO_OF_ROWS == lastitem.ROW_NUM) {
|
|
this.IsReachEnd = true;
|
|
} else {
|
|
this.IsReachEnd = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
closePage() {
|
|
this.isSave = true;
|
|
let data: any = null;
|
|
if (this.isSave == true) {
|
|
if (this.selEmp) {
|
|
// data = this.ReplacementList[this.selEmp];
|
|
data=this.selEmp;
|
|
} else {
|
|
let msg: string = this.ts.trPK("replacementRoll", "msg");
|
|
this.cs.presentAlert(msg);
|
|
return;
|
|
}
|
|
// if (typeof this.callback == 'function') {
|
|
// this.callback(data);
|
|
// }
|
|
|
|
|
|
// this.modalController.dismiss({
|
|
// 'dismissed': true,
|
|
// empData: data
|
|
// });
|
|
|
|
|
|
this.modalController.dismiss(data);
|
|
|
|
// }else{
|
|
|
|
// let msg: string = this.ts.trPK("replacementRoll", "msg");
|
|
// this.cs.presentAlert(msg);
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
closeModal() {
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
select(selectEmp,index){
|
|
console.log(selectEmp.EMPLOYEE_DISPLAY_NAME);
|
|
this.selEmp=selectEmp
|
|
console.log("this.selEmp" + this.selEmp);
|
|
|
|
this.active=index;
|
|
}
|
|
|
|
|
|
doInfinite(infiniteScroll) {
|
|
if (!this.IsReachEnd) {
|
|
|
|
|
|
const request = new ReplacementServiceRequest();
|
|
request.P_PAGE_NUM = this.P_PAGE_NUM;
|
|
request.P_PAGE_LIMIT = this.P_PAGE_LIMIT;
|
|
|
|
// request.P_SELECTED_EMPLOYEE_NUMBER=this.selEmp;
|
|
|
|
this.vacationRuleService.getReplacementList(request).
|
|
subscribe((result: any) => {
|
|
if (this.cs.validResponse(result)) {
|
|
if (this.cs.hasData(result.ReplacementList)) {
|
|
this.P_PAGE_NUM++;
|
|
result.ReplacementList.forEach(vr => {
|
|
if (vr.ROW_NUM == vr.NO_OF_ROWS) {
|
|
this.IsReachEnd = true;
|
|
}
|
|
else {
|
|
this.IsReachEnd = false;
|
|
}
|
|
this.ReplacementList.push(vr);
|
|
// this.pro.GetVacationRulesList.push(vr);
|
|
});
|
|
} else {
|
|
this.IsReachEnd = true;
|
|
}
|
|
}
|
|
//this.P_PAGE_NUM++;
|
|
if (infiniteScroll)
|
|
infiniteScroll.target.complete();
|
|
|
|
|
|
// console.log(resFlag);
|
|
}, (Error) => console.log(Error), () => infiniteScroll.target.complete());
|
|
} else {
|
|
if (infiniteScroll)
|
|
infiniteScroll.target.complete();
|
|
}
|
|
}
|
|
}
|