欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

element跨分頁操作選擇詳解

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

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

業(yè)務(wù)需求:在批量導(dǎo)出或者批量刪除的時候會涉及到跨分頁導(dǎo)出或者批量刪除,這是你會發(fā)現(xiàn),當你選擇后點擊分頁,發(fā)現(xiàn)之前選擇的數(shù)據(jù)已經(jīng)沒有了,現(xiàn)在就是要滿足分頁點擊分頁后原始數(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="序號" 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ù)對象" prop="vsoName" min-width="120"></el-table-column>
    <el-table-column label="身份證號" 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, // 分頁頁數(shù)
        pageSize: 10, // 分頁數(shù)量
      },
      multipleSelection: [], //多選的行數(shù)據(jù)
      multipleSelectionAll:[],// 當前頁選中的數(shù)據(jù)
      idKey: 'idCard',
    }
  },
  methods: {
   setSelectRow() {
      if (!this.multipleSelectionAll || this.multipleSelectionAll.length <= 0) {
        return;
      }
      // 標識當前行的唯一鍵的名稱
      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 () {
      // 標識當前行的唯一鍵的名稱
      let idKey = this.idKey;
      let that = this;
      //如果總記憶中還沒有選擇的數(shù)據(jù),那么就直接取當前頁選中的數(shù)據(jù),不需要后面一系列計算
      if (!this.multipleSelectionAll.length) {
        this.multipleSelectionAll = this.multipleSelection;
        return;
      }
      // 總選擇里面的key集合
      let selectAllIds = [];
      this.multipleSelectionAll.forEach(row=>{
        selectAllIds.push(row[idKey]);
      })
      let selectIds = []
      // 獲取當前頁選中的id
      this.multipleSelection.forEach(row=>{
        selectIds.push(row[idKey]);
        // 如果總選擇里面不包含當前頁選中的數(shù)據(jù),那么就加入到總選擇集合里
        if (selectAllIds.indexOf(row[idKey]) < 0) {
          that.multipleSelectionAll.push(row);
        }
      })
      let noSelectIds = [];
      // 得到當前頁沒有選中的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>

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

相關(guān)文章

  • vue實現(xiàn)動態(tài)列表尾部添加數(shù)據(jù)執(zhí)行動畫

    vue實現(xiàn)動態(tài)列表尾部添加數(shù)據(jù)執(zhí)行動畫

    這篇文章主要介紹了vue實現(xiàn)動態(tài)列表尾部添加數(shù)據(jù)執(zhí)行動畫方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • element?upload?鉤子函數(shù)的坑及解決

    element?upload?鉤子函數(shù)的坑及解決

    這篇文章主要介紹了element?upload?鉤子函數(shù)的坑及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • vue activated在子組件中的使用詳情

    vue activated在子組件中的使用詳情

    這篇文章主要介紹了vue activated在子組件中的使用,文章圍繞vue activated的xingu你資料講解展開內(nèi)容并附上具體代碼,需要的朋友可以參考一下
    2021-11-11
  • vue在頁面和方法中如何通過遍歷對象獲取對象的鍵(key)和值(value)

    vue在頁面和方法中如何通過遍歷對象獲取對象的鍵(key)和值(value)

    這篇文章主要介紹了vue在頁面和方法中如何通過遍歷對象獲取對象的鍵(key)和值(value)問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • Vue修改頁面標簽的方法示例

    Vue修改頁面標簽的方法示例

    vue項目有時候需要根據(jù)頁面需要動態(tài)的去修改頁面標題名稱,本文就來介紹一下,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友們下面隨著小編來一起學(xué)習學(xué)習吧
    2023-06-06
  • elementPlus修改主題色以及皮膚設(shè)置思路

    elementPlus修改主題色以及皮膚設(shè)置思路

    這篇文章主要介紹了elementPlus修改主題色以及皮膚設(shè)置思路,具有很好的參考價值,希望對大家有所幫助。
    2023-04-04
  • vue路由懶加載的實現(xiàn)方法

    vue路由懶加載的實現(xiàn)方法

    本篇文章主要介紹了vue路由懶加載的實現(xiàn)方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • Vue3進階主題Composition API使用詳解

    Vue3進階主題Composition API使用詳解

    這篇文章主要為大家介紹了Vue3進階主題Composition API使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-04-04
  • 解決vue3?defineProps?引入定義的接口報錯

    解決vue3?defineProps?引入定義的接口報錯

    這篇文章主要為大家介紹了解決vue3?defineProps?引入定義的接口報錯詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-05-05
  • vue組件開發(fā)之slider組件使用詳解

    vue組件開發(fā)之slider組件使用詳解

    這篇文章主要為大家詳細介紹了vue組件開發(fā)之slider組件的使用方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-08-08

最新評論