baseInfo.vue
15 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
<template>
<div class="base-info">
<el-form ref="baseForm" :model="accountAddForm" class="account-body-form" label-width="120px" :rules="baseRules">
<el-row>
<el-col :span="12">
<el-form-item label="商户名称:" prop="merchantName">
<el-input size="small" v-model="accountAddForm.merchantName" :disabled="isEdit" placeholder="请输入商户名称"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="商户简称:">
<el-input size="small" v-model="accountAddForm.merchantAbbreviation" placeholder="请输入商户简称"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="联系电话:" prop="merchantLegalPersonPhone" style="margin-bottom:5px">
<el-input maxlength="11" size="small" v-model="accountAddForm.merchantLegalPersonPhone" placeholder="请输入联系电话"></el-input>
<!-- <el-checkbox v-model="accountAddForm.isloginName">联系电话同时作为登录账户名</el-checkbox> -->
</el-form-item>
<el-checkbox v-model="accountAddForm.isloginName" style="margin-left:154px;margin-bottom:20px">联系电话同时作为登录账户名</el-checkbox>
</el-col>
<el-col :span="12">
<el-form-item label="联系人:">
<el-input size="small" v-model="accountAddForm.merchantLegalPerson" placeholder="请输入联系人"></el-input>
</el-form-item>
</el-col>
</el-row>
<div class="bottom-spe">
<el-row>
<el-col :span="12">
<ProvinceCity ref="provinceForm" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity" :detailAddressLabel="detailAddressLabel" @selectAddressByMap="selectAddressByMap"></ProvinceCity>
</el-col>
<el-col :span="12">
<el-form-item label="驻店联系方式:">
<el-input maxlength="11" size="small" v-model="accountAddForm.residentContact" placeholder="请输入驻店联系人"></el-input>
</el-form-item>
<el-form-item label=" " prop="residentPhone">
<el-input maxlength="13" size="small" class="phone-input" v-model="accountAddForm.residentPhone" placeholder="请输入驻店电话"></el-input>
</el-form-item>
</el-col>
</el-row>
</div>
<el-row>
<el-col :span="12">
<el-form-item label="营业时间:" class="open-time">
<el-time-picker size="small" value-format="HH:mm:ss" is-range v-model="accountAddForm.bussinessTime" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围"></el-time-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="主营品牌:">
<select-brand :brandListTree="brandListTree" @clickBrand="clickBrand" ref="brandListTree"></select-brand>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="经营业务类型:" class="bussiness-type">
<el-checkbox-group v-model="accountAddForm.businessType">
<el-checkbox v-for="item in businessType" :label="item.dictValue" :disabled="item.dictValue <= 6" :key="item">{{ item.dictLabel }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="门店照片:" style="margin-bottom:5px">
<div class="store-upload-list">
<template v-if="accountAddForm.merchantFiles.length && accountAddForm.merchantFiles.length > 0">
<div :key="index" v-for="(item, index) in accountAddForm.merchantFiles" class="store-border" @mouseenter="imgIndex = index" @mouseleave="imgIndex = ''">
<img :src="item.fileUrl" />
<div class="uploader-del-icon" v-if="imgIndex === index">
<i class="el-icon-delete-solid" @click.stop="delImg(index)"></i>
</div>
</div>
</template>
<el-upload action="" class="image-uploader" :show-file-list="false" list-type="picture-card" v-loading="loadingImg" :before-upload="upLoadImg">
<i class="el-icon-plus"></i>
</el-upload>
</div>
</el-form-item>
<div class="tips">图片格式仅支持JPG、PNG格式,大小1M</div>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
import util from '@/utils/util'
import SelectBrand from '../../baseInfo/selectBrand.vue'
import ProvinceCity from '@/components/province-city/index.vue'
export default {
name: 'base',
components: {
ProvinceCity,
SelectBrand
},
props: {
accountAddForm: {
type: Object
},
businessOption: {
type: Array
},
brandData: {
type: Array
},
businessScopeCustomize: {
type: Array
},
isEdit: {
type: Boolean,
value: false
}
},
data() {
const validatePhone = (rule, value, callback) => {
if (!util.checkPhone(value)) {
callback(new Error('请输入正确的手机号'))
} else {
callback()
}
}
const validatePhoneTwo = (rule, value, callback) => {
const reg = /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/
if (value == '' || value == undefined || value == null) {
callback()
} else {
if (!reg.test(value) && value != '') {
callback(new Error('请输入正确的电话号码或者固话号码'))
} else {
callback()
}
}
}
return {
subdistrict: 2,
detailAddressLabel: ' ',
imgIndex: '',
filterText: '',
defaultProps: {
children: 'children',
label: 'label'
},
dialogMapVisible: false,
baseRules: {
merchantName: [{ required: true, message: '请输入商户名称', trigger: 'blur' }],
merchantLegalPersonPhone: [
{ required: true, message: '请输入联系电话', trigger: 'blur' },
{ validator: validatePhone, trigger: 'blur' }
],
residentPhone: [{ validator: validatePhoneTwo, trigger: 'blur' }]
},
brandListTree: [],
provinceCode: '',
provinceName: '',
cityCode: '',
cityName: '',
isFirstBrand: false,
addressData: {}
}
},
watch: {
filterText(val) {
this.$refs.brandTree.filter(val)
}
},
methods: {
checkBrandList() {
// let merchantBrandMain = chant.filter(item => item)
// this.$set(this.accountAddForm, 'merchantBrandMain', merchantBrandMain)
console.log(this.accountAddForm.merchantBrandMain)
console.log(222222222)
if (!this.accountAddForm.merchantBrandMain) {
this.accountAddForm.merchantBrandMain = []
}
this.brandList()
// this.$refs.brandListTree.getCheckList(this.accountAddForm.merchantBrandMain)
},
checkBusinessType(type) {
if (!type) {
this.accountAddForm.businessType = [1, 2, 3, 4, 5, 6]
} else {
const businessType = type.split(',')
this.$set(
this.accountAddForm,
'businessType',
businessType.map(item => (item = parseInt(item)))
)
}
},
async brandList() {
this.$refs.brandListTree.loading = true
const brandListTree = await this.$apis.baseInfo.brandList({})
brandListTree.forEach(item => {
let child = item.children
if (!child) return
child.forEach(k => {
delete k.children
})
})
this.brandListTree = brandListTree
this.$refs.brandListTree.getCheckList(this.accountAddForm.merchantBrandMain)
this.$nextTick(() => {
this.$refs.brandListTree.loading = false
})
},
async getUserInfo() {
this.businessType = await this.$apis.store.findAllDictData({ dictType: 'business_type' })
},
// 点击主营品牌
clickBrand(val) {
if (!this.isFirstBrand) {
// this.brandList()
this.isFirstBrand = true
}
},
hanleSelectMap() {
this.dialogMapVisible = true
this.$nextTick(() => {
if (this.accountAddForm.merchantAddress && !this.$refs.mapForm.address) {
this.$refs.mapForm.address = this.accountAddForm.merchantAddress
this.$refs.mapForm.addMarker([this.accountAddForm.lng, this.accountAddForm.lat])
}
})
},
clickDeal() {
this.$parent.editStatus = true
},
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
// 当直接点击选择地址时,获取省市ID
init(province, city) {
this.$refs.provinceForm.init(province, city)
},
// 获取省
selectProvince(val) {
console.log(val)
this.$set(this.accountAddForm, 'merchantAddress', '')
// 强制更新 merchantAddress
this.$forceUpdate()
this.accountAddForm.cityName = ''
this.accountAddForm.provinceName = val.name
this.accountAddForm.provinceCode = val.adcode
},
// 获取市
selectCity(val) {
console.log(val)
if (val.name) {
this.accountAddForm.cityName = val.name
this.accountAddForm.cityCode = val.adcode
} else {
this.accountAddForm.cityName = ''
this.accountAddForm.cityCode = ''
}
this.$set(this.accountAddForm, 'merchantAddress', '')
this.$forceUpdate()
},
// 通过地图选择省市和详细地址
selectAddressByMap(val) {
console.log(val)
const { provinceName, cityName, fullAddress, lat, lng } = val
this.accountAddForm.merchantAddress = fullAddress
this.accountAddForm.provinceName = provinceName
this.accountAddForm.cityName = cityName
this.accountAddForm.lat = lat
this.accountAddForm.lng = lng
},
delImg(index) {
this.accountAddForm.merchantFiles.splice(index, 1)
},
addBusinessScope() {
this.businessScopeCustomize.push({ name: '' })
},
removeBusinessScope(index) {
this.businessScopeCustomize.splice(index, 1)
},
upLoadImg(file) {
let fileName = file.name
if (file.name.lastIndexOf('.') === -1) {
this.$message.warning('路径不正确')
return false
}
let AllImgExt = '.jpg|.jpeg|.gif|.bmp|.png|.swf'
let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
if (AllImgExt.indexOf(extName + '|') === -1) {
this.$message.warning('图片格式不正确')
return false
}
if (this.accountAddForm.merchantFiles.length == 3) {
this.$message.warning('最多上传3张')
return false
}
// if (fileSize < 3145728) {
if (window.FileReader) {
let reader = new FileReader()
let self = this
reader.readAsDataURL(file)
reader.onload = img => {
console.log(file)
let type = fileName.split('.')[1]
let imgUrl = img.target.result.split(',')[1]
// self.loadingImg = true;
self.$apis.common
.pictureUpload({
file: `${type}@${imgUrl}`
})
.then(res => {
if (res) {
self.accountAddForm.merchantFiles.push({
fileUrl: res,
fileName: ''
})
}
})
}
}
}
},
mounted() {
this.$refs.provinceForm.provinceList()
this.getUserInfo()
}
}
</script>
<style scoped lang="scss">
.base-info {
/deep/ {
.el-dialog__body {
padding: 20px 10px;
}
}
.account-body-form {
// width: 80%;
margin: 20px auto;
.form-row {
/deep/ .el-form-item__content {
display: flex;
}
.form-btn {
margin-left: 10px;
}
}
.merchant-row {
/deep/ {
.el-form-item__content {
line-height: 1;
}
.el-select {
.el-input {
width: 80px;
}
}
}
}
.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: 104px;
height: 104px;
line-height: 104px;
}
}
.brand-tree {
height: 300px;
overflow-y: auto;
}
.open-time {
/deep/ {
.el-range-editor--small.el-input__inner {
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;
margin-left: 154px;
margin-bottom: 20px;
}
.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;
}
}
}
}
/deep/ {
.tree-box {
border: 1px solid #e5e5e5;
}
.el-checkbox:last-of-type {
margin-right: 7px;
}
}
.account-body-form {
/deep/ {
.el-form-item {
margin-bottom: 20px;
display: flex;
}
.el-form-item__label {
width: 154px !important;
}
.el-form-item__content {
width: 404px;
margin-left: 0 !important;
}
.select-input-box {
width: 404px;
}
}
}
.bussiness-type {
/deep/ .el-form-item__content {
min-width: 1000px;
}
}
.bottom-spe {
.el-col {
/deep/ .el-form-item:first-child {
margin-bottom: 10px;
}
}
}
</style>