addDialog.vue
7.86 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
<!-- 新增提现弹窗 -->
<template>
<baseDialog
:dialog-config="dialogConfig"
:is-show.sync="visible"
class="accountDailog"
@handleClick="handleCashConfirm"
>
<el-form
ref="formRef"
:model="infoForm"
:rules="cashRules"
label-width="120px"
>
<el-form-item label="提现方:" prop="merchantId">
<el-select
v-model="infoForm.merchantId"
filterable
style="width: 310px"
placeholder="请选择提现商户"
@change="getBankBalance"
>
<el-option
v-for="(item, index) in baseData.merchantList"
:key="index"
:label="item.merchantName"
:value="item.merchantId"
/>
</el-select>
<p>银盛账户余额:{{ balance || balance === 0 ? balance : "-" }}</p>
</el-form-item>
<el-form-item label="提现金额:" prop="totalAmount">
<el-input
v-model="infoForm.totalAmount"
placeholder="请输入提现金额"
style="width: 310px"
:disabled="totalAmountDisabled"
@input="handleUpgradeNum"
/>
</el-form-item>
<el-form-item label="财务管理员:" prop="administrators">
<el-select
v-model="infoForm.administrators"
filterable
style="width: 310px"
>
<el-option
v-for="(item, index) in baseData.administratorsList"
:key="index"
:label="item.name + ' ' + item.phone"
:value="item.phone"
/>
</el-select>
</el-form-item>
<el-form-item label="验证码:" prop="smsCode">
<el-input
v-model="infoForm.smsCode"
placeholder="请输入验证码"
maxlength="6"
style="width: 200px"
/>
<el-button
type="primary"
size="small"
@click="handleSend"
:disabled="isSend"
class="cash-btn"
>
{{ isSend ? sendMsg + "秒后,重试" : "获取验证码" }}
</el-button>
<p v-show="showtips">
已向尾号为{{
infoForm.administrators ? infoForm.administrators.slice(-4) : ""
}}的手机号发送验证码,验证码30分钟内有效
</p>
</el-form-item>
<el-form-item label="备注:" prop="remark">
<el-input
v-model="infoForm.remark"
type="textarea"
maxlength="50"
placeholder="请输入备注"
show-word-limit
:rows="4"
style="width: 310px"
/>
</el-form-item>
</el-form>
<!-- </d2-dialog> -->
</baseDialog>
</template>
<script>
import { createWithdraw } from "@api/account"
import { sendToSmsCodeApi } from "@/api/sys.base"
import { getWithdrawTreasurerList } from "@api/transferAccountsManage"
import { getListApi } from "@api/publicAccount"
import {
transferAccountsRecordCreate,
getBankBalance
} from "@api/withdrawalManage"
import { limitPrice } from "@/common/format"
import { getDjzhySubMerchant } from "@api/merchant"
export default {
// name: 'AddDialog',
data() {
return {
dialogConfig: {
title: "新增提现",
width: "600px"
},
infoForm: {
administrators: "",
smsCode: "",
remark: "",
merchantId: "",
totalAmount: ""
},
oldVal: {
totalAmount: ""
},
cashRules: {
merchantId: [
{ required: true, message: "请选择提现方", trigger: "change" }
],
totalAmount: [
{
required: true,
message: "请输入金额,支持输入0~999999的数字,支持小数点后2位",
trigger: "change"
}
],
administrators: [
{ required: true, message: "请选择财务管理员", trigger: "change" }
],
smsCode: [
{ required: true, message: "请输入验证码", trigger: "change" }
]
},
// 验证码
showtips: false,
isSend: false,
sendMsg: "获取验证码",
time: "",
// 基本数据
baseData: {
administratorsList: [],
merchantList: []
},
balance: "",
totalAmountDisabled: true
}
},
props: {
addVisible: {
type: Boolean,
default: false
}
},
// watch: {
// addVisible(newVal, val) {
// newVal ? this.reset() : this.closeReset()
// }
// },
computed: {
visible: {
get() {
return this.addVisible
},
set(newVal) {
this.$emit("dialogClose", { flag: newVal, attrName: "addVisible" })
}
}
},
mounted() {
this.getMerchantList()
this.getAdminList()
},
methods: {
getMerchantList() {
var params = {}
params.currentPage = 1
params.pageSize = 10000
params.accountStatus = 3 // 生效
params.merchantTypeList = [2, 7, -1]
getListApi(params).then((res) => {
this.baseData.merchantList = res.list
// 获取获取嘀加智慧云子商户信息
// getDjzhySubMerchant({}).then((res) => {
// // 转入方选项中去除嘀加智慧云子商户
// // this.baseData.merchantList = this.baseData.merchantList.filter((item) => item.merchantId != res.merchantId)
// this.baseData.merchantList = this.baseData.merchantList
// })
})
},
getAdminList() {
getWithdrawTreasurerList({}).then((res) => {
this.baseData.administratorsList = res
this.infoForm.administrators = res[0].phone
})
},
getBankBalance(val) {
this.infoForm.totalAmount = ""
this.balance = ""
getBankBalance({ merchantId: val }).then((res) => {
if (res || res == 0) {
this.balance = res
if (this.balance) {
this.totalAmountDisabled = false
} else {
this.totalAmountDisabled = true
}
}
})
},
handleUpgradeNum(newVal) {
var maxVal = 999999
if (this.balance) {
maxVal = this.balance
}
// else {
// newVal = ''
// }
this.infoForm.totalAmount = limitPrice(
newVal,
this.oldVal.totalAmount,
6,
2,
0,
maxVal
)
this.oldVal.totalAmount = this.infoForm.totalAmount
},
handleCashConfirm() {
this.$refs.formRef.validate((valid) => {
if (valid) {
var params = {}
params.remark = this.infoForm.remark
params.smsCode = this.infoForm.smsCode
params.phone = this.infoForm.administrators
params.merchantId = this.infoForm.merchantId
if (this.infoForm.totalAmount > 0) {
params.totalAmount = this.infoForm.totalAmount
} else {
this.$message({
message: "提现金额必须大于0",
type: "warning",
showClose: true
})
return
}
console.log(params)
transferAccountsRecordCreate(params).then((res) => {
this.notice.okTips("操作成功")
this.visible = true
})
}
})
},
handleSend() {
if (!this.infoForm.administrators) {
this.notice.warningTips("请选择管理员")
return
}
sendToSmsCodeApi({ phone: this.infoForm.administrators }).then((res) => {
this.notice.okTips("已发送,30分钟内有效")
this.isSend = true
this.showtips = true
this.sendMsg = 60
this.msgDown()
})
},
msgDown() {
this.time = setTimeout(() => {
clearTimeout(this.time)
if (this.sendMsg > 1) {
--this.sendMsg
this.msgDown()
} else {
this.isSend = false
}
}, 1000)
}
}
}
</script>
<style scoped>
p {
margin: 0 0;
}
.cash-btn {
margin-left: 20px;
}
</style>