【table】复杂表格示例,多行表头,包含横表头+纵表头

效果:

在这里插入图片描述

代码:

<template>
    <div class="shunyin-table">
        <table>
            <tr>
                <th width="5%" rowspan="2"></th>
                <th width="5%" rowspan="2">品目</th>
                <th width="5%" colspan="3">工程间</th>
                <th width="5%" colspan="7">顺引</th>
                <th width="5%" colspan="9">顺建</th>
            </tr>
            <tr>
                <th  v-for="(e,index) of titleList" width="5%">{{ e }}</th>
            </tr>
            <tr>
                <th width="5%" rowspan="4">部品信息</th>
                <th width="5%">线侧</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.podLineNum: '' }}</td>
            </tr>
            <tr>
                <th width="5%">在途(满)</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.podOnWayFull : '' }}</td>
            </tr>
            <tr>
                <th width="5%">在途(空)</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.podOnWayEmpty : ''}}</td>
            </tr>
            <tr>
                <th width="5%">置场</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.podInArea : ''}}</td>
            </tr>
            <tr>
                <th width="5%" rowspan="4">机器人信息</th>
                <th width="5%">投入台数</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.robotTotal : ''}}</td>
            </tr>
            <tr>
                <th width="5%">运行台数</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.robotRun : ''}}</td>
            </tr>
            <tr>
                <th width="5%">异常台数</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.robotException : ''}}</td>
            </tr>
            <tr>
                <th width="5%">可动率</th>
                <td  v-for="(e,index) of dataList" width="5%">{{ e ? e.robotRate : '' }}</td>
            </tr>
        </table>
    </div>
</template>

<script>
    export default {
        props: {
            context: Object,
            data: {
                default: ''
            }
        },
        data() {
            return {
                message: '',
                dataList: new Array(18),
                title: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],
                titleList: ['保险杠','侧围杠','仪表板上板','右门板','左门板','油箱','地毯','HEV地毯','前排气','后排气','大灯','面板','空滤','中部通道','方向盘','水箱下横梁','导向头','发动机变速器'],
                test:[],
            }
        },
        mounted() {
            if(this.data && this.data.sysjRuntime){
                this.handleData(this.data.sysjRuntime)
            }
            // this.handleData(this.test)
        },
        methods: {
            handleData(sysjRuntime){
                let guideList = []
                let buildList = []
                let engineeringList = []
                this.dataList = new Array(18)
                sysjRuntime.forEach(item => {
                    if(item.text == '顺引'){
                        guideList = item.content
                    }else if(item.text == '顺建'){
                        buildList = item.content
                    }else if(item.text == '工程间'){
                        engineeringList = item.content
                    }
                })
                for(let i = 1; i <= 3; i++){
                    for(let j = 0; j < guideList.length; j++){
                        if(guideList[j].categoryName == i){
                            this.dataList[i-1] = guideList[j]
                            break
                        }
                    }
                }
                for(let i = 4; i <= 10; i++){
                    for(let j = 0; j < buildList.length; j++){
                        if(buildList[j].categoryName == i){
                            this.dataList[i-1] = buildList[j]
                            break
                        }
                    }
                }
                for(let i = 11; i <= 18; i++){
                    for(let j = 0; j < engineeringList.length; j++){
                        if(engineeringList[j].categoryName == i){
                            this.dataList[i-1] = engineeringList[j]
                            break
                        }
                    }
                }
                console.log(this.dataList)
            }
        }
    }
</script>

<style>
    .shunyin-table{
        position: absolute;
        width: 100%;
        height: 100%;
    }
    .shunyin-table table
    {
        border-collapse: collapse;
        margin: 0 auto;
        text-align: center;
        width: 100%;
        height: 100%;
    }
    .shunyin-table table th
    {
        background-color: #E9EBF0;
        border: 1px solid #D6DAE0;
        color: #666;
        height: 8%;
    }
    .shunyin-table table td
    {
        border: 1px solid #D6DAE0;
        color: #666;
    }

</style>
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值