selectCarDialog.vue
3.44 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
<template>
<GLDialog title="选择车系"
mode="mid"
:visible.sync="dialogVisible"
:before-close="handleClose"
:close-on-click-modal="false"
@onOk="handleConfirm"
@onCancel="handleClose">
<div class="car-container">
<div class="wrap">
<div class="item flex-center" v-for="item in carSeriesData" :key="item.id" @click="selectBrand(item)">
<span>{{ item.name }}</span>
<i class="el-icon-arrow-right"></i>
</div>
</div>
<div class="wrap">
<div class="item flex-center" v-for="(item, index) in sonBrandList" :key="item.id">
<el-checkbox :indeterminate="isIndeterminate(item)" v-model="item.checked" @change="selectCarSeries(index, item)">
<span class="flex-center">
{{ item.name }}
<i class="el-icon-arrow-right"></i>
</span>
</el-checkbox>
</div>
</div>
<div class="wrap">
<el-checkbox-group v-model="selectdData" @change="handleCheckedCitiesChange">
<el-checkbox class="item" v-for="item in carSeriesList" :label="item.name" :key="item.id">{{item.name}}</el-checkbox>
</el-checkbox-group>
</div>
</div>
</GLDialog>
</template>
<script>
import url from '@/assets/empty.png'
export default {
name: 'selectStore',
data() {
return {
carSeriesData: [],
sonBrandList: [],
curSonBrandIdx: -1,
selectdData: [],
isIndeterminate: true
}
},
computed:{
carSeriesList() {
return this.curSonBrandIdx == -1 ? [] : this.sonBrandList[this.curSonBrandIdx]?.childs?.forEach(item => item.checked = false)
}
},
props: {
dialogVisible:{
type: Boolean,
default: false
}
},
mounted() {
this.getCarSeriesData()
},
methods:{
getCarSeriesData() {
this.$apis.store.getCarSeriesApi({needCarSeries:true}).then(res => {
console.log(res)
if(res?.length){
this.carSeriesData = res
}
})
},
selectBrand(item) {
this.curSonBrandIdx = -1
this.sonBrandList = item.childs
console.log(item, this.sonBrandList)
},
selectCarSeries(idx, item){
if(this.curSonBrandIdx != idx) this.curSonBrandIdx = idx
}
}
}
</script>
<style lang="scss">
.car-container{
border: 1px solid #E8E8EA;
height: 476px;
display: flex;
.wrap{
flex: 1;
border-left: 1px solid #E8E8EA;
overflow-y: auto;
padding: 8px 0px 8px 12px;
&:first-child{
border: none;
}
.item{
height: 28px;
line-height: 28px;
font-size: 14px;
font-weight: 400;
color: #333333;
cursor: pointer;
}
.flex-center{
display: flex;
justify-content: space-between;
align-items: center;
}
.son-item{
display: inline-flex;
justify-content: space-between;
align-items: center;
width: calc(100% - 14px);
}
}
}
</style>