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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Response } from '@angular/http';
import { Storage } from '@ionic/storage';
import {AppService} from "../../../../service/http.service";
import {ChooseAddressPage} from "../chooseAddress/chooseAddress";
import { OutGoingReportEditPage } from '../outGoingReportEdit/outGoingReportEdit';
@IonicPage()
@Component({
selector: 'page-outGoingReportDetail',
templateUrl: 'outGoingReportDetail.html'
})
export class OutGoingReportDetailPage {
//临时个人报备
temp_userpre = {
id: '',
leaveDate : '',
backDate : '',
managerDesc : '',
outaddressids : '',
managerId: '',
areaName : '',
entTime : '',
premanagerImg: '',
premanagerIntroduce:''
}
//地点id,多个之间用逗号分隔
addressid = "";
//离沪地点显示
locations : any;
//报备实体
premanager;
//选择的所有地点
allselectedCity:Array<String> = [];
temp_city:Array<String> = [];
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public appService: AppService,
public storage: Storage
) {
//当前页面---个人报备页面2 (临时存储离沪数据)
//个人报备1——> 个人报备2页面
this.premanager = this.navParams.get("premanager");
this.storage.set('premanager',this.premanager);
if(this.premanager!=null ){
if(this.premanager["reserve1"]!=null && this.premanager["reserve2"]!=null){
//原来方法:this.newLeave.dateStart=new Date().toISOString();会误差8个小时,以下方法是个简单处理技巧,仅限中国地区使用 +8*60*60*1000
this.temp_userpre.leaveDate=new Date(this.premanager["reserve1"]).toISOString();//假期开始时间
this.temp_userpre.backDate=new Date(this.premanager["reserve2"]).toISOString();//假期结束时间
}
this.temp_userpre.managerId = this.premanager.id;
//报备截至时间
this.temp_userpre.entTime = this.premanager.endTime;
this.temp_userpre.premanagerImg = this.premanager.uploadPic;
this.temp_userpre.premanagerIntroduce = this.premanager.managerDesc;
//编辑初始化:查询
const data= {
premanagerId:this.premanager.id,
userId:''
};
if(this.navParams.get('userId')){
data.userId = this.navParams.get('userId');
}else if(this.navParams.get('doPremanager') == 'null'){
data.userId = null;
}
this.appService.ObserverHttpPost("/wisdomgroup/modules/userpre/getUserpre",data)
.subscribe((res: Response) => {
if( res ){
let result = res.json();
this.temp_userpre.id = result.id; //临时-id
if(result.isorFromsh == 1){ //离沪
this.temp_userpre.managerDesc = result.userpreDesc;
this.temp_userpre.leaveDate = result.formshTime;
this.temp_userpre.backDate = result.comeshTime;
this.allselectedCity = result.areaList; //地点回显
//将原保存的地点放入storage中
this.storage.set("cityList",this.allselectedCity);
}
}
}, error => {
}
);
}
//这个操作是拿出放在storage中城市地点的集合放在 当前页面的临时temp_city中
this.storage.get("cityList").then((value)=>{
if(value != null && value != ''){
this.temp_city = value;
this.allselectedCity = this.temp_city;
}
this.storage.get("city").then((value)=>{
if(value != null && value != ''){
//对每选择一个city都放在临时变量中再保存一次
this.temp_city.push(value);
this.storage.set('cityList',this.temp_city);
this.allselectedCity = this.temp_city;
}
this.storage.remove("city");
});
});
//地点城市页面 到 个人报备2(本页面) 页面
//get的目的是在地点城市页面到 个人报备2(此页面)数据仍然存在
this.storage.get("temp_userpre").then((value)=>{
if(value != null && value != ''){
this.temp_userpre = value;
}
});
}
ionViewDidEnter() {
const length = this.navCtrl.length();
if(length > 5){
this.navCtrl.remove(3, length-4);
}
}
//添加地点
addAddress(){
this.storage.remove('city');
this.storage.set('temp_userpre',this.temp_userpre);
this.navCtrl.push("ChooseAddressPage");
}
//删除地点
deleteAddress(city){
let index_city = 0;
for (let index = 0; index < this.allselectedCity.length; index++) {
const element = this.allselectedCity[index];
if(element["id"] == city ) {
index_city = index;
}
}
this.allselectedCity.splice(index_city,1);
this.storage.remove("cityList");
this.storage.set('cityList',this.allselectedCity);
}
//个人报备2 --> 个人报备1 页面
//保存 按钮
//将该页面值带入个人报备1页面 进行统一的个人报备
saveFieldValue(){
//1.离沪时间和回沪时间不能为空
if((this.temp_userpre.leaveDate == null || this.temp_userpre.leaveDate == '')
||( this.temp_userpre.backDate == null || this.temp_userpre.backDate == '')){
this.appService.alert("日期不能为空");
return false;
}
//2.判断回沪日期和离沪日期
let dateflag = Date.parse(this.temp_userpre.leaveDate.toString()) > Date.parse(this.temp_userpre.backDate.toString());
if(dateflag){
this.appService.alert("回沪日期应大于回沪日期");
return false;
}
//3.离沪地点不能为空
if(this.allselectedCity != null && this.allselectedCity.length>0){
if( this.allselectedCity != null && this.allselectedCity.length > 0){
this.addressid = '';
this.locations = '';
for (let index = 0; index < this.allselectedCity.length; index++) {
const element = this.allselectedCity[index];
this.addressid += element["id"]+",";
this.locations += element["areaName"]+",";
}
this.addressid = this.addressid.substring(0,this.addressid.lastIndexOf(","));
this.locations = this.locations.substring(0,this.locations.lastIndexOf(","));
this.temp_userpre.outaddressids = this.addressid;
this.temp_userpre.areaName = this.locations;
}
}else{
this.appService.alert("离沪地点不能为空");
return false;
}
this.storage.remove('temp_userpre');
this.storage.set('temp_userpre',this.temp_userpre);
this.navCtrl.push("OutGoingReportEditPage");
}
}