el-table根据条件给表头自定义另外的内容,直接上代码
在el-table-column 中加入:render-header=“renderHeader”
<el-table-column :width="item.width" :render-header="renderHeader"></el-table-column>
renderHeader(h, { column, $index }) {
if ($index == 1 || $index == 2 || $index == 3 || $index == 4 || $index == 5) {
let notes = ''
switch ($index) {
case 1: notes = '统计订单状态为已发货和已完成的产品数量'
break;
case 2: notes = '出入库申请后仓库审核通过的产品数量,包含退货完成的数量'
break;
case 3: notes = '统计已完成退货流程的产品数量'
break;
case 4: notes = '当前仓库内实际剩余的产品数量'
break;
case 5: notes = '统计当前订单状态为待审核,已发货,已完成产品数量'
break;
}
return h('div', [
h('span', column.label),
h('el-tooltip',
{ props: {
effect: 'dark',
content: notes,
placement: 'top'
}
},
[h('i', {
class: 'el-icon-question',
style: 'color:#409eff;margin-left:5px;'
})
],
),
]);
} else {
return h('div', [h('span', column.label)]);
}
},