vxe-gantt 4.0.5 → 4.0.7
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.
- package/es/gantt/src/emits.js +3 -1
- package/es/gantt/src/gantt-chart.js +18 -4
- package/es/gantt/src/gantt-header.js +17 -9
- package/es/gantt/src/gantt-view.js +259 -106
- package/es/gantt/src/gantt.js +9 -9
- package/es/gantt/style.css +7 -1
- package/es/gantt/style.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-gantt/style.css +7 -1
- package/es/vxe-gantt/style.min.css +1 -1
- package/lib/gantt/src/emits.js +1 -1
- package/lib/gantt/src/emits.min.js +1 -1
- package/lib/gantt/src/gantt-chart.js +24 -4
- package/lib/gantt/src/gantt-chart.min.js +1 -1
- package/lib/gantt/src/gantt-header.js +26 -14
- package/lib/gantt/src/gantt-header.min.js +1 -1
- package/lib/gantt/src/gantt-view.js +317 -116
- package/lib/gantt/src/gantt-view.min.js +1 -1
- package/lib/gantt/src/gantt.js +7 -7
- package/lib/gantt/src/gantt.min.js +1 -1
- package/lib/gantt/style/style.css +7 -1
- package/lib/gantt/style/style.min.css +1 -1
- package/lib/index.umd.js +377 -144
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-gantt/style/style.css +7 -1
- package/lib/vxe-gantt/style/style.min.css +1 -1
- package/package.json +3 -3
- package/packages/gantt/src/emits.ts +3 -1
- package/packages/gantt/src/gantt-chart.ts +20 -4
- package/packages/gantt/src/gantt-header.ts +18 -10
- package/packages/gantt/src/gantt-view.ts +273 -110
- package/packages/gantt/src/gantt.ts +7 -7
- package/styles/components/gantt-module/gantt-chart.scss +2 -0
- package/styles/components/gantt.scss +6 -1
- package/styles/theme/base.scss +1 -1
- package/styles/theme/dark.scss +1 -0
- package/styles/theme/light.scss +1 -0
package/es/gantt/src/emits.js
CHANGED
|
@@ -30,13 +30,28 @@ export default defineVxeComponent({
|
|
|
30
30
|
const progressField = computeProgressField.value;
|
|
31
31
|
const taskBarOpts = computeTaskBarOpts.value;
|
|
32
32
|
const { showProgress, showContent, contentMethod, barStyle } = taskBarOpts;
|
|
33
|
-
const
|
|
33
|
+
const isBarRowStyle = XEUtils.isFunction(barStyle);
|
|
34
|
+
const barStyObj = (barStyle ? (isBarRowStyle ? barStyle({ row, $gantt: $xeGantt }) : barStyle) : {}) || {};
|
|
35
|
+
const { round } = barStyObj;
|
|
34
36
|
const rowRest = fullAllDataRowIdData[rowid] || {};
|
|
35
37
|
const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0;
|
|
36
38
|
const isRsHeight = resizeHeight > 0;
|
|
37
39
|
const cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
|
|
38
40
|
let title = getStringValue(XEUtils.get(row, titleField));
|
|
39
41
|
const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0;
|
|
42
|
+
const vbStyle = {};
|
|
43
|
+
const vpStyle = {
|
|
44
|
+
width: `${progressValue || 0}%`
|
|
45
|
+
};
|
|
46
|
+
if (isBarRowStyle) {
|
|
47
|
+
const { bgColor, completedBgColor } = barStyObj;
|
|
48
|
+
if (bgColor) {
|
|
49
|
+
vbStyle.backgroundColor = bgColor;
|
|
50
|
+
}
|
|
51
|
+
if (completedBgColor) {
|
|
52
|
+
vpStyle.backgroundColor = completedBgColor;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
40
55
|
if (contentMethod) {
|
|
41
56
|
title = getStringValue(contentMethod({ row, title }));
|
|
42
57
|
}
|
|
@@ -53,6 +68,7 @@ export default defineVxeComponent({
|
|
|
53
68
|
}, [
|
|
54
69
|
h('div', {
|
|
55
70
|
class: taskBarSlot ? 'vxe-gantt-view--chart-custom-bar' : 'vxe-gantt-view--chart-bar',
|
|
71
|
+
style: vbStyle,
|
|
56
72
|
rowid,
|
|
57
73
|
onClick(evnt) {
|
|
58
74
|
$xeGantt.handleTaskBarClickEvent(evnt, { row });
|
|
@@ -66,9 +82,7 @@ export default defineVxeComponent({
|
|
|
66
82
|
showProgress
|
|
67
83
|
? h('div', {
|
|
68
84
|
class: 'vxe-gantt-view--chart-progress',
|
|
69
|
-
style:
|
|
70
|
-
width: `${progressValue || 0}%`
|
|
71
|
-
}
|
|
85
|
+
style: vpStyle
|
|
72
86
|
})
|
|
73
87
|
: renderEmptyElement($xeGantt),
|
|
74
88
|
showContent
|
|
@@ -5,6 +5,7 @@ const { getI18n } = VxeUI;
|
|
|
5
5
|
export default defineVxeComponent({
|
|
6
6
|
name: 'VxeGanttViewHeader',
|
|
7
7
|
setup() {
|
|
8
|
+
const $xeGantt = inject('$xeGantt', {});
|
|
8
9
|
const $xeGanttView = inject('$xeGanttView', {});
|
|
9
10
|
const { reactData, internalData } = $xeGanttView;
|
|
10
11
|
const refElem = ref();
|
|
@@ -12,7 +13,8 @@ export default defineVxeComponent({
|
|
|
12
13
|
const refHeaderTable = ref();
|
|
13
14
|
const refHeaderXSpace = ref();
|
|
14
15
|
const renderVN = () => {
|
|
15
|
-
const {
|
|
16
|
+
const { headerGroups, viewCellWidth } = reactData;
|
|
17
|
+
const { visibleColumn } = internalData;
|
|
16
18
|
return h('div', {
|
|
17
19
|
ref: refElem,
|
|
18
20
|
class: 'vxe-gantt-view--header-wrapper'
|
|
@@ -30,7 +32,7 @@ export default defineVxeComponent({
|
|
|
30
32
|
ref: refHeaderTable,
|
|
31
33
|
class: 'vxe-gantt-view--header-table'
|
|
32
34
|
}, [
|
|
33
|
-
h('colgroup', {},
|
|
35
|
+
h('colgroup', {}, visibleColumn.map((column, cIndex) => {
|
|
34
36
|
return h('col', {
|
|
35
37
|
key: cIndex,
|
|
36
38
|
style: {
|
|
@@ -39,11 +41,12 @@ export default defineVxeComponent({
|
|
|
39
41
|
});
|
|
40
42
|
})),
|
|
41
43
|
h('thead', {}, headerGroups.map(({ scaleItem, columns }, $rowIndex) => {
|
|
42
|
-
const { type, titleMethod } = scaleItem;
|
|
44
|
+
const { type, titleMethod, slots } = scaleItem;
|
|
45
|
+
const titleSlot = slots ? slots.title : null;
|
|
43
46
|
return h('tr', {
|
|
44
47
|
key: $rowIndex
|
|
45
48
|
}, columns.map((column, cIndex) => {
|
|
46
|
-
const dateObj = column
|
|
49
|
+
const { childCount, dateObj } = column;
|
|
47
50
|
let label = `${column.title}`;
|
|
48
51
|
if ($rowIndex < headerGroups.length - 1) {
|
|
49
52
|
if (scaleItem.type === 'day') {
|
|
@@ -53,15 +56,20 @@ export default defineVxeComponent({
|
|
|
53
56
|
label = getI18n(`vxe.gantt.${!$rowIndex && headerGroups.length > 1 ? 'tFullFormat' : 'tSimpleFormat'}.${type}`, dateObj);
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
let cellVNs = label;
|
|
60
|
+
const ctParams = { scaleObj: scaleItem, title: label, dateObj: dateObj, $rowIndex };
|
|
61
|
+
if (titleSlot) {
|
|
62
|
+
cellVNs = $xeGantt.callSlot(titleSlot, ctParams);
|
|
63
|
+
}
|
|
64
|
+
else if (titleMethod) {
|
|
65
|
+
cellVNs = `${titleMethod(ctParams)}`;
|
|
58
66
|
}
|
|
59
67
|
return h('th', {
|
|
60
68
|
key: cIndex,
|
|
61
69
|
class: 'vxe-gantt-view--header-column',
|
|
62
|
-
colspan:
|
|
63
|
-
title: label
|
|
64
|
-
},
|
|
70
|
+
colspan: childCount || null,
|
|
71
|
+
title: titleSlot ? null : label
|
|
72
|
+
}, cellVNs);
|
|
65
73
|
}));
|
|
66
74
|
}))
|
|
67
75
|
])
|
|
@@ -11,6 +11,7 @@ const { globalEvents } = VxeUI;
|
|
|
11
11
|
function createInternalData() {
|
|
12
12
|
return {
|
|
13
13
|
xeTable: null,
|
|
14
|
+
visibleColumn: [],
|
|
14
15
|
startMaps: {},
|
|
15
16
|
endMaps: {},
|
|
16
17
|
chartMaps: {},
|
|
@@ -25,16 +26,9 @@ function createInternalData() {
|
|
|
25
26
|
startIndex: 0,
|
|
26
27
|
endIndex: 0
|
|
27
28
|
},
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
offsetSize: 0,
|
|
32
|
-
visibleSize: 0,
|
|
33
|
-
visibleStartIndex: 0,
|
|
34
|
-
visibleEndIndex: 0,
|
|
35
|
-
startIndex: 0,
|
|
36
|
-
endIndex: 0
|
|
37
|
-
}
|
|
29
|
+
// 最后滚动位置
|
|
30
|
+
lastScrollTop: 0,
|
|
31
|
+
lastScrollLeft: 0
|
|
38
32
|
};
|
|
39
33
|
}
|
|
40
34
|
const maxYHeight = 5e6;
|
|
@@ -72,6 +66,8 @@ export default defineVxeComponent({
|
|
|
72
66
|
scrollbarWidth: 0,
|
|
73
67
|
// 横向滚动条的高度
|
|
74
68
|
scrollbarHeight: 0,
|
|
69
|
+
// 最后滚动时间戳
|
|
70
|
+
lastScrollTime: 0,
|
|
75
71
|
lazScrollLoading: false,
|
|
76
72
|
scrollVMLoading: false,
|
|
77
73
|
scrollYHeight: 0,
|
|
@@ -112,9 +108,12 @@ export default defineVxeComponent({
|
|
|
112
108
|
const { treeConfig } = ganttProps;
|
|
113
109
|
const { taskScaleList } = ganttReactData;
|
|
114
110
|
const { minViewDate, maxViewDate } = reactData;
|
|
111
|
+
const { scrollXStore } = internalData;
|
|
115
112
|
const minScale = XEUtils.last(taskScaleList);
|
|
116
113
|
const fullCols = [];
|
|
117
114
|
const groupCols = [];
|
|
115
|
+
scrollXStore.startIndex = 0;
|
|
116
|
+
scrollXStore.endIndex = 1;
|
|
118
117
|
if (minScale && minViewDate && maxViewDate) {
|
|
119
118
|
const minSType = minScale.type;
|
|
120
119
|
const weekScale = taskScaleList.find(item => item.type === 'week');
|
|
@@ -136,37 +135,37 @@ export default defineVxeComponent({
|
|
|
136
135
|
const currTime = minViewDate.getTime();
|
|
137
136
|
const diffDayNum = maxViewDate.getTime() - minViewDate.getTime();
|
|
138
137
|
const countSize = Math.max(5, Math.floor(diffDayNum / gapTime) + 1);
|
|
139
|
-
switch (minScale.type) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
138
|
+
// switch (minScale.type) {
|
|
139
|
+
// case 'day':
|
|
140
|
+
// case 'date':
|
|
141
|
+
// if (diffDayNum > (1000 * 60 * 60 * 24 * 366 * 3)) {
|
|
142
|
+
// reactData.tableColumn = []
|
|
143
|
+
// reactData.headerGroups = []
|
|
144
|
+
// return
|
|
145
|
+
// }
|
|
146
|
+
// break
|
|
147
|
+
// case 'hour':
|
|
148
|
+
// if (diffDayNum > (1000 * 60 * 60 * 24 * 31 * 3)) {
|
|
149
|
+
// reactData.tableColumn = []
|
|
150
|
+
// reactData.headerGroups = []
|
|
151
|
+
// return
|
|
152
|
+
// }
|
|
153
|
+
// break
|
|
154
|
+
// case 'minute':
|
|
155
|
+
// if (diffDayNum > (1000 * 60 * 60 * 24 * 3)) {
|
|
156
|
+
// reactData.tableColumn = []
|
|
157
|
+
// reactData.headerGroups = []
|
|
158
|
+
// return
|
|
159
|
+
// }
|
|
160
|
+
// break
|
|
161
|
+
// case 'second':
|
|
162
|
+
// if (diffDayNum > (1000 * 60 * 60 * 3)) {
|
|
163
|
+
// reactData.tableColumn = []
|
|
164
|
+
// reactData.headerGroups = []
|
|
165
|
+
// return
|
|
166
|
+
// }
|
|
167
|
+
// break
|
|
168
|
+
// }
|
|
170
169
|
const renderListMaps = {
|
|
171
170
|
year: [],
|
|
172
171
|
quarter: [],
|
|
@@ -220,47 +219,47 @@ export default defineVxeComponent({
|
|
|
220
219
|
year: {
|
|
221
220
|
field: yyyy,
|
|
222
221
|
title: yyyy,
|
|
223
|
-
|
|
222
|
+
dateObj
|
|
224
223
|
},
|
|
225
224
|
quarter: {
|
|
226
225
|
field: `${yyyy}_q${q}`,
|
|
227
|
-
title: q
|
|
228
|
-
|
|
226
|
+
title: `${q}`,
|
|
227
|
+
dateObj
|
|
229
228
|
},
|
|
230
229
|
month: {
|
|
231
230
|
field: `${yyyy}_${MM}`,
|
|
232
231
|
title: MM,
|
|
233
|
-
|
|
232
|
+
dateObj
|
|
234
233
|
},
|
|
235
234
|
week: {
|
|
236
235
|
field: `${yyyy}_W${W}`,
|
|
237
|
-
title: W
|
|
238
|
-
|
|
236
|
+
title: `${W}`,
|
|
237
|
+
dateObj
|
|
239
238
|
},
|
|
240
239
|
day: {
|
|
241
240
|
field: `${yyyy}_${MM}_${dd}_E${E}`,
|
|
242
|
-
title: E
|
|
243
|
-
|
|
241
|
+
title: `${E}`,
|
|
242
|
+
dateObj
|
|
244
243
|
},
|
|
245
244
|
date: {
|
|
246
245
|
field: `${yyyy}_${MM}_${dd}`,
|
|
247
246
|
title: dd,
|
|
248
|
-
|
|
247
|
+
dateObj
|
|
249
248
|
},
|
|
250
249
|
hour: {
|
|
251
250
|
field: `${yyyy}_${MM}_${dd}_${HH}`,
|
|
252
251
|
title: HH,
|
|
253
|
-
|
|
252
|
+
dateObj
|
|
254
253
|
},
|
|
255
254
|
minute: {
|
|
256
255
|
field: `${yyyy}_${MM}_${dd}_${HH}_${mm}`,
|
|
257
256
|
title: mm,
|
|
258
|
-
|
|
257
|
+
dateObj
|
|
259
258
|
},
|
|
260
259
|
second: {
|
|
261
260
|
field: `${yyyy}_${MM}_${dd}_${HH}_${mm}_${ss}`,
|
|
262
261
|
title: ss,
|
|
263
|
-
|
|
262
|
+
dateObj
|
|
264
263
|
}
|
|
265
264
|
};
|
|
266
265
|
const minCol = colMaps[minSType];
|
|
@@ -347,8 +346,10 @@ export default defineVxeComponent({
|
|
|
347
346
|
internalData.chartMaps = ctMaps;
|
|
348
347
|
}
|
|
349
348
|
}
|
|
350
|
-
|
|
349
|
+
internalData.visibleColumn = fullCols;
|
|
351
350
|
reactData.headerGroups = groupCols;
|
|
351
|
+
updateScrollXStatus();
|
|
352
|
+
handleTableColumn();
|
|
352
353
|
};
|
|
353
354
|
const handleUpdateData = () => {
|
|
354
355
|
const ganttProps = $xeGantt.props;
|
|
@@ -437,8 +438,8 @@ export default defineVxeComponent({
|
|
|
437
438
|
return nextTick();
|
|
438
439
|
};
|
|
439
440
|
const updateStyle = () => {
|
|
440
|
-
const { scrollbarWidth, scrollbarHeight,
|
|
441
|
-
const { elemStore } = internalData;
|
|
441
|
+
const { scrollbarWidth, scrollbarHeight, headerGroups, tableColumn } = reactData;
|
|
442
|
+
const { elemStore, visibleColumn } = internalData;
|
|
442
443
|
const $xeTable = internalData.xeTable;
|
|
443
444
|
const el = refElem.value;
|
|
444
445
|
if (!el || !el.clientHeight) {
|
|
@@ -519,37 +520,182 @@ export default defineVxeComponent({
|
|
|
519
520
|
yBottomCornerEl.style.display = tFooterHeight ? 'block' : '';
|
|
520
521
|
}
|
|
521
522
|
const colInfoElem = refColInfoElem.value;
|
|
523
|
+
let viewCellWidth = 40;
|
|
522
524
|
if (colInfoElem) {
|
|
523
|
-
|
|
525
|
+
viewCellWidth = colInfoElem.clientWidth || 40;
|
|
524
526
|
}
|
|
525
|
-
let viewTableWidth =
|
|
527
|
+
let viewTableWidth = viewCellWidth * visibleColumn.length;
|
|
526
528
|
if (bodyScrollElem) {
|
|
527
529
|
const viewWidth = bodyScrollElem.clientWidth;
|
|
528
530
|
const remainWidth = viewWidth - viewTableWidth;
|
|
529
531
|
if (remainWidth > 0) {
|
|
530
|
-
|
|
532
|
+
viewCellWidth += Math.floor(remainWidth / visibleColumn.length);
|
|
531
533
|
viewTableWidth = viewWidth;
|
|
532
534
|
}
|
|
533
535
|
}
|
|
536
|
+
reactData.viewCellWidth = viewCellWidth;
|
|
534
537
|
const headerTableElem = getRefElem(elemStore['main-header-table']);
|
|
535
538
|
const bodyTableElem = getRefElem(elemStore['main-body-table']);
|
|
539
|
+
const vmTableWidth = viewCellWidth * tableColumn.length;
|
|
536
540
|
if (headerTableElem) {
|
|
537
541
|
headerTableElem.style.width = `${viewTableWidth}px`;
|
|
538
542
|
}
|
|
539
543
|
if (bodyTableElem) {
|
|
540
|
-
bodyTableElem.style.width = `${
|
|
544
|
+
bodyTableElem.style.width = `${vmTableWidth}px`;
|
|
541
545
|
}
|
|
542
546
|
reactData.scrollXWidth = viewTableWidth;
|
|
543
547
|
return updateChart();
|
|
544
548
|
};
|
|
545
|
-
const
|
|
549
|
+
const handleRecalculateStyle = () => {
|
|
550
|
+
const el = refElem.value;
|
|
551
|
+
internalData.rceRunTime = Date.now();
|
|
552
|
+
if (!el || !el.clientWidth) {
|
|
553
|
+
return nextTick();
|
|
554
|
+
}
|
|
546
555
|
calcScrollbar();
|
|
547
556
|
updateStyle();
|
|
548
557
|
updateChart();
|
|
558
|
+
return computeScrollLoad();
|
|
559
|
+
};
|
|
560
|
+
const handleLazyRecalculate = () => {
|
|
561
|
+
return new Promise(resolve => {
|
|
562
|
+
const { rceTimeout, rceRunTime } = internalData;
|
|
563
|
+
const $xeTable = internalData.xeTable;
|
|
564
|
+
let refreshDelay = 50;
|
|
565
|
+
if ($xeTable) {
|
|
566
|
+
const { computeResizeOpts } = $xeTable.getComputeMaps();
|
|
567
|
+
const resizeOpts = computeResizeOpts.value;
|
|
568
|
+
refreshDelay = resizeOpts.refreshDelay || 50;
|
|
569
|
+
}
|
|
570
|
+
if (rceTimeout) {
|
|
571
|
+
clearTimeout(rceTimeout);
|
|
572
|
+
if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
|
|
573
|
+
resolve(handleRecalculateStyle());
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
nextTick(() => {
|
|
577
|
+
resolve();
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
resolve(handleRecalculateStyle());
|
|
583
|
+
}
|
|
584
|
+
internalData.rceTimeout = setTimeout(() => {
|
|
585
|
+
internalData.rceTimeout = undefined;
|
|
586
|
+
handleRecalculateStyle();
|
|
587
|
+
}, refreshDelay);
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
const computeScrollLoad = () => {
|
|
591
|
+
return nextTick().then(() => {
|
|
592
|
+
const { scrollXLoad } = reactData;
|
|
593
|
+
const { scrollXStore } = internalData;
|
|
594
|
+
// 计算 X 逻辑
|
|
595
|
+
if (scrollXLoad) {
|
|
596
|
+
const { toVisibleIndex: toXVisibleIndex, visibleSize: visibleXSize } = handleVirtualXVisible();
|
|
597
|
+
const offsetXSize = 2;
|
|
598
|
+
scrollXStore.preloadSize = 1;
|
|
599
|
+
scrollXStore.offsetSize = offsetXSize;
|
|
600
|
+
scrollXStore.visibleSize = visibleXSize;
|
|
601
|
+
scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex);
|
|
602
|
+
scrollXStore.visibleStartIndex = Math.max(scrollXStore.startIndex, toXVisibleIndex);
|
|
603
|
+
scrollXStore.visibleEndIndex = Math.min(scrollXStore.endIndex, toXVisibleIndex + visibleXSize);
|
|
604
|
+
updateScrollXData().then(() => {
|
|
605
|
+
loadScrollXData();
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
updateScrollXSpace();
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
const handleVirtualXVisible = () => {
|
|
614
|
+
const { viewCellWidth } = reactData;
|
|
615
|
+
const { elemStore } = internalData;
|
|
616
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
617
|
+
if (bodyScrollElem) {
|
|
618
|
+
const clientWidth = bodyScrollElem.clientWidth;
|
|
619
|
+
const scrollLeft = bodyScrollElem.scrollLeft;
|
|
620
|
+
const toVisibleIndex = Math.floor(scrollLeft / viewCellWidth) - 1;
|
|
621
|
+
const visibleSize = Math.ceil(clientWidth / viewCellWidth) + 1;
|
|
622
|
+
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(1, visibleSize) };
|
|
623
|
+
}
|
|
624
|
+
return { toVisibleIndex: 0, visibleSize: 6 };
|
|
625
|
+
};
|
|
626
|
+
const loadScrollXData = () => {
|
|
627
|
+
const { isScrollXBig } = reactData;
|
|
628
|
+
const { scrollXStore } = internalData;
|
|
629
|
+
const { preloadSize, startIndex, endIndex, offsetSize } = scrollXStore;
|
|
630
|
+
const { toVisibleIndex, visibleSize } = handleVirtualXVisible();
|
|
631
|
+
const offsetItem = {
|
|
632
|
+
startIndex: Math.max(0, isScrollXBig ? toVisibleIndex - 1 : toVisibleIndex - 1 - offsetSize - preloadSize),
|
|
633
|
+
endIndex: isScrollXBig ? toVisibleIndex + visibleSize : toVisibleIndex + visibleSize + offsetSize + preloadSize
|
|
634
|
+
};
|
|
635
|
+
scrollXStore.visibleStartIndex = toVisibleIndex - 1;
|
|
636
|
+
scrollXStore.visibleEndIndex = toVisibleIndex + visibleSize + 1;
|
|
637
|
+
const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem;
|
|
638
|
+
if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
|
|
639
|
+
if (startIndex !== offsetStartIndex || endIndex !== offsetEndIndex) {
|
|
640
|
+
scrollXStore.startIndex = offsetStartIndex;
|
|
641
|
+
scrollXStore.endIndex = offsetEndIndex;
|
|
642
|
+
updateScrollXData();
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
const updateScrollXData = () => {
|
|
647
|
+
handleTableColumn();
|
|
648
|
+
updateScrollXSpace();
|
|
549
649
|
return nextTick();
|
|
550
650
|
};
|
|
551
|
-
|
|
552
|
-
|
|
651
|
+
const updateScrollXStatus = () => {
|
|
652
|
+
const scrollXLoad = true;
|
|
653
|
+
reactData.scrollXLoad = scrollXLoad;
|
|
654
|
+
return scrollXLoad;
|
|
655
|
+
};
|
|
656
|
+
const handleTableColumn = () => {
|
|
657
|
+
const { scrollXLoad } = reactData;
|
|
658
|
+
const { visibleColumn, scrollXStore } = internalData;
|
|
659
|
+
const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
|
|
660
|
+
reactData.tableColumn = tableColumn;
|
|
661
|
+
};
|
|
662
|
+
const updateScrollXSpace = () => {
|
|
663
|
+
const { scrollXLoad, scrollXWidth, viewCellWidth } = reactData;
|
|
664
|
+
const { elemStore, scrollXStore } = internalData;
|
|
665
|
+
const bodyTableElem = getRefElem(elemStore['main-body-table']);
|
|
666
|
+
// const headerTableElem = getRefElem(elemStore['main-header-table'])
|
|
667
|
+
// const footerTableElem = getRefElem(elemStore['main-footer-table'])
|
|
668
|
+
const { startIndex } = scrollXStore;
|
|
669
|
+
let xSpaceLeft = 0;
|
|
670
|
+
if (scrollXLoad) {
|
|
671
|
+
xSpaceLeft = Math.max(0, startIndex * viewCellWidth);
|
|
672
|
+
}
|
|
673
|
+
// if (headerTableElem) {
|
|
674
|
+
// headerTableElem.style.transform = `translate(${xSpaceLeft}px, 0px)`
|
|
675
|
+
// }
|
|
676
|
+
if (bodyTableElem) {
|
|
677
|
+
bodyTableElem.style.transform = `translate(${xSpaceLeft}px, ${reactData.scrollYTop || 0}px)`;
|
|
678
|
+
}
|
|
679
|
+
// if (footerTableElem) {
|
|
680
|
+
// footerTableElem.style.transform = `translate(${xSpaceLeft}px, 0px)`
|
|
681
|
+
// }
|
|
682
|
+
const layoutList = ['header', 'body', 'footer'];
|
|
683
|
+
layoutList.forEach(layout => {
|
|
684
|
+
const xSpaceElem = getRefElem(elemStore[`main-${layout}-xSpace`]);
|
|
685
|
+
if (xSpaceElem) {
|
|
686
|
+
xSpaceElem.style.width = scrollXLoad ? `${scrollXWidth}px` : '';
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
const scrollXSpaceEl = refScrollXSpaceElem.value;
|
|
690
|
+
if (scrollXSpaceEl) {
|
|
691
|
+
scrollXSpaceEl.style.width = `${scrollXWidth}px`;
|
|
692
|
+
}
|
|
693
|
+
calcScrollbar();
|
|
694
|
+
return nextTick();
|
|
695
|
+
};
|
|
696
|
+
const triggerScrollXEvent = () => {
|
|
697
|
+
loadScrollXData();
|
|
698
|
+
};
|
|
553
699
|
const updateScrollYSpace = () => {
|
|
554
700
|
const { elemStore } = internalData;
|
|
555
701
|
const $xeTable = internalData.xeTable;
|
|
@@ -624,6 +770,13 @@ export default defineVxeComponent({
|
|
|
624
770
|
};
|
|
625
771
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
626
772
|
const handleScrollEvent = (evnt, isRollY, isRollX, scrollTop, scrollLeft) => {
|
|
773
|
+
if (isRollX) {
|
|
774
|
+
internalData.lastScrollLeft = scrollLeft;
|
|
775
|
+
}
|
|
776
|
+
if (isRollY) {
|
|
777
|
+
internalData.lastScrollTop = scrollTop;
|
|
778
|
+
}
|
|
779
|
+
reactData.lastScrollTime = Date.now();
|
|
627
780
|
checkLastSyncScroll(isRollX, isRollY);
|
|
628
781
|
};
|
|
629
782
|
const ganttViewMethods = {
|
|
@@ -716,7 +869,8 @@ export default defineVxeComponent({
|
|
|
716
869
|
}
|
|
717
870
|
},
|
|
718
871
|
triggerBodyScrollEvent(evnt) {
|
|
719
|
-
const {
|
|
872
|
+
const { scrollXLoad } = reactData;
|
|
873
|
+
const { elemStore, inVirtualScroll, inHeaderScroll, inFooterScroll, lastScrollLeft, lastScrollTop } = internalData;
|
|
720
874
|
if (inVirtualScroll) {
|
|
721
875
|
return;
|
|
722
876
|
}
|
|
@@ -727,36 +881,44 @@ export default defineVxeComponent({
|
|
|
727
881
|
const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
|
|
728
882
|
const xHandleEl = refScrollXHandleElem.value;
|
|
729
883
|
const yHandleEl = refScrollYHandleElem.value;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
syncTableScrollTop(currTopNum);
|
|
740
|
-
handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
|
|
884
|
+
const scrollLeft = wrapperEl.scrollLeft;
|
|
885
|
+
const scrollTop = wrapperEl.scrollTop;
|
|
886
|
+
const isRollX = scrollLeft !== lastScrollLeft;
|
|
887
|
+
const isRollY = scrollTop !== lastScrollTop;
|
|
888
|
+
internalData.inBodyScroll = true;
|
|
889
|
+
internalData.scrollRenderType = '';
|
|
890
|
+
if (isRollY) {
|
|
891
|
+
setScrollTop(yHandleEl, scrollTop);
|
|
892
|
+
syncTableScrollTop(scrollTop);
|
|
741
893
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
const wrapperEl = evnt.currentTarget;
|
|
752
|
-
if (wrapperEl) {
|
|
753
|
-
const isRollX = true;
|
|
754
|
-
const isRollY = false;
|
|
755
|
-
const currLeftNum = wrapperEl.scrollLeft;
|
|
756
|
-
handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
|
|
894
|
+
if (isRollX) {
|
|
895
|
+
internalData.inBodyScroll = true;
|
|
896
|
+
setScrollLeft(xHandleEl, scrollLeft);
|
|
897
|
+
setScrollLeft(headerScrollElem, scrollLeft);
|
|
898
|
+
if (scrollXLoad) {
|
|
899
|
+
triggerScrollXEvent();
|
|
900
|
+
}
|
|
757
901
|
}
|
|
902
|
+
handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, scrollLeft);
|
|
758
903
|
},
|
|
904
|
+
// triggerFooterScrollEvent (evnt) {
|
|
905
|
+
// const { inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData
|
|
906
|
+
// if (inVirtualScroll) {
|
|
907
|
+
// return
|
|
908
|
+
// }
|
|
909
|
+
// if (inHeaderScroll || inBodyScroll) {
|
|
910
|
+
// return
|
|
911
|
+
// }
|
|
912
|
+
// const wrapperEl = evnt.currentTarget as HTMLDivElement
|
|
913
|
+
// if (wrapperEl) {
|
|
914
|
+
// const isRollX = true
|
|
915
|
+
// const isRollY = false
|
|
916
|
+
// const currLeftNum = wrapperEl.scrollLeft
|
|
917
|
+
// handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum)
|
|
918
|
+
// }
|
|
919
|
+
// },
|
|
759
920
|
triggerVirtualScrollXEvent(evnt) {
|
|
921
|
+
const { scrollXLoad } = reactData;
|
|
760
922
|
const { elemStore, inHeaderScroll, inBodyScroll } = internalData;
|
|
761
923
|
if (inHeaderScroll || inBodyScroll) {
|
|
762
924
|
return;
|
|
@@ -771,6 +933,9 @@ export default defineVxeComponent({
|
|
|
771
933
|
internalData.inVirtualScroll = true;
|
|
772
934
|
setScrollLeft(headerScrollElem, currLeftNum);
|
|
773
935
|
setScrollLeft(bodyScrollElem, currLeftNum);
|
|
936
|
+
if (scrollXLoad) {
|
|
937
|
+
triggerScrollXEvent();
|
|
938
|
+
}
|
|
774
939
|
handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
|
|
775
940
|
}
|
|
776
941
|
},
|
|
@@ -792,23 +957,11 @@ export default defineVxeComponent({
|
|
|
792
957
|
}
|
|
793
958
|
},
|
|
794
959
|
handleUpdateSXSpace() {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
const xSpaceElem = getRefElem(elemStore[`main-${layout}-xSpace`]);
|
|
800
|
-
if (xSpaceElem) {
|
|
801
|
-
xSpaceElem.style.width = scrollXLoad ? `${scrollXWidth}px` : '';
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
const scrollXSpaceEl = refScrollXSpaceElem.value;
|
|
805
|
-
if (scrollXSpaceEl) {
|
|
806
|
-
scrollXSpaceEl.style.width = `${scrollXWidth}px`;
|
|
807
|
-
}
|
|
808
|
-
calcScrollbar();
|
|
809
|
-
return nextTick();
|
|
960
|
+
return updateScrollXSpace();
|
|
961
|
+
},
|
|
962
|
+
handleUpdateSYSpace() {
|
|
963
|
+
return updateScrollYSpace();
|
|
810
964
|
},
|
|
811
|
-
handleUpdateSYSpace: updateScrollYSpace,
|
|
812
965
|
handleUpdateSYStatus(sYLoad) {
|
|
813
966
|
reactData.scrollYLoad = sYLoad;
|
|
814
967
|
}
|