checkedAll (index) { // 全選按鈕
let list = this.list.checkBoxConditions[index].conditionItems
if (this.checked[index] === true) { // 實現全選
list.forEach(item => {
item.isChecked = false
})
} else {
list.forEach(item => {
item.isChecked = true
})
}
},
checkedSingle (index, subindex) { // 單選按鈕 決定全選按鈕
let num = 0 // 除了當前選項,其他選中的次數
let flag = false // 其他選項是否都選中
for (let j = 0; j < this.list.checkBoxConditions[index].conditionItems.length; j++) {
if (j === subindex) { // 當前選擇爲false爲選中,正好相反,在後續做處理
continue
}
if (this.list.checkBoxConditions[index].conditionItems[j].isChecked === true) { // 記錄剩餘的是否選中
num++
}
if (num === this.list.checkBoxConditions[index].conditionItems.length - 1) {
flag = true
} else {
flag = false
}
}
if (this.list.checkBoxConditions[index].conditionItems[subindex].isChecked === false && flag === true) { // 選中的select爲false和剩餘的爲true則爲true
this.checked[index] = true
} else {
this.checked[index] = false
}
}