最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

element跨分頁(yè)操作選擇詳解

 更新時(shí)間:2020年06月29日 11:45:16   作者:沫熙瑾年  
這篇文章主要為大家詳細(xì)介紹了element跨分頁(yè)操作選擇,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了element跨分頁(yè)操作選擇的具體代碼,供大家參考,具體內(nèi)容如下

業(yè)務(wù)需求:在批量導(dǎo)出或者批量刪除的時(shí)候會(huì)涉及到跨分頁(yè)導(dǎo)出或者批量刪除,這是你會(huì)發(fā)現(xiàn),當(dāng)你選擇后點(diǎn)擊分頁(yè),發(fā)現(xiàn)之前選擇的數(shù)據(jù)已經(jīng)沒(méi)有了,現(xiàn)在就是要滿足分頁(yè)點(diǎn)擊分頁(yè)后原始數(shù)據(jù)保留

<template>
  <div>
    <el-table
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%;"
      header-align="left"
      border
      ref="table"
      row-key="serviceDateId"
      @selection-change="handleSelectionChange"
      @row-dblclick="toDetail"
      @sort-change="sortChange"
    >
    <el-table-column type="selection" el-table-column width="50" fixed="left"></el-table-column>
    <el-table-column label="序號(hào)" width="80" fixed="left">
      <template slot-scope="{row,$index}">
        <span>{{$index + 1}}</span>
      </template>
    </el-table-column>
    <el-table-column label="服務(wù)日期" prop="serviceDate" sortable="custom" min-width="120" ></el-table-column>
    <el-table-column label="服務(wù)對(duì)象" prop="vsoName" min-width="120"></el-table-column>
    <el-table-column label="身份證號(hào)" prop="idCard" sortable="custom" min-width="200"></el-table-column>
    <el-table-column label="服務(wù)內(nèi)容" prop="serviceContentName" min-width="200"></el-table-column>
    <el-table-column label="服務(wù)結(jié)果" prop="serviceResultName" min-width="100"></el-table-column>
    <el-table-column label="志愿者" prop="volunteerName" sortable="custom" min-width="120" show-overflow-tooltip></el-table-column>
    <el-table-column label="志愿者所屬組織" prop="objName" min-width="200" show-overflow-tooltip></el-table-column>
    <el-table-column fixed="right" label="操作" width="150" header-align="center">
      <template slot-scope="{row,$index}">
        <span @click="handleEdit(row)" class="table-btn" v-has="{class: '編輯'}">編輯</span>
        <span @click="handleRemove($index, row)" class="table-btn"
          v-has="{class: '刪除'}">刪除</span>
      </template>
    </el-table-column>
  </el-table>
  <pagination
    v-show="total>0"
    :total="total"
    :page.sync="form.pageNum"
    :limit.sync="form.pageSize"
    @pagination="getData(form)"
  />
  </div>
</template>
<script>
export default {
  data(){
    return{
      ruleForm: {
        username: '',
        password:''
      },
      form: {
        pageNum: 1, // 分頁(yè)頁(yè)數(shù)
        pageSize: 10, // 分頁(yè)數(shù)量
      },
      multipleSelection: [], //多選的行數(shù)據(jù)
      multipleSelectionAll:[],// 當(dāng)前頁(yè)選中的數(shù)據(jù)
      idKey: 'idCard',
    }
  },
  methods: {
   setSelectRow() {
      if (!this.multipleSelectionAll || this.multipleSelectionAll.length <= 0) {
        return;
      }
      // 標(biāo)識(shí)當(dāng)前行的唯一鍵的名稱(chēng)
      let idKey = this.idKey;
      let selectAllIds = [];
      let that = this;
      this.multipleSelectionAll.forEach(row=>{
        selectAllIds.push(row[idKey]);
      })
      this.$refs.table.clearSelection();
      for(var i = 0; i < this.tableData.length; i++) {  
        if (selectAllIds.indexOf(this.tableData[i][idKey]) >= 0) {
        // 設(shè)置選中,記住table組件需要使用ref="table"
          this.$refs.table.toggleRowSelection(this.tableData[i], true);
        }
      }
    },
      // 記憶選擇核心方法
    changePageCoreRecordData () {
      // 標(biāo)識(shí)當(dāng)前行的唯一鍵的名稱(chēng)
      let idKey = this.idKey;
      let that = this;
      //如果總記憶中還沒(méi)有選擇的數(shù)據(jù),那么就直接取當(dāng)前頁(yè)選中的數(shù)據(jù),不需要后面一系列計(jì)算
      if (!this.multipleSelectionAll.length) {
        this.multipleSelectionAll = this.multipleSelection;
        return;
      }
      // 總選擇里面的key集合
      let selectAllIds = [];
      this.multipleSelectionAll.forEach(row=>{
        selectAllIds.push(row[idKey]);
      })
      let selectIds = []
      // 獲取當(dāng)前頁(yè)選中的id
      this.multipleSelection.forEach(row=>{
        selectIds.push(row[idKey]);
        // 如果總選擇里面不包含當(dāng)前頁(yè)選中的數(shù)據(jù),那么就加入到總選擇集合里
        if (selectAllIds.indexOf(row[idKey]) < 0) {
          that.multipleSelectionAll.push(row);
        }
      })
      let noSelectIds = [];
      // 得到當(dāng)前頁(yè)沒(méi)有選中的id
      this.tableData.forEach(row=>{
        if (selectIds.indexOf(row[idKey]) < 0) {
          noSelectIds.push(row[idKey]);
        }
      })
      noSelectIds.forEach(id=>{
        if (selectAllIds.indexOf(id) >= 0) {
          for(let i = 0; i< that.multipleSelectionAll.length; i ++) {
            if (that.multipleSelectionAll[i][idKey] == id) {
            // 如果總選擇中有未被選中的,那么就刪除這條
            that.multipleSelectionAll.splice(i, 1);
            break;
            }
          }
        }
      })
    },
    // 多選的行數(shù)據(jù)
    handleSelectionChange(val) {
      this.multipleSelection = val
        setTimeout(()=>{
      this.changePageCoreRecordData();
      }, 50)
    },
    // 獲取表格數(shù)據(jù)
    getData(form) {
      let parmas = _.cloneDeep(form);
      parmas.liveArea = typeof(parmas.liveArea) === 'object'?parmas.liveArea.join(''):parmas.liveArea;
      recordSearch(form).then(res => {
        if (res.rows) {
          this.tableData = res.rows;
          this.total = res.total;
          this.exportData = _.cloneDeep(form);
          setTimeout(()=>{
            this.setSelectRow();
          }, 50)
        }
        else {
          this.tableData = [];
          this.total = 0;
        }
      })
    }
  },
  mounted(){
    this.getData(this.form)
  }
}
</script>
<style lang="sass" scoped>
  
</style>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

元谋县| 正镶白旗| 虹口区| 收藏| 广汉市| 平泉县| 塔河县| 泸州市| 土默特右旗| 新宾| 孟津县| 黑水县| 兴仁县| 芒康县| 同仁县| 遂溪县| 利川市| 绥棱县| 北宁市| 镇巴县| 武胜县| 罗山县| 木里| 丁青县| 南靖县| 乡宁县| 响水县| 苏尼特右旗| 乐至县| 木里| 郓城县| 武川县| 荔浦县| 绩溪县| 肃北| 太白县| 盐边县| 新晃| 招远市| 鄂托克前旗| 天柱县|