addDialog.vue
8.1 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
<!-- 新增提现弹窗 -->
<template>
<baseDialog :config="config" :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.merchant" value-key="merchantId" filterable style="width: 310px"
placeholder="请选择门店">
<el-option v-for="(item, index) in baseData.merchantList" :key="index" :label="item.merchantName"
:value="item" />
</el-select>
<!-- <p>银盛账户余额:{{ balance || balance === 0 ? balance : "-" }}</p> -->
</el-form-item>
<el-form-item label="金额:" prop="tradeAmount">
<!-- :disabled="totalAmountDisabled" -->
<el-input v-model="infoForm.tradeAmount" placeholder="请输入金额" style="width: 310px" @input="handleUpgradeNum" />
</el-form-item>
<el-form-item label="收款类型:" prop="tradeType">
<el-select v-model="infoForm.tradeType" filterable style="width: 310px" placeholder="请选择收款类型">
<el-option v-for="(item, index) in baseData.tradeTypeList" :key="index" :label="item.label"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="收款日期:" prop="tradeTime">
<el-date-picker style="width: 310px" v-model="infoForm.tradeTime" type="datetime"
:picker-options="tradeTimePickerOptions" placeholder="选择日期时间">
</el-date-picker>
<!-- <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>
<!-- </d2-dialog> -->
</baseDialog>
</template>
<script>
import { deepClone } from "@/common/util"
import { sendToSmsCodeApi } from "@/api/sys.base"
import { advancePaymentMerchantPage, advancePaymentTradeAdd } from "@api/prepaymentManage"
import dayjs from "dayjs"
import { limitPrice } from "@/common/format"
export default {
// name: 'AddDialog',
data() {
return {
dialogConfig: {
title: "新增收款",
width: "600px"
},
config: {
showClose: true,
appendToBody: true, // 是否将自身插入至 body 元素,有嵌套的弹窗时一定要设置
isShowFooter: true,
cancel_name: "取 消",
confirm_name: "确 定"
},
infoForm: {
// administrators: "",
// smsCode: "",
// remark: "",
merchant: null,
merchantId: "",
// totalAmount: "",
tradeAmount: "",
tradeTime: "",
tradeType: "1"
},
oldVal: {
tradeAmount: ""
},
cashRules: {
merchantId: [
{ required: true, message: "请选择门店", trigger: "change" }
],
tradeAmount: [
{
required: true,
message: "请输入金额,支持输入0~999999999的数字,支持小数点后2位",
trigger: "change"
}
],
tradeType: [
{ required: true, message: "请选择收款类型", trigger: "change" }
],
tradeTime: [
{ required: true, message: "请选择收款日期", trigger: "change" },
{ validator: (rule, value, callback) => this.validateTradeTime(rule, value, callback), trigger: "change" }
]
// smsCode: [
// { required: true, message: "请输入验证码", trigger: "change" }
// ]
},
// 验证码
showtips: false,
isSend: false,
sendMsg: "获取验证码",
time: "",
// 基本数据
baseData: {
tradeTypeList: [
// 1:银行转账(对公),2:银行承兑,3:银行转账,4:银盛收款
{
id: "1",
label: "银行转账(对公)"
}
],
// administratorsList: [],
merchantList: []
},
balance: "",
// totalAmountDisabled: true
}
},
props: {
addVisible: {
type: Boolean,
default: false
}
},
computed: {
visible: {
get() {
return this.addVisible
},
set(newVal) {
this.$emit("update:addVisible", newVal)
}
},
tradeTimePickerOptions() {
const start = this.infoForm.merchant && this.infoForm.merchant.startDate
return {
disabledDate: (date) => {
const a = dayjs(date).startOf('day').valueOf()
const min = start ? dayjs(start).startOf('day').valueOf() : -Infinity
const max = dayjs().endOf('day').valueOf()
return a < min || a > max
}
}
}
},
watch: {
'infoForm.merchant'(val) {
this.infoForm.merchantId = val ? val.merchantId : ''
this.infoForm.merchantName = val ? val.merchantName : ''
this.infoForm.tradeTime = ''
}
},
mounted() {
this.getMerchantList()
// this.getAdminList()
},
methods: {
validateTradeTime(rule, value, callback) {
const start = this.infoForm.merchant && this.infoForm.merchant.startDate
if (start && value) {
const a = dayjs(value).startOf('day').valueOf()
const min = dayjs(start).startOf('day').valueOf()
const max = dayjs().endOf('day').valueOf()
if (a < min) return callback(new Error('收款日期需不早于门店开始日期'))
if (a > max) return callback(new Error('收款日期不可晚于当前时间'))
}
callback()
},
getMerchantList() {
var params = {}
params.currentPage = 1
// params.pageSize = 1000000
params.pageSize = 100
advancePaymentMerchantPage(params).then((res) => {
this.baseData.merchantList = res.list
})
},
handleUpgradeNum(newVal) {
var maxVal = 999999999
if (this.balance) {
maxVal = this.balance
}
// else {
// newVal = ''
// }
this.infoForm.tradeAmount = limitPrice(
newVal,
this.oldVal.tradeAmount,
13,
2,
-999999999,
maxVal,
'priceReg_negative_input'
)
this.oldVal.tradeAmount = this.infoForm.tradeAmount
},
handleCashConfirm() {
this.$refs.formRef.validate((valid) => {
if (valid) {
var params = deepClone(this.infoForm)
// params.
if (params.tradeTime) {
params.tradeTime = dayjs(params.tradeTime).format("YYYY-MM-DD HH:mm:ss")
}
// 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)
advancePaymentTradeAdd(params).then((res) => {
this.notice.okTips("新增成功")
this.visible = false
this.$emit("addDialogSuccess")
})
}
})
},
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>