<el-table ref="multipleTable" :data="datalist" style="width:100%" @select="handleselectRow" @select-all="handleselectAll" size="small" >
<el-table-column type="selection" prop="houseId" align="center"></el-table-column>
</el-table>
//初始化列表數據
init(currentPage, pageSize) {
let _this = this;
let parmas = {
currentPage: currentPage,
pageSize: pageSize,
communityId: this.form.communityId,
companyId: this.form.companyId
};
// this.Utils.exeuhttpResquestGet(this.apiUrls.communityManagement.getTableData, {}, result => {
_this.Utils.exeuhttpResquestPost(this.apiUrls.rate.selectHouseInfoRate, parmas, result => {
_this.datalist = result.data.data.dataList;
_this.total = result.data.data.totalCount;
_this.$nextTick(function () {
_this.memoryChecked();
})
});
},
//行選中函數 若有刪除,若無添加
handleselectRow(selection, row) {
if (this.selectObj[row.houseId]) {
delete this.selectObj[row.houseId]
} else {
this.selectObj[row.houseId] = row.houseId
}
},
//全選函數 點擊全選遍歷當頁數據若無添加,若是反選則刪除(判斷是否是全選還是反選)
handleselectAll(selection) {
this.datalist.forEach((row, index) => {
if (this.selectObj.hasOwnProperty(row.houseId)) {
selection.length ? null : delete this.selectObj[row.houseId]
} else {
this.selectObj[row.houseId] = row.houseId
}
});
},
//記憶函數
memoryChecked(){
this.datalist.forEach((row, index) => {
if (this.selectObj.hasOwnProperty(row.houseId)) {
this.$refs.multipleTable.toggleRowSelection(row, true);
} else {
this.$refs.multipleTable.toggleRowSelection(row, false);
}
});
},