ecodeSDK.overwritePropsFnQueueMapSet('Table', {
fn: (newProps) => {
if (!enable) return;
if (!ecCom.WeaTools.Base64) return; //组件加载完毕
if (!ecodeSDK.checkLPath('/spa/cube/index.html#/main/cube/search?customid=1')) return;
if (newProps.ecId != "_Route@9uoqid_Com@knmejd_Spin@j82znn_Animate@mbigvi");
//alert(6666) ;
console.log("数据输出:");
console.log(newProps.columns);
console.log(newProps.dataSource);
newProps.columns.map(function (item) {
console.log(item);
/*
* 单元格合并处理
* @param text 当前单元格的值
* @param data 当前分页所有数据
* @param key 当前列的dataIndex
* @param index 当前数据所在下标
* @returns {number} 待合并单元格数量
*/
//合并单元格行
const mergeCells = (text, data, key, index) => {
// 上一行该列数据是否一样
if (index !== 0 && text === data[index - 1][key]) {
return 0;
}
let rowSpan = 1;
// 判断下一行是否相等
for (let i = index + 1; i < data.length; i++) {
if (text !== data[i][key]) {
break
}
rowSpan++
}
return rowSpan
}
//数据根据合并字段排序
function bubbleSortByField(arr, field) {
const len = arr.length;
for (let i = 0; i < len - 1; i++) {
for (let j = 0; j < len - 1 - i; j++) {
if (arr[j][field] > arr[j + 1][field]) {
const temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
return arr;
}
//合并字段判断
if (item.dataIndex == 'fl') {
item.render = (value, record, index) => {
const obj = {
children: value !== null ? value : '',
props: {
rowSpan: 1
}
}
console.log(obj);
obj.props.rowSpan = mergeCells(value, bubbleSortByField(newProps.dataSource, 'fl'), 'fl', index)
return obj;
}
}
return item;
});
return newProps;
}
});
E9:Table建模查询列表根据显示值合并单元格行和列(ECODE)
于 2023-12-07 14:24:04 首次发布