Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const calcTable = (reference, table) => {
// 驱动最大的level
const counterContainer = {};
const {operations = {}} = reference.state;
// 是否启用编辑模式
const options = Init.readOptions(reference);
const isEdit = options["table.edit.enabled"];
table.columns.forEach(column => {
// 包含列的渲染处理
column.render = (text, record) => {
const currentRowSpan = record[`${column.level}._counter`];
const rowKey = record[`${column.level}.key`];
const checkKey = `${column.dataIndex}-${rowKey}`;
if (counterContainer[checkKey]) {
// 解决空行问题
return text ? {
children: text,
props: {
rowSpan: 0
}
} : {
children: text,
props: {
const initData = (reference: any, data: any = []) => {
// 计算Level
data.forEach(item => Ux.treeCounter(item, 1));
// 追加counter
const flatted = Ux.treeFlat(data);
// 每一行追加一个key防止rowKey问题
flatted.forEach(each => each.key = Ux.randomUUID());
// 编辑模式才会在空数据中增加
const options = Init.readOptions(reference);
if (options["table.edit.enabled"]) {
if (0 === flatted.length) {
// 最少有一行的前提就是table.empty.init = true
if (options['table.empty.init']) {
flatted.push(initRow(reference));
}
}
}
// 针对flatted的内容执行拉平处理
return flatted;
};
export default {