两笔数据设置的所有品牌,被设置过的不让再次设置,
el-cascader这里用的多选,已被选的数据被disabled掉
奥迪Q3已经被选,现在做个删除操作,props二级数据应该重新加载,删除后这个仍被禁用,但是打印出来的数据发生改变,可以用这个id的长度变化来重新加载
data 这里需要重新指向this,不然从接口返的数据赋值了goodId拿不到
propsGood: {
lazy: true,
checkStrictly: true,
multiple: true,
expandTrigger: 'hover',
lazyLoad(node, resolve) {
const { level, data } = node
if (level === 0) {
this.selectLoading = true
const queryObj = {
text: '',
page: 1,
rows: 20
}
getDataVehicle(queryObj, 'brand').then((res) => {
if (res.data) {
const data = res.data
const tempData = []
data.map((e) => {
const objStr = {
lid: e.id,
value: e.vehicleBrand,
label: e.vehicleBrand,
disabled: true,
leaf: level >= 2
}
tempData.push(objStr)
})
resolve(tempData)
// this.brandList = tempData
this.selectLoading = false
}
})
} else {
this.selectLoading = true
const queryObj = {
text: '',
pid: data.lid,
page: 1,
rows: 20
}
getDataVehicle(queryObj, 'type').then((res) => {
if (res.data) {
const data = res.data
const tempData = []
let objStr = {}
data.map((e) => {
let disabledIt = false
if (that.goodId.indexOf(e.id) !== -1) {
disabledIt = true
}
objStr = {
lid: e.id,
value: `${e.id}-${e.vehicleType}`,
label: e.vehicleType,
disabled: disabledIt,
leaf: true
}
tempData.push(objStr)
})
resolve(tempData)
}
})
}
}
},