addAccount.vue
18.6 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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
<template>
<div class="scrm-main" v-loading="loading">
<div v-show="step == 1">
<div class="account-header scrm-flex-between scrm-box-f">
<span>创建子商户/门店</span>
</div>
<div class="account-body scrm-box-f">
<div class="form-title">企业基本信息</div>
<base-info ref="baseInfoForm" :brandData="brandData" :accountAddForm="accountAddForm" :businessScopeCustomize="businessScopeCustomize" :businessOption="businessOption"></base-info>
</div>
<div class="account-body scrm-box-f">
<div class="form-title">账户信息</div>
<el-form ref="accountInfoForm" :model="accountInfoForm" class="account-body-form" :rules="accountInfoRules">
<el-row>
<el-col :span="12">
<el-form-item label="上级商户:">
{{ accountDetail.merchantName }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="上级商户模式:">
{{ accountDetail.merchantModelName }}
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<div class="el-form-item level-row is-required">
<label class="el-form-item__label">账户等级:</label>
<div class="el-form-item__content">
<el-select size="small" :disabled="nextStatus" v-model="accountDetail.merchantAccountLevel" placeholder="请选择">
<el-option v-for="item in accountLevel" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"></el-option>
</el-select>
</div>
</div>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="登录账户名:" prop="merchantLoginAccount">
<el-input :disabled="nextStatus" size="small" maxlength="15" v-model="accountInfoForm.merchantLoginAccount" placeholder="请输入登录账户名"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="登录密码:" prop="merchantLoginPassword">
<el-input maxlength="20" :disabled="nextStatus" size="small" type="password" v-model="accountInfoForm.merchantLoginPassword" placeholder="请输入登录密码(必须包含6-20个字母+数字)" show-password></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="16">
<div data-v-995a4ff0="" class="el-form-item is-required">
<label for="merchantLoginAccount" class="el-form-item__label">账户类型:</label>
<div class="el-form-item__content account-type">
<div data-v-995a4ff0="" class="el-input el-input--small">
<auto-button v-for="(item, index) in accountDetail.accountTypes" :key="index" :btnLabel="item.accounttypeName" :btnValue="item.accounttypeId" :stopClick="nextStatus" @getBtnStatus="getBtnStatus"></auto-button>
</div>
<div class="el-form-item__error" v-if="accountTypesRule">请选择账户类型</div>
</div>
</div>
</el-col>
</el-row>
</el-form>
</div>
</div>
<select-product v-show="step == 2" ref="productForm" title="功能权限"></select-product>
<GLFooter style="z-index: 2">
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleNext" v-show="step == 1">下一步</el-button>
<el-button type="primary" @click="handleSave(1)" v-show="step == 2">存草稿</el-button>
<el-button type="primary" @click="handlePrev" v-show="step == 2">上一步</el-button>
<el-button type="primary" @click="handleSave(2)" v-show="step == 2">确定</el-button>
</GLFooter>
</div>
</template>
<script>
import util from '@/utils/util'
import autoButton from '@/components/auto-button/index'
import selectProduct from './components/selectProduct'
import baseInfo from './components/baseInfo'
export default {
name: 'index',
components: {
autoButton,
selectProduct,
baseInfo
},
data() {
const validatePhone = (rule, value, callback) => {
if (!util.checkPhone(value)) {
callback(new Error('请输入正确的手机号'))
} else {
callback()
}
}
const validatePwd = (rule, value, callback) => {
if (!/^(?=.*\d)(?=.*[a-zA-Z])[\s\S]{6,20}$/.test(value)) {
callback(new Error('请输入正确的6-20个密码,必须同时包含字母、数字。'))
} else {
callback()
}
}
const validateAccountInfo = (rule, value, callback) => {
console.log(value)
if (value.length == 11 && !isNaN(value)) {
callback(new Error('登录账户名不可为 11 位纯数字'))
} else {
callback()
}
}
return {
loading: false,
editStatus: false,
nextStatus: false,
accountTypesRule: false,
filterText: '',
brandData: [],
defaultProps: {
children: 'children',
label: 'label'
},
parentId: '',
step: 1,
typeStatus: false,
loadingImg: false,
businessScopeCustomize: [{ name: '' }],
accountAddForm: {
status: '',
merchantFiles: [],
merchantType: 1,
businessType: [],
parentId: '',
isloginName: false
},
accounttypeId: [],
accountInfoForm: {},
accountDetail: {},
accountLevel: [],
businessOption: [],
accountValidityPeriod: [],
baseRules: {
merchantName: [{ required: true, message: '请输入商户名称', trigger: 'blur' }],
merchantLegalPersonPhone: [
{ required: true, message: '请输入联系电话', trigger: 'blur' },
{ validator: validatePhone, trigger: 'blur' }
]
},
accountInfoRules: {
merchantLoginAccount: [
{ required: true, message: '请输入登录账户名', trigger: 'blur' },
{ min: 3, max: 15, message: '长度在 3 到 15 个字符', trigger: 'blur' },
{ validator: validateAccountInfo, trigger: 'blur' }
],
merchantLoginPassword: [
{ required: true, message: '请输入登录密码', trigger: 'blur' },
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' },
{ validator: validatePwd, trigger: 'blur' }
]
}
}
},
watch: {
accountInfoForm: {
handler() {
this.editStatus = true
},
deep: true
},
accountDetail: {
handler() {
this.editStatus = true
},
deep: true
},
accountAddForm: {
handler() {
this.editStatus = true
},
deep: true
}
},
methods: {
getBtnStatus(status, value) {
this.editStatus = true
this.accountTypesRule = false
if (status) {
this.accounttypeId.push(value)
} else {
let idx = this.accounttypeId.findIndex(item => item == value)
this.accounttypeId.splice(idx, 1)
}
},
handleSave(status) {
let product = this.$refs.productForm.getSelectInfo()
if (status == 2 && product && product.every(item => item.products.length == 0)) {
this.$message.error('请选择产品')
return
}
let accountTypes = JSON.stringify(product)
let params = {
accountTypes,
status,
merchantId: this.parentId
}
this.$apis.store.updatePermissions(params).then(res => {
if (res) {
this.$router.push('/account/index')
}
})
},
handleCancel() {
if (this.editStatus) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning',
customClass: 'gl-message-box'
}).then(() => {
this.$router.push({
path: '/account/index'
})
})
} else {
this.$router.push({
path: '/account/index'
})
}
},
handlePrev() {
document.querySelector('#app').scrollTop = 0
this.step = 1
},
//下一步
handleNext() {
console.log(2222)
this.loading = true
const pm1 = new Promise((resolve, reject) => {
this.$refs.baseInfoForm.$refs.baseForm.validate(valid => {
if (valid) resolve()
else {
this.loading = false
setTimeout(() => {
var isError = document.getElementsByClassName('is-error')
isError[0].querySelector('input').focus()
}, 100)
reject()
}
})
})
const pm2 = new Promise((resolve, reject) => {
this.$refs.accountInfoForm.validate(valid => {
if (valid) resolve()
else {
this.loading = false
pm1.then(() => {
document.querySelector('#app').scrollTop = 1000
})
setTimeout(() => {
var isError = document.getElementsByClassName('is-error')
isError[0].querySelector('input').focus()
}, 100)
}
})
})
if (this.accounttypeId.length == 0) {
this.loading = false
this.accountTypesRule = true
return
}
if (this.accountAddForm.merchantType == 1 && this.accountAddForm.merchantOrgcode && !util.checkIdCard(this.accountAddForm.merchantOrgcode)) {
this.loading = false
this.$message.error('请输入正确的身份证号码')
document.querySelector('#app').scrollTop = 0
setTimeout(() => {
var isError = document.getElementsByClassName('card-input')
isError[0].querySelectorAll('.el-input__inner')[1].focus()
}, 100)
return
}
// if (this.accountAddForm.residentPhone && !util.checkPhone(this.accountAddForm.residentPhone)) {
// this.$message.error('请输入正确的驻店电话')
// document.querySelector('#app').scrollTop = 0
// setTimeout(() => {
// var isError = document.getElementsByClassName('phone-input')
// isError[0].querySelector('input').focus()
// }, 100)
// return
// }
const reg = /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/
if (this.accountAddForm.residentPhone) {
const result = reg.test(this.accountAddForm.residentPhone)
if (!result) {
this.loading = false
this.$message({
message: '请输入正确的驻店信息',
type: 'warning'
})
return false
}
}
let params = Object.assign({}, this.accountAddForm, this.accountInfoForm)
if (params.bussinessTime) {
params.bussinessBegintime = params.bussinessTime[0]
params.bussinessEndtime = params.bussinessTime[1]
}
if (params.businessType) {
params.businessType = params.businessType.join(',')
}
// const merchantBrandList = this.$refs.baseInfoForm.$refs.brandListTree.getMerchantBrandList()
// params.merchantBrandListJson = JSON.stringify(merchantBrandList)
params.isloginName ? (params.isloginName = 1) : (params.isloginName = 0)
params.merchantAccountLevel = this.accountDetail.merchantAccountLevel
params.status = 1
params.channelId = this.accountDetail.channelId
// let businessScopeCustomize = this.businessScopeCustomize.map(item => item.name)
// params.businessScopeCustomize = businessScopeCustomize.join(',')
params.accounttypeId = this.accounttypeId.join(',')
params.merchantFiles = JSON.stringify(params.merchantFiles)
params.merchantModel = this.accountDetail.merchantModel
let merchant
if (this.nextStatus) {
merchant = 'updateMerchant'
params.id = this.parentId
} else {
merchant = 'saveMerchant'
}
document.querySelector('#app').scrollTop = 0
console.log(params)
Promise.all([pm1, pm2]).then(() => {
this.$apis.store[merchant](params).then(res => {
if (res) {
this.loading = false
this.step = 2
this.nextStatus = true
if (typeof res == 'number') {
this.parentId = res
let para = {
accountlevel: this.accountDetail.merchantAccountLevel,
id: this.parentId,
parentId: this.accountAddForm.parentId
}
this.$refs.productForm.findMenuFunTreeByMerId(para, this.accounttypeId)
}
this.twoMerchantDetail(this.parentId)
}
})
})
},
findAllDictData(dictType) {
var params = {
dictType
}
this.$apis.store.findAllDictData(params).then(res => {
if (res) {
if (dictType == 'business_type') {
this.businessOption = res
}
}
})
},
addBusinessScope() {
this.businessScopeCustomize.push({ name: '' })
},
removeBusinessScope(index) {
this.businessScopeCustomize.splice(index, 1)
},
async findMerchantDetail() {
this.accountDetail = await this.$apis.store.findMerchantDetail({
id: this.accountAddForm.parentId
})
this.$apis.store.findAllDictData({ dictType: 'account_level' }).then(res => {
if (this.accountDetail.merchantAccountLevel == 1) {
this.accountLevel = res.filter(item => {
return item.dictValue != 1 && item.dictValue != 3
})
this.accountDetail.merchantAccountLevel = 2
} else if (this.accountDetail.merchantAccountLevel == 2) {
this.accountLevel = res.filter(item => {
return item.dictValue != 1 && item.dictValue != 2
})
this.accountDetail.merchantAccountLevel = 3
} else {
this.accountLevel = res.filter(item => {
return item.dictValue == 4
})
this.accountDetail.merchantAccountLevel = 4
}
this.$nextTick(() => {
this.editStatus = false
})
})
},
twoMerchantDetail(pid) {
this.$apis.store
.findMerchantDetail({
id: pid
})
.then(res => {
console.log(res)
})
},
getCarbrandTree() {
// this.$apis.baseInfo.brandList({ needCarSeries: true }).then(res => {
// this.brandData = res
// })
this.$apis.store.getCarbrandTree({}).then(res => {
this.brandData = res
})
}
},
mounted() {
document.querySelector('#app').scrollTop = this.accountAddForm.parentId = this.$route.params.id
this.$refs.baseInfoForm.checkBusinessType()
this.findMerchantDetail()
this.getCarbrandTree()
this.findAllDictData('business_type')
this.$refs.baseInfoForm.brandList()
// 1
}
}
</script>
<style scoped lang="scss">
.account-header {
height: 78px;
box-sizing: border-box;
font-size: 20px;
font-weight: 500;
color: #333333;
line-height: 20px;
padding: 0px 20px;
}
.merchant-row {
/deep/ {
.el-form-item__content {
line-height: 1;
}
.el-select {
.el-input {
width: 110px;
}
}
}
}
.account-body {
margin-top: 20px;
// &:nth-of-type(3) {
// margin-bottom: 70px;
// }
.form-title {
font-size: 16px;
font-weight: 500;
color: #333333;
line-height: 60px;
height: 60px;
border-bottom: 1px solid #d8d8d8;
padding-left: 20px;
}
&-form {
margin: 20px auto;
.form-row {
/deep/ .el-form-item__content {
display: flex;
}
.form-btn {
margin-left: 10px;
}
}
.store-upload-list {
display: flex;
flex-wrap: wrap;
.store-border {
position: relative;
width: 120px;
height: 80px;
border-radius: 2px;
margin-right: 15px;
margin-bottom: 15px;
}
.uploader-del-icon {
position: absolute;
top: 0px;
right: 0px;
width: 30px;
height: 30px;
line-height: 30px;
background: rgba(0, 0, 0, 0.4);
border-radius: 0px 0px 0px 100px;
cursor: pointer;
}
.el-icon-delete-solid {
color: #c5c5c5;
font-size: 14px;
margin-left: 12px;
}
}
.image-uploader {
/deep/ .el-upload {
width: 120px;
height: 80px;
line-height: 80px;
}
}
.brand-tree {
height: 300px;
overflow-y: auto;
}
.open-time {
/deep/ {
.el-range-editor--small.el-input__inner {
width: 100%;
}
}
}
.level-row {
/deep/ .el-select {
width: 100%;
}
}
.el-icon-btn {
color: #5850ff;
font-size: 16px;
margin-left: 6px;
cursor: pointer;
}
.tips {
font-size: 14px;
font-weight: 400;
color: #999999;
line-height: 30px;
}
.btn-unselect {
display: inline-block;
cursor: pointer;
position: relative;
height: 30px;
line-height: 30px;
margin-top: 6px;
padding-right: 30px;
cursor: pointer;
font-size: 0;
-webkit-transition: 0.1s linear;
transition: 0.1s linear;
box-sizing: border-box;
&.selectd-type {
.select-type-title {
background: #5850ff;
}
}
.select-type-title {
display: inline-block;
padding: 0 16px;
height: 100%;
font-size: 14px;
border-radius: 2px 0 0 2px;
background-color: #d2d2d2;
color: #fff;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.btn-icon {
display: inline-block;
position: absolute;
right: 0;
top: 0;
width: 30px;
height: 28px;
line-height: 28px;
border: 1px solid #dcdfe6;
border-left: none;
border-radius: 2px 0px 0px 2px;
color: #5850ff;
font-size: 20px;
text-align: center;
}
}
}
}
.footer-panel {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
width: 100%;
bottom: 0px;
height: 64px;
background: #ffffff;
z-index: 999;
// box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
}
/deep/ {
.el-form-item__content {
display: flex;
}
.el-form-item__label {
width: 154px !important;
line-height: 32px;
}
.el-form-item__content {
width: 404px;
margin-left: 0 !important;
line-height: 32px;
}
}
.account-type {
/deep/ {
.el-input {
min-width: 1000px !important;
}
}
}
</style>