vxe-gantt 0.0.2 → 3.0.0-beta.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.
Files changed (94) hide show
  1. package/README.md +18 -24
  2. package/es/components.js +3 -2
  3. package/es/gantt/src/gantt-body.js +137 -0
  4. package/es/gantt/src/gantt-chart.js +125 -0
  5. package/es/gantt/src/gantt-header.js +97 -0
  6. package/es/gantt/src/gantt-view.js +820 -0
  7. package/es/gantt/src/gantt.js +1897 -43
  8. package/es/gantt/src/util.js +9 -0
  9. package/es/gantt/style.css +624 -0
  10. package/es/gantt/style.min.css +1 -0
  11. package/es/index.esm.js +5 -2
  12. package/es/style.css +1 -0
  13. package/es/style.min.css +1 -0
  14. package/es/ui/index.js +55 -5
  15. package/es/ui/src/comp.js +1 -2
  16. package/es/ui/src/dom.js +44 -105
  17. package/es/ui/src/log.js +3 -2
  18. package/es/ui/src/utils.js +4 -3
  19. package/es/ui/src/vn.js +1 -32
  20. package/es/vxe-gantt/style.css +624 -0
  21. package/es/vxe-gantt/style.min.css +1 -0
  22. package/helper/vetur/attributes.json +1 -1
  23. package/helper/vetur/tags.json +1 -1
  24. package/lib/components.js +20 -19
  25. package/lib/components.min.js +1 -1
  26. package/lib/gantt/index.js +3 -3
  27. package/lib/gantt/index.min.js +1 -1
  28. package/lib/gantt/src/gantt-body.js +140 -0
  29. package/lib/gantt/src/gantt-body.min.js +1 -0
  30. package/lib/gantt/src/gantt-chart.js +134 -0
  31. package/lib/gantt/src/gantt-chart.min.js +1 -0
  32. package/lib/gantt/src/gantt-header.js +97 -0
  33. package/lib/gantt/src/gantt-header.min.js +1 -0
  34. package/lib/gantt/src/gantt-view.js +808 -0
  35. package/lib/gantt/src/gantt-view.min.js +1 -0
  36. package/lib/gantt/src/gantt.js +2045 -48
  37. package/lib/gantt/src/gantt.min.js +1 -1
  38. package/lib/gantt/src/util.js +16 -0
  39. package/lib/gantt/src/util.min.js +1 -0
  40. package/lib/gantt/style/style.css +624 -0
  41. package/lib/gantt/style/style.min.css +1 -0
  42. package/lib/index.common.js +12 -7
  43. package/lib/index.umd.js +11484 -235
  44. package/lib/index.umd.min.js +1 -1
  45. package/lib/style.css +1 -0
  46. package/lib/style.min.css +1 -0
  47. package/lib/ui/index.js +54 -14
  48. package/lib/ui/index.min.js +1 -1
  49. package/lib/ui/src/comp.js +3 -2
  50. package/lib/ui/src/comp.min.js +1 -1
  51. package/lib/ui/src/dom.js +78 -138
  52. package/lib/ui/src/dom.min.js +1 -1
  53. package/lib/ui/src/log.js +4 -3
  54. package/lib/ui/src/log.min.js +1 -1
  55. package/lib/ui/src/utils.js +5 -4
  56. package/lib/ui/src/utils.min.js +1 -1
  57. package/lib/ui/src/vn.js +1 -43
  58. package/lib/ui/src/vn.min.js +0 -1
  59. package/lib/vxe-gantt/index.js +4 -2
  60. package/lib/vxe-gantt/index.min.js +1 -1
  61. package/lib/vxe-gantt/style/style.css +624 -0
  62. package/lib/vxe-gantt/style/style.min.css +1 -0
  63. package/lib/vxe-ui/index.js +4 -2
  64. package/lib/vxe-ui/index.min.js +1 -1
  65. package/package.json +13 -13
  66. package/packages/components.ts +8 -5
  67. package/packages/gantt/index.ts +2 -2
  68. package/packages/gantt/src/gantt-body.ts +155 -0
  69. package/packages/gantt/src/gantt-chart.ts +143 -0
  70. package/packages/gantt/src/gantt-header.ts +109 -0
  71. package/packages/gantt/src/gantt-view.ts +908 -0
  72. package/packages/gantt/src/gantt.ts +2048 -46
  73. package/packages/gantt/src/util.ts +12 -0
  74. package/packages/index.ts +6 -2
  75. package/packages/ui/index.ts +56 -4
  76. package/packages/ui/src/comp.ts +2 -2
  77. package/packages/ui/src/dom.ts +53 -110
  78. package/packages/ui/src/log.ts +4 -2
  79. package/packages/ui/src/utils.ts +5 -3
  80. package/packages/ui/src/vn.ts +0 -37
  81. package/styles/components/gantt-module/all.scss +1 -0
  82. package/styles/components/gantt-module/gantt-chart.scss +65 -0
  83. package/styles/components/gantt.scss +591 -0
  84. package/styles/helpers/baseMixin.scss +96 -0
  85. package/styles/helpers/baseVar.scss +4 -0
  86. package/styles/helpers/placement.scss +39 -0
  87. package/styles/theme/base.scss +11 -0
  88. package/styles/theme/dark.scss +5 -0
  89. package/styles/theme/light.scss +5 -0
  90. package/types/all.d.ts +3 -3
  91. package/types/index.d.ts +2 -2
  92. package/README.en.md +0 -72
  93. package/README.ja-JP.md +0 -72
  94. package/README.zh-TW.md +0 -73
