el-table前端批量删除

本文介绍如何在Vue.js项目中使用Element UI组件库实现表格数据的批量删除功能。通过展示具体代码实现,详细解释了操作过程和关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

效果:

 代码:

template:
<el-table class="tipsTable" 
            @click.stop
              ref="tipsTable"
              :data="formDetail.tipsTable" 
              highlight-current-row
              @selection-change="handleSelectionChange"
              :header-cell-style="{ color: 'rgba(51, 51, 51, 1)',background: '#F6F7F9'}">
              <el-table-column v-if="formDetail.status == 1 || formDetail.status == 5" type="selection" width="60" align="center" />
              <el-table-column type="index" label="序号" width="80" align="center" />
              <el-table-column label="提示语" prop="tip">
                <template #default="{row}">
                  <el-input v-if="formDetail.status == 1 || formDetail.status == 5" 
                    style="width:100%" 
                    v-model="row.tip" 
                    placeholder="" />
                  <div v-else>{{row.tip}}</div>
                </template>
              </el-table-column>
              <el-table-column label="必填设置" prop="radio" width="150">
                <template #default="{row}">
                  <div v-if="formDetail.status == 1 || formDetail.status == 5">
                    <el-checkbox v-model="row.checked" label="1">{{}}</el-checkbox>
                    <span>设为必填项</span>
                  </div>
                  <div v-else>{{row.checked ? '必填项' : '非必填项'}}</div>
                </template>
              </el-table-column>
            </el-table>

script:
multipleSelection: null,
handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 报名内容设置-删除一条提示
    delTips() {
      if(this.multipleSelection && this.multipleSelection.length) {
        this.multipleSelection.forEach((item) => {
          this.formDetail.tipsTable.forEach((data,i) => {
            if(item.tip == data.tip) {
              this.formDetail.tipsTable.splice(i, 1)
            }
          })
        })
      } else {
        this.$message.warning('请选择需要删除的选项')
      }
    },

<!--考试安排--> <template> <div> <div class="search"> <el-input placeholder="请输入标题查询" style="width: 200px" v-model="name"></el-input> <el-button type="info" plain style="margin-left: 10px" @click="load(1)">查询</el-button> <el-button type="warning" plain style="margin-left: 10px" @click="reset">重置</el-button> </div> <div class="operation"> <el-button type="primary" plain @click="handleAdd">考试安排</el-button> <el-button type="danger" plain @click="delBatch">批量删除</el-button> </div> <div class="table"> <el-table :data="tableData" stripe @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" align="center"></el-table-column> <el-table-column prop="id" label="序号" width="80" align="center" sortable></el-table-column> <el-table-column prop="courseName" label="考试课程" show-overflow-tooltip></el-table-column> <el-table-column prop="teacherName" label="监考老师" show-overflow-tooltip></el-table-column> <el-table-column prop="roomName" label="考试教室" show-overflow-tooltip></el-table-column> <el-table-column prop="examTime" label="考试时间" show-overflow-tooltip></el-table-column> <el-table-column prop="time" label="创建时间"></el-table-column> <el-table-column label="操作" width="180" align="center"> <template v-slot="scope"> <el-button plain type="primary" @click="handleEdit(scope.row)" size="mini">编辑</el-button> <el-button plain type="danger" size="mini" @click=del(scope.row.id)>删除</el-button> </template> </el-table-column> </el-table> <div class="pagination"> <el-pagination background @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[5, 10, 20]" :page-size="pageSize" layout="total, prev, pager, next" :total="total"> </el-pagination> </div> </div>
最新发布
03-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值