donationDetail.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
// pages/main/finalpay/donationDetail/donationDetail.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
Page({
/**
* Page initial data
*/
data: {
settlement_record_id:"",
year: "2019",
showAddView: false,
infoList: [{}],
total_account: 0,
deductPick: ["30%", "100%"],
"donated_unit_code": "",
"donated_unit_name": "",
"donation_code": "",
"donation_year": "",
"donation_account": "",
"deduction_ratio": "", //扣除比例
"comment": "",
},
/**
* 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/donation-deduction",
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: result.data.items,
"donated_unit_code": "",
"donated_unit_name": "",
"donation_code": "",
"donation_year": "",
"donation_account": "",
"deduction_ratio": "", //扣除比例
"comment": "",
})
}
},
})
},
/**
* Lifecycle function--Called when page show
*/
onShow: function() {
},
getInputInfo:function(e){//
console.log("输入框", e.currentTarget.id,e.detail.value)
var key = e.currentTarget.id+""
if ("donated_unit_code"==key){
this.setData({"donated_unit_code": e.detail.value,})
}
if ("donated_unit_name" == key) {
this.setData({ "donated_unit_name": e.detail.value, })
}
if ("donation_code" == key) {
this.setData({ "donation_code": e.detail.value, })
}
if ("donation_year" == key) {
this.setData({ "donation_year": e.detail.value, })
}
if ("donation_account" == key) {
this.setData({ "donation_account": e.detail.value, })
}
if ("comment" == key) {
this.setData({ "comment": e.detail.value, })
}
},
deductRatioPicker:function(e){//捐赠比例
console.log('picker,携带值为', e.detail.value)
var new_data = this.data.deductPick[e.detail.value]
this.setData({
deduction_ratio: new_data ? new_data.replace("%",""):""
})
},
addItem: function() { //继续添加
if (!this.data.showAddView) {//是否新增了view
this.setData({
showAddView: true
})
return
}
if (!this.data.donated_unit_code || this.data.donated_unit_code.length < 1) {
this.showToast("请填写受赠单位纳税人识别号")
return
}
if (!this.data.donated_unit_name || this.data.donated_unit_name.length < 1) {
this.showToast("请填写受赠单位名称")
return
}
if (!this.data.donation_code || this.data.donation_code.length < 1) {
this.showToast("请填写捐赠凭证码")
return
}
if (!this.data.donation_year || this.data.donation_year.length < 1) {
this.showToast("请填写捐赠年度")
return
}
if (!this.data.donation_account || this.data.donation_account.length < 1) {
this.showToast("请填写扣除金额")
return
}
if (!this.data.deduction_ratio || this.data.deduction_ratio.length < 1) {
this.showToast("请选择扣除比例")
return
}
this.goSubmit("1")
},
goSubmit: function(type) {//type=“1”,继续添加(当前页面),type=2保存,返回列表
if (!this.data.donated_unit_code || this.data.donated_unit_code.length < 1) {
this.showToast("请填写受赠单位纳税人识别号")
return
}
if (!this.data.donated_unit_name || this.data.donated_unit_name.length < 1) {
this.showToast("请填写受赠单位名称")
return
}
if (!this.data.donation_code || this.data.donation_code.length < 1) {
this.showToast("请填写捐赠凭证码")
return
}
if (!this.data.donation_year || this.data.donation_year.length < 1) {
this.showToast("请填写捐赠年度")
return
}
if (!this.data.donation_account || this.data.donation_account.length < 1) {
this.showToast("请填写扣除金额")
return
}
if (!this.data.deduction_ratio || this.data.deduction_ratio.length < 1) {
this.showToast("请选择扣除比例")
return
}
var that = this
this.Authorization = app.globalData.Authorization;
wx.request({
url: baseUrl + "payroll/v1/settlement-tax/donation-deduction",
header: {
'Authorization': this.Authorization
},
method: "POST",
data: {
"years": that.data.year,
"settlement_record_id": that.data.settlement_record_id,
"donated_unit_code": that.data.donated_unit_code,
"donated_unit_name": that.data.donated_unit_name,
"donation_code": that.data.donation_code,
"donation_year": that.data.donation_year,
"donation_account": parseFloat(that.data.donation_account),
"deduction_ratio": parseFloat(that.data.deduction_ratio),
"comment":that.data.comment
},
success: function (result) {
console.log("infoList", result)
if (result.statusCode == 200) {
if (type == '1') {
that.getInfoList()
that.setData({
showAddView: true
})
} else {
wx.navigateBack({
delat: 1
})
}
}
},
})
},
/**
* 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() {
}
})