home.js
6.5 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
// pages/main/addtionalreduce/home.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
var format = require('../../../utils/util.js');
Page({
/**
* Page initial data
*/
data: {
datas: ["", ""],
is_declared: false,
hascompleted:false,
additionlist: [],
complete_item:[],
choosed_date: '',
has_showModal:false,//当前页面是否展示过modal
show_modal:false,
tip_detail:"尊敬的用户您好!2020年度的专项附加扣除申报已经启动,请您及时确认填报信息,确保专项附加扣除能正常享受扣除。",
declareStatus: {
"to_declare ": "待申报",
"declaring": "申报中",
"success": "审核成功",
"failed": "审核失败"
},
additiontitle: {
"children_education": "子女教育",
"continuing_education": "继续教育",
"support_duty": "赡养老人",
"medical_fund": "大病医疗",
"house_fund_rent": "住房",
"house_fund_loan": "住房",
"house_fund": "住房"
},
reducetype:{
"":"月",
"month":"月",
"year":"年"
},
datas02: ["子女教育", "继续教育", "赡养老人", "大病医疗", "住房贷款利息"]
},
/**
* Lifecycle function--Called when page load
*/
onLoad: function (options) {
console.log("onLoad");
var mydate = new Date();
this.setData({
choosed_date: mydate.getFullYear() ,
})
},
godeclare: function (e) {
console.log("godeclare", e);
var newdata = this.data.additionlist[e.currentTarget.id]
wx.navigateTo({
url: 'godeclare/godeclare?legal_entity_id=' + newdata.legal_entity_id + "&legal_entity=" + newdata.legal_entity + "&type=0",
})
},
goupdate: function (e) {
console.log("goupdate", e);
var newdata = this.data.additionlist[e.currentTarget.id]
wx.navigateTo({
url: 'godeclare/godeclare?legal_entity_id=' + newdata.legal_entity_id + "&legal_entity=" + newdata.legal_entity + "&select_data=" + JSON.stringify(newdata) + "&complete_data=" + JSON.stringify(this.data.complete_item) + "&type=1",
})
},
godetail: function () {
wx.navigateTo({
url: 'godetail/godetail',
})
},
lookandadd: function (e) {
var str = e.currentTarget.id.split('-')
var data = this.data.additionlist;
console.log("lookandadd", str,data);
wx.navigateTo({
url: 'lookandupdate/lookandupdate?status=' + data[str[0]].addition_items[str[1]].addition_category + "&employee_status=" + data[str[0]].employee_status + "&legal_entity_id=" + data[str[0]].legal_entity_id + "&legal_entity=" + data[str[0]].legal_entity,
})
},
/**
* Lifecycle function--Called when page is initially rendered
*/
onReady: function () {
console.log("onReady");
},
/**
* Lifecycle function--Called when page show
*/
onShow: function () {
console.log("onShow");
var that = this
this.getAdditionList()
},
//获取申报列表
getAdditionList: function () {
wx.showLoading({
title: '',
})
var that = this;
var Authorization = getApp().globalData.Authorization;
wx.request({
url: baseUrl + 'persontax/v1/person-additions',
data: {
years:that.data.choosed_date
// limit: 10,
// offset: 0
},
header: {
'content-type': 'application/json',
"Authorization": Authorization
},
success: function (res) {
if (res && res.data) {
console.log("show_modal", !res.data.new_addition_status)
that.setData({
show_modal: !that.data.has_showModal&&!res.data.new_addition_status,
complete_item: res.data.complete_item,
additionlist: that.handleData(res.data.items)
})
}
wx.hideLoading()
},
complete(res) {
that.setData({
hascompleted: true
})
console.log(res.data)
}
})
},
handleData: function (items) {
for (var i = 0; i < items.length ; i++){
var bigItem = items[i]
for (var j = 0; j < bigItem.addition_items.length; j++) {
var midItem = bigItem.addition_items[j]
if (midItem.addition_category == 'continuing_education'){
var majors = [], professions = []
for (var k = 0; k < midItem.detail_items.length; k++) {
var smallItem = midItem.detail_items[k]
if (smallItem.continue_education_type == 'major'){
majors.push(smallItem)
} else if (smallItem.continue_education_type == 'nomajor'){
professions.push(smallItem)
}
}
items[i].addition_items[j].majors = majors
items[i].addition_items[j].professions = professions
break;
}
}
}
console.log('items', items)
return items
},
datePickerChange: function (e) {
console.log("e", e)
var timestamp = Date.parse(new Date(e.detail.value)) / 1000
this.setData({
choosed_date: format.yearFormString(timestamp)
})
this.getAdditionList()
},
// 暂不确认
doNotConfirm:function(){
this.setData({
show_modal: false,
has_showModal: true
})
},
// 立即确认
doConfirm: function () {
this.setData({
show_modal: false,
has_showModal:true
})
this.quickAdd()
},
// 一键带入
quickAdd:function(){
var that = this;
var Authorization = getApp().globalData.Authorization;
wx.request({
url: baseUrl + 'persontax/v1/person-additions-update',
method:"POST",
data: {
user_id: app.globalData.userInfo?app.globalData.userInfo.id:""
},
header: {
'content-type': 'application/json',
"Authorization": Authorization
},
success: function (res) {
if (res && res.data) {
console.log("res", res)
that.setData({
choosed_date: "2020"
})
that.getAdditionList()
}
wx.hideLoading()
},
complete(res) {
console.log(res.data)
}
})
},
/**
* 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 () {
}
})