lookandupdate.js
16.8 KB
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
// pages/main/addtionalreduce/childreneducate/childreneducate.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
var format = require('../../../../utils/util.js');
Page({
/**
* Page initial data
*/
data: {
cur_status: "",
legal_entity_id: "",
legal_entity: "",
house_type: "",
declareStatus: {
"to_declare": "待申报",
"declaring": "申报中",
"success": "审核成功",
"failed": "审核失败"
},
additiontitle: {
"children_education": "子女教育",
"continuing_education": "继续教育",
"support_duty": "赡养老人",
"medical_fund": "大病医疗",
"house_fund": "住房"
},
title: '',
imgpath: '',
new_data: null,
modal_images: {
"children_education": "/images/childedu_declare.png",
"continuing_education": "/images/continueedu_declare.png",
"support_duty": "/images/support_older_declare.png",
"medical_fund": "/images/health_declare.png",
"house_fund": "/images/house_declare.png"
},
showModal_img: false,
showModal_reducetype: false,
showModal_addtype: false,
url_arr: {
"children_education": "persontax/v1/children-educations/",
"continuing_education": "persontax/v1/continuing-educations/",
"support_duty": "persontax/v1/support-duties/",
"medical_fund": "persontax/v1/medical-funds/",
"house_fund": "persontax/v1/house-funds/"
},
reducetype: {
"month": "月",
"year": "年"
},
issinglechildData: {
label: '是否独生子女',
bindtype: 'issingle_child',
selected: '',
isblack: '',
placeholder: '请选择是否独生子女',
values: ["是", "否"],
onChange: 'onPickerSelect'
},
shareMethodData: {
label: '分摊方式',
bindtype: 'share_method',
selected: '',
isblack: '',
values: ["赡养人平均分摊", "赡养人约定分摊", "被赡养人指定分摊"],
placeholder: '请选择分摊方式',
onChange: 'onPickerSelect'
},
additionInfo: [],
reducetypeData: ["月度", "年度"],
modalData: {},
children_modalData: {
title: "请选择子女进行申报",
datas: [],
lefttext: "添加新子女并申报",
righttext: "确定为该子女申报",
},
support_older_modalData: {
title: "请选择父母或祖父母进行申报",
datas: [],
lefttext: "添加被赡养人并申报",
righttext: "确定为该被赡养人申报",
},
medical_modalData: {
title: "请选择本人、配偶或子女进行大病支出申报",
datas: [],
lefttext: "添加家庭成员并申报",
righttext: "确定为该选择的人申报",
},
reduce_amount: -1,
selected_reduceindex: 0,
selected_addindex: 0
},
/**
* Lifecycle function--Called when page load
*/
onLoad: function(options) {
var that = this
var housetype, housestatus
console.log("options", options);
if (options.status == 'house_fund_rent') {
housetype = 'house_fund_rent'
housestatus = 'house_fund'
} else if (options.status == 'house_fund_loan') {
housetype = 'house_fund_loan'
housestatus = 'house_fund'
} else {
housetype = ''
housestatus = options.status
}
this.setData({
cur_status: housestatus,
house_type: housetype,
legal_entity_id: options.legal_entity_id,
legal_entity: options.legal_entity,
selected_reduceindex: options.status == 'medical_fund' ? 1 : 0
})
wx.setNavigationBarTitle({
"title": that.data.additiontitle[this.data.cur_status],
})
},
/**
* Lifecycle function--Called when page is initially rendered
*/
onReady: function() {
},
/**
* Lifecycle function--Called when page show
*/
onShow: function() {
var that = this
this.getAdditionInfo()
this.getTaxList()
},
getAdditionInfo() {
var that = this;
var Authorization = getApp().globalData.Authorization;
wx.request({
url: baseUrl + that.data.url_arr[that.data.cur_status] + that.data.legal_entity_id,
header: {
'content-type': 'application/json',
"Authorization": Authorization
},
success: function(res) {
if (res && res.data) {
console.log("res", res)
that.handleAddition(res.data)
}
}
})
},
handleAddition: function(data) {
var newdata = data.items
for (var i = 0; i < newdata.length; i++) {
if (newdata[i].education_start) {
newdata[i].education_start = this.formatDate(newdata[i].education_start)
}
if (newdata[i].education_end) {
newdata[i].education_end = this.formatDate(newdata[i].education_end)
}
if (newdata[i].approval_date) {
newdata[i].approval_date = this.formatDate(newdata[i].approval_date)
}
if (newdata[i].patient_birthday) {
newdata[i].patient_birthday = this.formatDate(newdata[i].patient_birthday)
}
//详情迁移
if (newdata[i].children_birthday) {
newdata[i].children_birthday = this.formatDate(newdata[i].children_birthday)
}
if (newdata[i].spouse_birthday) {
newdata[i].spouse_birthday = this.formatDate(newdata[i].spouse_birthday)
}
if (newdata[i].birthday) {
newdata[i].birthday = this.formatDate(newdata[i].birthday)
}
if (newdata[i].rent_start) {
newdata[i].rent_start = this.formatDate(newdata[i].rent_start)
}
if (newdata[i].rent_end) {
newdata[i].rent_end = this.formatDate(newdata[i].rent_end)
}
newdata[i].children_id_card_no = this.formatIdNum(newdata[i].children_id_card_no)
newdata[i].spouse_id_card_no = this.formatIdNum(newdata[i].spouse_id_card_no)
newdata[i].id_card_no = this.formatIdNum(newdata[i].id_card_no)
if (newdata[i].house_address) {
if (newdata[i].house_address.province == newdata[i].house_address.city) {
newdata[i].house_address_new = newdata[i].house_address.city + newdata[i].house_address.district
} else {
newdata[i].house_address_new = newdata[i].house_address.province + newdata[i].house_address.city + newdata[i].house_address.district
}
}
if (newdata[i].work_city) {
newdata[i].work_city_new = newdata[i].work_city.province + newdata[i].work_city.city
}
if (newdata[i].co_supporters && newdata[i].co_supporters.length > 0) {
for (var j = 0; j < newdata[i].co_supporters.length; j++) {
if (newdata[i].co_supporters[j].birthday) {
newdata[i].co_supporters[j].birthday = this.formatDate(newdata[i].co_supporters[j].birthday)
}
newdata[i].co_supporters[j].id_card_no = this.formatIdNum(newdata[i].co_supporters[j].id_card_no)
}
}
}
var housetype_new = this.data.house_type
if (newdata.length > 0 && newdata[0].type) {
housetype_new = newdata[0].type == 'loan' ? "house_fund_loan" : "house_fund_rent"
}
console.log("housetype_new", housetype_new)
this.setData({
house_type: housetype_new,
additionInfo: newdata
})
},
goaddSupporter: function() {
wx.navigateTo({
url: '../adddupporters/adddupporters?id=' + this.data.additionInfo[0].id,
})
},
// lookimg: function() { //查看材料
// if (this.data.imgpath && this.data.imgpath.length > 0) {
// wx.previewImage({
// urls: [this.data.imgpath],
// })
// } else {
// wx.showToast({
// title: '暂无可查看资料',
// })
// }
// },
showdetail: function(e) {
if (this.data.additionInfo && this.data.additionInfo.length > 0) {
console.log("showdetail", JSON.stringify(this.data.additionInfo[e.currentTarget.id]))
wx.navigateTo({
url: '../additiondetail/additiondetail?datas=' +
JSON.stringify(this.data.additionInfo[e.currentTarget.id]) + "&status=" + this.data.cur_status,
})
}
},
godelete: function(e) { //删除
var that = this;
var Authorization = getApp().globalData.Authorization;
wx.request({
url: baseUrl + 'persontax/v1/op/delete',
data: {
item_type: that.data.cur_status,
id: that.data.legal_entity_id
},
header: {
'content-type': 'application/json',
"Authorization": Authorization
},
method: "POST",
success: function(res) {
if (res && res.data) {
console.log("res", res)
}
}
})
},
goedit: function(e) { //编辑
console.log("goedit", e)
if (this.data.additionInfo && this.data.additionInfo.length > 0) {
wx.navigateTo({
url: '../addextrainfo/addextrainfo?datas=' + JSON.stringify(this.data.additionInfo[e.currentTarget.id]) + '&status=' + this.data.cur_status + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex] + '&isedit=true',
})
}
},
goadd: function(e) { //添加
console.log("goadd", e)
var that = this
if (this.data.cur_status == 'support_duty') {
if (this.data.issinglechildData.selected.length < 1) {
this.showToast("请选择是否独生子女")
return
}
if (this.data.issinglechildData.selected == "否") {
if (this.data.shareMethodData.selected.length < 1) {
this.showToast("请选择分摊方式")
return
}
if (this.data.reduce_amount == -1){
this.showToast("请输入扣除金额")
return
}else if (this.data.reduce_amount < 1 || this.data.reduce_amount > 1000) {
this.showToast("本年度月扣除金额不得大于1000")
return
}
} else {
this.setData({
reduce_amount: 2000
})
}
}
var modalinfo, senddata
if (this.data.cur_status == 'continuing_education' || this.data.cur_status == 'house_fund') {
wx.navigateTo({
url: '../addextrainfo/addextrainfo?datas=' + '' + '&status=' + this.data.cur_status + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
})
} else {
if (this.data.cur_status == 'children_education') { //modalData
modalinfo = this.data.children_modalData
} else if (this.data.cur_status == 'support_duty') {
modalinfo = this.data.support_older_modalData
} else if (this.data.cur_status == 'medical_fund') {
modalinfo = this.data.medical_modalData
}
senddata = JSON.stringify(modalinfo.datas[e.currentTarget.id])
console.log("modalinfo", modalinfo)
if (modalinfo.datas.length > 0) {
this.showAddtionmodal(modalinfo)
} else {
wx.navigateTo({
url: '../addextrainfo/addextrainfo?status=' + this.data.cur_status + '&datas=' + senddata + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
})
}
}
},
getTaxList: function() {
var that = this;
wx.showLoading({
title: '加载中',
})
var Authorization = app.globalData.Authorization;
console.log('Authorization', Authorization)
if (!Authorization || Authorization.length < 10) {
return
}
wx.request({
url: baseUrl + 'persontax/v1/personal-taxes',
method: "GET",
header: {
'content-type': 'application/json', // 默认值
"Authorization": Authorization
},
data: {
'all': true
},
success: function(res) {
console.log('succ', res)
if (res.statusCode == 200) {
that.handleData(res.data);
}
},
fail(res) {
console.log(res.data)
},
complete() {
wx.hideLoading()
that.setData({
load_finish: true
})
}
})
},
handleData: function(data) {
if (data.items && data.items.length > 0) {
var childRelativelist = []
var medicalRelativelist = []
var olderRelativelist = []
var childmodal = this.data.children_modalData
var oldermodal = this.data.support_older_modalData
var medicalmodal = this.data.medical_modalData
for (var i = 0; i < data.items.length; i++) {
if (data.items[i].family_ties == '子' || data.items[i].family_ties == '女') {
childRelativelist.push(data.items[i])
}
if (data.items[i].family_ties == '父母' || data.items[i].family_ties == '祖父母、外祖父母') {
olderRelativelist.push(data.items[i])
} else {
medicalRelativelist.push(data.items[i])
}
}
childmodal.datas = childRelativelist
oldermodal.datas = olderRelativelist
medicalmodal.datas = medicalRelativelist
this.setData({
children_modalData: childmodal,
support_older_modalData: oldermodal,
medical_modalData: medicalmodal
})
}
},
showModalImg: function(e) {
console.log("showModalImg", e)
this.setData({
showModal_img: true,
})
},
closeModalImg: function(e) {
console.log("closeModalImg", e)
this.setData({
showModal_img: false
})
},
// 扣除类型
showModalReducetype: function(e) {
console.log("reducetype", e)
this.setData({
showModal_reducetype: true,
})
},
showAddtionmodal: function(modalinfo) {
this.setData({
modalData: modalinfo,
showModal_addtype: true,
})
},
reduce_modalLeft: function() { //modal取消(扣除类型)
this.setData({
showModal_reducetype: false
})
},
reduce_modalRight: function() { //modal确认(扣除类型)
this.setData({
showModal_reducetype: false
})
},
modalLeft: function(e) { //modal(添加)
this.setData({
showModal_addtype: false
})
var senddata = ""
if (this.data.cur_status == 'support_duty') {
// senddata = JSON.stringify(this.data.additionInfo[0]);
}
wx.navigateTo({
url: '../addextrainfo/addextrainfo?status=' + this.data.cur_status + '&datas=' + senddata + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
})
},
modalRight: function(e) { //modal确认(添加)
console.log("modalConfirm", e)
this.setData({
showModal_addtype: false
})
var senddata = JSON.stringify(this.data.modalData.datas[this.data.selected_addindex])
console.log("senddata", senddata)
wx.navigateTo({
url: '../addextrainfo/addextrainfo?status=' + this.data.cur_status + '&datas=' + senddata + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
})
},
goselect: function(e) {
console.log("goselect", e)
if (this.data.showModal_reducetype) {
this.setData({
selected_reduceindex: e.currentTarget.id
})
}
if (this.data.showModal_addtype) {
this.setData({
selected_addindex: e.currentTarget.id
})
}
},
onPickerSelect: function(e) {
console.log('picker发送选择改变,携带值为', e)
switch (e.currentTarget.id) {
case 'issingle_child':
var issinglechildData = this.data.issinglechildData
issinglechildData.selected = issinglechildData.values[e.detail.value]
this.setData({
issinglechildData: issinglechildData
})
break;
case 'share_method':
var share_methodData = this.data.shareMethodData
share_methodData.selected = share_methodData.values[e.detail.value]
this.setData({
shareMethodData: share_methodData
})
break;
}
},
formatDate(date) {
if (date == 0 || date == -62135596800) {
date = ""
}else{
date = format.formatTime_date(date)
}
console.log("formatDate", date)
return date
},
formatIdNum: function(idnum) {
if (idnum && idnum.length >= 6 && idnum.length < 10) {
idnum = idnum.substring(0, 2) + '****' + idnum.substring(idnum.length - 2, idnum.length);
}
if (idnum && idnum.length >= 10) {
idnum = idnum.substring(0, 4) + '****' + idnum.substring(idnum.length - 4, idnum.length);
}
console.log("formatIdNum", idnum)
return idnum
},
bindinput: function(e) {
console.log("bindinput", e)
var inputamount
if (e.detail.value && e.detail.value.replace(/\s+/g, "").length>0){
inputamount = parseFloat(e.detail.value)+0
}else{
inputamount = -1
}
this.setData({
reduce_amount: inputamount
})
},
showToast: function(data) {
if (data && data.length > 0) {
wx.showToast({
title: data,
icon: "none"
})
}
},
/**
* Lifecycle function--Called when page hide
*/
onHide: function() {
},
/**
* Lifecycle function--Called when page unload
*/
onUnload: function() {
},
/**
* Page event handler function--Called when user drop down
*/
onPullDownRefresh: function() {
},
/**
* Called when page reach bottom
*/
onReachBottom: function() {
},
/**
* Called when user click on the top right corner to share
*/
onShareAppMessage: function() {
}
})