Commit d160fe05 by zhangquan

单选逻辑

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