|
@@ -1416,9 +1416,10 @@ export default {
|
|
|
result.data.rows.forEach(item => {
|
|
|
this.studentList.unshift(item)
|
|
|
})
|
|
|
+ this.studentList = this.deweight(this.studentList, "userId");
|
|
|
}
|
|
|
// this.studentList = this.studentList.concat(result.data.rows);
|
|
|
- this.unique(this.studentList, "userId");
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
// queryStudentList({ rows: 100, search: query }).then(res => {
|
|
@@ -1431,14 +1432,18 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 制定属性去重
|
|
|
- unique (arr, u_key) {
|
|
|
- let obj = {};
|
|
|
- arr.reduce((prev, next) => {
|
|
|
- obj[next[u_key] + typeof next[u_key]] ?
|
|
|
- "" :
|
|
|
- (obj[next[u_key] + typeof next[u_key]] = true && prev.push(next));
|
|
|
- return prev;
|
|
|
- }, []);
|
|
|
+ deweight (arr, key) {
|
|
|
+ let res = []
|
|
|
+ arr.forEach((item) => {
|
|
|
+ let list = []
|
|
|
+ res.forEach((resitem) => {
|
|
|
+ list.push(resitem[key])
|
|
|
+ })
|
|
|
+ if (list.indexOf(item[key]) === -1) {
|
|
|
+ res.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return res
|
|
|
}
|
|
|
}
|
|
|
// watch: {
|