element table 多选禁用某一行,表头全选框去除

业务场景:多选表格某行不可选择

实现如下图效果:
在这里插入图片描述

话不多说,直接上代码
<el-table
 ref="multipleTable" 
 :data="tableData" 
 border 
 :header-cell-style="headerCellStyle" 
 stripe tooltip-effect="dark" 
 style="width: 100%" 
 @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center" :selectable="selectable">
            </el-table-column>
            <el-table-column type="index" width="55" label="序号" align="center">
            </el-table-column>
            <el-table-column label="文件名" prop="name" align="center" :formatter="fieldFormatter">
            </el-table-column>
            <el-table-column label="文件附件" align="center" prop="appendixName">
                <template slot-scope="scope">
                     <a :class="scope.row.appendixName ? 'table-href' : ''" :href="scope.row.appendixUrl" target="_blank">{{ scope.row.appendixName || '-' }}</a>
                </template>
            </el-table-column>
            <el-table-column label="操作" width="200" align="center">
                <template slot-scope="scope">
                    <el-button
                    size="mini"
                    type="text"
                    v-if="!scope.row.isEdit && scope.row.isHidden"
                    @click="handleRecovery(scope.$index, scope.row)">恢复</el-button>
                    <el-button
                    size="mini"
                    type="text"
                    v-if="!scope.row.isEdit && !scope.row.isHidden"
                    @click="handleHide(scope.$index, scope.row)">列表隐藏</el-button>
                    <el-button
                    size="mini"
                    type="text"
                    @click="handleUp(scope.$index, scope.row)" v-if="scope.$index !== 0">上移</el-button>
                    <el-button
                    size="mini"
                    type="text"
                    @click="handleDown(scope.$index, scope.row)" v-if="scope.$index !== (tableData.length - 1)">下移</el-button>
                </template>
            </el-table-column>
        </el-table>
后端data返回数据
tableData: [
                {
                    appendixName: '1.请求书.pdf',
                    appendixUrl: '1.pdf',
                    id: 5,
                    isHidden: 0,
                    name: '123',
                    no: 0,
                    workId: 61
                },
                {
                    appendixName: '1.请求书.pdf',
                    appendixUrl: '2.pdf',
                    id: 5,
                    isHidden: 1,
                    name: '123',
                    no: 0,
                    workId: 61
                },
                {
                    appendixName: '1.请求书.pdf',
                    appendixUrl: '3.pdf',
                    id: 5,
                    isHidden: 1,
                    name: '123',
                    no: 0,
                    workId: 61
                },
                {
                    appendixName: '1.请求书.pdf',
                    appendixUrl: '4.pdf',
                    id: 5,
                    isHidden: 0,
                    name: '123',
                    no: 0,
                    workId: 61
                },
                {
                    appendixName: '1.请求书.pdf',
                    appendixUrl: '5.pdf',
                    id: 5,
                    isHidden: 0,
                    name: '123',
                    no: 0,
                    workId: 61
                }
            ]
调用方法
selectable (row, index) { // 禁用某一行
    return row.isHidden === 0 // isHidden 0-否 1-是 返回false不可选
},
headerCellStyle (row) { // 设置样式,隐藏头部checkbox全选框
    let sty = 'background:'#eef1f6',color:'#606266';' // 表头背景,字体颜色
    if (row.columnIndex === 0) {
        sty += 'text-indent: 1000px'
    }
    return sty
},
注意,selectable方法仅用于多选table表格有效,且需写在el-table-column上,返回false时禁用选择
  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值