Commit d160fe05 by zhangquan

单选逻辑

1 parent 68c0ca16
......@@ -9,7 +9,7 @@
<div class="car-container">
<div class="wrap">
<div class="item son-brand-wrap" v-for="(item, index) in carSeriesData" :key="item.id">
<el-checkbox :disabled="!(item.childs && item.childs.length)" :indeterminate="isIndeterminate(item, 1)" :value="isChecked(item, 1)" @change="changeBrandStatus($event, item, index)"></el-checkbox>
<el-checkbox v-if="!singleChoice" :disabled="!(item.childs && item.childs.length)" :indeterminate="isIndeterminate(item, 1)" :value="isChecked(item, 1)" @change="changeBrandStatus($event, item, index)"></el-checkbox>
<span :class="['son-brand-label', {'curItem' : curBrandInfo.id==item.id}]" @click="showSonBrandList(item)">
{{ item.name }}
<i v-if="item.childs && item.childs.length" class="el-icon-arrow-right"></i>
......@@ -49,7 +49,8 @@
curSonBrandInfo: {
id: '',
name: ''
}
},
isClearData: true
}
},
computed:{
......@@ -58,6 +59,10 @@
dialogVisible:{
type: Boolean,
default: false
},
singleChoice:{
type: Boolean,
default: false
}
},
......@@ -84,6 +89,10 @@
console.log(this.selectdData)
},
changeSonBrandStatus(e, row, idx){
if(this.singleChoice && this.isClearData) {
this.selectdData = {}
this.isClearData = false
}
const {id:rootId, name: rootName} = this.curBrandInfo
if(this.selectdData[rootId]){
if(this.selectdData[rootId][row.id]){
......@@ -106,6 +115,10 @@
}
},
changeCarSeriesStatus(e, row, idx){
if(this.singleChoice && this.isClearData) {
this.selectdData = {}
this.isClearData = false
}
const {id:rootId, name: rootName} = this.curBrandInfo
const {id: parentId, name: parentName} = this.curSonBrandInfo
if(this.selectdData[rootId]){
......@@ -125,6 +138,8 @@
console.log(this.selectdData)
},
showSonBrandList(row){
if(row.id == this.curBrandInfo.id) return
this.isClearData = true
this.curBrandInfo = {
id: row.id,
name: row.name
......@@ -132,8 +147,8 @@
this.sonBrandList = row?.childs || []
this.carSeriesList = []
},
// 切换子品牌
showCarSeriesList(row){
if(row.id == this.curSonBrandInfo.id) return
this.curSonBrandInfo = {
id: row.id,
name: row.name
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!