這是加上邊框的,
去掉邊框后這個表格看著更明顯一點,表格一行放多行內(nèi)容,并讓第二行進(jìn)行列合并,第一行不合并文章來源:http://www.zghlxwxcb.cn/news/detail-505824.html
<template>
<div>
<el-table
:data="data"
:span-method="arraySpanMethod"
style="width: 100%"
>
<el-table-column
label="訂艙編號"
>
<template slot-scope="scope">
<div>{{ scope.row.ebNo }}</div>
<div>開航日期:{{ scope.row.sailingTime }}</div>
</template>
</el-table-column>
<el-table-column
label="提單號"
>
<template slot-scope="scope">
<div>
<el-row>
<el-col :span="12">{{ scope.row.blNo }}</el-col>
<el-col :span="12"><span style="marginLeft: 10px">{{ scope.row.putCode }}</span></el-col>
</el-row>
</div>
<div>目的港:{{ scope.row.startPortData.nameEn }}</div>
</template>
</el-table-column>
<el-table-column label="MB/L" />
<el-table-column
label="委托編號"
>
<template slot-scope="scope">
<div>
<el-row>
<el-col :span="12">{{ scope.row.entrustNub }}</el-col>
<el-col :span="12"><span style="marginLeft: 10px">{{ scope.row.shipName }}</span></el-col>
</el-row>
</div>
<div>發(fā)票號:{{ scope.row.fapiao }}</div>
</template>
</el-table-column>
<el-table-column
label="船名"
>
<template slot-scope="scope">
<div>{{ scope.row.shipName }}</div>
<div>{{ scope.row.fapiao1 }}</div>
</template>
</el-table-column>
<el-table-column
label="航次"
>
<template slot-scope="scope">
<div>{{ scope.row.voyage }}</div>
<div><i class="el-icon-circle-close" style="color: red" />費用未確認(rèn)</div>
</template>
</el-table-column>
<el-table-column
label="金額"
>
<template slot-scope="scope">
<div>${{ scope.row.money }}</div>
<div><span>1412</span></div>
</template>
</el-table-column>
<el-table-column
label="caozu"
>
<template>
<div><el-button>賬單詳情</el-button></div>
<div><el-button>訂單詳情</el-button></divw>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default {
data() {
return {
data: [
{
ebNo: '624235234017150',
createTime: '2021-02-22T07:25:08.000Z',
sailingTime: '2021-02-26',
shipName: 'CONTI COURAGE',
voyage: '1234',
entrustNub: '543543',
blNo: 'JJCSHBKK261238',
putCode: 'JJCSHBKK261238',
fapiao: '1265413254674127431323574315641234',
fapiao1: '12324',
sea_order_bind: {
status: 10,
updateUser: '0'
},
startPortData: {
name: '上海',
nameEn: 'SHANGHAI'
},
purposePortData: {
name: '新加坡',
nameEn: 'SINGAPORE'
},
uploadPortsea: {
name: '新加坡',
nameEn: 'SINGAPORE'
},
endPortPierData: null,
carrier: {
code: 'COSCO',
name: '中遠(yuǎn)',
nameEn: 'COSCO'
}
}
]
}
},
methods: {
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
// columnIndex 列的下標(biāo),從0開始
if (columnIndex === 1 || columnIndex === 3) {
return [1, 2] // 行1 列2
} else if (columnIndex === 2 || columnIndex === 4) {
return [0, 0] // 隱藏操作,如果兩列合并不做這個隱藏會使表格數(shù)據(jù)整體后移
}
}
}
}
</script>
該方法其實就是普通的列合并,只不過使用了row和col使效果看著像是第一行沒合并,第二行才合并文章來源地址http://www.zghlxwxcb.cn/news/detail-505824.html
到了這里,關(guān)于element-ui 表格一行顯示多行內(nèi)容并實現(xiàn)多行內(nèi)某一行列合并的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!