objectSpanMethod的理解
1、 rowspan = 0;colspan = 0, 当前单元格不显示
2、 rowspan = 1;colspan = 1, 当前单元格正常显示
1、 rowspan = x;colspan = y, 当前行往下合并x行,当前列往右合并y列
效果:

代码:
<template>
<div style="padding: 20px">
<el-table
:data="tableData"
max-height="800"
:border="true"
fit
:span-method="objectSpanMethod"
>
<template v-for="(item, index) in tableHeader">
<reportTableColumn
v-if="item.children && item.children.length"
:columnHeader="item"
:key="index"
/>
<el-table-column
v-else
:fixed="item.fixed"
:align="item.align"
:prop="item.prop"
:label="item.label"
:key="index"
:min-width="item.width"
:show-overflow-tooltip="true"
>
</el-table-column>
</template>
</el-table>
</div>
</template>
<script>
import reportTableColumnVue from "./components/reportTableColumn.vue";
import testData from "./testData.js";
export default {
name: "test",
components: {
reportTableColumn: reportTableColumnVue,
},
data() {
return {
tableData: [],
staticTableHeadData: [
{
label: "工程量名称",
prop: "outPutName",
align: "left",
width: "260",
},
{
prop: "",
width: 150,
label: "工程量",
align: "center",
children: [
{
prop: "outPutMainValue",
width: 150,
label: "主审",
align: "center",
},
{
prop: "outPutSubValue",
width: 150,
label: "送审",
align: "center",
},
],
},
{ label: "差异量", prop: "showDiffSize", align: "right", width: "150" },
{
label: "差异率(%)",
prop: "showDiffRate",
align: "right",
width: "150",
},
], //土建和安装静态表头
dynamicTableHeadData: [
{
prop: "所属算量楼层",
width: 100,
fixed: true,
label: "楼层",
align: "center",
},
{
prop: "混凝土强度等级",
width: 100,
fixed: true,
label: "砼标号",
align: "center",
},
{
prop: "构件编号/类型名称",
width: 100,
fixed: true,
label: "构件编号",
align: "center",
},
], //后台返回的动态表头
spanRow: [0, 1, 2], //需要设置合并行的列
spanArr: [],
tableHeaderList: [],
};
},
created() {
this.tableHeader = [
...this.dynamicTableHeadData,
...this.staticTableHeadData,
];
},
mounted() {
this.tableData = testData.tableData1;
this.$nextTick(() => {
this.getAllSpanRow();
});
},
methods: {
/**
* 设置表格的合并行
* @param row
* @param column
* @param rowIndex
* @param columnIndex
* @returns {{colspan: number, rowspan: *}}
*/
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
let rowspan = 1,
colspan = 1; //正常显示
if (row[column.property] === "小计" || row[column.property] === "合计") {
//记录小计单元格的行号,获取小计后合并的单元使用
this.sumIndex = rowIndex;
let sum = 1;
for (let i = columnIndex + 1; i < this.tableHeaderList.length; i++) {
//小计单元格合并规则:小计后值为空 则往后合并列(sum + 1)
let value = this.tableData[rowIndex][this.tableHeaderList[i]];
if (value === "") {
sum += 1;
}
}
rowspan = 1;
colspan = sum;
} else if (rowIndex === this.sumIndex && row[column.property] === "") {
//小计后合并的单元格 不用显示了
rowspan = 0;
colspan = 0;
}
//根据传入合并列下标数组,计算每列的合并行和列
let spanRow = this.spanRow;
if (
!!spanRow &&
spanRow.includes(columnIndex) &&
this.spanArr.length > 0
) {
rowspan = this.spanArr[columnIndex][rowIndex];
colspan = rowspan > 0 ? colspan : 0;
} else {
rowspan = rowspan;
colspan = colspan;
}
return {
rowspan,
colspan,
};
},
/**
* 计算每个单元格的rowspan
* @param idx 需要设置合并行的 列下标
* @param prop 单元格数据名称
*/
getSpanArr(idx, prop) {
this.spanArr[idx] = [];
this.position = 0;
let tableData = this.tableData;
tableData.forEach((item, index) => {
if (index === 0) {
this.spanArr[idx].push(1);
this.position = 0;
} else {
if (
tableData[index][prop] !== "" &&
tableData[index][prop] === tableData[index - 1][prop]
) {
this.spanArr[idx][this.position] += 1; //有相同项
this.spanArr[idx].push(0); // 名称相同后往数组里面加一项0
} else {
this.spanArr[idx].push(1); //同列的前后两行单元格不相同
this.position = index;
}
}
});
},
/**
* 获取所有单元格行的合并数
*/
getAllSpanRow() {
this.spanArr = [];
this.tableHeaderList = [];
if (!this.spanRow || !this.tableData || this.tableData.length === 0) {
return;
} else {
this.getPropList(this.tableHeader);
this.spanRow.forEach((item, i) => {
this.getSpanArr(item, this.tableHeaderList[item]);
});
}
},
/**
* 按表格顺序存放表头的prop
*/
getPropList(data) {
data.forEach((item, i) => {
let { prop, children } = item;
if (!!prop) {
this.tableHeaderList.push(prop);
} else {
this.getPropList(children);
}
});
},
},
};
</script>
reportTableColumn组件:(对多级表头做处理)
<template>
<el-table-column
class="reportTableColumn"
:align="columnHeader.align"
:label="columnHeader.label"
:prop="columnHeader.prop"
>
<template v-for="(item, index) in columnHeader.children">
<tableColumn
v-if="item.children && item.children.length"
:columnHeader="item"
:key="index"
/>
<el-table-column
v-else
:prop="item.prop"
:fixed="item.fixed"
:align="item.align"
:label="item.label"
:min-width="item.width"
:key="index"
:width="widthRollStatus ? item.width + 'px' : ''"
:show-overflow-tooltip="true"
>
</el-table-column
>>
</template>
</el-table-column>
</template>
<script>
export default {
name: "tableColumn",
props: {
columnHeader: {
type: Object,
required: true,
},
widthRollStatus: {
type: Boolean,
default: false,
},
},
};
</script>
测试数据:
const data1 = [
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "体积",
outPutMainValue: 29.25,
outPutSubValue: 0,
showDiffSize: "29.25",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "模板面积",
outPutMainValue: 216.25,
outPutSubValue: 0,
showDiffSize: "216.25",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "数量",
outPutMainValue: 39,
outPutSubValue: 0,
showDiffSize: "39",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 7.2168,
showDiffSize: "-7.2168",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 44.2266,
showDiffSize: "-44.2266",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 10,
showDiffSize: "-10",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 26.5665,
showDiffSize: "-26.5665",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.1635,
showDiffSize: "-4.1635",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "体积",
outPutMainValue: 232.979,
outPutSubValue: 0,
showDiffSize: "232.979",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "模板面积",
outPutMainValue: 1793.1666,
outPutSubValue: 0,
showDiffSize: "1793.1666",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "数量",
outPutMainValue: 441,
outPutSubValue: 4,
showDiffSize: "437",
showDiffRate: "99.09",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 6.4,
showDiffSize: "-6.4",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.64,
showDiffSize: "-0.64",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 2,
showDiffSize: "-2",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 2.4,
showDiffSize: "-2.4",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.16,
showDiffSize: "-0.16",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "ZHZ1",
outPutName: "体积",
outPutMainValue: 6,
outPutSubValue: 0,
showDiffSize: "6",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "ZHZ1",
outPutName: "模板面积",
outPutMainValue: 45.84,
outPutSubValue: 0,
showDiffSize: "45.84",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "ZHZ1",
outPutName: "数量",
outPutMainValue: 12,
outPutSubValue: 0,
showDiffSize: "12",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "ZHZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "ZHZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "体积",
outPutMainValue: 268.229,
outPutSubValue: 7.2168,
showDiffSize: "261.0122",
showDiffRate: "97.31",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "模板面积",
outPutMainValue: 2055.2566,
outPutSubValue: 44.2266,
showDiffSize: "2011.03",
showDiffRate: "97.85",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "数量",
outPutMainValue: 492,
outPutSubValue: 16,
showDiffSize: "476",
showDiffRate: "96.75",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "体积",
outPutMainValue: 268.229,
outPutSubValue: 7.2168,
showDiffSize: "261.0122",
showDiffRate: "97.31",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "模板面积",
outPutMainValue: 2055.2566,
outPutSubValue: 44.2266,
showDiffSize: "2011.03",
showDiffRate: "97.85",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "数量",
outPutMainValue: 492,
outPutSubValue: 16,
showDiffSize: "476",
showDiffRate: "96.75",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "1F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 4,
showDiffSize: "-4",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 6.4,
showDiffSize: "-6.4",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.64,
showDiffSize: "-0.64",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ2",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 4.524,
showDiffSize: "-4.524",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ2",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 22.6194,
showDiffSize: "-22.6194",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ2",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 5,
showDiffSize: "-5",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ2",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 12.5665,
showDiffSize: "-12.5665",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ2",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 2.5135,
showDiffSize: "-2.5135",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ3",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 2.97,
showDiffSize: "-2.97",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ3",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 25.2,
showDiffSize: "-25.2",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ3",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 5,
showDiffSize: "-5",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ3",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 14,
showDiffSize: "-14",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ3",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 1.65,
showDiffSize: "-1.65",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 2,
showDiffSize: "-2",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 2.4,
showDiffSize: "-2.4",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.16,
showDiffSize: "-0.16",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 7.494,
showDiffSize: "-7.494",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 47.8194,
showDiffSize: "-47.8194",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 16,
showDiffSize: "-16",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 7.494,
showDiffSize: "-7.494",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 47.8194,
showDiffSize: "-47.8194",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 16,
showDiffSize: "-16",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "3F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
];
const data2 = [
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "体积",
outPutMainValue: 3,
outPutSubValue: 0,
showDiffSize: "3",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "模板面积",
outPutMainValue: 22.25,
outPutSubValue: 0,
showDiffSize: "22.25",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "数量",
outPutMainValue: 4,
outPutSubValue: 0,
showDiffSize: "4",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 4,
showDiffSize: "-4",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 6.4,
showDiffSize: "-6.4",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.64,
showDiffSize: "-0.64",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-2",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 4.524,
showDiffSize: "-4.524",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-2",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 22.6194,
showDiffSize: "-22.6194",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-2",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 5,
showDiffSize: "-5",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-2",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 12.5665,
showDiffSize: "-12.5665",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-2",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 2.5135,
showDiffSize: "-2.5135",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-3",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 2.97,
showDiffSize: "-2.97",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-3",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 25.2,
showDiffSize: "-25.2",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-3",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 5,
showDiffSize: "-5",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-3",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 14,
showDiffSize: "-14",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ-3",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 1.65,
showDiffSize: "-1.65",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 2,
showDiffSize: "-2",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 2.4,
showDiffSize: "-2.4",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.16,
showDiffSize: "-0.16",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "体积",
outPutMainValue: 3,
outPutSubValue: 7.494,
showDiffSize: "-4.494",
showDiffRate: "-149.8",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "模板面积",
outPutMainValue: 22.25,
outPutSubValue: 47.8194,
showDiffSize: "-25.5694",
showDiffRate: "-114.92",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "数量",
outPutMainValue: 4,
outPutSubValue: 16,
showDiffSize: "-12",
showDiffRate: "-300",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "体积",
outPutMainValue: 3,
outPutSubValue: 7.494,
showDiffSize: "-4.494",
showDiffRate: "-149.8",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "模板面积",
outPutMainValue: 22.25,
outPutSubValue: 47.8194,
showDiffSize: "-25.5694",
showDiffRate: "-114.92",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "数量",
outPutMainValue: 4,
outPutSubValue: 16,
showDiffSize: "-12",
showDiffRate: "-300",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "4F",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 7.494,
showDiffSize: "-7.494",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 47.8194,
showDiffSize: "-47.8194",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 10,
showDiffSize: "-10",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 26.5665,
showDiffSize: "-26.5665",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "AKZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.1635,
showDiffSize: "-4.1635",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "体积",
outPutMainValue: 4.5,
outPutSubValue: 0,
showDiffSize: "4.5",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "模板面积",
outPutMainValue: 33.77,
outPutSubValue: 0,
showDiffSize: "33.77",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "数量",
outPutMainValue: 19,
outPutSubValue: 4,
showDiffSize: "15",
showDiffRate: "78.95",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 6.4,
showDiffSize: "-6.4",
showDiffRate: "100",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.64,
showDiffSize: "-0.64",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "体积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "模板面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "数量",
outPutMainValue: 0,
outPutSubValue: 2,
showDiffSize: "-2",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 2.4,
showDiffSize: "-2.4",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "KZ4",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0.16,
showDiffSize: "-0.16",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "YBZ1",
outPutName: "体积",
outPutMainValue: 5.76,
outPutSubValue: 0,
showDiffSize: "5.76",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "YBZ1",
outPutName: "模板面积",
outPutMainValue: 48.96,
outPutSubValue: 0,
showDiffSize: "48.96",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "YBZ1",
outPutName: "数量",
outPutMainValue: 16,
outPutSubValue: 0,
showDiffSize: "16",
showDiffRate: "100",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "YBZ1",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "YBZ1",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 0,
showDiffSize: "0",
showDiffRate: "100",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "体积",
outPutMainValue: 10.26,
outPutSubValue: 7.494,
showDiffSize: "2.766",
showDiffRate: "26.96",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "模板面积",
outPutMainValue: 82.73,
outPutSubValue: 47.8194,
showDiffSize: "34.9106",
showDiffRate: "42.2",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "数量",
outPutMainValue: 35,
outPutSubValue: 16,
showDiffSize: "19",
showDiffRate: "54.29",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "C30",
"构件编号/类型名称": "小计",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "体积",
outPutMainValue: 10.26,
outPutSubValue: 7.494,
showDiffSize: "2.766",
showDiffRate: "26.96",
type: "sum",
diffSize: "normal",
diffRate: "normal",
line: 4,
spanList: [
[1, 2],
[0, 0],
[0, 0],
],
},
{
所属算量楼层: "转换层",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "模板面积",
outPutMainValue: 82.73,
outPutSubValue: 47.8194,
showDiffSize: "34.9106",
showDiffRate: "42.2",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "数量",
outPutMainValue: 35,
outPutSubValue: 16,
showDiffSize: "19",
showDiffRate: "54.29",
type: "sum",
diffSize: "red",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "周长",
outPutMainValue: 0,
outPutSubValue: 35.3665,
showDiffSize: "-35.3665",
showDiffRate: "100",
type: "sum",
diffSize: "green",
diffRate: "normal",
},
{
所属算量楼层: "转换层",
混凝土强度等级: "小计",
"构件编号/类型名称": "",
outPutName: "截面面积",
outPutMainValue: 0,
outPutSubValue: 4.9635,
showDiffSize: "-4.9635",
showDiffRate: "100",
type: "sum",
diffSize: "normal",
diffRate: "normal",
},
];
export default {
tableData1: data1,
tableData2: data2,
};
这是一个关于在Vue.js项目中使用Element-UI组件库实现表格行和列合并的示例。代码展示了如何通过`span-method`属性来处理表格数据,根据特定条件合并单元格,如当数据项为小计或合计时进行行合并,以及根据预定义的列下标进行列合并。此外,还涉及到了多级表头的数据处理和表格数据的计算逻辑。
1287

被折叠的 条评论
为什么被折叠?



