![![在这里插入图片描述](https://img-blog.csdnimg.cn/2020030216452264.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDcxMzQ0Ng==,size_16,color_FFFFFF,t_70](https://img-blog.csdnimg.cn/20200303144346940.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDcxMzQ0Ng==,size_16,color_FFFFFF,t_70)
<el-table
:data="assessJson.rows"
highlight-current-row
border
style="width: 100%"
:span-method="objectSpanMethod"
>
<el-table-column
prop="quotaType"
label="指标类型"
align="center"
width="180">
<template slot-scope="scope">
<span>{{ scope.row.quotaType | invoiceStatusFilter }}</span>
</template>
</el-table-column>
getSpanArr(data) {
this.spanArr = [];
for (var i = 0; i < data.length; i++) {
if (i === 0) {
this.spanArr.push(1);
this.pos = 0;
} else {
if (data[i].quotaType === data[i - 1].quotaType) {
this.spanArr[this.pos] += 1;
this.spanArr.push(0);
} else {
this.spanArr.push(1);
this.pos = i;
}
}
}
},
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
const _row = this.spanArr[rowIndex];
const _col = _row > 0 ? 1 : 0;
return {
rowspan: _row,
colspan: _col
};
};
if (rowIndex === 0) {
if (columnIndex === 8) {
const listVal = this.assessJson.length;
return {
rowspan: listVal,
colspan: 1
};
}
}
},
assessList(){
let param = Object.assign({}, this.QuotaPagesVal);
apis.handBookApi
.apis(param)
.then(data => {
if (data && data.data) {
var json = data.data;
if (json && json.code == 1) {
console.log("考核标准");
console.log(json.rows);
this.QuotaPagesVal.total = json.records;
let transferList = [];
let transferList2 = [];
let transferList3 = [];
json.rows.forEach(item => {
if(item.quotaType == 1){
transferList.push(item);
}else if(item.quotaType == 2){
transferList2.push(item);
}else if(item.quotaType == 3){
transferList3.push(item);
}
});
transferList.push(...transferList2);
transferList.push(...transferList3);
console.log("合并后的数组");
console.log(transferList);
this.getSpanArr(transferList);
this.assessJson = transferList;
console.log("处理过的数据");
console.log(transferList);
return
}
}
})
.catch(err => {
this.$message({ message: "考核标准列表查询异常,请重试", type: "error" });
});
},