基于el-table的操作栏按钮太多,添加“更多”按钮

话不多说上代码:

<el-table-column fixed="right" label="操作" align="left" width="190">
                    <template #default="scope">
                        <el-button link type="primary" size="small" @click="pricingDetail(scope.row, 1)"
                            v-if="scope.row.finalStatus == 1">修改</el-button>
                        <el-button link type="primary" size="small" @click="pricingDetail(scope.row, 1)"
                            v-if="scope.row.finalStatus == 0">填写</el-button>
                        <el-button link type="primary" size="small" @click="pricingDetail(scope.row, 2)">查看</el-button>
                        <el-popover placement="bottom" :width="150" trigger="click">
                            <template #reference>
                                <el-button link type="primary" size="small">更多</el-button>
                            </template>
                            <div style="width: 90px;">
                                <el-button style="display: block;padding-left: 14px;" link type="primary" size="small" @click="confirmPriceOrder(scope.row, 1)"
                                    v-if="scope.row.finalStatus == 1">确认定价单</el-button>
                                <el-button style="display: block;" link type="primary" v-if="scope.row.finalStatus !== 2" size="small"
                                    @click="reject(scope.row, 1)">驳回报价单</el-button>
                                <el-button style="display: block;" link type="primary" v-if="scope.row.finalStatus !== 2" size="small"
                                    @click="reject(scope.row, 2)">驳回成本投入</el-button>
                                <el-button style="display: block;" link type="primary" v-if="scope.row.finalStatus !== 2" size="small"
                                    @click="reject(scope.row, 0)">全部驳回</el-button>
                                <el-button style="display: block;" link type="primary" size="small" @click="Log(scope.row, 1)"
                                    v-if="scope.row.finalStatus == 0 || 1 || 2">日志</el-button>
                                <el-button style="display: block;" link type="primary" size="small" @click="exportList(scope.row, 2)"
                                    v-if="scope.row.finalStatus == 1 && scope.row.useTo == 0">导出表格</el-button>
                            </div>
                        </el-popover>
                    </template>
                </el-table-column>

您可以在el-table的columns中定义一个slot来实现操作列的显示更多。具体做法如下: 1. 在columns中定义一个type为'operation'的column,该column的width可以根据您的需求进行设置。 2. 在该column中定义一个slot,用来放置操作按钮。 3. 在该slot中,可以定义多个按钮,您可以使用el-button或其他UI组件来实现,同时可以为按钮绑定点击事件。 4. 如果您的操作按钮过多,可以使用el-dropdown组件来进行收纳。 以下是一个示例代码片段: ```html <el-table :data="tableData"> <el-table-column prop="name" label="姓名"></el-table-column> <el-table-column prop="age" label="年龄"></el-table-column> <el-table-column label="操作" width="200" type="operation"> <template slot-scope="scope"> <el-dropdown> <el-button type="primary">更多操作</el-button> <el-dropdown-menu slot="dropdown"> <el-dropdown-item @click="handleEdit(scope.$index, scope.row)">编辑</el-dropdown-item> <el-dropdown-item @click="handleDelete(scope.$index, scope.row)">删除</el-dropdown-item> <el-dropdown-item @click="handleView(scope.$index, scope.row)">查看</el-dropdown-item> <!-- 更多按钮 --> </el-dropdown-menu> </el-dropdown> </template> </el-table-column> </el-table> ``` 在上述示例中,我们定义了一个type为'operation'的column,并在该column中定义了一个slot。在该slot中,我们使用了el-dropdown组件来收纳操作按钮。您可以根据实际需求来定义操作按钮及其事件处理函数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值