yi-bi-ez-table 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1680 @@
1
+ import _ from 'lodash';
2
+ import { chnToEn, getDateList, getYearList, getMonthList, getCatchFunction, expr2FnBody, getMeasureDataType, getWeekName } from './utils';
3
+ import { CALCULATED_REGEX, RANK_TYPES } from './constants';
4
+ import { deepRenameExprKey, getStyleType } from './utils';
5
+ export class EZTableHeader {
6
+ constructor() {
7
+ this.getShowSizeExprKey = (measureList) => {
8
+ return measureList.filter(item => !item.expr && item.supportSize && item.showSize).map(item => item.exprKey);
9
+ };
10
+ this.checkMerge = (measureList, hasMergeGroup, dateRangeDicList, dateRangeDic, measureDic, measureSizeGroup, queryMeasureList) => {
11
+ if (!hasMergeGroup) {
12
+ return false;
13
+ }
14
+ let mergeGroupCount = 0;
15
+ let passed = false;
16
+ for (let i = 0, leng = measureList.length; i < leng; i++) {
17
+ const m = measureList[i];
18
+ if (m.isGroup && m.isMerge) {
19
+ mergeGroupCount++;
20
+ passed = this.checkMergeOfGroup(m.children || []);
21
+ }
22
+ else if (m.isGroup && !m.isMerge) {
23
+ this.checkMerge(m.children || [], hasMergeGroup, dateRangeDicList, dateRangeDic, measureDic, measureSizeGroup, queryMeasureList);
24
+ }
25
+ }
26
+ if (mergeGroupCount > 1) {
27
+ // console.error('一张表只能有一个合并分日期的分组');
28
+ throw new Error('一张表只能有一个合并分日期的分组');
29
+ }
30
+ passed = mergeGroupCount === 1 && passed;
31
+ if (passed) {
32
+ for (let i = 0, leng = measureList.length; i < leng; i++) {
33
+ const m = measureList[i];
34
+ if (m.isGroup && m.isMerge) {
35
+ // m.originalChildren = [...m.children];
36
+ m.originalChildren = _.cloneDeep(m.children);
37
+ this.setMergeGroup(m, dateRangeDicList, dateRangeDic, measureDic, measureSizeGroup, queryMeasureList);
38
+ break;
39
+ }
40
+ else if (m.isGroup && !m.isMerge) {
41
+ this.checkMerge(m.children || [], hasMergeGroup, dateRangeDicList, dateRangeDic, measureDic, measureSizeGroup, queryMeasureList);
42
+ }
43
+ }
44
+ }
45
+ return passed;
46
+ };
47
+ this.deepSizeList = (children, isFirst, parentKeys = [], group, groupKey, sizeList = [], dataList, measureSizeKey, sizeGroupDic, measureSizeGroup, measureListDic) => {
48
+ if (children && children.length) {
49
+ children.forEach((child, i) => {
50
+ // let key = this.getNewKey(child, [...parentKeys]);
51
+ let key = this.getNewKey(child, _.cloneDeep(parentKeys));
52
+ const firstLabel = parentKeys && parentKeys.length ? parentKeys[0] : key.substring(0, key.indexOf('['));
53
+ if (!isFirst || i !== 0) {
54
+ isFirst = false;
55
+ }
56
+ if (isFirst && i === 0) {
57
+ dataList.forEach(data => data[key] = data.尺码组);
58
+ }
59
+ else if (!child.isGroup) {
60
+ const groupStr = groupKey.split(']')[0];
61
+ let count = groupStr.split('[').length;
62
+ if (group.expr) {
63
+ let expr = child.expr;
64
+ const fields = expr?.match(CALCULATED_REGEX);
65
+ if (fields && fields.length) {
66
+ for (let fI = 0, leng = fields.length; fI < leng; fI++) {
67
+ let sizeArr = key.split(groupStr)[1].split('[').map(item => item.split(']')[0]).slice(1);
68
+ const field = fields[fI];
69
+ const sizeIndex = measureSizeKey.findIndex(item => item === field.substring(1, field.length - 1));
70
+ if (sizeList && sizeList.length) {
71
+ const f = field.substring(1, field.length - 1);
72
+ const sizeArrI = sizeArr.findIndex(s => s !== 'null');
73
+ if (sizeArrI === -1) {
74
+ continue;
75
+ }
76
+ const sizeI = sizeGroupDic[sizeList[sizeArrI]].findIndex(s => s === sizeArr[sizeArrI]);
77
+ const groupList = measureSizeGroup[f]?.sort();
78
+ const newSizeArr = [];
79
+ groupList?.forEach(g => {
80
+ if (sizeGroupDic[g]) {
81
+ newSizeArr.push(sizeGroupDic[g][sizeI]);
82
+ }
83
+ });
84
+ sizeArr = newSizeArr;
85
+ }
86
+ if (sizeIndex > -1) {
87
+ let k = measureSizeKey[sizeIndex].split(']')[0] + '[';
88
+ k = k.split(']')[0];
89
+ sizeArr.forEach((size, sizeI) => {
90
+ k += `${size + (sizeI === sizeArr.length - 1 ? '' : '[')}`;
91
+ });
92
+ count = k.split('[').length - 1;
93
+ k = k.padEnd(k.length + count, ']');
94
+ expr = expr.replace(field, `{${k}}`);
95
+ }
96
+ }
97
+ }
98
+ child.expr = expr;
99
+ }
100
+ else {
101
+ const sizeArr = key.split(groupStr)[1].split('[').map(item => item.split(']')[0]).slice(1);
102
+ sizeArr.forEach((size, sizeI) => {
103
+ let k = `${groupStr}[${size}`;
104
+ k = k.padEnd(k.length + count, ']');
105
+ dataList.forEach((data, dataI) => {
106
+ if (data[k] || data[k] === 0) {
107
+ const groupI = measureSizeGroup[firstLabel]?.indexOf(data.尺码组);
108
+ if (sizeI === groupI) {
109
+ if (child.displayName === '度量') {
110
+ let mKey = child.exprKey;
111
+ if (child.children && child.children.length === 1 && child.children[0].displayName === '度量') {
112
+ mKey = child.children[0].exprKey;
113
+ }
114
+ // key = this.getNewKey({ displayName: data[mKey] }, [...parentKeys]);
115
+ key = this.getNewKey({ displayName: data[mKey] }, _.cloneDeep(parentKeys));
116
+ if (data.same?.index || data.same?.index === 0) {
117
+ dataList.forEach((item, itemI) => {
118
+ if (item.same?.index === data.same.index) {
119
+ item[key] = data[k];
120
+ }
121
+ });
122
+ }
123
+ }
124
+ data[key] = data[k];
125
+ }
126
+ }
127
+ });
128
+ });
129
+ }
130
+ if (child.style?.conditionList?.length) {
131
+ child.style = _.cloneDeep(child.style);
132
+ child.style.conditionList.forEach(c => {
133
+ if (c.op === 'expr') {
134
+ let expr = c.value;
135
+ const fields = _.uniq(expr.match(CALCULATED_REGEX));
136
+ if (fields && fields.length) {
137
+ for (let fI = 0, leng = fields.length; fI < leng; fI++) {
138
+ let sizeArr = key.split(groupStr)[1].split('[').map(item => item.split(']')[0]).slice(1);
139
+ const field = fields[fI];
140
+ const measureKey = field.substring(1, field.length - 1);
141
+ let sizeIndex = measureSizeKey.findIndex(item => item === measureKey);
142
+ if (sizeIndex < 0) {
143
+ const calcExprList = measureListDic[measureKey]?.expr?.match(CALCULATED_REGEX);
144
+ for (let i = 0; i < calcExprList?.length; i++) {
145
+ let m = calcExprList[i];
146
+ m = m.substring(1, m.length - 1);
147
+ sizeIndex = measureSizeKey.findIndex(item => item === m);
148
+ if (sizeIndex > -1) {
149
+ const sizeArrI = sizeArr.findIndex(s => s !== 'null');
150
+ if (sizeArrI === -1) {
151
+ continue;
152
+ }
153
+ const sizeI = sizeGroupDic[sizeList[sizeArrI]].findIndex(s => s === sizeArr[sizeArrI]);
154
+ const groupList = measureSizeGroup[m]?.sort();
155
+ const newSizeArr = [];
156
+ groupList?.forEach(g => {
157
+ if (sizeGroupDic[g]) {
158
+ newSizeArr.push(sizeGroupDic[g][sizeI]);
159
+ }
160
+ });
161
+ sizeArr = newSizeArr;
162
+ break;
163
+ }
164
+ }
165
+ }
166
+ else if (sizeList && sizeList.length) {
167
+ const f = field.substring(1, field.length - 1);
168
+ const sizeArrI = sizeArr.findIndex(s => s !== 'null');
169
+ if (sizeArrI === -1) {
170
+ continue;
171
+ }
172
+ const sizeI = sizeGroupDic[sizeList[sizeArrI]].findIndex(s => s === sizeArr[sizeArrI]);
173
+ const groupList = measureSizeGroup[f]?.sort();
174
+ const newSizeArr = [];
175
+ groupList?.forEach(g => {
176
+ newSizeArr.push(sizeGroupDic[g][sizeI]);
177
+ });
178
+ sizeArr = newSizeArr;
179
+ }
180
+ if (sizeIndex > -1) {
181
+ // let k = measureSizeKey[sizeIndex].split(']')[0] + '[';
182
+ // k = k.split(']')[0];
183
+ let k = measureKey + '[';
184
+ sizeArr.forEach((size, sizeI) => {
185
+ k += `${size + (sizeI === sizeArr.length - 1 ? '' : '[')}`;
186
+ });
187
+ count = k.split('[').length - 1;
188
+ k = k.padEnd(k.length + count, ']');
189
+ expr = expr.replace(field, `{${k}}`);
190
+ }
191
+ }
192
+ }
193
+ c.value = expr;
194
+ const computeExpr = c.value.replaceAll('{', '(data.data["').replaceAll('}', '"] || 0)');
195
+ c.computeFn = getCatchFunction(expr2FnBody(computeExpr));
196
+ }
197
+ });
198
+ }
199
+ }
200
+ if (child.children && child.children.length) {
201
+ this.deepSizeList(child.children, isFirst, [...parentKeys, child.displayName], group, groupKey, sizeList, dataList, measureSizeKey, sizeGroupDic, measureSizeGroup, measureListDic);
202
+ }
203
+ });
204
+ }
205
+ };
206
+ this.setExprDateRange = (item, dateList, keyList) => {
207
+ if (!item.expr) {
208
+ return;
209
+ }
210
+ if (!dateList || Object.keys(dateList).length <= 0) {
211
+ return;
212
+ }
213
+ const children = [];
214
+ const valueList = [];
215
+ let keyOfMaxLeng = keyList[0];
216
+ keyList.forEach(k => {
217
+ const list = dateList[k];
218
+ valueList.push(list);
219
+ if (list.length > dateList[keyOfMaxLeng].length) {
220
+ keyOfMaxLeng = k;
221
+ }
222
+ });
223
+ // @ts-ignore
224
+ const diff = valueList.length > 1 ? _.difference(...valueList) : [];
225
+ dateList[keyOfMaxLeng].forEach((d, dI) => {
226
+ const child = {
227
+ ...item,
228
+ displayName: diff && diff.length ? `${dI + 1}` : d,
229
+ isGroup: false,
230
+ mark: undefined,
231
+ };
232
+ if (item.expr) {
233
+ let expr = item.expr;
234
+ const fields = expr.match(CALCULATED_REGEX);
235
+ fields?.forEach(field => {
236
+ const count = field.split('[').length - 1;
237
+ const key = keyList.find(k => `{${k}}` === field);
238
+ if (key) {
239
+ const j = key.indexOf(']');
240
+ const date = dateList[key][dI];
241
+ let k = key.substring(0, j > -1 ? j : undefined) + '[' + date + ']';
242
+ k = k.padEnd(k.length + count, ']');
243
+ expr = expr.replace(field, `{${k}}`);
244
+ }
245
+ });
246
+ child.expr = expr;
247
+ }
248
+ children.push(child);
249
+ });
250
+ item.isGroup = true;
251
+ item.children = children;
252
+ };
253
+ this.setExprDateRangeOld = (item, dateList, keyList) => {
254
+ if (!item.expr) {
255
+ return;
256
+ }
257
+ const children = [];
258
+ dateList.forEach((d, dI) => {
259
+ const child = {
260
+ ...item,
261
+ displayName: d,
262
+ isGroup: false,
263
+ mark: undefined,
264
+ };
265
+ if (item.expr) {
266
+ let expr = item.expr;
267
+ const fields = expr.match(CALCULATED_REGEX);
268
+ fields?.forEach(field => {
269
+ const count = field.split('[').length - 1;
270
+ const key = keyList.find(k => `{${k}}` === field);
271
+ if (key) {
272
+ const j = key.indexOf(']');
273
+ let k = key.substring(0, j > -1 ? j : undefined) + '[' + d + ']';
274
+ k = k.padEnd(k.length + count, ']');
275
+ expr = expr.replace(field, `{${k}}`);
276
+ }
277
+ });
278
+ child.expr = expr;
279
+ }
280
+ children.push(child);
281
+ });
282
+ item.isGroup = true;
283
+ item.children = children;
284
+ };
285
+ // 分时段
286
+ this.setHourMeasure = (queryMeasureList) => {
287
+ const hourMeasureKeys = [];
288
+ this.findHourMeasures(queryMeasureList, hourMeasureKeys);
289
+ this.findHoureRange(queryMeasureList, hourMeasureKeys);
290
+ };
291
+ this.findHoureRange = (measureList, hourMeasureKeys, parentKeys = []) => {
292
+ if (measureList && measureList.length) {
293
+ measureList.forEach((item, itemI) => {
294
+ const time = this.findHourDateType(item);
295
+ if (time) {
296
+ const { start, end } = this.getHourStartAndEnd(time);
297
+ const children = [];
298
+ for (let i = start; i <= end; i++) {
299
+ let name = `${i}`;
300
+ name = name.length === 1 ? `0${name}` : name;
301
+ const data = {
302
+ ...item,
303
+ dateType: undefined,
304
+ isGroup: false,
305
+ displayName: name,
306
+ mark: undefined,
307
+ };
308
+ children.push(data);
309
+ }
310
+ item.isGroup = true;
311
+ item.children = children;
312
+ }
313
+ else if (item.expr && !item.children) {
314
+ const expr = item.expr;
315
+ const hourList = [];
316
+ const fields = expr.match(CALCULATED_REGEX);
317
+ fields?.forEach((f, i) => {
318
+ const k = f.substring(1, f.length - 1);
319
+ const hourItem = hourMeasureKeys.find(h => h.key === k);
320
+ if (hourItem) {
321
+ for (let j = hourItem.start; j <= hourItem.end; j++) {
322
+ let name = `${j}`;
323
+ name = name.length === 1 ? `0${name}` : name;
324
+ if (!hourList.includes(name)) {
325
+ hourList.push(name);
326
+ }
327
+ }
328
+ }
329
+ });
330
+ if (hourList && hourList.length) {
331
+ hourList.sort();
332
+ hourMeasureKeys.push({
333
+ key: item.exprKey,
334
+ start: Number(hourList[0]),
335
+ end: Number(hourList[hourList.length - 1])
336
+ });
337
+ const children = [];
338
+ hourList.forEach(h => {
339
+ let newExpr = item.expr;
340
+ fields?.forEach((f, i) => {
341
+ const k = f.substring(1, f.length - 1);
342
+ const hourItem = hourMeasureKeys.find(h => h.key === k);
343
+ if (hourItem) {
344
+ newExpr = newExpr.replace(f, `{${this.getKey(hourItem.key, h)}}`);
345
+ }
346
+ });
347
+ children.push({
348
+ ...item,
349
+ expr: newExpr,
350
+ displayName: h,
351
+ mark: undefined,
352
+ });
353
+ });
354
+ item.isGroup = true;
355
+ item.children = children;
356
+ }
357
+ }
358
+ else if (item.isGroup && item.children && item.children.length) {
359
+ this.findHoureRange(item.children, hourMeasureKeys, [...parentKeys, item.displayName]);
360
+ }
361
+ });
362
+ }
363
+ };
364
+ this.setMeasureWeekGroup = (value, group, queryMeasureList) => {
365
+ const weekMeasureKeys = [];
366
+ this.findWeekMeasure(value, queryMeasureList, weekMeasureKeys);
367
+ this.findWeekGroup(value, queryMeasureList, group, weekMeasureKeys);
368
+ };
369
+ this.getHeaderKey = (header, rowspan, suffixDic, groupByDimList, combineChildren, key, bindDimOfParent) => {
370
+ const isRank = RANK_TYPES.some(item => item.value === header.measureType);
371
+ if (isRank) {
372
+ // fixed 之前添加的排名增加了 aggFunc 导致报错的问题
373
+ delete header.aggFunc;
374
+ }
375
+ let subLabel = '';
376
+ if (suffixDic && key && suffixDic[key]) {
377
+ subLabel += `(${suffixDic[key]})`;
378
+ }
379
+ // const itemCalculate = isRank ? null : header.expr;
380
+ const itemCalculate = header.expr;
381
+ let h = {
382
+ rowspan,
383
+ label: header.displayName,
384
+ subLabel: subLabel || header.subLabel,
385
+ key: header.realKey || key,
386
+ dataType: header.dataType || getMeasureDataType(header),
387
+ customNumberFilter: header.vtype === 0 || !!(header.expr && header.measureType !== 'CONDITION'),
388
+ customDateFilter: header.vtype === 2,
389
+ customFilter: header.measureType === 'CONDITION',
390
+ format: header.format,
391
+ styleType: getStyleType(header.format),
392
+ itemCalculate,
393
+ totalCalculate: isRank ? 'CUSTOM' : (header.aggFunc || (header.vtype === 0 || !!header.expr ? 'SUM' : header.vtype ? 'MAX' : undefined)),
394
+ rank: isRank ? { measure: header.expr, type: header.measureType } : null,
395
+ measureType: header.measureType,
396
+ isHide: header.isHide,
397
+ backgroundColor: header.style && header.style.backgroundColor ? header.style.backgroundColor : null,
398
+ color: header.style && header.style.color ? header.style.color : null,
399
+ styleConditionList: header.style?.conditionList || null,
400
+ type: 'MEASURE',
401
+ width: header.width,
402
+ dateRangeSumList: header.dateRangeSumList,
403
+ mark: header.mark,
404
+ fixed: header.fixed,
405
+ groupList: header.groupList,
406
+ mergeCalcList: header.mergeCalcList,
407
+ groupAggFunc: header.groupAggFunc,
408
+ style: header.style,
409
+ bindDim: header.bindDim,
410
+ bindDimOrder: header.bindDimOrder,
411
+ bindDimOrderMeasureName: header.bindDimOrderMeasureName,
412
+ bindDimMeasureAlign: header.bindDimMeasureAlign,
413
+ code: header.code,
414
+ bindDimOfParent,
415
+ computeParam: header.computeParam,
416
+ aggRange: header.aggRange,
417
+ };
418
+ if (h.measureType === 'GROUP_RATIO' && h.computeParam?.groupByList?.length) {
419
+ h.computeParam.groupByList = h.computeParam.groupByList.filter(item => groupByDimList.some(g => g.displayName === item.displayName));
420
+ }
421
+ if (combineChildren && combineChildren.length) {
422
+ const action = combineChildren.find(child => {
423
+ if (child.action &&
424
+ child.action.anchor &&
425
+ child.action.anchor.valueList &&
426
+ child.action.anchor.valueList.length &&
427
+ child.action.anchor.valueList[0] === '度量') {
428
+ const valueList = [...child.action.anchor.valueList];
429
+ valueList.shift();
430
+ const m = {
431
+ displayName: valueList.pop(),
432
+ };
433
+ const itemKey = this.getNewKey(m, valueList);
434
+ // 处理绑定维度跳转问题
435
+ if (h.bindDimOfParent) {
436
+ if (valueList[0] === h.bindDimOfParent.code && m.displayName === h.label) {
437
+ return true;
438
+ }
439
+ }
440
+ if (itemKey === h.key) {
441
+ return true;
442
+ }
443
+ }
444
+ });
445
+ if (action) {
446
+ h.customDrill = true;
447
+ h.action = action.action;
448
+ }
449
+ }
450
+ if (header.headerFilter) {
451
+ h = { ...h, ...header.headerFilter };
452
+ }
453
+ return h;
454
+ };
455
+ this.deepMeasureTree = (hideSizeGroup, measureList, rowSpan, i, parentKeys = [], groupKey = '', bindDimOfParent = null, params) => {
456
+ const { headers, queryMeasureList, hasMergeGroup, passedOfMergeGroup, dataList, suffixDic, groupByDimList, combineChildren, measureSizeGroup, hasVerticalOfBindDim, maxRowspan, } = params;
457
+ if (measureList && measureList.length) {
458
+ if (!headers[i]) {
459
+ headers[i] = [];
460
+ }
461
+ let bindDimCode = null;
462
+ measureList.forEach((item, j) => {
463
+ if (measureList === queryMeasureList) {
464
+ bindDimOfParent = null;
465
+ }
466
+ if (!item.isGroup) {
467
+ const key = this.getNewKey(item, parentKeys);
468
+ // 设置合并分日期分组 -> 分尺码的数据格式,样式等
469
+ if (hasMergeGroup && item.isMerge && passedOfMergeGroup && !item.dataType && item.originalChildren?.length) {
470
+ dataList.forEach((data, dI) => {
471
+ if (!data.dataType) {
472
+ data.dataType = {};
473
+ }
474
+ if (!data.format) {
475
+ data.format = {};
476
+ }
477
+ if (!data.style) {
478
+ data.style = {};
479
+ }
480
+ const h = item.originalChildren[dI % item.originalChildren.length];
481
+ data.dataType[key] = data.dataType[item.exprKey];
482
+ data.format[key] = h.format;
483
+ data.style[key] = h.style;
484
+ });
485
+ }
486
+ const headerItem = this.getHeaderKey(item, rowSpan, suffixDic, groupByDimList, combineChildren, key, bindDimOfParent);
487
+ headers[i].push(headerItem);
488
+ // 添加隐藏尺码组逻辑
489
+ if (hideSizeGroup && item.isSizeGroup) {
490
+ headerItem.isHide = true;
491
+ }
492
+ }
493
+ else if (item.isGroup && item.children?.length) {
494
+ let isHide = item.isHide;
495
+ if (item.children && item.children.length) {
496
+ isHide = this.getIsGroupHide(item.children);
497
+ }
498
+ // 添加隐藏尺码组逻辑
499
+ if (hideSizeGroup && item.isSizeGroup) {
500
+ isHide = true;
501
+ }
502
+ const isMerge = item.isGroup && item.isMerge;
503
+ const header = {
504
+ label: item.displayName,
505
+ colspan: this.getColSpan(hideSizeGroup, item.children),
506
+ realColspan: item.children?.length,
507
+ isHide: item.isHide || isHide,
508
+ mark: item.mark,
509
+ isMerge,
510
+ originalChildren: isMerge ? item.originalChildren : null,
511
+ mergeChildren: isMerge ? item.children : null,
512
+ width: item.width,
513
+ style: item.style,
514
+ bindDim: item.bindDim,
515
+ bindDimOrder: item.bindDimOrder,
516
+ bindDimOrderMeasureName: item.bindDimOrderMeasureName,
517
+ bindDimMeasureAlign: item.bindDimMeasureAlign,
518
+ code: item.code,
519
+ };
520
+ bindDimOfParent = header.bindDim ? {
521
+ code: item.code,
522
+ bindDim: header.bindDim,
523
+ bindDimOrder: header.bindDimOrder,
524
+ bindDimOrderMeasureName: header.bindDimOrderMeasureName,
525
+ bindDimMeasureAlign: header.bindDimMeasureAlign,
526
+ leng: header.realColspan,
527
+ } : null;
528
+ const headerKey = this.getNewKey(item, parentKeys);
529
+ if (measureSizeGroup && measureSizeGroup[headerKey]) {
530
+ header.showSize = true;
531
+ header.groupKey = headerKey;
532
+ }
533
+ const timeRange = item.dateType?.find(d => d.type === 'TIME_RANGE');
534
+ if (timeRange && timeRange.valueList && timeRange.valueList.length) {
535
+ const dateValue = timeRange.valueList[0];
536
+ header.isDateRange = dateValue === 1;
537
+ header.isTimeRange = dateValue === 2;
538
+ header.groupKey = headerKey;
539
+ }
540
+ if (hasVerticalOfBindDim && header.bindDimMeasureAlign === 'vertical') {
541
+ header.colspan = header.realColspan = item.children.find(child => child.isGroup) ? item.children.length : 1;
542
+ const lastChildren = this.deleteLastChildren(item);
543
+ header.originalChildren = lastChildren.children;
544
+ if (bindDimOfParent) {
545
+ bindDimOfParent.originalChildren = lastChildren.children;
546
+ }
547
+ else {
548
+ header.originalChildren = lastChildren.children;
549
+ }
550
+ if (!item.children || !item.children.length) {
551
+ header.key = this.getNewKey(item, parentKeys);
552
+ header.dataType = 'NUMBER';
553
+ }
554
+ if (bindDimCode !== header.code || (!bindDimOfParent && !bindDimCode && !headers[i].some(h => h.key === '度量'))) {
555
+ headers.forEach(headerList => {
556
+ headerList.forEach(h => {
557
+ if (h.type === 'DIM' && h.rowspan > 1) {
558
+ h.rowspan--;
559
+ }
560
+ });
561
+ });
562
+ bindDimCode = header.code;
563
+ headers[i].push({
564
+ label: '度量',
565
+ key: '度量',
566
+ dataType: 'STRING',
567
+ type: 'MEASURE',
568
+ rowspan: lastChildren.rowspan,
569
+ originalChildren: lastChildren.children,
570
+ isHide: headers[i].some(h => h.key === '度量' && h.label === '度量' && h.type === 'MEASURE' && h.originalChildren?.length),
571
+ });
572
+ }
573
+ }
574
+ headers[i].push(header);
575
+ if (item.children && item.children.length) {
576
+ const key = this.getNewKey(item, parentKeys);
577
+ if (measureSizeGroup[key] && measureSizeGroup[key].length) {
578
+ groupKey = key;
579
+ }
580
+ this.deepMeasureTree(hideSizeGroup, item.children, maxRowspan - i - 1, i + 1, [...parentKeys, item.displayName], groupKey, bindDimOfParent, params);
581
+ }
582
+ }
583
+ });
584
+ }
585
+ };
586
+ // setCustomFilter(headers: Array<Array<IHeaderKey>>, dataList: any[]): void {
587
+ // headers.forEach(header => {
588
+ // header.forEach(h => {
589
+ // if (h.customFilter) {
590
+ // h.filterVisible = false;
591
+ // h.filterSelectedList = h.filterSelectedList || [];
592
+ // const listOfFilter: Array<IListOfFilter> = [];
593
+ // const listOfMap = {};
594
+ // const allListOfFilter: Array<IListOfFilter> = [];
595
+ // const allListOfMap = {};
596
+ // dataList.forEach(item => {
597
+ // const value = h.isProductImage ? getImageDisplayName(item[h.key]) : item[h.key];
598
+ // if (listOfFilter.length <= 100) {
599
+ // if (!listOfMap[value]) {
600
+ // listOfFilter.push({
601
+ // text: value,
602
+ // value,
603
+ // });
604
+ // listOfMap[value] = true;
605
+ // }
606
+ // }
607
+ // if (!allListOfMap[value]) {
608
+ // allListOfFilter.push({
609
+ // text: value,
610
+ // value,
611
+ // });
612
+ // allListOfMap[value] = true;
613
+ // }
614
+ // });
615
+ // h.listOfFilter = listOfFilter;
616
+ // h.allListOfFilter = [...allListOfFilter];
617
+ // }
618
+ // });
619
+ // });
620
+ // }
621
+ }
622
+ getAllHeaders(params) {
623
+ const { dimList, measureList, measureDic, measureSizeGroup, sizeGroupDic, dataList, suffixDic, dateRangeDic, combineChildren, } = params;
624
+ const measureListDic = {};
625
+ measureList.forEach(item => {
626
+ measureListDic[item.exprKey] = item;
627
+ });
628
+ const headers = this.getTableHeaders(measureDic, measureSizeGroup, sizeGroupDic, dataList, suffixDic, dimList, measureList, dateRangeDic, measureListDic, combineChildren);
629
+ let headersOfMerge = [];
630
+ const hasMergeGroup = measureList.some(item => item.isMerge);
631
+ if (hasMergeGroup) {
632
+ headersOfMerge = this.getTableHeaders(measureDic, measureSizeGroup, sizeGroupDic, dataList, suffixDic, dimList, measureList, dateRangeDic, measureListDic, combineChildren, true);
633
+ }
634
+ let headersOfBindDimVertical = [];
635
+ const hasVerticalOfBindDim = measureList.some(item => item.bindDimMeasureAlign === 'vertical');
636
+ if (hasVerticalOfBindDim) {
637
+ headersOfBindDimVertical = this.getTableHeaders(measureDic, measureSizeGroup, sizeGroupDic, dataList, suffixDic, dimList, measureList, dateRangeDic, measureListDic, combineChildren, false, true);
638
+ }
639
+ return {
640
+ headers,
641
+ headersOfMerge,
642
+ headersOfBindDimVertical,
643
+ };
644
+ }
645
+ getTableHeaders(measureDic, measureSizeGroup, sizeGroupDic, dataList, suffixDic, dimList, measureList, dateRangeDic, measureListDic, combineChildren, hasMergeGroup, hasVerticalOfBindDim) {
646
+ dimList[dimList.length - 1].groupBy = false;
647
+ return this.getHeaders(measureDic, dimList, measureList, measureSizeGroup, sizeGroupDic, dataList, suffixDic, dateRangeDic, measureListDic, combineChildren, hasMergeGroup, hasVerticalOfBindDim);
648
+ }
649
+ getHeaders(measureDic, dimList, queryMeasureList, measureSizeGroup, sizeGroupDic, dataList, suffixDic, dateRangeDic, measureListDic, combineChildren, hasMergeGroup, hasVerticalOfBindDim) {
650
+ const headers = [];
651
+ this.setMaxLengSizeList(measureSizeGroup);
652
+ this.initTree(queryMeasureList);
653
+ const dateRangekeys = Object.keys(dateRangeDic || {});
654
+ const dateRangeDicList = this.getDateRangeDicList(dateRangekeys, dateRangeDic);
655
+ const passedOfMergeGroup = this.checkMerge(queryMeasureList, hasMergeGroup, dateRangeDicList, dateRangeDic, measureDic, measureSizeGroup, queryMeasureList);
656
+ const measureSizeKey = Object.keys(measureSizeGroup || {});
657
+ this.setMeasureSize(queryMeasureList, measureSizeKey, measureSizeGroup);
658
+ const sizeDim = dimList.find(d => (d.dimCode === '尺码组' || d.displayName === '尺码组'));
659
+ const hideSizeGroup = sizeDim && sizeDim.paramList && sizeDim.paramList.length > 0 && sizeDim.paramList[0].valueList[0] === 3;
660
+ this.findMeasureGroup(hideSizeGroup, queryMeasureList, [], measureSizeGroup, sizeGroupDic, dataList, measureSizeKey, measureListDic);
661
+ // 分日期
662
+ this.findDateRangeDic(queryMeasureList, dateRangeDicList, dateRangekeys, dateRangeDic);
663
+ // 分时段dateType
664
+ this.setHourMeasure(queryMeasureList);
665
+ // 5 分自然周,6 分周次
666
+ this.setMeasureWeekGroup(5, measureDic?.measureWeekGroup, queryMeasureList);
667
+ this.setMeasureWeekGroup(6, measureDic?.measureSingleWeekGroup, queryMeasureList);
668
+ const maxRowspan = this.getRowSpan(queryMeasureList);
669
+ this.setDimHeader(dimList, headers, maxRowspan, combineChildren);
670
+ const groupByDimList = this.getGroupByDimList(dimList);
671
+ this.deepMeasureTree(hideSizeGroup, queryMeasureList, maxRowspan, 0, [], '', null, {
672
+ headers,
673
+ queryMeasureList,
674
+ hasMergeGroup,
675
+ passedOfMergeGroup,
676
+ dataList,
677
+ suffixDic,
678
+ groupByDimList,
679
+ combineChildren,
680
+ measureSizeGroup,
681
+ hasVerticalOfBindDim,
682
+ maxRowspan,
683
+ });
684
+ // this.setCustomFilter(headers, dataList)
685
+ // console.log('headers = ', JSON.parse(JSON.stringify(headers)))
686
+ // console.log('headers = ', headers);
687
+ return headers;
688
+ }
689
+ setMeasureSize(measureList, measureSizeKey, measureSizeGroup) {
690
+ measureList.forEach(item => {
691
+ if (item.expr) {
692
+ const keys = [];
693
+ measureSizeKey.forEach(sizeKey => {
694
+ const reg = new RegExp(_.escapeRegExp(`{${sizeKey}}`), 'g');
695
+ const sizeMatch = item.expr.match(reg);
696
+ if (sizeMatch && sizeMatch.length) {
697
+ const firstMatch = sizeMatch[0];
698
+ const firstKey = firstMatch.substring(1, firstMatch.length - 1);
699
+ keys.push(firstKey);
700
+ }
701
+ });
702
+ const sizeList = [];
703
+ keys.forEach(k => {
704
+ measureSizeGroup[k]?.forEach(size => {
705
+ if (!sizeList.includes(size)) {
706
+ sizeList.push(size);
707
+ }
708
+ });
709
+ });
710
+ if (sizeList && sizeList.length) {
711
+ measureSizeGroup[item.exprKey] = sizeList;
712
+ measureSizeKey.push(item.exprKey);
713
+ }
714
+ }
715
+ });
716
+ }
717
+ setMaxLengSizeList(measureSizeGroup) {
718
+ if (measureSizeGroup) {
719
+ let maxLengSizeList = [];
720
+ Object.keys(measureSizeGroup).forEach(item => {
721
+ maxLengSizeList = maxLengSizeList.concat(measureSizeGroup[item]);
722
+ });
723
+ maxLengSizeList = _.uniq(maxLengSizeList);
724
+ Object.keys(measureSizeGroup).forEach(item => {
725
+ measureSizeGroup[item] = maxLengSizeList;
726
+ });
727
+ }
728
+ }
729
+ getHourStartAndEnd(time) {
730
+ let [type, start, end] = time.valueList;
731
+ start = start || 0;
732
+ end = !end && end !== 0 ? 24 : end;
733
+ return {
734
+ start,
735
+ end,
736
+ };
737
+ }
738
+ findHourDateType(measure) {
739
+ let time = null;
740
+ if (!measure.isGroup && measure.dateType) {
741
+ time = measure.dateType.find(d => d.type === 'TIME_RANGE' && d.valueList && d.valueList.length && d.valueList[0] === 2);
742
+ }
743
+ return time;
744
+ }
745
+ initTree(measureList) {
746
+ if (measureList && measureList.length) {
747
+ measureList.forEach(item => {
748
+ if (item.isGroup && item.isHide && item.children?.length) {
749
+ item.children.forEach(c => {
750
+ if (!c.isHide) {
751
+ c.isHide = true;
752
+ }
753
+ });
754
+ }
755
+ if (!item.isGroup && item.expr) {
756
+ item.expr = chnToEn(item.expr);
757
+ }
758
+ else if (item.isGroup && item.children && item.children.length) {
759
+ this.initTree(item.children);
760
+ }
761
+ });
762
+ }
763
+ }
764
+ getKey(key, name) {
765
+ let lastIndex = key.indexOf(']');
766
+ if (lastIndex === -1) {
767
+ lastIndex = key.length;
768
+ }
769
+ key = key.slice(0, lastIndex) + `[${name}]` + key.slice(lastIndex);
770
+ return key;
771
+ }
772
+ getNewKey(item, parentKeys = []) {
773
+ let key = item.displayName;
774
+ if (parentKeys.length) {
775
+ key = '';
776
+ parentKeys.forEach((p, pI) => {
777
+ if (pI === 0) {
778
+ key = p;
779
+ }
780
+ else {
781
+ key = this.getKey(key, p);
782
+ }
783
+ });
784
+ key = this.getKey(key, item.displayName);
785
+ }
786
+ return key;
787
+ }
788
+ getDateRangeDicList(dateRangekeys, dateRangeDic) {
789
+ const dateRangeDicList = {};
790
+ dateRangekeys?.forEach(k => {
791
+ if (dateRangeDic[k].startDate && dateRangeDic[k].endDate) {
792
+ const dateList = getDateList(new Date(dateRangeDic[k].startDate), new Date(dateRangeDic[k].endDate));
793
+ dateRangeDicList[k] = dateList;
794
+ }
795
+ if (dateRangeDic[k].startYear && dateRangeDic[k].endYear) {
796
+ const yearList = getYearList(new Date(dateRangeDic[k].startYear), new Date(dateRangeDic[k].endYear));
797
+ dateRangeDicList[k] = yearList;
798
+ }
799
+ if (dateRangeDic[k].startMonth && dateRangeDic[k].endMonth) {
800
+ const monthList = getMonthList(new Date(dateRangeDic[k].startMonth), new Date(dateRangeDic[k].endMonth));
801
+ dateRangeDicList[k] = monthList;
802
+ }
803
+ });
804
+ return dateRangeDicList;
805
+ }
806
+ getMergeGroupChildKey(measureList) {
807
+ return measureList.map(item => item.exprKey);
808
+ }
809
+ getDateTypeExprKey(measureList) {
810
+ return measureList.filter(item => !item.expr && item.dateType?.length).map(item => item.exprKey);
811
+ }
812
+ findDateType(measureList) {
813
+ let dateType = null;
814
+ const findItem = (list) => {
815
+ for (let i = 0, leng = list.length; i < leng; i++) {
816
+ const item = list[i];
817
+ if (!item.expr && item.dateType?.length && item.dateType.some(d => d.type === 'TIME_RANGE') && !dateType) {
818
+ dateType = item.dateType.find(d => d.type === 'TIME_RANGE');
819
+ return true;
820
+ }
821
+ else if (item.isGroup && item.children?.length && findItem(item.children)) {
822
+ return true;
823
+ }
824
+ }
825
+ };
826
+ findItem(measureList);
827
+ return dateType;
828
+ }
829
+ findShowSize(measureList) {
830
+ let showSize = false;
831
+ const findItem = (list) => {
832
+ for (let i = 0, leng = list.length; i < leng; i++) {
833
+ const item = list[i];
834
+ if (!item.expr && !showSize) {
835
+ showSize = item.supportSize && item.showSize;
836
+ return true;
837
+ }
838
+ else if (item.isGroup && item.children?.length && findItem(item.children)) {
839
+ return true;
840
+ }
841
+ }
842
+ };
843
+ findItem(measureList);
844
+ return showSize;
845
+ }
846
+ checkMergeOfGroup(measureList) {
847
+ let warningMessage = '';
848
+ const dateType = this.findDateType(measureList);
849
+ const showSize = this.findShowSize(measureList);
850
+ const mergeGroupChildKey = this.getMergeGroupChildKey(measureList);
851
+ const check = (list) => {
852
+ for (let i = 0, leng = list.length; i < leng; i++) {
853
+ const item = list[i];
854
+ if (!showSize) {
855
+ if (!item.expr &&
856
+ !item.isGroup &&
857
+ item.dateType?.length &&
858
+ !item.dateType.some(d => d.type === dateType.type && d.valueList[0] === dateType.valueList[0])) {
859
+ warningMessage = '合并分日期的分组中的度量, 分日期方式须相同或都分尺码';
860
+ }
861
+ if (item.expr && !mergeGroupChildKey.some(k => item.expr.includes(k))) {
862
+ warningMessage = '合并分日期的分组中的计算度量或条件度量, 须包含该分组下的度量';
863
+ }
864
+ }
865
+ else {
866
+ if (!item.expr &&
867
+ !item.isGroup &&
868
+ (!item.supportSize ||
869
+ !item.showSize)) {
870
+ warningMessage = '合并分日期的分组中的度量, 分日期方式须相同或都分尺码';
871
+ }
872
+ if (item.expr && !mergeGroupChildKey.some(k => item.expr.includes(k))) {
873
+ warningMessage = '合并分日期的分组中的计算度量或条件度量, 须包含该分组下的度量';
874
+ }
875
+ }
876
+ }
877
+ };
878
+ if (showSize || dateType) {
879
+ check(measureList);
880
+ }
881
+ if (warningMessage) {
882
+ throw new Error(warningMessage);
883
+ }
884
+ return !warningMessage;
885
+ }
886
+ // 设置合并分日期 分组的 children
887
+ setMergeGroup(m, dateRangeDicList, dateRangeDic, measureDic, measureSizeGroup, queryMeasureList) {
888
+ // const measureList = [...m.children];
889
+ const measureList = _.cloneDeep(m.children);
890
+ // const measureListLeng = measureList.length;
891
+ let exprKeyList = this.getDateTypeExprKey(measureList);
892
+ const showSize = this.findShowSize(measureList);
893
+ if (showSize) {
894
+ exprKeyList = this.getShowSizeExprKey(measureList);
895
+ }
896
+ const dateType = this.findDateType(measureList);
897
+ let exprKey = exprKeyList[0];
898
+ exprKey = exprKey?.substring(0, exprKey?.lastIndexOf('[') + 1) + '度量' + exprKey?.substring(exprKey?.indexOf(']'));
899
+ const firstChild = {
900
+ displayName: '度量',
901
+ vtype: 1,
902
+ fixed: m.groupFixed,
903
+ exprKey,
904
+ };
905
+ const children = [firstChild];
906
+ const childNotExpr = measureList.filter(item => !item.expr && !item.isGroup);
907
+ if (!showSize) {
908
+ if (dateType.type === 'TIME_RANGE' && dateType.valueList[0] === 1) {
909
+ // 分日期
910
+ const dateList = [];
911
+ exprKeyList.forEach(item => {
912
+ dateRangeDicList[item]?.forEach(date => {
913
+ if (!dateList.includes(date)) {
914
+ dateList.push(date);
915
+ }
916
+ });
917
+ });
918
+ dateList.sort();
919
+ dateList.forEach(d => {
920
+ children.push({
921
+ displayName: d,
922
+ });
923
+ });
924
+ }
925
+ else if (dateType.type === 'TIME_RANGE' && dateType.valueList[0] === 2) {
926
+ // 分时段
927
+ const hourList = [];
928
+ childNotExpr?.forEach(c => {
929
+ const time = this.findHourDateType(c);
930
+ if (time) {
931
+ const { start, end } = this.getHourStartAndEnd(time);
932
+ for (let h = start; h <= end; h++) {
933
+ if (!hourList.includes(h)) {
934
+ hourList.push(h);
935
+ }
936
+ }
937
+ }
938
+ });
939
+ hourList.sort((a, b) => a - b);
940
+ hourList.forEach(d => {
941
+ children.push({
942
+ displayName: d,
943
+ });
944
+ });
945
+ }
946
+ else if (dateType.type === 'TIME_RANGE' && dateType.valueList[0] === 3) {
947
+ // 分年份
948
+ const yearList = [];
949
+ exprKeyList.forEach(k => {
950
+ const list = getYearList(new Date(dateRangeDic[k].startYear), new Date(dateRangeDic[k].endYear));
951
+ list.forEach(year => {
952
+ if (!yearList.includes(year)) {
953
+ yearList.push(year);
954
+ }
955
+ });
956
+ });
957
+ yearList.sort();
958
+ yearList.forEach(d => {
959
+ children.push({
960
+ displayName: d,
961
+ });
962
+ });
963
+ }
964
+ else if (dateType.type === 'TIME_RANGE' && dateType.valueList[0] === 4) {
965
+ // 分月份
966
+ const monthList = [];
967
+ exprKeyList.forEach(k => {
968
+ const list = getMonthList(new Date(dateRangeDic[k].startMonth), new Date(dateRangeDic[k].endMonth));
969
+ list.forEach(month => {
970
+ if (!monthList.includes(month)) {
971
+ monthList.push(month);
972
+ }
973
+ });
974
+ });
975
+ monthList.sort();
976
+ monthList.forEach(d => {
977
+ children.push({
978
+ displayName: d,
979
+ });
980
+ });
981
+ }
982
+ else if (dateType.type === 'TIME_RANGE' && dateType.valueList[0] === 5) {
983
+ // 分自然周
984
+ const weekList = [];
985
+ exprKeyList.forEach(item => {
986
+ measureDic?.measureWeekGroup[item].forEach(week => {
987
+ if (!weekList.includes(week)) {
988
+ weekList.push(week);
989
+ }
990
+ });
991
+ });
992
+ weekList.sort();
993
+ weekList.forEach(d => {
994
+ children.push({
995
+ displayName: d,
996
+ });
997
+ });
998
+ }
999
+ else if (dateType.type === 'TIME_RANGE' && dateType.valueList[0] === 6) {
1000
+ // 分周次
1001
+ const weekList = [];
1002
+ exprKeyList.forEach(item => {
1003
+ measureDic?.measureSingleWeekGroup[item].forEach(week => {
1004
+ if (!weekList.includes(week)) {
1005
+ weekList.push(week);
1006
+ }
1007
+ });
1008
+ });
1009
+ // 上市分析(/insight/product-launch)中不排序
1010
+ if (!dateType.notSort) {
1011
+ weekList.sort();
1012
+ }
1013
+ weekList.forEach(d => {
1014
+ children.push({
1015
+ displayName: d,
1016
+ });
1017
+ });
1018
+ }
1019
+ }
1020
+ else {
1021
+ // 分尺码
1022
+ const groupList = [];
1023
+ exprKeyList.forEach(item => {
1024
+ measureSizeGroup[item]?.forEach(group => {
1025
+ if (!groupList.includes(group)) {
1026
+ groupList.push(group);
1027
+ }
1028
+ });
1029
+ });
1030
+ groupList.sort();
1031
+ m.isGroup = false;
1032
+ measureSizeGroup[m.displayName] = groupList;
1033
+ }
1034
+ m.children = children;
1035
+ deepRenameExprKey(queryMeasureList);
1036
+ }
1037
+ setSizeGroupChildren(deepCount, children, sizeI, size, data, groupList, sizeGroupDic, isSizeGroup) {
1038
+ const child = children[sizeI];
1039
+ if (!child.children) {
1040
+ child.children = [];
1041
+ }
1042
+ // const deepChildren = (item: IDisplayMeasure, count: number) => {
1043
+ // if (count === deepCount) {
1044
+ // const pushData: any = { ...data, isGroup: false, displayName: size, mark: undefined, groupList };
1045
+ // if (sizeI === 0) {
1046
+ // pushData.expr = undefined;
1047
+ // }
1048
+ // // if (Object.keys(sizeGroupDic).includes(size)) {
1049
+ // // pushData.dataType = 'STRING';
1050
+ // // }
1051
+ // if (sizeGroupDic[size]) {
1052
+ // pushData.dataType = 'STRING';
1053
+ // }
1054
+ // item.children = [pushData];
1055
+ // item.isGroup = true;
1056
+ // delete item.headerKey;
1057
+ // return false;
1058
+ // }
1059
+ // if (deepChildren(item.children[0], count + 1)) {
1060
+ // return true;
1061
+ // }
1062
+ // };
1063
+ this.deepChildrenOfSizeGroup(child, 0, deepCount, data, size, sizeI, groupList, sizeGroupDic, isSizeGroup);
1064
+ }
1065
+ deepChildrenOfSizeGroup(item, count, deepCount, data, size, sizeI, groupList, sizeGroupDic, isSizeGroup) {
1066
+ if (count === deepCount) {
1067
+ // 隐藏分尺码的尺码组逻辑 isSizeGroup
1068
+ const pushData = { ...data, isGroup: false, displayName: size, mark: undefined, groupList, isSizeGroup };
1069
+ if (sizeI === 0) {
1070
+ pushData.expr = undefined;
1071
+ pushData.aggFunc = 'NOT_SHOW';
1072
+ }
1073
+ // if (Object.keys(sizeGroupDic).includes(size)) {
1074
+ // pushData.dataType = 'STRING';
1075
+ // }
1076
+ if (sizeGroupDic[size]) {
1077
+ pushData.dataType = 'STRING';
1078
+ }
1079
+ item.children = [pushData];
1080
+ item.isGroup = true;
1081
+ delete item.headerKey;
1082
+ return false;
1083
+ }
1084
+ if (this.deepChildrenOfSizeGroup(item.children[0], count + 1, deepCount, data, size, sizeI, groupList, sizeGroupDic, isSizeGroup)) {
1085
+ return true;
1086
+ }
1087
+ }
1088
+ setSizeDataList(group, groupKey, sizeList = [], dataList, measureSizeKey, sizeGroupDic, measureSizeGroup, measureListDic) {
1089
+ this.deepSizeList(group.children, true, [groupKey], group, groupKey, sizeList, dataList, measureSizeKey, sizeGroupDic, measureSizeGroup, measureListDic);
1090
+ }
1091
+ setSizeGroup(hideSizeGroup, item, key, measureSizeGroup, sizeGroupDic, sizeList) {
1092
+ const children = [];
1093
+ let maxLeng = 0;
1094
+ const groupList = (sizeList || measureSizeGroup[key]).sort();
1095
+ groupList.forEach(g => {
1096
+ if (sizeGroupDic[g] && sizeGroupDic[g].length) {
1097
+ maxLeng = Math.max(maxLeng, sizeGroupDic[g].length);
1098
+ }
1099
+ });
1100
+ const originChildren = item.children;
1101
+ groupList.forEach((g, gI) => {
1102
+ if (gI === 0) {
1103
+ // 隐藏分尺码的尺码组
1104
+ children.push({
1105
+ displayName: g,
1106
+ width: item.width,
1107
+ groupList,
1108
+ isSizeGroup: true
1109
+ });
1110
+ }
1111
+ else {
1112
+ this.setSizeGroupChildren(gI - 1, children, 0, g, item, groupList, sizeGroupDic, true);
1113
+ }
1114
+ });
1115
+ // 隐藏分尺码的尺码组逻辑
1116
+ if (!hideSizeGroup && groupList.length === 1) {
1117
+ this.setSizeGroupChildren(0, children, 0, groupList[0], item, groupList, sizeGroupDic, false);
1118
+ }
1119
+ groupList.forEach((g, gI) => {
1120
+ if (sizeGroupDic[g]) {
1121
+ const oldLeng = sizeGroupDic[g].length;
1122
+ sizeGroupDic[g].length = maxLeng;
1123
+ sizeGroupDic[g].fill(null, oldLeng);
1124
+ sizeGroupDic[g].forEach((size, sizeI) => {
1125
+ if (gI === 0) {
1126
+ children.push({
1127
+ ...item,
1128
+ displayName: size,
1129
+ headerKey: size,
1130
+ expr: item.expr,
1131
+ width: item.width,
1132
+ mark: undefined,
1133
+ groupList,
1134
+ });
1135
+ }
1136
+ else {
1137
+ this.setSizeGroupChildren(gI - 1, children, sizeI + 1, size, item, groupList, sizeGroupDic, false);
1138
+ }
1139
+ });
1140
+ }
1141
+ });
1142
+ if (originChildren && originChildren.length) {
1143
+ children.splice(1, 0, ...originChildren);
1144
+ }
1145
+ item.isGroup = true;
1146
+ item.children = children;
1147
+ }
1148
+ findMeasureGroup(hideSizeGroup, measureList, parentKeys, measureSizeGroup, sizeGroupDic, dataList, measureSizeKey, measureListDic) {
1149
+ if (measureList && measureList.length) {
1150
+ measureList.forEach((item, itemI) => {
1151
+ if (!item.isGroup) {
1152
+ const key = this.getNewKey(item, parentKeys);
1153
+ if (measureSizeGroup?.[key]?.length) {
1154
+ this.setSizeGroup(hideSizeGroup, item, key, measureSizeGroup, sizeGroupDic);
1155
+ this.setSizeDataList(item, key, [], dataList, measureSizeKey, sizeGroupDic, measureSizeGroup, measureListDic);
1156
+ }
1157
+ else if (item.expr) {
1158
+ const keys = [];
1159
+ measureSizeKey.forEach(sizeKey => {
1160
+ const reg = new RegExp(_.escapeRegExp(`{${sizeKey}}`), 'g');
1161
+ const sizeMatch = item.expr.match(reg);
1162
+ if (sizeMatch && sizeMatch.length) {
1163
+ const firstMatch = sizeMatch[0];
1164
+ const firstKey = firstMatch.substring(1, firstMatch.length - 1);
1165
+ keys.push(firstKey);
1166
+ }
1167
+ });
1168
+ const sizeList = [];
1169
+ keys.forEach(k => {
1170
+ measureSizeGroup[k]?.forEach(size => {
1171
+ if (!sizeList.includes(size)) {
1172
+ sizeList.push(size);
1173
+ }
1174
+ });
1175
+ });
1176
+ if (sizeList && sizeList.length) {
1177
+ measureSizeGroup[item.exprKey] = sizeList;
1178
+ measureSizeKey.push(item.exprKey);
1179
+ this.setSizeGroup(hideSizeGroup, item, null, measureSizeGroup, sizeGroupDic, sizeList);
1180
+ this.setSizeDataList(item, key, sizeList, dataList, measureSizeKey, sizeGroupDic, measureSizeGroup, measureListDic);
1181
+ }
1182
+ }
1183
+ }
1184
+ else if (item.children && item.children.length) {
1185
+ this.findMeasureGroup(hideSizeGroup, item.children, [...parentKeys, item.displayName], measureSizeGroup, sizeGroupDic, dataList, measureSizeKey, measureListDic);
1186
+ }
1187
+ });
1188
+ }
1189
+ }
1190
+ setDateRange(item, key, dateRangeDicList) {
1191
+ const children = [];
1192
+ const showWeek = item.dateType.find(d => d.type === 'TIME_RANGE' && d.valueList && d.valueList.length && d.valueList[0] === 1 && d.valueList[1] === true);
1193
+ dateRangeDicList[key].forEach((d, dI) => {
1194
+ const child = {
1195
+ ...item,
1196
+ displayName: d,
1197
+ isGroup: false,
1198
+ mark: undefined,
1199
+ };
1200
+ if (d && showWeek) {
1201
+ child.subLabel = getWeekName(d, true);
1202
+ }
1203
+ if (child.style?.conditionList?.length) {
1204
+ child.style.conditionList.forEach(c => {
1205
+ if (c.op === 'expr') {
1206
+ let expr = c.value;
1207
+ const fields = _.uniq(expr.match(CALCULATED_REGEX));
1208
+ fields.forEach((f) => {
1209
+ const dr = f.replace('{', '').replace('}', '');
1210
+ if (dateRangeDicList[dr]) {
1211
+ const date = dateRangeDicList[dr][dI];
1212
+ if (date) {
1213
+ // expr
1214
+ const count = f.split('[').length;
1215
+ const j = f.indexOf(']');
1216
+ let k = dr.substring(0, j > -1 ? j : undefined) + '[' + date + ']';
1217
+ k = k.padEnd(count, ']');
1218
+ expr = expr.replaceAll(f, `{${k}}`);
1219
+ c.value = expr;
1220
+ }
1221
+ }
1222
+ });
1223
+ const computeExpr = c.value.replaceAll('{', '(data.data["').replaceAll('}', '"] || 0)');
1224
+ c.computeFn = getCatchFunction(expr2FnBody(computeExpr));
1225
+ }
1226
+ });
1227
+ }
1228
+ if (item.expr) {
1229
+ let expr = item.expr;
1230
+ const fields = expr.match(CALCULATED_REGEX);
1231
+ fields?.forEach(field => {
1232
+ const count = field.split('[').length;
1233
+ if (field === `{${key}}`) {
1234
+ const j = field.indexOf(']');
1235
+ let k = key.substring(0, j > -1 ? j : undefined) + '[' + d + ']';
1236
+ k = k.padEnd(count, ']');
1237
+ expr = expr.replace(field, `{${k}}`);
1238
+ }
1239
+ });
1240
+ child.expr = expr;
1241
+ }
1242
+ children.push(child);
1243
+ });
1244
+ item.isGroup = true;
1245
+ item.children = children;
1246
+ }
1247
+ // 分日期
1248
+ findDateRangeDic(measureList, dateRangeDicList, dateRangekeys, dateRangeDic, parentKeys = []) {
1249
+ if (measureList && measureList.length) {
1250
+ measureList.forEach((item, itemI) => {
1251
+ if (!item.isGroup) {
1252
+ const key = this.getNewKey(item, parentKeys);
1253
+ if (dateRangeDicList[key] && dateRangeDicList[key].length) {
1254
+ this.setDateRange(item, key, dateRangeDicList);
1255
+ }
1256
+ if (item.expr && !item.children && item.measureType !== 'DATE_RANGE_SUM') {
1257
+ const keys = [];
1258
+ dateRangekeys.forEach(dateKey => {
1259
+ const reg = new RegExp(_.escapeRegExp(`{${dateKey}}`), 'g');
1260
+ const sizeMatch = item.expr.match(reg);
1261
+ if (sizeMatch && sizeMatch.length && !item.children) {
1262
+ const firstMatch = sizeMatch[0];
1263
+ const firstKey = firstMatch.substring(1, firstMatch.length - 1);
1264
+ keys.push(firstKey);
1265
+ dateRangekeys.push(item.exprKey);
1266
+ }
1267
+ });
1268
+ // 设置计算日期范围
1269
+ if (keys.length) {
1270
+ const dateList = {};
1271
+ keys.forEach(k => {
1272
+ if (dateRangeDic[k] && dateRangeDic[k].startDate) {
1273
+ const itemDateList = getDateList(new Date(dateRangeDic[k].startDate), new Date(dateRangeDic[k].endDate));
1274
+ itemDateList.forEach(date => {
1275
+ if (!dateList[k]) {
1276
+ dateList[k] = [];
1277
+ }
1278
+ if (!dateList[k].includes(date)) {
1279
+ dateList[k].push(date);
1280
+ }
1281
+ });
1282
+ }
1283
+ if (dateRangeDic[k] && dateRangeDic[k].startYear) {
1284
+ const itemDateList = getYearList(new Date(dateRangeDic[k].startYear), new Date(dateRangeDic[k].endYear));
1285
+ itemDateList.forEach(date => {
1286
+ if (!dateList[k]) {
1287
+ dateList[k] = [];
1288
+ }
1289
+ if (!dateList[k].includes(date)) {
1290
+ dateList[k].push(date);
1291
+ }
1292
+ });
1293
+ }
1294
+ if (dateRangeDic[k] && dateRangeDic[k].startMonth) {
1295
+ const itemDateList = getMonthList(new Date(dateRangeDic[k].startMonth), new Date(dateRangeDic[k].endMonth));
1296
+ itemDateList.forEach(date => {
1297
+ if (!dateList[k]) {
1298
+ dateList[k] = [];
1299
+ }
1300
+ if (!dateList[k].includes(date)) {
1301
+ dateList[k].push(date);
1302
+ }
1303
+ });
1304
+ }
1305
+ });
1306
+ Object.keys(dateList).forEach(k => {
1307
+ dateList[k].sort();
1308
+ });
1309
+ this.setExprDateRange(item, dateList, keys);
1310
+ // 修复计算度量和条件度量引用的计算或条件度量存在分日期导致该度量无法分日期的问题
1311
+ if (item.children && item.children.length && /^\d{4}-\d{2}-\d{2}$/.test(item.children[0].displayName)) {
1312
+ dateRangeDic[item.exprKey] = {
1313
+ startDate: item.children[0].displayName,
1314
+ endDate: item.children[0].displayName
1315
+ };
1316
+ if (item.children.length > 0) {
1317
+ dateRangeDic[item.exprKey].endDate = item.children[item.children.length - 1].displayName;
1318
+ }
1319
+ }
1320
+ }
1321
+ }
1322
+ else if (item.expr && !item.children && item.measureType === 'DATE_RANGE_SUM') {
1323
+ const expr = item.expr;
1324
+ const fields = expr.match(CALCULATED_REGEX);
1325
+ const dateRangeSumList = [];
1326
+ fields.forEach((f, i) => {
1327
+ const k = f.substring(1, f.length - 1);
1328
+ if (i === 0) {
1329
+ if (dateRangeDicList[k]) {
1330
+ this.setExprDateRangeOld(item, dateRangeDicList[k], []);
1331
+ }
1332
+ }
1333
+ if (dateRangeDicList[k]) {
1334
+ dateRangeSumList.push({
1335
+ key: k,
1336
+ dateList: dateRangeDicList[k],
1337
+ });
1338
+ }
1339
+ });
1340
+ item.children?.forEach(child => child.dateRangeSumList = dateRangeSumList);
1341
+ }
1342
+ }
1343
+ else if (item.children && item.children.length) {
1344
+ this.findDateRangeDic(item.children, dateRangeDicList, dateRangekeys, dateRangeDic, [...parentKeys, item.displayName]);
1345
+ }
1346
+ });
1347
+ }
1348
+ }
1349
+ findHourMeasures(measureList, hourMeasureKeys, parentKeys = []) {
1350
+ measureList.forEach(item => {
1351
+ const time = this.findHourDateType(item);
1352
+ if (time) {
1353
+ const key = this.getNewKey(item, parentKeys);
1354
+ const { start, end } = this.getHourStartAndEnd(time);
1355
+ hourMeasureKeys.push({
1356
+ key,
1357
+ start,
1358
+ end,
1359
+ });
1360
+ }
1361
+ else if (item.isGroup && item.children && item.children.length) {
1362
+ this.findHourMeasures(item.children, [...parentKeys, item.displayName]);
1363
+ }
1364
+ });
1365
+ }
1366
+ findWeekType(measure, value) {
1367
+ let week = null;
1368
+ if (!measure.isGroup && measure.dateType) {
1369
+ week = measure.dateType.find(d => d.type === 'TIME_RANGE' && d.valueList && d.valueList.length && d.valueList[0] === value);
1370
+ }
1371
+ return week;
1372
+ }
1373
+ findWeekMeasure(value, measureList, weekMeasureKeys, parentKeys = []) {
1374
+ measureList.forEach(item => {
1375
+ const week = this.findWeekType(item, value);
1376
+ if (week) {
1377
+ const key = this.getNewKey(item, parentKeys);
1378
+ weekMeasureKeys.push(key);
1379
+ }
1380
+ else if (item.isGroup && item.children && item.children.length) {
1381
+ this.findWeekMeasure(value, item.children, weekMeasureKeys, [...parentKeys, item.displayName]);
1382
+ }
1383
+ });
1384
+ }
1385
+ findWeekGroup(value, measureList, group, weekMeasureKeys, parentKeys = []) {
1386
+ if (measureList && measureList.length) {
1387
+ measureList.forEach((item, itemI) => {
1388
+ const week = this.findWeekType(item, value);
1389
+ if (week) {
1390
+ const key = this.getNewKey(item, parentKeys);
1391
+ const children = [];
1392
+ for (let i = 0, leng = group[key].length; i < leng; i++) {
1393
+ const name = group[key][i];
1394
+ const data = {
1395
+ ...item,
1396
+ dateType: undefined,
1397
+ isGroup: false,
1398
+ displayName: name,
1399
+ mark: undefined,
1400
+ };
1401
+ children.push(data);
1402
+ }
1403
+ item.isGroup = true;
1404
+ item.children = children;
1405
+ }
1406
+ else if (item.expr && !item.children) {
1407
+ const expr = item.expr;
1408
+ const weekList = {};
1409
+ const fields = expr.match(CALCULATED_REGEX);
1410
+ let keyInFieldsOfWeekMeasure = '';
1411
+ fields?.forEach((f, i) => {
1412
+ const k = f.substring(1, f.length - 1);
1413
+ const weekItem = weekMeasureKeys.find(h => h === k);
1414
+ if (weekItem) {
1415
+ if (!keyInFieldsOfWeekMeasure) {
1416
+ keyInFieldsOfWeekMeasure = weekItem;
1417
+ }
1418
+ if (!weekList[weekItem]) {
1419
+ weekList[weekItem] = [];
1420
+ }
1421
+ for (let j = 0, leng = group[weekItem].length; j < leng; j++) {
1422
+ const name = group[weekItem][j];
1423
+ if (!weekList[weekItem].includes(name)) {
1424
+ weekList[weekItem].push(name);
1425
+ }
1426
+ }
1427
+ }
1428
+ });
1429
+ if (item.calcRule === 'SEQUENCE' && weekList) {
1430
+ const list = [];
1431
+ Object.keys(weekList).forEach(k => {
1432
+ weekList[k].forEach(item => {
1433
+ if (!list.some(l => l === item)) {
1434
+ list.push(item);
1435
+ }
1436
+ });
1437
+ });
1438
+ list.sort();
1439
+ Object.keys(weekList).forEach(k => {
1440
+ weekList[k] = [...list];
1441
+ });
1442
+ }
1443
+ const valueList = [];
1444
+ let keyOfMaxLeng = keyInFieldsOfWeekMeasure || weekMeasureKeys[0];
1445
+ weekMeasureKeys.forEach(k => {
1446
+ const list = weekList[k];
1447
+ valueList.push(list);
1448
+ if (list?.length > weekList[keyOfMaxLeng]?.length) {
1449
+ keyOfMaxLeng = k;
1450
+ }
1451
+ });
1452
+ // @ts-ignore
1453
+ const diff = valueList.length > 1 ? _.difference(...valueList) : [];
1454
+ if (weekList[keyOfMaxLeng] && weekList[keyOfMaxLeng].length) {
1455
+ weekList[keyOfMaxLeng].sort();
1456
+ const children = [];
1457
+ weekList[keyOfMaxLeng]?.forEach((h, hI) => {
1458
+ const child = {
1459
+ ...item,
1460
+ displayName: diff && diff.length ? `${hI + 1}` : h,
1461
+ mark: undefined,
1462
+ };
1463
+ let newExpr = item.expr;
1464
+ fields?.forEach((f, i) => {
1465
+ const k = f.substring(1, f.length - 1);
1466
+ const weekItem = weekMeasureKeys.find(w => w === k);
1467
+ if (weekItem) {
1468
+ newExpr = newExpr.replace(f, `{${this.getKey(weekItem, weekList[weekItem][hI])}}`);
1469
+ }
1470
+ });
1471
+ child.expr = newExpr;
1472
+ children.push(child);
1473
+ });
1474
+ item.isGroup = true;
1475
+ item.children = children;
1476
+ weekMeasureKeys.push(item.exprKey);
1477
+ group[item.exprKey] = children.map(child => child.displayName);
1478
+ }
1479
+ }
1480
+ else if (item.isGroup && item.children && item.children.length) {
1481
+ this.findWeekGroup(value, item.children, group, weekMeasureKeys, [...parentKeys, item.displayName]);
1482
+ }
1483
+ });
1484
+ }
1485
+ }
1486
+ getRowSpan(measureList) {
1487
+ let globalRowSpan = 1;
1488
+ let rowSpan = 1;
1489
+ const deepList = (list, level = 1) => {
1490
+ if (list && list.length) {
1491
+ list.forEach(item => {
1492
+ if (item.isGroup && item.children && item.children.length) {
1493
+ rowSpan = level + 1;
1494
+ deepList(item.children, level + 1);
1495
+ }
1496
+ else {
1497
+ if (rowSpan > globalRowSpan) {
1498
+ globalRowSpan = rowSpan;
1499
+ }
1500
+ }
1501
+ });
1502
+ }
1503
+ };
1504
+ deepList(measureList);
1505
+ return globalRowSpan > 1 ? globalRowSpan : null;
1506
+ }
1507
+ getColSpan(hideSizeGroup, measureList, isReal = false) {
1508
+ let colSpan = 0;
1509
+ const deepList = (list) => {
1510
+ if (list && list.length) {
1511
+ list.forEach(item => {
1512
+ // 隐藏分尺码的尺码组逻辑
1513
+ if (!hideSizeGroup || !item.isSizeGroup) {
1514
+ if (!isReal && !item.isGroup && !item.isHide) {
1515
+ colSpan++;
1516
+ }
1517
+ if (isReal && !item.isGroup) {
1518
+ colSpan++;
1519
+ }
1520
+ }
1521
+ if (item.isGroup && item.children && item.children.length) {
1522
+ deepList(item.children);
1523
+ }
1524
+ });
1525
+ }
1526
+ };
1527
+ deepList(measureList);
1528
+ return colSpan >= 1 ? colSpan : null;
1529
+ }
1530
+ setDimHeader(dimList, headers, maxRowspan, combineChildren) {
1531
+ dimList.forEach(item => {
1532
+ if (!headers[0]) {
1533
+ headers[0] = [];
1534
+ }
1535
+ let trigger = null;
1536
+ if (item.paramList && item.paramList.length) {
1537
+ const triggerParam = item.paramList.find(p => p.type === 'TRIGGER');
1538
+ const triggerValue = triggerParam?.valueList[0];
1539
+ if (triggerValue === 1) {
1540
+ trigger = 'hover';
1541
+ }
1542
+ else if (triggerValue === 3) {
1543
+ trigger = 'thumbnail';
1544
+ }
1545
+ }
1546
+ let h = {
1547
+ rowspan: maxRowspan,
1548
+ label: item.displayName,
1549
+ key: item.displayName,
1550
+ dataType: 'STRING',
1551
+ customFilter: item.customFilter ?? true,
1552
+ groupBy: item.groupBy,
1553
+ isProductImage: item.dimCode?.includes('图片地址'),
1554
+ type: 'DIM',
1555
+ width: item.width,
1556
+ fixed: item.fixed,
1557
+ mark: item.mark,
1558
+ trigger,
1559
+ backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : null,
1560
+ color: item.style && item.style.color ? item.style.color : null,
1561
+ styleConditionList: item.style?.conditionList || null,
1562
+ style: item.style,
1563
+ showItemGroupSummary: item.showItemGroupSummary,
1564
+ itemCalculate: item.expr || undefined,
1565
+ dimType: item.dimType,
1566
+ expr: item.expr,
1567
+ totalCalculate: item.expr ? 'CUSTOM' : undefined,
1568
+ dimExpanded: item.dimExpanded,
1569
+ };
1570
+ if (combineChildren && combineChildren.length) {
1571
+ const action = combineChildren.find(child => {
1572
+ if (!child.action.anchor || !child.action.anchor.valueList || !child.action.anchor.valueList.length) {
1573
+ const lastDimAndFilter = child.action.dimAndFilterList[child.action.dimAndFilterList.length - 1];
1574
+ return lastDimAndFilter.parent &&
1575
+ lastDimAndFilter.parent.dataSet === item.dataSet &&
1576
+ lastDimAndFilter.parent.dimCode === item.dimCode &&
1577
+ lastDimAndFilter.parent.displayName === item.displayName;
1578
+ }
1579
+ else if (child.action.anchor.valueList[0] === '维度') {
1580
+ const { valueList } = child.action.anchor;
1581
+ return item.displayName === valueList[valueList.length - 1];
1582
+ }
1583
+ });
1584
+ if (action) {
1585
+ h.customDrill = true;
1586
+ h.action = action.action;
1587
+ }
1588
+ }
1589
+ if (item.headerFilter) {
1590
+ h = { ...h, ...item.headerFilter };
1591
+ }
1592
+ headers[0].push(h);
1593
+ });
1594
+ }
1595
+ getGroupByDimList(dimList) {
1596
+ let groupByDimList = [];
1597
+ const groupList = dimList.filter((item) => !!item.dimCode);
1598
+ if (groupList?.length) {
1599
+ const groupByI = groupList.findIndex((item) => !item.groupBy);
1600
+ if (groupByI > -1) {
1601
+ groupByDimList = groupList.filter((item, i) => i <= groupByI);
1602
+ }
1603
+ }
1604
+ return groupByDimList;
1605
+ }
1606
+ getIsGroupHide(list) {
1607
+ // let isHide = true;
1608
+ // const deepChildren = (list: Array<IDisplayMeasure>) => {
1609
+ // if (list && list.length) {
1610
+ // for (let i = 0, leng = list.length; i < leng; i++) {
1611
+ // const item = list[i];
1612
+ // if (!item.isHide) {
1613
+ // isHide = false;
1614
+ // return false;
1615
+ // } else if (item.children && item.children.length && deepChildren(item.children)) {
1616
+ // return true;
1617
+ // }
1618
+ // }
1619
+ // }
1620
+ // };
1621
+ // deepChildren(list);
1622
+ // return isHide;
1623
+ if (!list) {
1624
+ return true;
1625
+ }
1626
+ for (const item of list) {
1627
+ if (!item.isHide) {
1628
+ return false; // 直接返回结果,避免不必要的循环
1629
+ }
1630
+ if (item.children) {
1631
+ // 如果子项没隐藏(即getIsGroupHide(item.children)返回false),返回false
1632
+ if (!this.getIsGroupHide(item.children)) {
1633
+ return false;
1634
+ }
1635
+ }
1636
+ }
1637
+ // 如果所有项都隐藏,返回true
1638
+ return true;
1639
+ }
1640
+ deleteLastChildren(measure) {
1641
+ const lastData = {
1642
+ rowspan: 1,
1643
+ children: null,
1644
+ };
1645
+ const getLast = (data, rowspan = 1) => {
1646
+ if (data?.children?.find(item => !item.isGroup)) {
1647
+ lastData.rowspan = rowspan;
1648
+ lastData.children = data.children;
1649
+ data.isGroup = false;
1650
+ data.children = undefined;
1651
+ }
1652
+ else if (data?.children?.length) {
1653
+ for (let j = 0, leng = data.children.length; j < leng; j++) {
1654
+ const item = data.children[j];
1655
+ getLast(item, rowspan + 1);
1656
+ }
1657
+ }
1658
+ };
1659
+ getLast(measure);
1660
+ return lastData;
1661
+ // const getLast = (data: IDisplayMeasure, rowspan = 1) => {
1662
+ // if (data?.children?.find(item => !item.isGroup)) {
1663
+ // data.isGroup = false;
1664
+ // data.children = undefined;
1665
+ // return {
1666
+ // rowspan,
1667
+ // children: data.children,
1668
+ // };
1669
+ // } else if (data?.children?.length) {
1670
+ // for (let j = 0, leng = data.children.length; j < leng; j++) {
1671
+ // const item = data.children[j];
1672
+ // const result = getLast(item, rowspan + 1);
1673
+ // if (result) return result;
1674
+ // }
1675
+ // }
1676
+ // return null;
1677
+ // }
1678
+ // return getLast(measure) || { rowspan: 1, children: null };
1679
+ }
1680
+ }