element ui中表格table翻頁記憶勾選狀態


 <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);
        }
      });
    },

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM