antdesignvue表格纵向动态合并单元格js
const temp = {} // 当前重复的值,⽀持多列
const mergeCellKey = (text, array, columns) => {
let i = 0
if (text !== temp[columns]) {
temp[columns] = text
array.forEach((item) => {
if (item[columns] === temp[columns]) {
i += 1
}
})
}
return i
}
const renderContent = (value, row, index) => {
const obj = {
children: value,
attrs: {}
}
return obj
}
export { mergeCellKey, renderContent }
antdesignvue 表格合计
vue 页⾯
import { mergeCellKey,renderContent } from '@/utils/mergeCell'
{
title: '区县代码',
align: 'center',
dataIndex: 'QXDM',
customRender: (value, row, index) => {
const obj = {
children: value,
attrs: {},
};
wSpan = mergeCellKey(row.QXDM, this.dataSource, 'QXDM')
return obj;
},
},
效果