我想合并三个圈出来的地方,
后端返回的数据结构是2个,我把它扁平化成4个了并且绑定了,现在想合并单元格,但是猪脑不够用了,而且拆了之后它那个switch怎么绑定回父级的row也没想好。有没有巨佬帮一下我,非常感谢
<template>
<el-table :data="flattenedData" :span-method="objectSpanMethod" border>
<el-table-column type="selection" align="center" :reserve-selection="true" fixed width="50">
</el-table-column>
<el-table-column prop="name" label="商品信息" width="200">
<template slot-scope="scope">
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column prop="agency.name" label="适用机构" width="120">
<template slot-scope="scope">
<span>{{ scope.row.agency.name }}</span>
</template>
</el-table-column>
<el-table-column label="分佣比例" align="center" prop="agency.marketPrice" />
<el-table-column label="是否首页推荐" align="center" min-width="80">
<template slot-scope="scope">
<el-switch v-model="scope.row.bili" active-value="1" inactive-value="0"></el-switch>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
rawData: [
{
id:1,
name: '入职体检A',
bili: 1,
agencies: [
{
name: '博爱医院',
marketPrice: 100.00,
costPrice: 30.00,
platformPrice: 80.00,
totalProfit: 120.00,
platformShare: 80,
platformProfit: 72.00,
businessShare: 20,
businessProfit: 18.00,
rowspan: 3
},
{
name: '天美体检',
marketPrice: 200.00,
costPrice: 40.00,
platformPrice: 150.00,
totalProfit: 110.00,
platformShare: 80,
platformProfit: 72.00,
businessShare: 20,
businessProfit: 18.00,
rowspan: 0
},
{
name: '美年体检',
marketPrice: 300.00,
costPrice: 50.00,
platformPrice: 100.00,
totalProfit: 100.00,
platformShare: 80,
platformProfit: 72.00,
businessShare: 20,
businessProfit: 18.00,
rowspan: 0
}
]
},
{
id:2,
name: '入职体检B',
bili: 0,
agencies: [
{
name: '博爱医院',
marketPrice: 200.00,
costPrice: 100.00,
platformPrice: 150.00,
totalProfit: 90.00,
platformShare: 80,
platformProfit: 72.00,
businessShare: 20,
businessProfit: 18.00,
rowspan: 1
}
]
}
],
flattenedData: []
};
},
created() {
this.flattenData();
},
methods: {
flattenData() {
this.flattenedData = [];
this.rawData.forEach(product => {
product.agencies.forEach(agency => {
this.flattenedData.push({
name: product.name,
agency: agency,
bili: product.bili
});
});
});
console.log(this.flattenedData)
}
}
};
</script>
<style scoped>
.el-table .cell {
display: flex;
align-items: center;
}
</style>
不要合并单元格,就一行写,有多个子项的时候自己模拟单元格下边框