@@ -0,0 +1,820 @@
1
+ import { defineVxeComponent } from '../../ui/src/comp';
2
+ import { VxeUI } from '@vxe-ui/core';
3
+ import { setScrollTop, setScrollLeft } from '../../ui/src/dom';
4
+ import { getRefElem } from './util';
5
+ import XEUtils from 'xe-utils';
6
+ import GanttViewHeaderComponent from './gantt-header';
7
+ import GanttViewBodyComponent from './gantt-body';
8
+ const { globalEvents } = VxeUI;
9
+ function createInternalData() {
10
+ return {
11
+ xeTable: null,
12
+ startMaps: {},
13
+ endMaps: {},
14
+ chartMaps: {},
15
+ elemStore: {},
16
+ // 存放横向 X 虚拟滚动相关的信息
17
+ scrollXStore: {
18
+ preloadSize: 0,
19
+ offsetSize: 0,
20
+ visibleSize: 0,
21
+ visibleStartIndex: 0,
22
+ visibleEndIndex: 0,
23
+ startIndex: 0,
24
+ endIndex: 0
25
+ },
26
+ // 存放纵向 Y 虚拟滚动相关信息
27
+ scrollYStore: {
28
+ preloadSize: 0,
29
+ offsetSize: 0,
30
+ visibleSize: 0,
31
+ visibleStartIndex: 0,
32
+ visibleEndIndex: 0,
33
+ startIndex: 0,
34
+ endIndex: 0
35
+ }
36
+ };
37
+ }
38
+ const maxYHeight = 5e6;
39
+ const maxXWidth = 5e6;
40
+ function handleParseColumn($xeGanttView) {
41
+ const $xeGantt = $xeGanttView.$xeGantt;
42
+ const reactData = $xeGanttView.reactData;
43
+ const internalData = $xeGanttView.internalData;
44
+ const { minViewDate, maxViewDate } = reactData;
45
+ const taskViewOpts = $xeGantt.computeTaskViewOpts;
46
+ const fullCols = [];
47
+ const groupCols = [];
48
+ switch (taskViewOpts.mode) {
49
+ case 'year':
50
+ break;
51
+ case 'quarter':
52
+ break;
53
+ case 'month':
54
+ break;
55
+ case 'week':
56
+ break;
57
+ default: {
58
+ if (minViewDate && maxViewDate) {
59
+ const currTime = minViewDate.getTime();
60
+ const diffDayNum = maxViewDate.getTime() - minViewDate.getTime();
61
+ const countDayNum = Math.max(6, Math.floor(diffDayNum / 86400000) + 1);
62
+ const groupList = [];
63
+ const colList = [];
64
+ const groupMaps = {};
65
+ for (let i = 0; i < countDayNum; i++) {
66
+ const itemDate = new Date(currTime + (i * 86400000));
67
+ const yyyyy = `${itemDate.getFullYear()}-${itemDate.getMonth() + 1}`;
68
+ const mmDd = `${itemDate.getDate()}`;
69
+ let groupCol = groupMaps[yyyyy];
70
+ const column = {
71
+ field: `${yyyyy}-${mmDd}`,
72
+ title: mmDd
73
+ };
74
+ if (groupCol) {
75
+ groupCol.children.push(column);
76
+ fullCols.push(groupCol);
77
+ }
78
+ else {
79
+ groupCol = {
80
+ field: yyyyy,
81
+ title: yyyyy,
82
+ children: [column]
83
+ };
84
+ groupList.push(groupCol);
85
+ fullCols.push(groupCol);
86
+ groupMaps[yyyyy] = groupCol;
87
+ }
88
+ colList.push(column);
89
+ }
90
+ groupCols.push(groupList, colList);
91
+ const $xeTable = internalData.xeTable;
92
+ if ($xeTable) {
93
+ const startField = $xeGantt.computeStartField;
94
+ const endField = $xeGantt.computeEndField;
95
+ const tableInternalData = $xeTable;
96
+ const { afterFullData } = tableInternalData;
97
+ const ctMaps = {};
98
+ afterFullData.forEach(row => {
99
+ const rowid = $xeTable.getRowid(row);
100
+ const startValue = XEUtils.get(row, startField);
101
+ const endValue = XEUtils.get(row, endField);
102
+ if (startValue && endValue) {
103
+ const startDate = XEUtils.toStringDate(startValue);
104
+ const endDate = XEUtils.toStringDate(endValue);
105
+ const oLeftSize = Math.floor((startDate.getTime() - minViewDate.getTime()) / 86400000);
106
+ const oWidthSize = Math.floor((endDate.getTime() - startDate.getTime()) / 86400000) + 1;
107
+ ctMaps[rowid] = {
108
+ row,
109
+ rowid,
110
+ oLeftSize,
111
+ oWidthSize
112
+ };
113
+ }
114
+ });
115
+ internalData.chartMaps = ctMaps;
116
+ }
117
+ }
118
+ break;
119
+ }
120
+ }
121
+ reactData.tableColumn = fullCols;
122
+ reactData.headerGroups = groupCols;
123
+ }
124
+ function handleUpdateData($xeGanttView) {
125
+ const $xeGantt = $xeGanttView.$xeGantt;
126
+ const reactData = $xeGanttView.reactData;
127
+ const internalData = $xeGanttView.internalData;
128
+ const $xeTable = internalData.xeTable;
129
+ const sdMaps = {};
130
+ const edMaps = {};
131
+ let minDate = null;
132
+ let maxDate = null;
133
+ if ($xeTable) {
134
+ const startField = $xeGantt.computeStartField;
135
+ const endField = $xeGantt.computeEndField;
136
+ const tableInternalData = $xeTable;
137
+ const { afterFullData } = tableInternalData;
138
+ afterFullData.forEach(row => {
139
+ const startValue = XEUtils.get(row, startField);
140
+ const endValue = XEUtils.get(row, endField);
141
+ if (startValue && endValue) {
142
+ const startDate = XEUtils.toStringDate(startValue);
143
+ if (!minDate || minDate.getTime() > startDate.getTime()) {
144
+ minDate = startDate;
145
+ }
146
+ const endDate = XEUtils.toStringDate(endValue);
147
+ if (!maxDate || maxDate.getTime() < endDate.getTime()) {
148
+ maxDate = endDate;
149
+ }
150
+ }
151
+ });
152
+ }
153
+ reactData.minViewDate = minDate;
154
+ reactData.maxViewDate = maxDate;
155
+ internalData.startMaps = sdMaps;
156
+ internalData.endMaps = edMaps;
157
+ handleParseColumn($xeGanttView);
158
+ }
159
+ function calcScrollbar($xeGanttView) {
160
+ const $xeGantt = $xeGanttView.$xeGantt;
161
+ const reactData = $xeGanttView.reactData;
162
+ const internalData = $xeGanttView.internalData;
163
+ const { scrollXWidth, scrollYHeight } = reactData;
164
+ const { elemStore } = internalData;
165
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
166
+ const bodyWrapperElem = getRefElem(elemStore['main-body-wrapper']);
167
+ const xHandleEl = $xeGanttView.$refs.refScrollXHandleElem;
168
+ const yHandleEl = $xeGanttView.$refs.refScrollYHandleElem;
169
+ let overflowY = false;
170
+ let overflowX = false;
171
+ if (bodyWrapperElem) {
172
+ overflowY = scrollYHeight > bodyWrapperElem.clientHeight;
173
+ if (yHandleEl) {
174
+ reactData.scrollbarWidth = scrollbarOpts.width || (yHandleEl.offsetWidth - yHandleEl.clientWidth) || 14;
175
+ }
176
+ reactData.overflowY = overflowY;
177
+ overflowX = scrollXWidth > bodyWrapperElem.clientWidth;
178
+ if (xHandleEl) {
179
+ reactData.scrollbarHeight = scrollbarOpts.height || (xHandleEl.offsetHeight - xHandleEl.clientHeight) || 14;
180
+ }
181
+ reactData.overflowX = overflowX;
182
+ }
183
+ }
184
+ function updateChart($xeGanttView) {
185
+ const reactData = $xeGanttView.reactData;
186
+ const internalData = $xeGanttView.internalData;
187
+ const { viewCellWidth } = reactData;
188
+ const { elemStore, chartMaps } = internalData;
189
+ const chartWrapper = getRefElem(elemStore['main-chart-wrapper']);
190
+ if (chartWrapper) {
191
+ XEUtils.arrayEach(chartWrapper.children, (rowEl) => {
192
+ const barEl = rowEl.children[0];
193
+ if (!barEl) {
194
+ return;
195
+ }
196
+ const rowid = rowEl.getAttribute('rowid');
197
+ const rowRest = rowid ? chartMaps[rowid] : null;
198
+ if (rowRest) {
199
+ barEl.style.left = `${viewCellWidth * rowRest.oLeftSize}px`;
200
+ barEl.style.width = `${viewCellWidth * rowRest.oWidthSize}px`;
201
+ }
202
+ });
203
+ }
204
+ return $xeGanttView.$nextTick();
205
+ }
206
+ function updateStyle($xeGanttView) {
207
+ const $xeGantt = $xeGanttView.$xeGantt;
208
+ const reactData = $xeGanttView.reactData;
209
+ const internalData = $xeGanttView.internalData;
210
+ const { scrollbarWidth, scrollbarHeight, tableColumn } = reactData;
211
+ const { elemStore } = internalData;
212
+ const $xeTable = internalData.xeTable;
213
+ const el = $xeGanttView.$refs.refElem;
214
+ if (!el || !el.clientHeight) {
215
+ return;
216
+ }
217
+ const scrollbarXToTop = $xeGantt.computeScrollbarXToTop;
218
+ const xLeftCornerEl = $xeGanttView.$refs.refScrollXLeftCornerElem;
219
+ const xRightCornerEl = $xeGanttView.$refs.refScrollXRightCornerElem;
220
+ const scrollXVirtualEl = $xeGanttView.$refs.refScrollXVirtualElem;
221
+ const osbWidth = scrollbarWidth;
222
+ const osbHeight = scrollbarHeight;
223
+ let tbHeight = 0;
224
+ let tHeaderHeight = 0;
225
+ let tFooterHeight = 0;
226
+ if ($xeTable) {
227
+ const tableInternalData = $xeTable;
228
+ tbHeight = tableInternalData.tBodyHeight;
229
+ tHeaderHeight = tableInternalData.tHeaderHeight;
230
+ tFooterHeight = tableInternalData.tFooterHeight;
231
+ }
232
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
233
+ if (headerScrollElem) {
234
+ headerScrollElem.style.height = `${tHeaderHeight}px`;
235
+ }
236
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
237
+ if (bodyScrollElem) {
238
+ bodyScrollElem.style.height = `${tbHeight}px`;
239
+ }
240
+ if (scrollXVirtualEl) {
241
+ scrollXVirtualEl.style.height = `${osbHeight}px`;
242
+ scrollXVirtualEl.style.visibility = 'visible';
243
+ }
244
+ const xWrapperEl = $xeGanttView.$refs.refScrollXWrapperElem;
245
+ if (xWrapperEl) {
246
+ xWrapperEl.style.left = scrollbarXToTop ? `${osbWidth}px` : '';
247
+ xWrapperEl.style.width = `${el.clientWidth - osbWidth}px`;
248
+ }
249
+ if (xLeftCornerEl) {
250
+ xLeftCornerEl.style.width = scrollbarXToTop ? `${osbWidth}px` : '';
251
+ xLeftCornerEl.style.display = scrollbarXToTop ? (osbHeight ? 'block' : '') : '';
252
+ }
253
+ if (xRightCornerEl) {
254
+ xRightCornerEl.style.width = scrollbarXToTop ? '' : `${osbWidth}px`;
255
+ xRightCornerEl.style.display = scrollbarXToTop ? '' : (osbHeight ? 'block' : '');
256
+ }
257
+ const scrollYVirtualEl = $xeGanttView.$refs.refScrollYVirtualElem;
258
+ if (scrollYVirtualEl) {
259
+ scrollYVirtualEl.style.width = `${osbWidth}px`;
260
+ scrollYVirtualEl.style.height = `${tbHeight + tHeaderHeight + tFooterHeight}px`;
261
+ scrollYVirtualEl.style.visibility = 'visible';
262
+ }
263
+ const yTopCornerEl = $xeGanttView.$refs.refScrollYTopCornerElem;
264
+ if (yTopCornerEl) {
265
+ yTopCornerEl.style.height = `${tHeaderHeight}px`;
266
+ yTopCornerEl.style.display = tHeaderHeight ? 'block' : '';
267
+ }
268
+ const yWrapperEl = $xeGanttView.$refs.refScrollYWrapperElem;
269
+ if (yWrapperEl) {
270
+ yWrapperEl.style.height = `${tbHeight}px`;
271
+ yWrapperEl.style.top = `${tHeaderHeight}px`;
272
+ }
273
+ const yBottomCornerEl = $xeGanttView.$refs.refScrollYBottomCornerElem;
274
+ if (yBottomCornerEl) {
275
+ yBottomCornerEl.style.height = `${tFooterHeight}px`;
276
+ yBottomCornerEl.style.top = `${tHeaderHeight + tbHeight}px`;
277
+ yBottomCornerEl.style.display = tFooterHeight ? 'block' : '';
278
+ }
279
+ const colInfoElem = $xeGanttView.$refs.refColInfoElem;
280
+ if (colInfoElem) {
281
+ reactData.viewCellWidth = colInfoElem.clientWidth || 40;
282
+ }
283
+ let viewTableWidth = reactData.viewCellWidth * tableColumn.length;
284
+ if (bodyScrollElem) {
285
+ const viewWidth = bodyScrollElem.clientWidth;
286
+ const remainWidth = viewWidth - viewTableWidth;
287
+ if (remainWidth > 0) {
288
+ reactData.viewCellWidth += Math.floor(remainWidth / tableColumn.length);
289
+ viewTableWidth = viewWidth;
290
+ }
291
+ }
292
+ const headerTableElem = getRefElem(elemStore['main-header-table']);
293
+ const bodyTableElem = getRefElem(elemStore['main-body-table']);
294
+ if (headerTableElem) {
295
+ headerTableElem.style.width = `${viewTableWidth}px`;
296
+ }
297
+ if (bodyTableElem) {
298
+ bodyTableElem.style.width = `${viewTableWidth}px`;
299
+ }
300
+ reactData.scrollXWidth = viewTableWidth;
301
+ return updateChart($xeGanttView);
302
+ }
303
+ function handleLazyRecalculate($xeGanttView) {
304
+ calcScrollbar($xeGanttView);
305
+ updateStyle($xeGanttView);
306
+ return $xeGanttView.$nextTick();
307
+ }
308
+ function updateScrollXSpace($xeGanttView) {
309
+ const reactData = $xeGanttView.reactData;
310
+ const internalData = $xeGanttView.internalData;
311
+ const { scrollXLoad, scrollXWidth } = reactData;
312
+ const { elemStore } = internalData;
313
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
314
+ const bodyTableElem = getRefElem(elemStore['main-body-table']);
315
+ let xSpaceLeft = 0;
316
+ let clientWidth = 0;
317
+ if (bodyScrollElem) {
318
+ clientWidth = bodyScrollElem.clientWidth;
319
+ }
320
+ // 虚拟渲染
321
+ let isScrollXBig = false;
322
+ let ySpaceWidth = scrollXWidth;
323
+ if (scrollXWidth > maxXWidth) {
324
+ // 触右
325
+ if (bodyScrollElem && bodyTableElem && bodyScrollElem.scrollLeft + clientWidth >= maxXWidth) {
326
+ xSpaceLeft = maxXWidth - bodyTableElem.clientWidth;
327
+ }
328
+ else {
329
+ xSpaceLeft = (maxXWidth - clientWidth) * (xSpaceLeft / (scrollXWidth - clientWidth));
330
+ }
331
+ ySpaceWidth = maxXWidth;
332
+ isScrollXBig = true;
333
+ }
334
+ if (bodyTableElem) {
335
+ bodyTableElem.style.transform = `translate(${xSpaceLeft}px, ${reactData.scrollYTop || 0}px)`;
336
+ }
337
+ const layoutList = ['header', 'body', 'footer'];
338
+ layoutList.forEach(layout => {
339
+ const xSpaceElem = getRefElem(elemStore[`main-${layout}-xSpace`]);
340
+ if (xSpaceElem) {
341
+ xSpaceElem.style.width = scrollXLoad ? `${ySpaceWidth}px` : '';
342
+ }
343
+ });
344
+ reactData.scrollXLeft = xSpaceLeft;
345
+ reactData.scrollXWidth = ySpaceWidth;
346
+ reactData.isScrollXBig = isScrollXBig;
347
+ const scrollXSpaceEl = $xeGanttView.$refs.refScrollXSpaceElem;
348
+ if (scrollXSpaceEl) {
349
+ scrollXSpaceEl.style.width = `${ySpaceWidth}px`;
350
+ }
351
+ calcScrollbar($xeGanttView);
352
+ return $xeGanttView.$nextTick().then(() => {
353
+ updateStyle($xeGanttView);
354
+ });
355
+ }
356
+ function updateScrollYSpace($xeGanttView) {
357
+ const reactData = $xeGanttView.reactData;
358
+ const internalData = $xeGanttView.internalData;
359
+ const { scrollYLoad, overflowY } = reactData;
360
+ const { elemStore } = internalData;
361
+ const $xeTable = internalData.xeTable;
362
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
363
+ const bodyTableElem = getRefElem(elemStore['main-body-table']);
364
+ let ySpaceTop = 0;
365
+ let scrollYHeight = 0;
366
+ let isScrollYBig = false;
367
+ if ($xeTable) {
368
+ const tableReactData = $xeTable;
369
+ ySpaceTop = tableReactData.scrollYTop;
370
+ scrollYHeight = tableReactData.scrollYHeight;
371
+ isScrollYBig = tableReactData.isScrollYBig;
372
+ }
373
+ let ySpaceHeight = scrollYHeight;
374
+ let scrollYTop = ySpaceTop;
375
+ let clientHeight = 0;
376
+ if (bodyScrollElem) {
377
+ clientHeight = bodyScrollElem.clientHeight;
378
+ }
379
+ if (isScrollYBig) {
380
+ // 触底
381
+ if (bodyScrollElem && bodyTableElem && bodyScrollElem.scrollTop + clientHeight >= maxYHeight) {
382
+ scrollYTop = maxYHeight - bodyTableElem.clientHeight;
383
+ }
384
+ else {
385
+ scrollYTop = (maxYHeight - clientHeight) * (ySpaceTop / (scrollYHeight - clientHeight));
386
+ }
387
+ ySpaceHeight = maxYHeight;
388
+ }
389
+ if (!(scrollYLoad && overflowY)) {
390
+ scrollYTop = 0;
391
+ }
392
+ if (bodyTableElem) {
393
+ bodyTableElem.style.transform = `translate(${reactData.scrollXLeft || 0}px, ${scrollYTop}px)`;
394
+ }
395
+ const layoutList = ['header', 'body', 'footer'];
396
+ layoutList.forEach(layout => {
397
+ const ySpaceElem = getRefElem(elemStore[`main-${layout}-ySpace`]);
398
+ if (ySpaceElem) {
399
+ ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
400
+ }
401
+ });
402
+ const scrollYSpaceEl = $xeGanttView.$refs.refScrollYSpaceElem;
403
+ if (scrollYSpaceEl) {
404
+ scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
405
+ }
406
+ reactData.scrollYTop = scrollYTop;
407
+ reactData.scrollYHeight = scrollYHeight;
408
+ reactData.isScrollYBig = isScrollYBig;
409
+ calcScrollbar($xeGanttView);
410
+ return $xeGanttView.$nextTick().then(() => {
411
+ updateStyle($xeGanttView);
412
+ });
413
+ }
414
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
415
+ function checkLastSyncScroll($xeGanttView, isRollX, isRollY) {
416
+ const reactData = $xeGanttView.reactData;
417
+ const internalData = $xeGanttView.internalData;
418
+ const { lcsTimeout } = internalData;
419
+ reactData.lazScrollLoading = true;
420
+ if (lcsTimeout) {
421
+ clearTimeout(lcsTimeout);
422
+ }
423
+ internalData.lcsTimeout = setTimeout(() => {
424
+ internalData.lcsRunTime = Date.now();
425
+ internalData.lcsTimeout = undefined;
426
+ internalData.intoRunScroll = false;
427
+ internalData.inVirtualScroll = false;
428
+ internalData.inWheelScroll = false;
429
+ internalData.inHeaderScroll = false;
430
+ internalData.inBodyScroll = false;
431
+ internalData.inFooterScroll = false;
432
+ reactData.lazScrollLoading = false;
433
+ }, 200);
434
+ }
435
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
436
+ function handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, scrollTop, scrollLeft) {
437
+ checkLastSyncScroll($xeGanttView, isRollX, isRollY);
438
+ }
439
+ /**
440
+ * 同步表格滚动
441
+ */
442
+ function syncTableScrollTop($xeGanttView, scrollTop) {
443
+ const internalData = $xeGanttView.internalData;
444
+ const $xeTable = internalData.xeTable;
445
+ if ($xeTable) {
446
+ const tableInternalData = $xeTable;
447
+ const { elemStore: tableElemStore } = tableInternalData;
448
+ const tableBodyScrollElem = getRefElem(tableElemStore['main-body-scroll']);
449
+ if (tableBodyScrollElem) {
450
+ tableBodyScrollElem.scrollTop = scrollTop;
451
+ }
452
+ }
453
+ }
454
+ export default defineVxeComponent({
455
+ name: 'VxeGanttView',
456
+ inject: {
457
+ $xeGantt: {
458
+ default: null
459
+ }
460
+ },
461
+ provide() {
462
+ const $xeGanttView = this;
463
+ return {
464
+ $xeGanttView
465
+ };
466
+ },
467
+ props: {},
468
+ data() {
469
+ const xID = XEUtils.uniqueId();
470
+ const reactData = {
471
+ // 是否启用了横向 X 可视渲染方式加载
472
+ scrollXLoad: false,
473
+ // 是否启用了纵向 Y 可视渲染方式加载
474
+ scrollYLoad: false,
475
+ // 是否存在纵向滚动条
476
+ overflowY: false,
477
+ // 是否存在横向滚动条
478
+ overflowX: false,
479
+ // 纵向滚动条的宽度
480
+ scrollbarWidth: 0,
481
+ // 横向滚动条的高度
482
+ scrollbarHeight: 0,
483
+ lazScrollLoading: false,
484
+ scrollVMLoading: false,
485
+ scrollYHeight: 0,
486
+ scrollYTop: 0,
487
+ isScrollYBig: false,
488
+ scrollXLeft: 0,
489
+ scrollXWidth: 0,
490
+ isScrollXBig: false,
491
+ minViewDate: null,
492
+ maxViewDate: null,
493
+ tableData: [],
494
+ tableColumn: [],
495
+ headerGroups: [],
496
+ viewCellWidth: 40,
497
+ rowHeightStore: {
498
+ large: 52,
499
+ default: 48,
500
+ medium: 44,
501
+ small: 40,
502
+ mini: 36
503
+ }
504
+ };
505
+ const internalData = createInternalData();
506
+ return {
507
+ xID,
508
+ reactData,
509
+ internalData
510
+ };
511
+ },
512
+ computed: Object.assign({}, {}),
513
+ methods: {
514
+ //
515
+ // Method
516
+ //
517
+ refreshData() {
518
+ const $xeGanttView = this;
519
+ handleUpdateData($xeGanttView);
520
+ return handleLazyRecalculate($xeGanttView);
521
+ },
522
+ updateViewData() {
523
+ const $xeGanttView = this;
524
+ const reactData = $xeGanttView.reactData;
525
+ const internalData = $xeGanttView.internalData;
526
+ const $xeTable = internalData.xeTable;
527
+ if ($xeTable) {
528
+ const tableReactData = $xeTable;
529
+ const { tableData } = tableReactData;
530
+ reactData.tableData = tableData;
531
+ }
532
+ return $xeGanttView.$nextTick();
533
+ },
534
+ connectUpdate({ $table }) {
535
+ const $xeGanttView = this;
536
+ const internalData = $xeGanttView.internalData;
537
+ if ($table) {
538
+ internalData.xeTable = $table;
539
+ }
540
+ return $xeGanttView.$nextTick();
541
+ },
542
+ handleUpdateStyle() {
543
+ const $xeGanttView = this;
544
+ return updateStyle($xeGanttView);
545
+ },
546
+ handleLazyRecalculate() {
547
+ const $xeGanttView = this;
548
+ return handleLazyRecalculate($xeGanttView);
549
+ },
550
+ triggerHeaderScrollEvent(evnt) {
551
+ const $xeGanttView = this;
552
+ const internalData = $xeGanttView.internalData;
553
+ const { elemStore, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData;
554
+ if (inVirtualScroll) {
555
+ return;
556
+ }
557
+ if (inBodyScroll || inFooterScroll) {
558
+ return;
559
+ }
560
+ const wrapperEl = evnt.currentTarget;
561
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
562
+ const xHandleEl = $xeGanttView.$refs.refScrollXHandleElem;
563
+ if (bodyScrollElem && wrapperEl) {
564
+ const isRollX = true;
565
+ const isRollY = false;
566
+ const currLeftNum = wrapperEl.scrollLeft;
567
+ internalData.inHeaderScroll = true;
568
+ setScrollLeft(xHandleEl, currLeftNum);
569
+ setScrollLeft(bodyScrollElem, currLeftNum);
570
+ handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
571
+ }
572
+ },
573
+ triggerBodyScrollEvent(evnt) {
574
+ const $xeGanttView = this;
575
+ const internalData = $xeGanttView.internalData;
576
+ const { elemStore, inVirtualScroll, inHeaderScroll, inFooterScroll } = internalData;
577
+ if (inVirtualScroll) {
578
+ return;
579
+ }
580
+ if (inHeaderScroll || inFooterScroll) {
581
+ return;
582
+ }
583
+ const wrapperEl = evnt.currentTarget;
584
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
585
+ const xHandleEl = $xeGanttView.$refs.refScrollXHandleElem;
586
+ const yHandleEl = $xeGanttView.$refs.refScrollYHandleElem;
587
+ if (headerScrollElem && wrapperEl) {
588
+ const isRollX = true;
589
+ const isRollY = true;
590
+ const currLeftNum = wrapperEl.scrollLeft;
591
+ const currTopNum = wrapperEl.scrollTop;
592
+ internalData.inBodyScroll = true;
593
+ setScrollLeft(xHandleEl, currLeftNum);
594
+ setScrollLeft(headerScrollElem, currLeftNum);
595
+ setScrollTop(yHandleEl, currTopNum);
596
+ syncTableScrollTop($xeGanttView, currTopNum);
597
+ handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
598
+ }
599
+ },
600
+ triggerFooterScrollEvent(evnt) {
601
+ const $xeGanttView = this;
602
+ const internalData = $xeGanttView.internalData;
603
+ const { inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData;
604
+ if (inVirtualScroll) {
605
+ return;
606
+ }
607
+ if (inHeaderScroll || inBodyScroll) {
608
+ return;
609
+ }
610
+ const wrapperEl = evnt.currentTarget;
611
+ if (wrapperEl) {
612
+ const isRollX = true;
613
+ const isRollY = false;
614
+ const currLeftNum = wrapperEl.scrollLeft;
615
+ handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
616
+ }
617
+ },
618
+ triggerVirtualScrollXEvent(evnt) {
619
+ const $xeGanttView = this;
620
+ const internalData = $xeGanttView.internalData;
621
+ const { elemStore, inHeaderScroll, inBodyScroll } = internalData;
622
+ if (inHeaderScroll || inBodyScroll) {
623
+ return;
624
+ }
625
+ const wrapperEl = evnt.currentTarget;
626
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
627
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
628
+ if (wrapperEl) {
629
+ const isRollY = false;
630
+ const isRollX = true;
631
+ const currLeftNum = wrapperEl.scrollLeft;
632
+ internalData.inVirtualScroll = true;
633
+ setScrollLeft(headerScrollElem, currLeftNum);
634
+ setScrollLeft(bodyScrollElem, currLeftNum);
635
+ handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
636
+ }
637
+ },
638
+ triggerVirtualScrollYEvent(evnt) {
639
+ const $xeGanttView = this;
640
+ const internalData = $xeGanttView.internalData;
641
+ const { elemStore, inHeaderScroll, inBodyScroll } = internalData;
642
+ if (inHeaderScroll || inBodyScroll) {
643
+ return;
644
+ }
645
+ const wrapperEl = evnt.currentTarget;
646
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
647
+ if (wrapperEl) {
648
+ const isRollY = true;
649
+ const isRollX = false;
650
+ const currTopNum = wrapperEl.scrollTop;
651
+ internalData.inVirtualScroll = true;
652
+ setScrollTop(bodyScrollElem, currTopNum);
653
+ syncTableScrollTop($xeGanttView, currTopNum);
654
+ handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, currTopNum, wrapperEl.scrollLeft);
655
+ }
656
+ },
657
+ updateScrollXSpace() {
658
+ const $xeGanttView = this;
659
+ return updateScrollXSpace($xeGanttView);
660
+ },
661
+ updateScrollYSpace() {
662
+ const $xeGanttView = this;
663
+ return updateScrollYSpace($xeGanttView);
664
+ },
665
+ handleGlobalResizeEvent() {
666
+ const $xeGanttView = this;
667
+ handleLazyRecalculate($xeGanttView);
668
+ },
669
+ //
670
+ // Render
671
+ //
672
+ renderScrollX(h) {
673
+ const $xeGanttView = this;
674
+ return h('div', {
675
+ key: 'vsx',
676
+ ref: 'refScrollXVirtualElem',
677
+ class: 'vxe-gantt-view--scroll-x-virtual'
678
+ }, [
679
+ h('div', {
680
+ ref: 'refScrollXLeftCornerElem',
681
+ class: 'vxe-gantt-view--scroll-x-left-corner'
682
+ }),
683
+ h('div', {
684
+ ref: 'refScrollXWrapperElem',
685
+ class: 'vxe-gantt-view--scroll-x-wrapper'
686
+ }, [
687
+ h('div', {
688
+ ref: 'refScrollXHandleElem',
689
+ class: 'vxe-gantt-view--scroll-x-handle',
690
+ on: {
691
+ scroll: $xeGanttView.triggerVirtualScrollXEvent
692
+ }
693
+ }, [
694
+ h('div', {
695
+ ref: 'refScrollXSpaceElem',
696
+ class: 'vxe-gantt-view--scroll-x-space'
697
+ })
698
+ ])
699
+ ]),
700
+ h('div', {
701
+ ref: 'refScrollXRightCornerElem',
702
+ class: 'vxe-gantt-view--scroll-x-right-corner'
703
+ })
704
+ ]);
705
+ },
706
+ renderScrollY(h) {
707
+ const $xeGanttView = this;
708
+ return h('div', {
709
+ ref: 'refScrollYVirtualElem',
710
+ class: 'vxe-gantt-view--scroll-y-virtual'
711
+ }, [
712
+ h('div', {
713
+ ref: 'refScrollYTopCornerElem',
714
+ class: 'vxe-gantt-view--scroll-y-top-corner'
715
+ }),
716
+ h('div', {
717
+ ref: 'refScrollYWrapperElem',
718
+ class: 'vxe-gantt-view--scroll-y-wrapper'
719
+ }, [
720
+ h('div', {
721
+ ref: 'refScrollYHandleElem',
722
+ class: 'vxe-gantt-view--scroll-y-handle',
723
+ on: {
724
+ scroll: $xeGanttView.triggerVirtualScrollYEvent
725
+ }
726
+ }, [
727
+ h('div', {
728
+ ref: 'refScrollYSpaceElem',
729
+ class: 'vxe-gantt-view--scroll-y-space'
730
+ })
731
+ ])
732
+ ]),
733
+ h('div', {
734
+ ref: 'refScrollYBottomCornerElem',
735
+ class: 'vxe-gantt-view--scroll-y-bottom-corner'
736
+ })
737
+ ]);
738
+ },
739
+ renderViewport(h) {
740
+ return h('div', {
741
+ class: 'vxe-gantt-view--viewport-wrapper'
742
+ }, [
743
+ h(GanttViewHeaderComponent),
744
+ h(GanttViewBodyComponent)
745
+ ]);
746
+ },
747
+ renderBody(h) {
748
+ const $xeGanttView = this;
749
+ const $xeGantt = $xeGanttView.$xeGantt;
750
+ const scrollbarYToLeft = $xeGantt.computeScrollbarYToLeft;
751
+ return h('div', {
752
+ class: 'vxe-gantt-view--layout-wrapper'
753
+ }, scrollbarYToLeft
754
+ ? [
755
+ $xeGanttView.renderScrollY(h),
756
+ $xeGanttView.renderViewport(h)
757
+ ]
758
+ : [
759
+ $xeGanttView.renderViewport(h),
760
+ $xeGanttView.renderScrollY(h)
761
+ ]);
762
+ },
763
+ renderVN(h) {
764
+ const $xeGanttView = this;
765
+ const $xeGantt = $xeGanttView.$xeGantt;
766
+ const reactData = $xeGanttView.reactData;
767
+ const { overflowX, overflowY, scrollXLoad, scrollYLoad } = reactData;
768
+ const taskViewOpts = $xeGantt.computeTaskViewOpts;
769
+ const scrollbarXToTop = $xeGantt.computeScrollbarXToTop;
770
+ return h('div', {
771
+ ref: 'refElem',
772
+ class: ['vxe-gantt-view', `mode--${taskViewOpts.mode || 'day'}`, {
773
+ 'is--scroll-y': overflowY,
774
+ 'is--scroll-x': overflowX,
775
+ 'is--virtual-x': scrollXLoad,
776
+ 'is--virtual-y': scrollYLoad
777
+ }]
778
+ }, [
779
+ h('div', {
780
+ class: 'vxe-gantt-view--render-wrapper'
781
+ }, scrollbarXToTop
782
+ ? [
783
+ $xeGanttView.renderScrollX(h),
784
+ $xeGanttView.renderBody(h)
785
+ ]
786
+ : [
787
+ $xeGanttView.renderBody(h),
788
+ $xeGanttView.renderScrollX(h)
789
+ ]),
790
+ h('div', {
791
+ class: 'vxe-gantt-view--render-vars'
792
+ }, [
793
+ h('div', {
794
+ ref: 'refColInfoElem',
795
+ class: 'vxe-gantt-view--column-info'
796
+ })
797
+ ])
798
+ ]);
799
+ }
800
+ },
801
+ watch: {
802
+ 'reactData.tableData'() {
803
+ const $xeGanttView = this;
804
+ handleUpdateData($xeGanttView);
805
+ }
806
+ },
807
+ mounted() {
808
+ const $xeGanttView = this;
809
+ globalEvents.on($xeGanttView, 'resize', $xeGanttView.handleGlobalResizeEvent);
810
+ },
811
+ beforeDestroy() {
812
+ const $xeGanttView = this;
813
+ const internalData = $xeGanttView.internalData;
814
+ globalEvents.off($xeGanttView, 'keydown');
815
+ XEUtils.assign(internalData, createInternalData());
816
+ },
817
+ render(h) {
818
+ return this.renderVN(h);
819
+ }
820
+ });