Element实现表格嵌套、多个表格共用一个表头的方法

2020-06-16 06:41:45易采站长站整理

<el-table-column :label="item===scope.row.ext.default?'运送到':''" prop="area"></el-table-column>
<el-table-column :label="item===scope.row.ext.default?'首重':''" prop="weight"></el-table-column>
<el-table-column :label="item===scope.row.ext.default?'运费':''" prop="first_price"></el-table-column>
<el-table-column :label="item===scope.row.ext.default?'续重':''" prop="weight_incre"></el-table-column>
<el-table-column :label="item===scope.row.ext.default?'最终运费':''" prop="extend_price"></el-table-column>
</el-table>
</div>

</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default {
data () {
return {
// res 参考的是后端返回的数据格式,
res: [
{
id: 1,
dealer_id: 0,
name: '成都运费模板',
type: 1,
ext: {
default: [{ area: '默认', type: 1, region: '1', weight: '首重d', weight_incre: '续重d', first_price: '运费d', extend_price: '最终运费d' }],
free: [{ area: 'free', type: 1, region: '1', weight: '首重f', weight_incre: '续重f', first_price: '运费f', extend_price: '最终运费f' }, { area: 'free', type: 1, region: '1', weight: '首重f', weight_incre: '续重f', first_price: '运费f', extend_price: '最终运费f' }],
pay: [{ area: 'pay', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }, { area: 'pay', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }, { area: 'pay', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }] }
},
{
id: 2,
dealer_id: 0,
name: '重庆运费模板',
type: 2,
ext: {
default: [{ area: '默认1', type: 1, region: '1', weight: '首重d', weight_incre: '续重d', first_price: '运费d', extend_price: '最终运费d' }],
free: [{ area: 'free1', type: 1, region: '1', weight: '首重f', weight_incre: '续重f', first_price: '运费f', extend_price: '最终运费f' }, { area: 'free', type: 1, region: '1', weight: '首重f', weight_incre: '续重f', first_price: '运费f', extend_price: '最终运费f' }],
pay: [{ area: 'pay1', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }, { area: 'pay', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }, { area: 'pay', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }, { area: 'pay1', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }, { area: 'pay', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }, { area: 'pay', type: 1, region: '1', weight: '首重p', weight_incre: '续重p', first_price: '运费p', extend_price: '最终运费p' }] }