|
|
@@ -250,4 +250,57 @@ export let categoryName = { |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
export function mergeSpan(params) { |
|
|
|
return { |
|
|
|
methods: { |
|
|
|
reduceData(data) { |
|
|
|
let arr = data; |
|
|
|
let prev = new Array(params.length).fill(undefined); |
|
|
|
try { |
|
|
|
return arr.map((item, index) => { |
|
|
|
params.forEach((param, ind) => { |
|
|
|
if (item[param.name].trim() != prev[ind]) { |
|
|
|
let num = ind; |
|
|
|
while (num--) { |
|
|
|
if (prev[num] !== undefined && item[params[num].name].trim() !== prev[num]) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (num < 0) { |
|
|
|
prev[ind] = item[param.name] |
|
|
|
let spans = []; |
|
|
|
for (let i = 0; i <= ind; i++) { |
|
|
|
spans.push(params[i].name) |
|
|
|
} |
|
|
|
item[param.name + 'Row'] = getNumber(item, index, arr, spans) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
return item; |
|
|
|
}) |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
}, |
|
|
|
arraySpanMethod({ row, column, rowIndex, columnIndex }) { |
|
|
|
for (let param of params) { |
|
|
|
if (param.col.includes(columnIndex)) { |
|
|
|
if (row[param.name + 'Row']) { |
|
|
|
return { |
|
|
|
rowspan: row[param.name + "Row"], |
|
|
|
colspan: 1 |
|
|
|
} |
|
|
|
} else { |
|
|
|
return { |
|
|
|
rowspan: 0, |
|
|
|
colspan: 1 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
} |