http://element-plus.org/zh-CN/component/table.html#%E5%90%88%E5%B9%B6%E8%A1%8C%E6%88%96%E5%88%97
<script setup>
import { onMounted, ref } from 'vue'
import './index.css'
const objectSpanMethod = ({
row,
column,
rowIndex,
columnIndex,
}) => {
if (columnIndex === 0) {
console.log(row)
if (row.branchNameIndex === 1) {
return {
rowspan: row.count,
colspan: 1,
}
} else {
return {
rowspan: 0,
colspan: 0,
}
}
}
}
let tableData = [
{
deviceName: "生产设施",
branchName: "一部",
branchTotalStableRate: "97.63",
deviceTotalDeviationTime: "72.00",
deviceTotalStableRate: "1.71",
deviceTotalCountTime: "97.08",
comLevelDeviationTime: "0.7",
comLevelTime: "24.00"
},
{
deviceName: "生产设施222",
branchTotalStableRate: "98.88",
branchName: "一部",
deviceTotalDeviationTime: "72.00",
deviceTotalStableRate: "0.81",
deviceTotalCountTime: "97.08",
comLevelDeviationTime: "0.7",
comLevelTime: "24.00"
},
{
deviceName: "生产设施",
branchName: "一部",
branchTotalStableRate: "97.63",
deviceTotalDeviationTime: "72.00",
deviceTotalStableRate: "1.71",
deviceTotalCountTime: "97.08",
comLevelDeviationTime: "0.7",
comLevelTime: "24.00"
},
{
deviceName: "生产设施",
branchName: "四部",
branchTotalStableRate: "97.63",
deviceTotalDeviationTime: "72.00",
deviceTotalStableRate: "1.71",
deviceTotalCountTime: "97.08",
comLevelDeviationTime: "0.7",
comLevelTime: "24.00"
},
{
deviceName: "生产设施",
branchName: "四部",
branchTotalStableRate: "97.63",
deviceTotalDeviationTime: "72.00",
deviceTotalStableRate: "1.71",
deviceTotalCountTime: "97.08",
comLevelDeviationTime: "0.7",
comLevelTime: "24.00"
},
{
deviceName: "生产设施",
branchName: "五部",
branchTotalStableRate: "97.63",
deviceTotalDeviationTime: "72.00",
deviceTotalStableRate: "1.71",
deviceTotalCountTime: "97.08",
comLevelDeviationTime: "0.7",
comLevelTime: "24.00"
},
{
deviceName: "生产设施",
branchName: "五部",
branchTotalStableRate: "97.63",
deviceTotalDeviationTime: "72.00",
deviceTotalStableRate: "1.71",
deviceTotalCountTime: "97.08",
comLevelDeviationTime: "0.7",
comLevelTime: "24.00"
},
]
let obj = {}
const formatData = (list) => {
list.forEach(item => {
let count = list.filter(listItem => listItem.branchName === item.branchName).length
if (obj[item.branchName] ) {
obj[item.branchName]++
} else {
obj[item.branchName] = 1
}
item.branchNameIndex = obj[item.branchName]
item.count = count
})
tableData = list
}
formatData(tableData)
onMounted(() => {
})
</script>
<template>
<div id="m-list" class="js-list" style="position: relative">
<el-table
:data="tableData"
:span-method="objectSpanMethod"
border
style="width: 100%; margin-top: 20px"
>
<el-table-column prop="branchName" label="branchName" />
<el-table-column prop="deviceName" label="deviceName" width="180" />
<el-table-column prop="count" label="count" />
<el-table-column prop="branchNameIndex" label="branchNameIndex" />
</el-table>
</div>
</template>
人工智能学习网站
标签:el,行或列,comLevelTime,合并,deviceTotalCountTime,branchTotalStableRate,item,deviceTot From: https://blog.csdn.net/xutongbao/article/details/141412483