diff --git a/src/views/portal/course/Index.vue b/src/views/portal/course/Index.vue index e8814861..ea6298c5 100644 --- a/src/views/portal/course/Index.vue +++ b/src/views/portal/course/Index.vue @@ -7,7 +7,8 @@
- @@ -69,7 +70,7 @@ 全部
- {{three.name}} + {{three.name}}
@@ -353,21 +354,42 @@ export default { list.push(item); } }); - this.oneList.forEach(item=>{ - if(item.checked){ - list.push(item); - } - }); - this.twoList.forEach(item=>{ - if(item.checked){ - list.push(item); - } - }); - this.threeList.forEach(item=>{ - if(item.checked){ - list.push(item); - } - }); + this.oneList.forEach(one=>{ + var twoChildChecked=false;//是否有下级 + one.children.forEach(two=>{ + if(two.checked){ + twoChildChecked=true; + } + var threeChildChecked=false; + two.children.forEach(three=>{ + if(three.checked){ + list.push(three); + threeChildChecked=true; + } + }); + if(two.checked && !threeChildChecked){ + list.push(two); + } + }); + if(one.checked && !twoChildChecked){ + list.push(one); + } + }) + // this.oneList.forEach(item=>{ + // if(item.checked){ + // list.push(item); + // } + // }); + // this.twoList.forEach(item=>{ + // if(item.checked){ + // list.push(item); + // } + // }); + // this.threeList.forEach(item=>{ + // if(item.checked){ + // list.push(item); + // } + // }); //console.log(list,'list'); return list; }, @@ -523,6 +545,7 @@ export default { } this.searchData(); }, + handleTypeAllClick(t){ if(t==1){ this.ctypeList.forEach(ct=>{ @@ -555,42 +578,116 @@ export default { } this.searchData(); }, + handleClearTags(){ + //清空所有的条件 + this.keyword=''; + this.ctypeList.forEach(item=>{ + item.checked=false; + }); + this.oneList.forEach(one=>{ + one.checked=false; + one.children.forEach(two=>{ + two.checked=false; + two.children.forEach(three=>{ + three.checked=false; + }) + }) + }); + this.twoList=[]; + this.threeList=[]; + this.searchData(); + }, handleTypeClick(item,list){ - //item.checked=!item.checked; + item.checked=!item.checked; //使用上面一行是可以多选,使用下面是单选 - list.forEach(row=>{ - row.checked=false; - }) - item.checked=true; + // list.forEach(row=>{ + // row.checked=false; + // }) + // item.checked=true; this.searchData(); }, - handleOptionClick(item,list){ - //item.checked=!item.checked; + handleOptionClick(item,list,level){ + item.checked=!item.checked; //使用上面一行是可以多选,使用下面是单选 - list.forEach(row=>{ - row.checked=false; - }) - item.checked=true; + // list.forEach(row=>{ + // row.checked=false; + // }) + // item.checked=true; + //以下是新的规则的修改, + if(!item.checked){ + //清空它下面的所有的中的 + item.children.forEach(subItem=>{ + subItem.checked=false; + if(subItem.children){ + subItem.children.forEach(sub=>{ + sub.checked=false; + }) + } + }); + if(level==1){ + this.twoList=[]; + this.threeList=[]; + } + if(level==2){ + this.threeList=[]; + } + this.searchData(); + return; + } - this.handleChangeTypes(); + let $this=this; + if(level==1){ //一级的情况 + this.twoList=[]; + this.threeList=[]; + let lastCheked=null; + item.children.forEach(two=>{ + $this.twoList.push(two); + if(two.checked){ + lastCheked=two; + } + }); + if(lastCheked!=null){ + $this.threeList=lastCheked.children; + item.children.forEach(three=>{ + }); + } + }else if(level==2){ //二级的情况 + this.threeList=item.children; + }else if(level==3){ //三级的情况 + + } + //this.handleChangeTypes(item); this.searchData(); }, - handleChangeTypes(){ + handleChangeTypes(item){ + console.log(item); //重新计算 this.twoList=[]; this.threeList=[]; let $this=this; + // this.oneList.forEach(one=>{ + // if(one.checked){ + // one.children.forEach(two=>{ + // $this.twoList.push(two); + // if(two.checked){ + // two.children.forEach(three=>{ + // $this.threeList.push(three); + // }) + // } + // }); + // } + // }) this.oneList.forEach(one=>{ if(one.checked){ - one.children.forEach(two=>{ - $this.twoList.push(two); - if(two.checked){ + one.children.forEach(two=>{ + $this.twoList.push(two); + if(two.checked){ two.children.forEach(three=>{ $this.threeList.push(three); }) - } - }); + } + }); } }) }, @@ -599,6 +696,7 @@ export default { try { const { result, status } = await apiType.tree(1); if (status === 200) { + let tree=[]; result.forEach(item=>{ let newItem={ type:11, @@ -634,6 +732,7 @@ export default { } $this.oneList.push(newItem); }); + } } catch (error) { console.log(error);