payApproval.vue
9.87 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
<!-- 付款审批 -->
<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="284px" ref="payFormRef" :formObj="payForm" :formData="payFormData" :formRules="payRule">
<template slot="captcha">
<div class="captcha-wrap">
<el-input v-model="payForm.captcha" placeholder="请输入"></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: ''
},
payFormData: [
{
label: '此次付款渠道',
name: 'paymentChannelId',
type: 'select',
optionsName: 'payChannelList',
optionId: 'id',
optionLabel: 'channelInfo',
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.getAdmin()
this.getPaymentEntityList()
this.calculateAmount()
this.isCodeDisabled = false
clearInterval(this.timer)
this.timer = null
this.payForm.captcha = ''
}
},
{
label: '此次付款主体',
name: 'paymentSubjectId',
type: 'select',
optionsName: 'paymentEntityList',
optionId: 'id',
optionLabel: 'name',
changeAttr: val => {}
},
{
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',
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',
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' }]
},
// 基本数据
baseData: {
payChannelList: [],
//付款主体
paymentEntityList: []
}
}
},
props: {
payVisible: { type: Boolean, default: false },
recordInfo: {
type: Object,
default: () => {
return {}
}
}
},
watch: {
payVisible(newVal) {
console.log(newVal)
this.isVisible = newVal
if (newVal) {
this.getChannel()
this.$utils.getOptionsList(this, 'payFormData', false)
}
}
},
mounted() {},
methods: {
calculateAmount() {
let {taxRate,pointTotal} =this.recordInfo,
rate = taxRate.split('%')[0];
console.log(rate)
//本批次号积分提现总金额+渠道税点(积分总额×税点),保留小数点后 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.channelName + item.name
return {
channelInfo,
...item
}
})
this.baseData.payChannelList = arr
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) {
this.baseData.adminList = res.map(item => {
return {
adminId: `${item.phone}`,
adminName: `${item.name} ${item.phone}`,
name: item.name,
phone: item.phone
}
})
this.$utils.getOptionsList(this, 'payFormData', false, 'approverId')
this.payForm.approverId = this.baseData.adminList[0].adminId
this.payForm.phone = this.baseData.adminList[0].phone
}
})
},
//付款
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 => {
this.$message({
message: res.code == '0' ? '付款审批成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
})
.finally(() => {
this.cancelPay()
this.loading = false
})
}
})
},
cancelPay() {
this.ids = ''
this.payForm = {
paymentChannelId: '',
paymentSubjectId: '',
explain: '',
approverId: '',
phone: '',
captcha: '',
remark: ''
}
this.isCodeDisabled = false
clearInterval(this.timer)
this.timer = null
this.$emit('cancelPay')
},
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;
}
}
.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>