select和table聯動
阿新 • • 發佈:2018-11-08
因為搞了好幾天也沒在網上找到答案。所以用了自己想的辦法,後來感覺還是很笨的辦法,不過總算解決了
screen(value4,value5,value6,currentPage) { this.axios .get(`/teacher/mapping/list`, { schoolId: this.value4 , gradeId: this.value5 , subjectId: this.value6 , pageNum: this.currentPage, size: 10 }) .then(res => res.data) .then(data => { if(data.code == 200) { var arr = []//陣列1 var arr1 = []//陣列2 var arr2 = []//陣列3 //如果三個中任何一個被選擇的話執行這個 for(let i=0;i<this.list.length;i++){ if(this.value5 == this.list[i].gradeId){ arr.push(this.list[i]) } if(this.value4 == this.list[i].schoolId){ arr.push(this.list[i]) } if(this.value6 == this.list[i].subjectId){ arr.push(this.list[i]) } } // 如果三個中有任意兩個被選擇的話執行arr1 for(var j=0;j<this.list.length;j++){ if(this.value5 == this.list[j].gradeId && this.value4 == this.list[j].schoolId){ arr1.push(this.list[j]) } if(this.value4 == this.list[j].schoolId && this.value6 == this.list[j].subjectId){ arr1.push(this.list[j]) } if(this.value6 == this.list[j].subjectId && this.value5 == this.list[j].gradeId){ arr1.push(this.list[j]) } } // 如果三個都被選擇的話執行arr2 for(var k=0;k<this.list.length;k++){ if(this.value5 == this.list[k].gradeId && this.value4 == this.list[k].schoolId && this.value6 == this.list[k].subjectId){ arr2.push(this.list[k]) } } //下面個判斷出來的結果必須放在最後。不然會出錯 if(this.value4 != '' || this.value5 != '' || this.value6 != ''){ this.list = arr } if(this.value5 != '' && this.value4 != '' || this.value4 != '' && this.value6 != '' || this.value6 != '' && this.value5 != ''){ this.list = arr1 } if(this.value6 != '' && this.value5 != '' && this.value4 != ''){ this.list = arr2 } } }) },
當點選篩選按鈕的時候改變下面的table表格的資料
以後如果有更好的辦法會更新