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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {Response} from '@angular/http';
import {AppGlobal, AppService} from '../../../service/http.service';
import { Storage } from "@ionic/storage";
import {ContactListPage} from '../contactList/contactList';
import {MyBlockPage} from "../my-block/my-block";
@IonicPage()
@Component({
selector: 'page-contract-personinfo',
templateUrl: 'contract-personinfo.html',
})
export class ContractPersoninfoPage {
contactPersonInfo = {
gender: '',
telephone: '',
email: '',
abbreviation: ''
};
id;
picture: string = AppGlobal.picture;
user; //登录人信息
orgName; //登录人部门
edit = false;
email;
abbreviation;
telephone;
isContact;
role; //权限
nowOrgName;
constructor(public navCtrl: NavController,
public navParams: NavParams,
public appService: AppService,
public storage: Storage) {
}
ionViewDidEnter() {
this.id = this.navParams.get("id");
this.getPersonInfo();
this.getRole();
this.user = this.storage.get("user").then((value) => {
this.user = value;
this.getOrgName(this.user.id, result => {
let data = result;
this.orgName = data["orgName"];
});
});
}
//获取当前登录人部门
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 => {
});
}
//获取权限
getRole(){
this.appService.ObserverHttpGet("/wisdomgroup/app/getRoles", null).subscribe((res: Response) => {
this.role = res.json();
}, error => {
this.appService.alert('系统错误!');
});
}
getPersonInfo() {
const data = {
'userId': this.id
};
this.appService.ObserverHttpGet("/wisdomgroup/modules/telpBookPerson", data)
.subscribe((res: Response) => {
this.contactPersonInfo = res.json().data.user;
this.isContact = res.json().data.isContact;
this.nowOrgName = res.json().data.orgName;
this.email = this.contactPersonInfo.email;
this.abbreviation = this.contactPersonInfo.abbreviation;
this.telephone = this.contactPersonInfo.telephone;
}, error => {
}
);
}
//添加常用联系人
addcontactPersons() {
const data = {
'relUserId': this.id,
'moduleName': 'appcontact'
}
this.appService.ObserverHttpPostOption("/wisdomgroup/app/contact/addGeneralContactPersons", data)
.subscribe((res: Response) => {
let data = res.json();
if (data["result"] == '2') {
this.appService.popToastView('该联系人已在常用联系人中!', 'top', 2000);
} else if (data["result"] == '3') {
this.appService.popToastView('添加常用联系人失败!', 'top', 2000);
} else {
this.appService.popToastView('添加常用联系人成功!','middle',2000);
this.getPersonInfo();
// this.navCtrl.push("ContactListPage");
}
//this.navCtrl.pop();
}, error => {
}
);
}
//移除常用联系人
cancelGenaralPersons() {
const data = {
relUserId: this.id,
moduleName: 'appcontact',
};
this.appService.ObserverHttpPost("/wisdomgroup/app/contact/deleteGeneralContactPersons", data)
.subscribe((res: Response) => {
let data = res.json();
this.getPersonInfo();
this.appService.popToastView('移除常用联系人成功!', 'middle', 2000);
}, error => {
}
);
}
call(number) {
window.location.href = "tel:" + number;
}
editFun() {
this.edit = true;
}
//跳转设置分组
usualContactSet() {
this.navCtrl.push('MyBlockPage', {'item': this.contactPersonInfo});
}
//取消编辑
editCancel() {
this.getPersonInfo();
this.edit = false;
}
//完成
editDone() {
const data = {
email: this.email,
telephone: this.telephone,
abbreviation: this.abbreviation
};
this.appService.ObserverHttpPut("/wisdomgroup/modules/telpBookPerson/", this.id, data)
.subscribe((res: Response) => {
let data = res.json();
this.getPersonInfo();
this.edit = false;
}, error => {
}
);
}
}