Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
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
149
150
151
152
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams, ToastController, Content} from 'ionic-angular';
import {Response} from '@angular/http';
import {Storage} from '@ionic/storage';
import {AppGlobal, AppService} from '../../../service/http.service';
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)
picture: string = AppGlobal.picture;
generalContactPersons: Array<string> = [];
//部门id
orgid: string;
orgName: string;
constructor(public navCtrl: NavController,
public navParams: NavParams,
public storage: Storage,
public appService: AppService,
public toast: ToastController,) {
}
ionViewDidEnter(): void {
this.orgid = this.navParams.get("orgid");
this.orgName = this.navParams.get("orgName");
//加载联系人(常用联系人,部门下人员)
if (this.orgid != null && this.orgid != '') {
this.getGeneralContactPersons(); //常用联系人ids数组
this.initOrganizationPersons(); //加载部门下人员
} else {
this.initGeneralContactPersons(); //加载常用联系人
}
}
//加载常用联系人
initGeneralContactPersons() {
const data = {
'order': 1
};
this.appService.ObserverHttpGetOption("/wisdomgroup/app/contact/getGeneralContactPersons", data)
.subscribe((res: Response) => {
let data = res.json();
this.contactPersons = data;
this.contactPersons.forEach(element => {
//常用联系人的部门信息
this.getOrgName(element["id"], result => {
element["orgName"] = result["orgName"];
});
//是否已添加到常用联系人中:
//false:按钮为:添加常用联系人
//常用联系人:默认为true 有移除常用联系人按钮
element["hasgeneralpersonsflag"] = true;
});
}, error => {
}
);
}
//根据用户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 => {
});
}
//加载部门下人员
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();
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 => {
}
);
}
//跳转联系人信息页面
contactPersonInfo(contactPerson) {
this.navCtrl.push("ContractPersoninfoPage", {"id": contactPerson.id});
}
// 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"]);
});
}, error => {
}
);
}
goBack() {
this.navCtrl.popToRoot();
}
}