payApproval.vue
13.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
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
<!-- 付款审批 -->
<template>
<GLDialog class="gl-form-page gl-form-min payWrap" title="付款审批" mode="mid" :visible.sync="isVisible" :close-on-click-modal="false" :before-close="cancelPay">
<glsx-combi-form formRef="payChildRef" defaultWidth="432px" ref="payFormRef" :formObj="payForm" :formData="payFormData" :formRules="payRule">
<template slot="channelHtml">
<el-cascader style="width: 432px" :props="props" v-model="payForm.channelList" :placeholder="'请选择'" filterable @change="selectAddAttr($event, 'payForm')"></el-cascader>
</template>
<template slot="captcha">
<div class="captcha-wrap">
<el-input v-model="payForm.captcha" placeholder="请输入" style="width: 432px"></el-input>
<div class="captcha-text" @click.prevent="getCode">
{{ !isCodeDisabled ? '获取验证码' : count + 's' }}
</div>
</div>
</template>
<template slot="textHtml" slot-scope="scope">
{{ recordInfo[scope.scope.name] }}
</template>
</glsx-combi-form>
<span slot="footer" class="dialog-footer">
<el-button plain size="small" class="btn-three" @click="cancelPay">取消</el-button>
<el-button type="primary" size="small" :loading="loading" @click="comfirmPay">确定</el-button>
</span>
</GLDialog>
</template>
<script>
export default {
data() {
return {
loading: false,
isVisible: false,
count: '',
timer: null,
isCodeDisabled: false,
payForm: {
paymentChannelId: '',
paymentSubjectId: '',
explain: '',
approverId: '',
phone: '',
captcha: '',
remark: '',
channelList: []
},
payFormData: [
// {
// label: '付款渠道',
// name: 'paymentChannelId',
// type: 'select',
// optionsName: 'payChannelList',
// optionId: 'id',
// optionLabel: 'name',
// changeAttr: val => {
// this.payForm.channel = this.baseData.payChannelList.find(item => item.id === val).channel
// this.recordInfo.taxRate = this.baseData.payChannelList.find(item => item.id === val).tax + '%'
// this.payForm.paymentSubjectId=''
// this.getAdmin()
// this.getPaymentEntityList()
// this.calculateAmount()
// this.isCodeDisabled = false
// clearInterval(this.timer)
// this.timer = null
// this.payForm.captcha = ''
// }
// },
{
label: '付款渠道',
name: 'channelList',
addHtml: 'channelHtml'
},
{
label: '批次号',
name: 'batchNo',
addHtml: 'textHtml'
},
{
label: '积分总额',
name: 'pointTotal',
addHtml: 'textHtml'
},
{
label: '付款总额/元',
name: 'paymentTotal',
addHtml: 'textHtml'
},
{
label: '税点',
name: 'taxRate',
addHtml: 'textHtml'
},
{
label: '管理员',
name: 'approverId',
type: 'select',
optionsName: 'adminList',
optionId: 'adminId',
optionLabel: 'adminName',
optionList: [],
changeAttr: val => {
this.payForm.phone = val
this.isCodeDisabled = false
clearInterval(this.timer)
this.timer = null
this.payForm.captcha = ''
}
},
{
label: '验证码',
addHtml: 'captcha',
name: 'captcha'
},
{
label: '发票及其他说明',
name: 'explain',
type: 'input',
inputType: 'textarea',
placeholder: '说明本次付款是否已升票、历次付款有无欠票及相应欠票金额,及其他需要补充说明的情况。如无则输入“无”。',
maxlength: 200
},
{
label: '备注',
name: 'remark',
type: 'input',
inputType: 'textarea',
maxlength: 50
}
],
payRule: {
approverId: [{ required: true, message: '请选择管理员', trigger: 'change' }],
paymentChannelId: [{ required: true, message: '请选择付款渠道', trigger: 'change' }],
paymentSubjectId: [{ required: true, message: '请选择付款主体', trigger: 'change' }],
captcha: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
explain: [{ required: true, message: '请输入发票及其他说明', trigger: 'blur' }],
channelList: [{ required: true, message: '请选择付款渠道', trigger: 'change' }]
},
// 基本数据
baseData: {
payChannelList: [],
//付款主体
paymentEntityList: []
},
props: {
lazy: true,
lazyLoad: (node, resolve) => {
console.log(node, node.value)
const { level, value } = node
let res
let obj = {
0: async () => {
res = await this.getlistChannel()
resolve(res)
},
1: async () => {
res = await this.getListPaymentEntity(value)
resolve(res)
},
2: async () => {
this.payForm.paymentSubjectId = value
let channel = node.parent ? node.parent.value : ''
res = await this.getListPayLevy(value, channel)
resolve(res)
},
3: async () => {
this.payForm.paymentChannelId = value
}
}
obj[level]()
}
}
}
},
props: {
payVisible: { type: Boolean, default: false },
recordInfo: {
type: Object,
default: () => {
return {}
}
}
},
watch: {
payVisible(newVal) {
this.isVisible = newVal
}
},
mounted() {},
methods: {
async getlistChannel() {
let arr = await this.$apis.withdraw.getChannelList()
let list = arr.map(item => {
return {
label: item.channelName,
value: item.channel
}
})
return list
},
async getListPaymentEntity(value) {
let arr = await this.$apis.withdraw.getListPaymentEntity({
channel: value
})
let list = arr.map(item => {
return {
label: item.paymentEntityName,
value: item.paymentEntityId
}
})
return list
},
async getListPayLevy(paymentEntityId, channel) {
this.baseData.paymentEntityList = await this.$apis.withdraw.getListPayLevy({
paymentEntityId,
channel
})
let list = this.baseData.paymentEntityList.map(item => {
return {
label: item.levyName,
value: item.id,
leaf: true
}
})
return list
},
async selectAddAttr(e, formName) {
console.log(e)
this.payForm.paymentSubjectId = ''
let [value1, value2, value3] = e
if (value1) this[formName].channel = value1
if (value2) this[formName].paymentSubjectId = value2
if (value3) this[formName].paymentChannelId = value3 //代征主体
await this.getListPayLevy(value2, value1) //重新获取代征主体获取最新的税率
this.recordInfo.taxRate = this.baseData.paymentEntityList.find(item => item.id === value3).tax + '%'
this.getAdmin()
this.calculateAmount()
this.isCodeDisabled = false
clearInterval(this.timer)
this.timer = null
this.payForm.captcha = ''
},
calculateAmount() {
let { taxRate, pointTotal } = this.recordInfo,
rate = taxRate.split('%')[0]
//本批次号积分提现总金额+渠道税点(积分总额×税点),保留小数点后 2位
this.recordInfo.paymentTotal = (pointTotal + pointTotal * (rate / 100)).toFixed(2)
},
// //积分提现获取业务对应的付款渠道
// getChannel(transferType) {
// let arr = []
// this.$apis.withdraw.getChannelAccount().then(res => {
// if (res) {
// console.log(res)
// // arr = res.map(item => {
// // let channelInfo = item.name
// // return {
// // channelInfo,
// // ...item
// // }
// // })
// this.baseData.payChannelList = [...res]
// this.$utils.getOptionsList(this, 'payFormData', false, 'paymentChannelId')
// //默认选择
// if (this.baseData.payChannelList.length > 0) {
// this.payForm.paymentChannelId = this.baseData.payChannelList[0].id
// this.payForm.channel = this.baseData.payChannelList[0].channel
// this.recordInfo.taxRate = this.baseData.payChannelList[0].tax + '%'
// this.calculateAmount()
// }
// this.getPaymentEntityList()
// this.getAdmin()
// }
// })
// },
// //支付主体
// getPaymentEntityList() {
// let params = { channelAccountId: this.payForm.paymentChannelId }
// this.$apis.withdraw.getPaymentEntityList(params).then(res => {
// if (res) {
// console.log(res)
// this.baseData.paymentEntityList = res
// this.$utils.getOptionsList(this, 'payFormData', false, 'paymentSubjectId')
// // 默认选择
// if (this.baseData.paymentEntityList.length > 0) {
// this.payForm.paymentSubjectId = this.baseData.paymentEntityList[0].id
// }
// }
// })
// },
getAdmin() {
this.$apis.withdraw.getAdmin({ channel: this.payForm.channel }).then(res => {
if (res && res.length > 0) {
this.baseData.adminList = res.map(item => {
return {
adminId: `${item.adminPhone}`,
adminName: `${item.adminName} ${item.adminPhone}`,
name: item.adminName,
phone: item.adminPhone
}
})
this.payForm.approverId = this.baseData.adminList[0].adminId
this.payForm.phone = this.baseData.adminList[0].phone
} else {
this.payForm.approverId = ''
this.payForm.phone = ''
this.baseData.adminList = []
}
this.$utils.getOptionsList(this, 'payFormData', false, 'approverId')
})
},
//付款
comfirmPay() {
this.$refs.payFormRef.$refs.payChildRef.validate(valid => {
if (valid) {
this.loading = true
let params = {
phone: this.payForm.phone,
id: this.recordInfo.id,
paymentChannelId: this.payForm.paymentChannelId,
paymentSubjectId: this.payForm.paymentSubjectId,
captcha: this.payForm.captcha,
explain: this.payForm.explain,
remark: this.payForm.remark
}
params.approver = this.baseData.adminList.find(item => item.adminId == this.payForm.approverId).name
this.$apis.withdraw
.applyApprovalOA(params)
.then(res => {
if (res.code == '0') {
this.cancelPay()
}
this.$message({
message: res.code == '0' ? '付款审批成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
})
.finally(() => {
this.loading = false
})
}
})
},
cancelPay() {
this.ids = ''
this.payForm = {
paymentChannelId: '',
paymentSubjectId: '',
explain: '',
approverId: '',
phone: '',
captcha: '',
remark: ''
}
this.isCodeDisabled = false
this.baseData.adminList =[]
this.payFormData[this.findFormAttrId('payFormData', 'approverId')].optionList = []
clearInterval(this.timer)
this.timer = null
this.$emit('cancelPay')
if (this.$refs.payFormRef && this.$refs.payFormRef.$refs.payChildRef) {
this.$refs.payFormRef.$refs.payChildRef.resetFields()
}
},
findFormAttrId(formData, name) {
return this[formData].findIndex(item => item.name == name) || 0
},
getCode() {
if (this.isCodeDisabled) return
if (!this.timer) {
this.count = 60
// var params = {
// phoneType: 'RG',
// phone: this.ruleForm.registerPhone
// }
this.$apis.withdraw
.getSms({
channel: this.payForm.channel,
phone: this.payForm.phone
})
.then(res => {
if (res.code == 0) {
this.$message.success('短信验证码发送成功')
this.isCodeDisabled = true
this.timer = setInterval(() => {
if (this.count > 0 && this.count <= 60) {
this.count--
} else {
this.isCodeDisabled = false
clearInterval(this.timer)
this.timer = null
}
}, 1000)
} else {
this.$message.error(res.message)
}
})
}
}
}
}
</script>
<style lang="scss" scoped>
.payWrap {
/deep/ {
.el-form--inline .el-form-item {
display: block;
}
.el-form .el-select .el-input {
width: 100%;
}
.el-form .el-input {
width: 100%;
}
}
.captcha-wrap {
.captcha-text {
font-size: 12px;
color: #5850ff;
position: absolute;
right: 0;
top: 2px;
margin-right: 10px;
cursor: pointer;
width: 100px;
height: 32px;
text-align: right;
}
}
}
</style>