|
@@ -34,7 +34,7 @@
|
|
|
>
|
|
>
|
|
|
<text class="category-name">{{ child.name }}</text>
|
|
<text class="category-name">{{ child.name }}</text>
|
|
|
<view class="checkbox">
|
|
<view class="checkbox">
|
|
|
- <text v-if="selectedSecondLevel.includes(child.id)" class="checked">✓</text>
|
|
|
|
|
|
|
+ <text v-if="selectedSecondLevel.includes(String(child.id))" class="checked">✓</text>
|
|
|
<text v-else class="unchecked">○</text>
|
|
<text v-else class="unchecked">○</text>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -184,7 +184,7 @@ const setSelectedState = (ids) => {
|
|
|
// 先查找二级分类
|
|
// 先查找二级分类
|
|
|
for (const parent of props.categoryList) {
|
|
for (const parent of props.categoryList) {
|
|
|
if (parent.child) {
|
|
if (parent.child) {
|
|
|
- const child = parent.child.find(c => String(c.id) === id)
|
|
|
|
|
|
|
+ const child = parent.child.find(c => String(c.id) == id)
|
|
|
if (child) {
|
|
if (child) {
|
|
|
if (!selectedSecondLevel.value.includes(id)) {
|
|
if (!selectedSecondLevel.value.includes(id)) {
|
|
|
selectedSecondLevel.value.push(id)
|
|
selectedSecondLevel.value.push(id)
|
|
@@ -194,20 +194,20 @@ const setSelectedState = (ids) => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ console.log("found",found,id)
|
|
|
// 如果没有找到对应的二级分类,检查是否是一级分类
|
|
// 如果没有找到对应的二级分类,检查是否是一级分类
|
|
|
if (!found) {
|
|
if (!found) {
|
|
|
- const firstLevel = props.categoryList.find(item => String(item.id) === id)
|
|
|
|
|
|
|
+ const firstLevel = props.categoryList.find(item => String(item.id) == id)
|
|
|
if (firstLevel) {
|
|
if (firstLevel) {
|
|
|
// 如果是一级分类,检查是否有子分类
|
|
// 如果是一级分类,检查是否有子分类
|
|
|
if (firstLevel.child && firstLevel.child.length > 0) {
|
|
if (firstLevel.child && firstLevel.child.length > 0) {
|
|
|
// 有子分类的一级分类:选中所有子分类
|
|
// 有子分类的一级分类:选中所有子分类
|
|
|
- firstLevel.child.forEach(child => {
|
|
|
|
|
- const childId = String(child.id)
|
|
|
|
|
- if (!selectedSecondLevel.value.includes(childId)) {
|
|
|
|
|
- selectedSecondLevel.value.push(childId)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // firstLevel.child.forEach(child => {
|
|
|
|
|
+ // const childId = String(child.id)
|
|
|
|
|
+ // if (!selectedSecondLevel.value.includes(childId)) {
|
|
|
|
|
+ // selectedSecondLevel.value.push(childId)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
} else {
|
|
} else {
|
|
|
// 没有子分类的一级分类:直接选中
|
|
// 没有子分类的一级分类:直接选中
|
|
|
if (!selectedSecondLevel.value.includes(id)) {
|
|
if (!selectedSecondLevel.value.includes(id)) {
|