赞
踩
<template>
<div class="payment_c">
<div class="pament_container">
<div class="tab_sec">
<el-table
:data="tableList"
class="table_content"
height="calc(100% - 30px)"
border
:row-class-name="tableRowClassName"
:span-method="objectSpanMethod"
:header-cell-style="headerColor"
style="width: 100%"
>
<el-table-column
label="XXX"
width="97"
prop="industry"
align="center"
>
<template slot-scope="scope">
<div
:style="
'height:' +
scope.row.industrycount * 40 +
'px;line-height:' +
scope.row.industrycount * 48 +
'px'
"
:class="
scope.row.industrynumber % 2 === 0
? 'blue text_ellipsis'
: 'white text_ellipsis'
"
>
{{ scope.row.industry }}
</div>
</template>
</el-table-column>
<el-table-column
prop="custname"
label="XXX"
:show-overflow-tooltip="true"
width="217"
>
<template slot-scope="scope">
<div
:style="
'height:' +
scope.row.custnamecount * 40 +
'px;line-height:' +
scope.row.custnamecount * 48 +
'px'
"
:class="
scope.row.custnamenumber % 2 === 0
? 'white text_ellipsis'
: 'blue text_ellipsis'
"
>
{{ scope.row.custname }}
</div>
</template>
</el-table-column>
<el-table-column
prop="statusName"
align="center"
:show-overflow-tooltip="true"
label="XXX"
width="112"
>
</el-table-column>
</el-table>
</div>
</div>
</div>
</template>
<script>
import requestRes from "@/utils/res_request.js";
export default {
data() {
return {
tableList: [],//表格
};
},
created() {
this.init('2020-10-31', 1);
},
methods: {
// 获取数据
init(
time = "",
unit = 1,
industry = "",
pageNum = 1,
pageSize = 20
) {
this.$request
.get(
`XXX接口?time=${time}&unit=${unit}&pageNum=${pageNum}&pageSize=${pageSize}&industrys=${industry}`
)
.then((res) => {
console.log('res',res);
let res1 = requestRes(res.data, this.$router);
if (res1.count > 0) {
this.tableList = this.$tableDataChange.listHandle(res1.list);
} else {
this.tableList = [];
}
this.total = res1.count;
});
},
listHandle(list) {
return this.$listHandle(list);
},
//合并行
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
// console.log(row, column, rowIndex, columnIndex);
if (columnIndex === 0) {
if (row.industrycount > 1) {
return {
rowspan: row.industrycount,
colspan: 1,
};
} else if(row.industrycount === 1){
return {
rowspan: 1,
colspan: 1,
};
}else{
return {
rowspan: 0,
colspan: 0,
};
}
}
if (columnIndex === 1) {
if (row.custnamecount > 1) {
return {
rowspan: row.custnamecount,
colspan: 1,
};
} else if (row.custnamecount === 1) {
return {
rowspan: 1,
colspan: 1,
};
} else {
return {
rowspan: 0,
colspan: 0,
};
}
}
},
// 给头部添加样式
headerColor({ rowIndex, columnIndex }) {
return this.$headerColor.headerColor(rowIndex);
},
// 表格斑马纹
tableRowClassName({ row, rowIndex }) {
return this.$tableRowClassName.tableRowClassName(rowIndex);
},
},
};
</script>
[
{
custname: "XXX 有限公司",
custnamecount: 2, //公司合并的行
custnamenumber: 0,
industry: "SXXX"
industrycount: 3, //产业合并的行
industrynumber: 0,
}
]
function listHandle(list) {
for (var key in list[0]) {
var k = 0;
var j = 0;
while (k < list.length) {
list[k][key + "count"] = 1;
list[k][key + 'number'] = j;
for (var i = k + 1; i <= list.length - 1; i++) {
if (list[k][key] == list[i][key] && list[k][key] != "") {
list[k][key + "count"]++;
list[i][key + "count"] = 0;
list[i][key + 'number'] = j;
} else {
break;
}
}
j++
k = i;
}
}
return list;
}
const headerColor = function(rowIndex) {
if (rowIndex === 0) {
return { background: "#e92323", color: "#fff" };
} else {
return { background: "#133890", color: "#fff" };
}
}
const tableRowClassName = function(rowIndex) {
if (rowIndex % 2 === 0) {
return "bg";
} else {
return "bgnone";
}
}
<style scoped lang="scss">
.payment_table_container {
width: 100%;
overflow-y: hidden;
overflow-x: scroll;
}
.pament_title {
width: 307px;
}
.pament_header_left .pament_header_searchForm {
height: 236px;
}
::v-deep .el-table {
td {
padding: 0px !important;
}
}
::v-deep .el-table__body-wrapper{
height: 87% !important;
}
::v-deep .el-table{
td{
padding:0px;
}
}
::v-deep .el-table__row{
&>td:nth-child(1){
padding: 0!important;
.el-tooltip{
padding: 0!important;
}
.cell{
padding: 0!important;
}
}
&>td:nth-child(2){
padding: 0!important;
.el-tooltip{
padding: 0!important;
}
.cell{
padding: 0!important;
}
}
}
// 表格样式
::v-deep .el-table {
font-size: 14px;
// font-family: SourceHanSansCN-Bold, SourceHanSansCN;
th {
padding: 3px 0px;
text-align: center;
font-size: 18px;
.is-leaf {
border: none;
}
}
td {
padding: 10px 0px;
border-bottom: none;
.is-leaf {
border: none;
}
}
}
.blue {
background: #d5dffc;
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 10px;
}
.white {
background: #fff;
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 10px;
}
::v-deep .bg {
background: #d5dffc !important;
}
::v-deep .bgnone {
background: #fff !important;
}
</style>
<el-table-column label="1 经营性额度" align="center">
<el-table-column
label=" 经营性额度小计"
width="200"
prop="jyxed"
:show-overflow-tooltip="true"
align="right"
>
</el-table-column>
<el-table-column
label="1.1 流贷"
width="200"
prop="jyxed1"
:show-overflow-tooltip="true"
align="right"
>
<el-table-column />
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。