endowmentInsurDetail.js
7.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
// pages/main/finalpay/otherDeductDetail/endowmentInsurDetail.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
var format = require('../../../../utils/util.js');
Page({
/**
* Page initial data
*/
data: {
settlement_record_id: "",
year: "2019",
infoList: [{}],
total_account:0,
showAddView: false,
option_start_date: "",
option_end_date: "",
"tax_extension_account": "",
"option_start_time": "", //申报扣除月份起,
"option_end_time": "", //申报扣除月份止,
"tax_check_code": "",
"year_premium": "", //年度保费,
"month_premium": "", //月度保费
"year_deduction": "", //本年扣除金额
},
/**
* Lifecycle function--Called when page load
*/
onLoad: function(options) {
this.setData({
settlement_record_id: options.id
})
this.getInfoList()
},
/**
* Lifecycle function--Called when page is initially rendered
*/
onReady: function() {
},
getInfoList: function() {
var that = this
this.Authorization = getApp().globalData.Authorization;
wx.request({
url: baseUrl + "payroll/v1/settlement-tax/tax-extension",
header: {
'Authorization': this.Authorization
},
data: {
"years": that.data.year,
"settlement_record_id": that.data.settlement_record_id
},
success: function(result) {
console.log("infoList", result)
if (result.statusCode == 200) {
that.setData({
total_account: result.data.total_account,
infoList: that.handleData(result.data.items),
option_start_date: "",
option_end_date: "",
"tax_extension_account": "",
"option_start_time": "", //申报扣除月份起,
"option_end_time": "", //申报扣除月份止,
"tax_check_code": "",
"year_premium": "", //年度保费,
"month_premium": "", //月度保费
"year_deduction": "", //本年扣除金额
})
}
},
})
},
handleData: function(items) { //解析列表数据时间戳
for (var i = 0; i < items.length; i++) {
if (items[i].option_start_time && items[i].option_start_time > 1000) {
items[i].option_start_time = format.formatTime_date(items[i].option_start_time)
} else {
items[i].option_start_time = ""
}
if (items[i].option_end_time && items[i].option_end_time > 1000) {
items[i].option_end_time = format.formatTime_date(items[i].option_end_time)
} else {
items[i].option_end_time = ""
}
}
return items
},
bindDatePicker: function(e) { //时间选择
var datelong = Date.parse(new Date(e.detail.value)) / 1000
console.log("picker", e)
if ("option_start_time" == e.currentTarget.id) {
this.setData({
option_start_date: e.detail.value,
option_start_time: datelong
})
} else if ("option_end_time" == e.currentTarget.id) {
this.setData({
option_end_date: e.detail.value,
option_end_time: datelong
})
}
},
getInputInfo: function(e) { //
console.log("输入框", e.currentTarget.id, e.detail.value)
var key = e.currentTarget.id + ""
if ("tax_extension_account" == key) {
this.setData({
"tax_extension_account": e.detail.value,
})
}
if ("tax_check_code" == key) {
this.setData({
"tax_check_code": e.detail.value,
})
}
if ("year_premium" == key) {
this.setData({
"year_premium": e.detail.value,
})
}
if ("month_premium" == key) {
this.setData({
"month_premium": e.detail.value,
})
}
if ("year_deduction" == key) {
this.setData({
"year_deduction": e.detail.value,
})
}
},
/**
* Lifecycle function--Called when page show
*/
onShow: function() {
},
addItem: function() { //继续添加
if (!this.data.showAddView) { //是否新增了view
this.setData({
showAddView: true
})
return
}
if (!this.data.tax_extension_account || this.data.tax_extension_account.length < 1) {
this.showToast("请填写税延养老账号编号")
return
}
if (!this.data.option_start_time || this.data.option_start_time.length < 1000 || !this.data.option_end_time || this.data.option_end_time.length < 1000) {
this.showToast("请选择申报扣除起止月")
return
}
if (!this.data.tax_check_code || this.data.tax_check_code.length < 1) {
this.showToast("请填写报税校验码")
return
}
if (!this.data.year_premium || this.data.year_premium.length < 1) {
this.showToast("请填写年度保费")
return
}
if (!this.data.month_premium || this.data.month_premium.length < 1) {
this.showToast("请填写月度保费")
return
}
if (!this.data.year_deduction || this.data.year_deduction.length < 1) {
this.showToast("请填写本年扣除金额")
return
}
this.goSubmit("1")
},
goSubmit: function(type) {
if (!this.data.tax_extension_account || this.data.tax_extension_account.length < 1) {
this.showToast("请填写税延养老账号编号")
return
}
if (!this.data.option_start_time || this.data.option_start_time.length < 1000 || !this.data.option_end_time || this.data.option_end_time.length < 1000) {
this.showToast("请选择申报扣除起止月")
return
}
if (!this.data.tax_check_code || this.data.tax_check_code.length < 1) {
this.showToast("请填写报税校验码")
return
}
if (!this.data.year_premium || this.data.year_premium.length < 1) {
this.showToast("请填写年度保费")
return
}
if (!this.data.month_premium || this.data.month_premium.length < 1) {
this.showToast("请填写月度保费")
return
}
if (!this.data.year_deduction || this.data.year_deduction.length < 1) {
this.showToast("请填写本年扣除金额")
return
}
var that = this
this.Authorization = app.globalData.Authorization;
wx.request({
url: baseUrl + "payroll/v1/settlement-tax/tax-extension",
header: {
'Authorization': this.Authorization
},
method: "POST",
data: {
"years": that.data.year,
"settlement_record_id": that.data.settlement_record_id,
"tax_extension_account": that.data.tax_extension_account,
"option_start_time": that.data.option_start_time, //申报扣除月份起,
"option_end_time": that.data.option_end_time, //申报扣除月份止,
"tax_check_code": that.data.tax_check_code,
"year_premium": parseFloat(that.data.year_premium), //年度保费,
"month_premium": parseFloat(that.data.month_premium), //月度保费
"year_deduction": parseFloat(that.data.year_deduction), //本年扣除金额
},
success: function(result) {
console.log("infoList", result)
if (result.statusCode == 200) {
if (type == '1') {
that.getInfoList()
that.setData({
showAddView: true
})
} else {
wx.navigateBack({
delta: 2
})
}
}
}
})
},
/**
* Lifecycle function--Called when page hide
*/
onHide: function() {
},
/**
* Lifecycle function--Called when page unload
*/
onUnload: function() {
},
showToast: function(data) {
if (data && data.length > 0) {
wx.showToast({
title: data,
icon: "none",
duration: 2000
})
}
},
/**
* 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() {
}
})