Element UI 分页列表中如何保留之前选中的数据

首先在 selection 上加入  :reserve-selection="true"

<el-table-column type="selection" width="55" :reserve-selection="true"/>

在el-table上加入 row-key 、ref 、@selection-change

<el-table v-loading="creativeLoading" :data="picListData" row-key="id" ref="picTable" @selection-change="handlePicSelectionChange"></el-table>

ref 用于后面清空选中项使用(this.$refs.wTable.clearSelection();

/** 图片多选框选中数据 */
      handlePicSelectionChange(selection) {
        this.picIds = [];
        this.picIds = selection.map(item => item.id)
      },
<!-- 图片列表对话框 -->
    <el-dialog :title="title" :visible.sync="picOpen" width="900px" append-to-body :close-on-click-modal="false">
      <el-form :model="creativeQueryParams" ref="creativeQueryForm" :inline="true" label-width="120px">
        <el-form-item label="图片ID">
          <el-input
            v-model="creativeQueryParams.materialId"
            placeholder="请输入图片ID"
            size="small"
            clearable
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="small" @click="videoHandleQuery">搜索</el-button>
        </el-form-item>
      </el-form>
      <span class="red">图片无法区分是大图横图、大图竖图、小图,需要您自行根据宽度、高度选择</span>
      <el-table v-loading="creativeLoading" :data="picListData" row-key="id" ref="picTable" @selection-change="handlePicSelectionChange">
        <el-table-column type="selection" width="55" :reserve-selection="true"/>
        <el-table-column label="图片" align="center" prop="url">
          <template slot-scope="scope">
            <!--<img style="width: 200px;" :src="'https://sf3-ttcdn-tos.pstatp.com/obj/'+scope.row.id">-->
            <el-image
              style="width: 100px; height: 100px"
              :src="'https://sf3-ttcdn-tos.pstatp.com/obj/'+scope.row.id"
              fit="fit"></el-image>
          </template>
        </el-table-column>
        <el-table-column label="ID" align="center" prop="material_id" />
        <el-table-column label="宽度" align="center" prop="width" width="80"/>
        <el-table-column label="高度" align="center" prop="height" width="80"/>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini"
                       type="text"
                       @click="choosePic(scope.row)"
            >使用</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="creativeQueryParams.totalNumber>0"
        :total="creativeQueryParams.totalNumber"
        :page.sync="creativeQueryParams.pageNum"
        :limit.sync="creativeQueryParams.pageSize"
        @pagination="picListsPage"
      />
    </el-dialog>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值