divisionRule.vue
14.4 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
<!-- 分账规则 -->
<template>
<d2-dialog title="分账规则"
:is-visible="divisionRuleVisible"
width="900px"
btn-ok-label="确定"
@confirmDialog="handleRuleConfirm"
@closeDialog="handleRuleClose">
<span slot="sub-title">规则设置提交后,第二天生效!</span>
<div class="division-rule"
v-loading="$store.state.d2admin.loading.value">
<el-form ref="divisionRuleRef"
:model="form"
:rules="rules"
label-suffix=":"
label-width="180px">
<el-form-item label=""
prop="autoFlag">
<span class="tips-block"
slot="label">
<span class="tips-label">线上自动分账</span>
<el-tooltip popper-class="tooltip-class"
effect="dark"
content="产生交易后会自动打款给商户,开启及关闭操作第二天生效。"
placement="top">
<span class="tips-icon" />
</el-tooltip>:
</span>
<el-radio-group v-model="form.autoFlag">
<el-switch v-model="form.autoFlag"
active-value="Y"
inactive-value="N" />
</el-radio-group>
</el-form-item>
<el-form-item label="结算时间方式"
prop="settleTimeType">
<span class="tips-block"
slot="label">
<span class="tips-label">分账周期</span>
<el-tooltip popper-class="tooltip-class"
effect="dark"
content="用户支付的款项可按T+1或指定日自动打款给商户。"
placement="top">
<span class="tips-icon" />
</el-tooltip>:
</span>
<el-radio-group v-model="form.settleTimeType"
:disabled="form.autoFlag === 'N'">
<div class="block_item">
<el-radio :label="1">
分账周期 T+
<el-input-number v-model="settleTimeObj.first"
controls-position="right"
size="small"
:min="0"
:max="30"
:disabled="form.settleTimeType === 2 || form.autoFlag === 'N'" />
日
<span v-show="form.settleTimeType === 1">(分账后第2天到分账方对公账户)</span>
</el-radio>
</div>
<div class="block_item">
<el-radio :label="2">
固定日期分账:每月
<el-input-number v-model="settleTimeObj.second"
controls-position="right"
size="small"
:min="1"
:max="31"
:disabled="form.settleTimeType === 1 || form.autoFlag === 'N'" />
日
<span
v-show="form.settleTimeType === 2">(上个月整月的分账金额于次月{{ +settleTimeObj.second + 1 }}日分账到分账方对公账户)</span>
</el-radio>
</div>
</el-radio-group>
</el-form-item>
<el-form-item label="分账方金额分配">
<span>请为分账方选择分账金额,选择的分账金额会全款打至对应的分账方账户中</span>
</el-form-item>
<el-form-item label=""
label-width="54px">
<table cellpadding="0"
cellspacing="0"
class="table-block">
<tr>
<th rowspan="2">
分账方-账户
</th>
<th colspan="6">
分账金额
</th>
</tr>
<tr>
<td>平台方分账金额</td>
<td>服务商分账金额</td>
<td>导流方分账金额</td>
<td>产品成本</td>
<td>额外成本</td>
<td>市场费</td>
</tr>
<tr>
<td class="p-b-20">
<p>默认:嘀加智慧云</p>
<p v-show="merchantInfo.partnerMerchant">
服务商:{{ merchantInfo.partnerMerchant ? merchantInfo.partnerMerchant.merchantName : '' }}{{ merchantInfo.partnerMerchant ? ( '(' + merchantInfo.partnerMerchant.merchantId + ')') : '' }}
</p>
<p>
导流方:{{ merchantInfo.merchantName }}
</p>
</td>
<td class="p-b-20">
<el-form-item label-width="0px">
<el-radio-group v-model="djDivisionDefalut"
:disabled="form.autoFlag === 'N'">
<el-radio :label="1" />
<el-radio v-show="merchantInfo.partnerMerchant"
disabled
:label="2" />
<el-radio disabled
:label="3" />
</el-radio-group>
</el-form-item>
</td>
<td class="p-b-20">
<el-form-item label-width="0"
prop="partnerProfitDivisionFlag"
:rules="form.autoFlag === 'N' ? [] : [{ required: true, message: '请选择服务商分账金额', trigger: 'change' }]">
<el-radio-group v-model="form.partnerProfitDivisionFlag"
:disabled="form.autoFlag === 'N'"
@change="e => handleClearValid(e, 'partnerProfitDivisionFlag')">
<el-radio :label="1" />
<el-radio v-show="merchantInfo.partnerMerchant"
:label="2" />
<el-radio :label="3" />
</el-radio-group>
</el-form-item>
</td>
<td class="p-b-20">
<el-form-item label-width="0"
prop="shopProfitDivisionFlag"
:rules="form.autoFlag === 'N' ? [] : [{ required: true, message: '请选择导流方分账金额', trigger: 'change' }]">
<el-radio-group v-model="form.shopProfitDivisionFlag"
:disabled="form.autoFlag === 'N'"
@change="e => handleClearValid(e, 'shopProfitDivisionFlag')">
<el-radio :label="1" />
<el-radio v-show="merchantInfo.partnerMerchant"
:label="2" />
<el-radio :label="3" />
</el-radio-group>
</el-form-item>
</td>
<td class="p-b-20">
<el-form-item label-width="0"
prop="goodsCostDivisionFlag"
:rules="form.autoFlag === 'N' ? [] : [{ required: true, message: '请选择商品成本', trigger: 'change' }]">
<el-radio-group v-model="form.goodsCostDivisionFlag"
:disabled="form.autoFlag === 'N'"
@change="e => handleClearValid(e, 'goodsCostDivisionFlag')">
<el-radio :label="1" />
<el-radio v-show="merchantInfo.partnerMerchant"
:label="2" />
<el-radio :label="3" />
</el-radio-group>
</el-form-item>
</td>
<td class="p-b-20">
<el-form-item label-width="0"
prop="extraCostDivisionFlag"
:rules="form.autoFlag === 'N' ? [] : [{ required: true, message: '请选择额外成本', trigger: 'change' }]">
<el-radio-group v-model="form.extraCostDivisionFlag"
:disabled="form.autoFlag === 'N'"
@change="e => handleClearValid(e, 'extraCostDivisionFlag')">
<el-radio :label="1" />
<el-radio v-show="merchantInfo.partnerMerchant"
:label="2" />
<el-radio :label="3" />
</el-radio-group>
</el-form-item>
</td>
<td class="p-b-20">
<el-form-item label-width="0"
prop="incentiveCostDivisionFlag"
:rules="form.autoFlag === 'N' ? [] : [{ required: true, message: '请选择激励费', trigger: 'change' }]">
<el-radio-group v-model="form.incentiveCostDivisionFlag"
:disabled="form.autoFlag === 'N'"
@change="e => handleClearValid(e, 'incentiveCostDivisionFlag')">
<el-radio :label="1" />
<el-radio v-show="merchantInfo.partnerMerchant"
:label="2" />
<el-radio :label="3" />
</el-radio-group>
</el-form-item>
</td>
</tr>
</table>
</el-form-item>
<div>
<el-form-item label="管理员手机号验证">
{{ adminInfo.name }} {{ adminInfo.phone }}
<el-button size="small"
type="primary"
@click="handleSend"
:disabled="isSend">
{{ isSend ? sendMsg + '秒后,重试' : '获取验证码' }}
</el-button>
</el-form-item>
<el-form-item label="验证码"
prop="smsCode">
<el-input placeholder="请填写验证码"
v-model="form.smsCode"
size="small"
style="width: 220px;" />
</el-form-item>
</div>
</el-form>
</div>
</d2-dialog>
</template>
<script>
import { sendSms, getAdminInfo, getDivisionRuleApi, updateDivisionRuleApi } from '@api/merchant'
export default {
name: 'DivisionRule',
data() {
return {
form: {
autoFlag: 'N',
settleTimeType: 1,
shopProfitDivisionFlag: '',
partnerProfitDivisionFlag: '',
goodsCostDivisionFlag: '',
extraCostDivisionFlag: '',
incentiveCostDivisionFlag: '',
smsCode: ''
},
djDivisionDefalut: 1,
rules: {
autoFlag: [{ required: true, message: '请选择是否开启自动打款结算', trigger: 'change' }],
settleTimeType: [{ required: true, message: '请选择结算时间方式', trigger: 'change' }],
smsCode: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
},
// 结算周期
settleTimeObj: {
first: '1',
second: '1'
},
// 发送短信
isSend: false,
sendMsg: '发送验证短信',
adminInfo: {
name: '',
phone: ''
}
}
},
props: {
divisionRuleVisible: {
type: Boolean,
default: false
},
merchantInfo: {
type: Object,
default: () => { }
}
},
watch: {
divisionRuleVisible(newVal) {
newVal ? this.getRule() : this.closeReset()
this.$refs.divisionRuleRef && this.$refs.divisionRuleRef.resetFields()
}
},
mounted() {
getAdminInfo({}).then(res => {
this.adminInfo = res
})
},
methods: {
closeReset() {
this.settleTimeObj = {
first: '1',
second: '1'
}
this.isSend = false
this.showtips = false
this.time && clearTimeout(this.time)
},
handleSend() {
sendSms({}).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)
},
getRule() {
getDivisionRuleApi({ merchantId: this.merchantInfo.merchantId }).then(res => {
if (res) {
Object.assign(this.form, res)
this.settleTimeObj[res.settleTimeType === 1 ? 'first' : 'second'] = res.settleTime
}
})
},
handleClearValid(e, validField) {
this.$refs.divisionRuleRef.clearValidate(validField)
},
handleRuleConfirm() {
this.$refs.divisionRuleRef.validate(valid => {
if (valid) {
var params = {
...this.form,
merchantId: this.merchantInfo.merchantId,
channelType: this.merchantInfo.channelType,
settleTime: this.settleTimeObj[this.form.settleTimeType === 1 ? 'first' : 'second']
}
// console.log(params)
updateDivisionRuleApi(params).then(res => {
this.notice.okTips()
this.$emit('handleRuleClose')
})
}
})
},
handleRuleClose() {
this.$emit('handleRuleClose')
}
}
}
</script>
<style>
.division-rule table {
width: 98%;
color: #666666;
border: 1px solid #e5e6e7;
border-width: 1px 0 0 1px;
}
.division-rule table tr {
height: 30px;
line-height: 30px;
}
.division-rule table th,
.division-rule table td {
font-size: 12px;
font-weight: normal;
padding: 0px 10px;
border: 1px solid #e5e6e7;
border-width: 0px 1px 1px 0px;
border-spacing: 0;
text-align: center;
/* white-space: nowrap; */
/* overflow: hidden; */
/* text-overflow: ellipsis; */
}
.division-rule .flex {
display: flex;
justify-content: space-around;
}
.division-rule .table-block .el-radio {
display: block;
height: 42px;
line-height: 42px;
margin-right: 0;
}
.division-rule .table-block .el-radio__label {
display: none !important;
}
.p-b-20 {
padding-bottom: 26px !important;
}
</style>