Newer
Older
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController,Content } from 'ionic-angular';
import { Response } from '@angular/http';
import { ContractPersoninfoPage } from '../contract-personinfo/contract-personinfo';
@IonicPage()
@Component({
selector: 'page-contactList',
templateUrl: 'contactList.html'
})
export class ContactListPage {
//联系人列表
//contactPersons: Array<string> = [];
contactPersons: Array<string>[];
//常用联系人列表(只存联系人id)
generalContactPersons:Array<string> = [];
//部门id
orgid:string;
orgName:string;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public storage: Storage,
public appService: AppService,
public toast: ToastController,) {
}
this.orgid = this.navParams.get("orgid");
this.orgName = this.navParams.get("orgName");
//加载联系人(常用联系人,部门下人员)
this.getGeneralContactPersons(); //常用联系人ids数组
this.initOrganizationPersons(); //加载部门下人员
const data = {
'order':1
};
this.appService.ObserverHttpGetOption("/wisdomgroup/app/contact/getGeneralContactPersons",data)
.subscribe((res: Response) => {
let data = res.json();
console.log("data1:"+JSON.stringify(data));
this.contactPersons = data;
this.contactPersons.forEach(element => {
//常用联系人的部门信息
this.getOrgName(element["id"],result=>{
element["orgName"] = result["orgName"];
});
//是否已添加到常用联系人中:
//true:按钮为:移除常用联系人
//false:按钮为:添加常用联系人
//常用联系人:默认为true 有移除常用联系人按钮
element["hasgeneralpersonsflag"] = true;
});
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
this.appService.alert('网络异常!');
}
);
}
//根据用户id获取部门信息
getOrgName(id,callback?): any {
this.appService.ObserverHttpPost("/wisdomgroup/app/getOrgName",{"userid":id})
.toPromise()
.then(res => {
var data = res.json();
callback(data == null ? "[]" : data);
})
.catch(error => {
this.appService.alert('网络异常!');
});
}
//加载部门下人员
initOrganizationPersons(){
//this.appService.ObserverHttpGet("/wisdomgroup/app/getAllUserByOrgid",{"orgId":this.orgid})
this.appService.ObserverHttpGet("/wisdomgroup/sysmanagement/user/getAllUserByOrgid",{"orgId":this.orgid})
.subscribe((res: Response) => {
let data = res.json();
console.log("data:"+data);
this.contactPersons = data;
this.contactPersons.forEach(element => {
//部门人员的部门信息
element["orgName"] = this.orgName;
//暂时设置为false:添加联系人按钮
//后期要判断是否已添加过该联系人
//默认是添加按钮:false
element["hasgeneralpersonsflag"] = false;
//判断是否在常用联系人中存在:移除按钮
for (let index = 0; index < this.generalContactPersons.length; index++) {
const strid = this.generalContactPersons[index];
if(element["id"] == strid){
element["hasgeneralpersonsflag"] = true;
break;
}
}
});
}, error => {
this.appService.alert('网络异常!');
}
);
}
//跳转联系人信息页面
contactPersonInfo(contactPerson){
}
// search(){
// if(this.orgid != null && this.orgid != ''){
// this.navCtrl.push("SearchPage",{"orgid":this.orgid,"orgName":this.orgName}); //组织部门下搜索
// }else{ //全局搜索
// this.navCtrl.push("SearchPage");
// }
// }
//获取常用联系人ids,数组:此方法主要是在部门人员列表中判断:
//当前人员是否在常用联系人中来判别:添加/移出联系人按钮
getGeneralContactPersons(){
const data = {
'order':1
};
this.appService.ObserverHttpGetOption("/wisdomgroup/app/contact/getGeneralContactPersons",data)
.subscribe((res: Response) => {
let data = res.json();
data.forEach(element => {
this.generalContactPersons.push(element["id"]);
});