<div class="prods-select-body">
<el-table
ref="prodTable"
:data="dataList"
:header-cell-style="{height: '42px', background: '#F6F7FA', color:'#666666','font-weight': '500'}"
:cell-style="{height: '64px', padding: '8px 0', color:'#000'}"
v-loading="dataListLoading"
:row-key="getRowKeys"
@select-all="tableSelect"
@select="tableSelect"
style="width: 100%"
height="420"
>
</el-table>
</div>
tableSelect(selection){
let uncheckDataList = [], checkDataList = [];
if(selection.length < 1){
uncheckDataList = this.dataList;
}else{
uncheckDataList = this.dataList.filter(v=>{
return selection.some(e => e.prodId != v.prodId);
})
checkDataList = this.dataList.filter(v=>{
return selection.some(e => e.prodId == v.prodId);
})
}
if(uncheckDataList.length){
let newArr = [];
newArr = this.selectProds.filter((item) => {
return uncheckDataList.findIndex(e=> e.prodId == item.prodId) < 0
});
this.selectProds = JSON.parse(JSON.stringify(newArr));
}
if(checkDataList)
this.selectProds = this.selectProds.concat(checkDataList)
let map = new Map();
for (let item of this.selectProds) {
map.set(item.prodId, item);
}
this.selectProds = [...map.values()];
},