elementui 双表格 翻页带上之前勾线的数据
项目需要 上面的数据赋值到下面的table=>这个简单 只涉及到一个复制数据的问题;()
多选框的事件
tablechange(val) {
// this,copyData就是下面表格是数据
this.copyData=this.LightData.concat(val);
// 过滤重复的数据;
this.copyData= this.copyData.reduce((item, next) => {
if (!hash[next.guid]) {
hash[next.guid] = true
item.push(next)
}
return item
}, [])
},
翻页之后的数据处理 重点来了 只有关键代码
USER.getNoInThisGroupUserInfo(data).then(res => {
this.totalint = res.data.data.total;
//diaData 是后台获取的数据
this.diaData = res.data.data.records;
let sameData = '';
let sameArr = [];
//this.copyData是上面那个函数获取的数据
this.copyData.forEach((ab, cd) => {
this.diaData.forEach((a, c) => {
if (ab.guId == a.guId) {
// 有人觉得 我写法怎么那么垃圾 直接赋值不就好了
// 那我告诉你 直接赋值真不行
sameData = this.diaData[c] = this.copyData[cd]
sameArr.push(sameData)
}
})
})
this.checkDom(sameArr)
})
// 勾选函数
checkDom(sameArr) {
if (sameArr.length >= 1) {
this.$nextTick(() => {
sameArr.forEach(row => {
//<el-table :data="diaData" style="width: 100%" max-height="200" @selection-change="tablechange" ref="checkTable">
this.$refs.checkTable.toggleRowSelection(row);
});
})
}
},
测试可以的 !