Commit 740d0e37 by zhangquan

车系弹窗修改

1 parent f9e8801b
......@@ -8,7 +8,7 @@
@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)">
<div :class="['item', 'flex-center',{'curItem' : curBrandId==item.id}]" v-for="item in carSeriesData" :key="item.id" @click="selectBrand(item)">
<span>{{ item.name }}</span>
<i class="el-icon-arrow-right"></i>
</div>
......@@ -16,7 +16,7 @@
<div class="wrap">
<div class="item son-brand-wrap" v-for="(item, index) in sonBrandList" :key="item.id">
<el-checkbox :indeterminate="isIndeterminate(item)" :value="isChecked(item.id, 'son')" @change="selectSonBrand($event, item, index)"></el-checkbox>
<span class="son-brand-label" @click="showCarSeries(item)">
<span :class="['son-brand-label', {'curItem' : curSonBrandId==item.id}]" @click="showCarSeries(item)">
{{ item.name }}{{ isIndeterminate(item) }}
<i class="el-icon-arrow-right"></i>
</span>
......@@ -40,10 +40,11 @@
carSeriesData: [],
sonBrandList: [],
carSeriesList: [],
curSonBrandId: '',
selectdData: [],
checkedList: [],
checked: true,
curBrandId: '',
curSonBrandId: '',
firstClick: false
}
},
computed:{
......@@ -73,6 +74,7 @@
const _notExistItem= item?.childs?.find(row => this.selectdData.includes(row.id))
return !!_existItem && !!_notExistItem
},
// 获取数据源
getCarSeriesData() {
this.$apis.case.getCarSeriesApi({needCarSeries:true}).then(res => {
console.log(res)
......@@ -81,38 +83,58 @@
}
})
},
// 切换品牌
selectBrand(item) {
if(this.curBrandId == item.id) return;
this.curBrandId = item.id
this.sonBrandList = item?.childs || []
console.log(item, this.sonBrandList)
this.curSonBrandId = ''
this.carSeriesList = []
},
// 选中子品牌
selectSonBrand(e, item , index){
console.log(e, item , index)
const { id } = item
const _targetIdx = this.checkedList.findIndex(ele => ele == id)
if(_targetIdx>-1){
this.checkedList.splice(_targetIdx, 1)
item.childs.forEach(row => {
const spliceIdx = this.selectdData.findIndex(ele => ele == row.id)
this.selectdData.splice(spliceIdx, 1)
})
}else{
this.checkedList.push(id)
let ids = item.childs.map(item => item.id)
this.selectdData = [...new Set([...this.selectdData, ...ids])]
}
console.log(this.checkedList)
},
// 选中车系
selectCarSeries(){
if(!this.firstClick){
this.selectdData = []
this.firstClick = true
}
const unChecked = this.carSeriesList.find(item => !this.selectdData.includes(item.id))
const checked = this.carSeriesList.find(item => this.selectdData.includes(item.id))
if(!unChecked) {
const _targetIdx = this.checkedList.findIndex(ele => ele == this.curSonBrandId)
if(!unChecked && _targetIdx==-1) {
this.checkedList.push(this.curSonBrandId)
}
if(!checked){
const _targetIdx = this.checkedList.findIndex(ele => ele == this.curSonBrandId)
if(!checked && _targetIdx>-1){
this.checkedList.splice(_targetIdx, 1)
}
},
// 切换子品牌
showCarSeries(item){
if(!this.firstClick){
this.selectdData = []
this.firstClick = true
}
if(this.curSonBrandId == item.id) return;
this.curSonBrandId = item.id
this.carSeriesList = item?.childs
},
handleConfirm(){
console.log(this.selectdData,155)
console.log(this.checkedList,155)
}
}
}
......@@ -123,6 +145,9 @@
border: 1px solid #E8E8EA;
height: 476px;
display: flex;
.el-checkbox{
display: block;
}
.wrap{
flex: 1;
border-left: 1px solid #E8E8EA;
......@@ -150,7 +175,6 @@
align-items: center;
.son-brand-label{
margin-left: 4px;
line-height: 29px;
flex: 1;
display: flex;
justify-content: space-between;
......@@ -170,6 +194,9 @@
// }
// }
}
.curItem{
color: #5850FF!important;
}
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!