//SKU合并列表数据
function objectSpanMethod({ row, column, rowIndex, columnIndex }:any){
let data = goodsList.value //拿到当前tatle 的数据
let cellValue = row[column.property]; //当前位置的值
let noSortArr = ['attr_string', 'goods_unit', 'goods_sum', 'sale_money', 'sum_shop_price', 'profit'] //不需要合并的字段(不进行合并行的prop)
if (cellValue && !noSortArr.includes(column.property)) {
let prevRow = data[rowIndex - 1]; //获取到上一条数据
let nextRow = data[rowIndex + 1]; //下一条数据
if (prevRow && prevRow[column.property] === cellValue) {
//当有上一条数据,并且和当前值相等时
return { rowspan: 0, colspan: 0 };
} else {
let countRowspan = 1;
while (nextRow && nextRow[column.property] === cellValue) {
//当有下一条数据并且和当前值相等时,获取新的下一条
nextRow = data[++countRowspan + rowIndex];
}
if (countRowspan > 1) {
return { rowspan: countRowspan, colspan: 1 };
}
}
}
}