vxe-gantt 4.0.27 → 4.1.1
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 +2 -0
- package/es/gantt/src/gantt-chart.js +28 -18
- package/es/gantt/src/gantt-header.js +18 -6
- package/es/gantt/src/gantt-view.js +307 -47
- package/es/gantt/src/gantt.js +151 -8
- package/es/gantt/src/util.js +11 -0
- package/es/ui/index.js +4 -1
- package/es/ui/src/log.js +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 +36 -16
- package/lib/gantt/src/gantt-chart.min.js +1 -1
- package/lib/gantt/src/gantt-header.js +15 -5
- package/lib/gantt/src/gantt-header.min.js +1 -1
- package/lib/gantt/src/gantt-view.js +357 -50
- package/lib/gantt/src/gantt-view.min.js +1 -1
- package/lib/gantt/src/gantt.js +163 -6
- package/lib/gantt/src/gantt.min.js +1 -1
- package/lib/gantt/src/util.js +12 -0
- package/lib/gantt/src/util.min.js +1 -1
- package/lib/index.umd.js +590 -80
- package/lib/index.umd.min.js +1 -1
- package/lib/ui/index.js +4 -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/package.json +3 -3
- package/packages/gantt/src/emits.ts +2 -0
- package/packages/gantt/src/gantt-chart.ts +34 -13
- package/packages/gantt/src/gantt-header.ts +15 -6
- package/packages/gantt/src/gantt-view.ts +310 -46
- package/packages/gantt/src/gantt.ts +162 -8
- package/packages/gantt/src/util.ts +13 -0
- package/packages/ui/index.ts +3 -0
package/es/gantt/src/emits.js
CHANGED
|
@@ -32,7 +32,7 @@ export default defineVxeComponent({
|
|
|
32
32
|
const progressField = computeProgressField.value;
|
|
33
33
|
const taskBarOpts = computeTaskBarOpts.value;
|
|
34
34
|
const barParams = { $gantt: $xeGantt, row };
|
|
35
|
-
const { showProgress, showContent, contentMethod, barStyle, drag } = taskBarOpts;
|
|
35
|
+
const { showProgress, showContent, contentMethod, barStyle, drag, showTooltip } = taskBarOpts;
|
|
36
36
|
const isBarRowStyle = XEUtils.isFunction(barStyle);
|
|
37
37
|
const barStyObj = (barStyle ? (isBarRowStyle ? barStyle(barParams) : barStyle) : {}) || {};
|
|
38
38
|
const { round } = barStyObj;
|
|
@@ -58,7 +58,32 @@ export default defineVxeComponent({
|
|
|
58
58
|
if (contentMethod) {
|
|
59
59
|
title = getStringValue(contentMethod({ row, title }));
|
|
60
60
|
}
|
|
61
|
-
const ctParams = { source: sourceType, type: viewType, row, $rowIndex, rowIndex, _rowIndex };
|
|
61
|
+
const ctParams = { source: sourceType, type: viewType, row, $rowIndex, rowIndex, _rowIndex, $gantt: $xeGantt };
|
|
62
|
+
const ons = {
|
|
63
|
+
onClick(evnt) {
|
|
64
|
+
$xeGantt.handleTaskBarClickEvent(evnt, barParams);
|
|
65
|
+
},
|
|
66
|
+
onDblclick(evnt) {
|
|
67
|
+
$xeGantt.handleTaskBarDblclickEvent(evnt, barParams);
|
|
68
|
+
},
|
|
69
|
+
onMousedown(evnt) {
|
|
70
|
+
if ($xeGantt.handleTaskBarMousedownEvent) {
|
|
71
|
+
$xeGantt.handleTaskBarMousedownEvent(evnt, barParams);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (showTooltip) {
|
|
76
|
+
ons.onMouseover = (evnt) => {
|
|
77
|
+
const ttParams = Object.assign({ $event: evnt }, ctParams);
|
|
78
|
+
$xeGantt.triggerTaskBarTooltipEvent(evnt, ttParams);
|
|
79
|
+
$xeGantt.dispatchEvent('task-bar-mouseenter', ttParams, evnt);
|
|
80
|
+
};
|
|
81
|
+
ons.onMouseleave = (evnt) => {
|
|
82
|
+
const ttParams = Object.assign({ $event: evnt }, ctParams);
|
|
83
|
+
$xeGantt.handleTaskBarTooltipLeaveEvent(evnt, ttParams);
|
|
84
|
+
$xeGantt.dispatchEvent('task-bar-mouseleave', ttParams, evnt);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
62
87
|
return h('div', {
|
|
63
88
|
key: treeConfig ? rowid : $rowIndex,
|
|
64
89
|
rowid,
|
|
@@ -74,22 +99,7 @@ export default defineVxeComponent({
|
|
|
74
99
|
$xeGantt.handleTaskBarContextmenuEvent(evnt, ctParams);
|
|
75
100
|
}
|
|
76
101
|
}, [
|
|
77
|
-
h('div', {
|
|
78
|
-
class: taskBarSlot ? 'vxe-gantt-view--chart-custom-bar' : 'vxe-gantt-view--chart-bar',
|
|
79
|
-
style: vbStyle,
|
|
80
|
-
rowid,
|
|
81
|
-
onClick(evnt) {
|
|
82
|
-
$xeGantt.handleTaskBarClickEvent(evnt, barParams);
|
|
83
|
-
},
|
|
84
|
-
onDblclick(evnt) {
|
|
85
|
-
$xeGantt.handleTaskBarDblclickEvent(evnt, barParams);
|
|
86
|
-
},
|
|
87
|
-
onMousedown(evnt) {
|
|
88
|
-
if ($xeGantt.handleTaskBarMousedownEvent) {
|
|
89
|
-
$xeGantt.handleTaskBarMousedownEvent(evnt, barParams);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, taskBarSlot
|
|
102
|
+
h('div', Object.assign({ class: taskBarSlot ? 'vxe-gantt-view--chart-custom-bar' : 'vxe-gantt-view--chart-bar', style: vbStyle, rowid }, ons), taskBarSlot
|
|
93
103
|
? $xeGantt.callSlot(taskBarSlot, barParams)
|
|
94
104
|
: [
|
|
95
105
|
showProgress
|
|
@@ -47,20 +47,29 @@ export default defineVxeComponent({
|
|
|
47
47
|
});
|
|
48
48
|
})),
|
|
49
49
|
h('thead', {}, headerGroups.map(({ scaleItem, columns }, $rowIndex) => {
|
|
50
|
-
const { type, titleMethod, headerCellStyle, slots } = scaleItem;
|
|
50
|
+
const { type, titleFormat, titleMethod, headerCellStyle, slots } = scaleItem;
|
|
51
51
|
const titleSlot = slots ? slots.title : null;
|
|
52
|
-
const
|
|
52
|
+
const isLast = $rowIndex === headerGroups.length - 1;
|
|
53
|
+
const todayValue = isLast && showNowLine ? todayDateMaps[type] : null;
|
|
53
54
|
return h('tr', {
|
|
54
55
|
key: $rowIndex
|
|
55
56
|
}, columns.map((column, cIndex) => {
|
|
56
57
|
const { field, childCount, dateObj } = column;
|
|
57
58
|
let label = `${column.title}`;
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (scaleItem.type === 'day') {
|
|
60
|
+
label = getI18n(`vxe.gantt.dayss.w${dateObj.e}`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if ($rowIndex) {
|
|
64
|
+
label = getI18n(`vxe.gantt.tSimpleFormat.${type}`, dateObj);
|
|
61
65
|
}
|
|
62
66
|
else {
|
|
63
|
-
|
|
67
|
+
if (isLast && scaleItem.type === 'week') {
|
|
68
|
+
label = getI18n(`vxe.gantt.tSimpleFormat.${type}`, dateObj);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
label = getI18n(`vxe.gantt.tFullFormat.${type}`, dateObj);
|
|
72
|
+
}
|
|
64
73
|
}
|
|
65
74
|
}
|
|
66
75
|
let cellVNs = label;
|
|
@@ -71,6 +80,9 @@ export default defineVxeComponent({
|
|
|
71
80
|
else if (titleMethod) {
|
|
72
81
|
cellVNs = `${titleMethod(ctParams)}`;
|
|
73
82
|
}
|
|
83
|
+
else if (titleFormat) {
|
|
84
|
+
cellVNs = XEUtils.toDateString(dateObj.date, titleFormat);
|
|
85
|
+
}
|
|
74
86
|
let cellStys = {};
|
|
75
87
|
if (headerCellStyle) {
|
|
76
88
|
if (XEUtils.isFunction(headerCellStyle)) {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { h, ref, reactive, nextTick, inject, watch, provide, onMounted, onUnmounted } from 'vue';
|
|
1
|
+
import { h, ref, reactive, nextTick, inject, watch, provide, computed, onMounted, onUnmounted } from 'vue';
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp';
|
|
3
3
|
import { setScrollTop, setScrollLeft, removeClass, addClass } from '../../ui/src/dom';
|
|
4
4
|
import { VxeUI } from '@vxe-ui/core';
|
|
5
|
-
import { getRefElem } from './util';
|
|
5
|
+
import { getRefElem, getStandardGapTime } from './util';
|
|
6
6
|
import XEUtils from 'xe-utils';
|
|
7
7
|
import GanttViewHeaderComponent from './gantt-header';
|
|
8
8
|
import GanttViewBodyComponent from './gantt-body';
|
|
9
9
|
import GanttViewFooterComponent from './gantt-footer';
|
|
10
10
|
const { globalEvents } = VxeUI;
|
|
11
11
|
const sourceType = 'gantt';
|
|
12
|
+
const minuteMs = 1000 * 60;
|
|
13
|
+
const dayMs = minuteMs * 60 * 24;
|
|
12
14
|
function createInternalData() {
|
|
13
15
|
return {
|
|
14
16
|
xeTable: null,
|
|
@@ -40,7 +42,7 @@ export default defineVxeComponent({
|
|
|
40
42
|
setup(props, context) {
|
|
41
43
|
const xID = XEUtils.uniqueId();
|
|
42
44
|
const $xeGantt = inject('$xeGantt', {});
|
|
43
|
-
const { computeTaskOpts, computeStartField, computeEndField, computeScrollbarOpts, computeScrollbarXToTop, computeScrollbarYToLeft } = $xeGantt.getComputeMaps();
|
|
45
|
+
const { computeTaskOpts, computeStartField, computeEndField, computeScrollbarOpts, computeScrollbarXToTop, computeScrollbarYToLeft, computeScaleUnit, computeWeekScale, computeMinScale } = $xeGantt.getComputeMaps();
|
|
44
46
|
const refElem = ref();
|
|
45
47
|
const refScrollXVirtualElem = ref();
|
|
46
48
|
const refScrollYVirtualElem = ref();
|
|
@@ -89,7 +91,72 @@ export default defineVxeComponent({
|
|
|
89
91
|
const refMaps = {
|
|
90
92
|
refElem
|
|
91
93
|
};
|
|
92
|
-
const
|
|
94
|
+
const computeScaleDateList = computed(() => {
|
|
95
|
+
const { minViewDate, maxViewDate } = reactData;
|
|
96
|
+
const minScale = computeMinScale.value;
|
|
97
|
+
const dateList = [];
|
|
98
|
+
if (!minViewDate || !maxViewDate) {
|
|
99
|
+
return dateList;
|
|
100
|
+
}
|
|
101
|
+
const startTime = minViewDate.getTime();
|
|
102
|
+
const endTime = maxViewDate.getTime();
|
|
103
|
+
switch (minScale.type) {
|
|
104
|
+
case 'year': {
|
|
105
|
+
let currDate = XEUtils.getWhatYear(minViewDate, 0, 'first');
|
|
106
|
+
while (currDate <= maxViewDate) {
|
|
107
|
+
const itemDate = currDate;
|
|
108
|
+
dateList.push(itemDate);
|
|
109
|
+
currDate = XEUtils.getWhatYear(currDate, 1);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case 'quarter': {
|
|
114
|
+
let currDate = XEUtils.getWhatQuarter(minViewDate, 0, 'first');
|
|
115
|
+
while (currDate <= maxViewDate) {
|
|
116
|
+
const itemDate = currDate;
|
|
117
|
+
dateList.push(itemDate);
|
|
118
|
+
currDate = XEUtils.getWhatQuarter(currDate, 1);
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 'month': {
|
|
123
|
+
let currDate = XEUtils.getWhatMonth(minViewDate, 0, 'first');
|
|
124
|
+
while (currDate <= maxViewDate) {
|
|
125
|
+
const itemDate = currDate;
|
|
126
|
+
dateList.push(itemDate);
|
|
127
|
+
currDate = XEUtils.getWhatMonth(currDate, 1);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case 'week': {
|
|
132
|
+
let currDate = XEUtils.getWhatWeek(minViewDate, 0, minScale.startDay, minScale.startDay);
|
|
133
|
+
while (currDate <= maxViewDate) {
|
|
134
|
+
const itemDate = currDate;
|
|
135
|
+
dateList.push(itemDate);
|
|
136
|
+
currDate = XEUtils.getWhatWeek(currDate, 1);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'day':
|
|
141
|
+
case 'date':
|
|
142
|
+
case 'hour':
|
|
143
|
+
case 'minute':
|
|
144
|
+
case 'second': {
|
|
145
|
+
const gapTime = getStandardGapTime(minScale.type);
|
|
146
|
+
let currTime = startTime;
|
|
147
|
+
while (currTime <= endTime) {
|
|
148
|
+
const itemDate = new Date(currTime);
|
|
149
|
+
dateList.push(itemDate);
|
|
150
|
+
currTime += gapTime;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return dateList;
|
|
156
|
+
});
|
|
157
|
+
const computeMaps = {
|
|
158
|
+
computeScaleDateList
|
|
159
|
+
};
|
|
93
160
|
const $xeGanttView = {
|
|
94
161
|
xID,
|
|
95
162
|
props,
|
|
@@ -126,36 +193,16 @@ export default defineVxeComponent({
|
|
|
126
193
|
second: `${yyyy}_${MM}_${dd}_${HH}_${mm}_${ss}`
|
|
127
194
|
};
|
|
128
195
|
};
|
|
129
|
-
const
|
|
130
|
-
const ganttProps = $xeGantt.props;
|
|
196
|
+
const handleColumnHeader = () => {
|
|
131
197
|
const ganttReactData = $xeGantt.reactData;
|
|
132
|
-
const { treeConfig } = ganttProps;
|
|
133
198
|
const { taskScaleList } = ganttReactData;
|
|
134
|
-
const
|
|
135
|
-
const minScale =
|
|
199
|
+
const scaleUnit = computeScaleUnit.value;
|
|
200
|
+
const minScale = computeMinScale.value;
|
|
201
|
+
const weekScale = computeWeekScale.value;
|
|
202
|
+
const scaleDateList = computeScaleDateList.value;
|
|
136
203
|
const fullCols = [];
|
|
137
204
|
const groupCols = [];
|
|
138
|
-
if (minScale &&
|
|
139
|
-
const minSType = minScale.type;
|
|
140
|
-
const weekScale = taskScaleList.find(item => item.type === 'week');
|
|
141
|
-
let gapTime = 1000 * 60 * 60 * 24;
|
|
142
|
-
switch (minScale.type) {
|
|
143
|
-
case 'hour':
|
|
144
|
-
gapTime = 1000 * 60 * 60;
|
|
145
|
-
break;
|
|
146
|
-
case 'minute':
|
|
147
|
-
gapTime = 1000 * 60;
|
|
148
|
-
break;
|
|
149
|
-
case 'second':
|
|
150
|
-
gapTime = 1000;
|
|
151
|
-
break;
|
|
152
|
-
default: {
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const currTime = minViewDate.getTime();
|
|
157
|
-
const diffDayNum = maxViewDate.getTime() - minViewDate.getTime();
|
|
158
|
-
const countSize = Math.max(5, Math.floor(diffDayNum / gapTime) + 1);
|
|
205
|
+
if (minScale && scaleUnit && scaleDateList.length) {
|
|
159
206
|
const renderListMaps = {
|
|
160
207
|
year: [],
|
|
161
208
|
quarter: [],
|
|
@@ -179,7 +226,7 @@ export default defineVxeComponent({
|
|
|
179
226
|
second: {}
|
|
180
227
|
};
|
|
181
228
|
const handleData = (type, colMaps, minCol) => {
|
|
182
|
-
if (
|
|
229
|
+
if (minScale.type === type) {
|
|
183
230
|
return;
|
|
184
231
|
}
|
|
185
232
|
const currCol = colMaps[type];
|
|
@@ -197,14 +244,14 @@ export default defineVxeComponent({
|
|
|
197
244
|
currGpCol.children.push(minCol);
|
|
198
245
|
}
|
|
199
246
|
};
|
|
200
|
-
for (let i = 0; i <
|
|
201
|
-
const itemDate =
|
|
247
|
+
for (let i = 0; i < scaleDateList.length; i++) {
|
|
248
|
+
const itemDate = scaleDateList[i];
|
|
202
249
|
const [yyyy, MM, dd, HH, mm, ss] = XEUtils.toDateString(itemDate, 'yyyy-M-d-H-m-s').split('-');
|
|
203
250
|
const e = itemDate.getDay();
|
|
204
251
|
const E = e + 1;
|
|
205
252
|
const q = Math.ceil((itemDate.getMonth() + 1) / 3);
|
|
206
253
|
const W = XEUtils.getYearWeek(itemDate, weekScale ? weekScale.startDay : undefined);
|
|
207
|
-
const dateObj = { yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e };
|
|
254
|
+
const dateObj = { date: itemDate, yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e };
|
|
208
255
|
const colMaps = {
|
|
209
256
|
year: {
|
|
210
257
|
field: yyyy,
|
|
@@ -252,14 +299,14 @@ export default defineVxeComponent({
|
|
|
252
299
|
dateObj
|
|
253
300
|
}
|
|
254
301
|
};
|
|
255
|
-
const minCol = colMaps[
|
|
302
|
+
const minCol = colMaps[minScale.type];
|
|
256
303
|
if (minScale.level < 19) {
|
|
257
304
|
handleData('year', colMaps, minCol);
|
|
258
305
|
}
|
|
259
306
|
if (minScale.level < 17) {
|
|
260
307
|
handleData('quarter', colMaps, minCol);
|
|
261
308
|
}
|
|
262
|
-
if (minScale.level <
|
|
309
|
+
if (minScale.level < 15) {
|
|
263
310
|
handleData('month', colMaps, minCol);
|
|
264
311
|
}
|
|
265
312
|
if (minScale.level < 13) {
|
|
@@ -268,7 +315,7 @@ export default defineVxeComponent({
|
|
|
268
315
|
if (minScale.level < 11) {
|
|
269
316
|
handleData('day', colMaps, minCol);
|
|
270
317
|
}
|
|
271
|
-
if (minScale.level <
|
|
318
|
+
if (minScale.level < 9) {
|
|
272
319
|
handleData('date', colMaps, minCol);
|
|
273
320
|
}
|
|
274
321
|
if (minScale.level < 7) {
|
|
@@ -277,10 +324,13 @@ export default defineVxeComponent({
|
|
|
277
324
|
if (minScale.level < 5) {
|
|
278
325
|
handleData('minute', colMaps, minCol);
|
|
279
326
|
}
|
|
327
|
+
if (minScale.level < 3) {
|
|
328
|
+
handleData('second', colMaps, minCol);
|
|
329
|
+
}
|
|
280
330
|
fullCols.push(minCol);
|
|
281
331
|
}
|
|
282
332
|
taskScaleList.forEach(scaleItem => {
|
|
283
|
-
if (scaleItem.type ===
|
|
333
|
+
if (scaleItem.type === minScale.type) {
|
|
284
334
|
groupCols.push({
|
|
285
335
|
scaleItem,
|
|
286
336
|
columns: fullCols
|
|
@@ -299,6 +349,211 @@ export default defineVxeComponent({
|
|
|
299
349
|
columns: list
|
|
300
350
|
});
|
|
301
351
|
});
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
fullCols,
|
|
355
|
+
groupCols
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
const createChartRender = (fullCols) => {
|
|
359
|
+
const { minViewDate } = reactData;
|
|
360
|
+
const minScale = computeMinScale.value;
|
|
361
|
+
const scaleUnit = computeScaleUnit.value;
|
|
362
|
+
const weekScale = computeWeekScale.value;
|
|
363
|
+
switch (scaleUnit) {
|
|
364
|
+
case 'year': {
|
|
365
|
+
const indexMaps = {};
|
|
366
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
367
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy');
|
|
368
|
+
indexMaps[yyyyMM] = i;
|
|
369
|
+
});
|
|
370
|
+
return (startValue, endValue) => {
|
|
371
|
+
const startDate = parseStringDate(startValue);
|
|
372
|
+
const endDate = parseStringDate(endValue);
|
|
373
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy');
|
|
374
|
+
const startFirstDate = XEUtils.getWhatYear(startDate, 0, 'first');
|
|
375
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy');
|
|
376
|
+
const endFirstDate = XEUtils.getWhatYear(endDate, 0, 'first');
|
|
377
|
+
const dateSize = Math.floor((XEUtils.getWhatYear(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs);
|
|
378
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
|
|
379
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
|
|
380
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
|
|
381
|
+
return {
|
|
382
|
+
offsetLeftSize,
|
|
383
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
case 'quarter': {
|
|
388
|
+
const indexMaps = {};
|
|
389
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
390
|
+
const q = XEUtils.toDateString(dateObj.date, 'yyyy-q');
|
|
391
|
+
indexMaps[q] = i;
|
|
392
|
+
});
|
|
393
|
+
return (startValue, endValue) => {
|
|
394
|
+
const startDate = parseStringDate(startValue);
|
|
395
|
+
const endDate = parseStringDate(endValue);
|
|
396
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-q');
|
|
397
|
+
const startFirstDate = XEUtils.getWhatQuarter(startDate, 0, 'first');
|
|
398
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-q');
|
|
399
|
+
const endFirstDate = XEUtils.getWhatQuarter(endDate, 0, 'first');
|
|
400
|
+
const dateSize = Math.floor((XEUtils.getWhatQuarter(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs);
|
|
401
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
|
|
402
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
|
|
403
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
|
|
404
|
+
return {
|
|
405
|
+
offsetLeftSize,
|
|
406
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
case 'month': {
|
|
411
|
+
const indexMaps = {};
|
|
412
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
413
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM');
|
|
414
|
+
indexMaps[yyyyMM] = i;
|
|
415
|
+
});
|
|
416
|
+
return (startValue, endValue) => {
|
|
417
|
+
const startDate = parseStringDate(startValue);
|
|
418
|
+
const endDate = parseStringDate(endValue);
|
|
419
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM');
|
|
420
|
+
const startFirstDate = XEUtils.getWhatMonth(startDate, 0, 'first');
|
|
421
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM');
|
|
422
|
+
const endFirstDate = XEUtils.getWhatMonth(endDate, 0, 'first');
|
|
423
|
+
const dateSize = Math.floor((XEUtils.getWhatMonth(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs);
|
|
424
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
|
|
425
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
|
|
426
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
|
|
427
|
+
return {
|
|
428
|
+
offsetLeftSize,
|
|
429
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
case 'week': {
|
|
434
|
+
const indexMaps = {};
|
|
435
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
436
|
+
const yyyyW = XEUtils.toDateString(dateObj.date, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined });
|
|
437
|
+
indexMaps[yyyyW] = i;
|
|
438
|
+
});
|
|
439
|
+
return (startValue, endValue) => {
|
|
440
|
+
const startDate = parseStringDate(startValue);
|
|
441
|
+
const endDate = parseStringDate(endValue);
|
|
442
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined });
|
|
443
|
+
const startFirstDate = XEUtils.getWhatWeek(startDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined);
|
|
444
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined });
|
|
445
|
+
const endFirstDate = XEUtils.getWhatWeek(endDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined);
|
|
446
|
+
const dateSize = Math.floor((XEUtils.getWhatWeek(endDate, 1, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined).getTime() - endFirstDate.getTime()) / dayMs);
|
|
447
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
|
|
448
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
|
|
449
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
|
|
450
|
+
return {
|
|
451
|
+
offsetLeftSize,
|
|
452
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
case 'day':
|
|
457
|
+
case 'date': {
|
|
458
|
+
const indexMaps = {};
|
|
459
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
460
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd');
|
|
461
|
+
indexMaps[yyyyMM] = i;
|
|
462
|
+
});
|
|
463
|
+
return (startValue, endValue) => {
|
|
464
|
+
const startDate = parseStringDate(startValue);
|
|
465
|
+
const endDate = parseStringDate(endValue);
|
|
466
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd');
|
|
467
|
+
const startFirstDate = XEUtils.getWhatDay(startDate, 0, 'first');
|
|
468
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd');
|
|
469
|
+
const endFirstDate = XEUtils.getWhatDay(endDate, 0, 'first');
|
|
470
|
+
const minuteSize = Math.floor((XEUtils.getWhatDay(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs);
|
|
471
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize;
|
|
472
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize;
|
|
473
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
|
|
474
|
+
return {
|
|
475
|
+
offsetLeftSize,
|
|
476
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
case 'hour': {
|
|
481
|
+
const indexMaps = {};
|
|
482
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
483
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH');
|
|
484
|
+
indexMaps[yyyyMM] = i;
|
|
485
|
+
});
|
|
486
|
+
return (startValue, endValue) => {
|
|
487
|
+
const startDate = parseStringDate(startValue);
|
|
488
|
+
const endDate = parseStringDate(endValue);
|
|
489
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH');
|
|
490
|
+
const startFirstDate = XEUtils.getWhatHours(startDate, 0, 'first');
|
|
491
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH');
|
|
492
|
+
const endFirstDate = XEUtils.getWhatHours(endDate, 0, 'first');
|
|
493
|
+
const minuteSize = Math.floor((XEUtils.getWhatHours(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs);
|
|
494
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize;
|
|
495
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize;
|
|
496
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
|
|
497
|
+
return {
|
|
498
|
+
offsetLeftSize,
|
|
499
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
case 'minute': {
|
|
504
|
+
const indexMaps = {};
|
|
505
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
506
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH:mm');
|
|
507
|
+
indexMaps[yyyyMM] = i;
|
|
508
|
+
});
|
|
509
|
+
return (startValue, endValue) => {
|
|
510
|
+
const startDate = parseStringDate(startValue);
|
|
511
|
+
const endDate = parseStringDate(endValue);
|
|
512
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH:mm');
|
|
513
|
+
const startFirstDate = XEUtils.getWhatMinutes(startDate, 0, 'first');
|
|
514
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH:mm');
|
|
515
|
+
const endFirstDate = XEUtils.getWhatMinutes(endDate, 0, 'first');
|
|
516
|
+
const minuteSize = Math.floor((XEUtils.getWhatMinutes(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs);
|
|
517
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize;
|
|
518
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize;
|
|
519
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
|
|
520
|
+
return {
|
|
521
|
+
offsetLeftSize,
|
|
522
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
case 'second': {
|
|
527
|
+
const gapTime = getStandardGapTime(minScale.type);
|
|
528
|
+
return (startValue, endValue) => {
|
|
529
|
+
const startDate = parseStringDate(startValue);
|
|
530
|
+
const endDate = parseStringDate(endValue);
|
|
531
|
+
let offsetLeftSize = 0;
|
|
532
|
+
let offsetWidthSize = 0;
|
|
533
|
+
if (minViewDate) {
|
|
534
|
+
offsetLeftSize = (startDate.getTime() - minViewDate.getTime()) / gapTime;
|
|
535
|
+
offsetWidthSize = ((endDate.getTime() - startDate.getTime()) / gapTime) + 1;
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
offsetLeftSize,
|
|
539
|
+
offsetWidthSize
|
|
540
|
+
};
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return () => {
|
|
545
|
+
return {
|
|
546
|
+
offsetLeftSize: 0,
|
|
547
|
+
offsetWidthSize: 0
|
|
548
|
+
};
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
const handleParseColumn = () => {
|
|
552
|
+
const ganttProps = $xeGantt.props;
|
|
553
|
+
const { treeConfig } = ganttProps;
|
|
554
|
+
const { minViewDate, maxViewDate } = reactData;
|
|
555
|
+
const { fullCols, groupCols } = handleColumnHeader();
|
|
556
|
+
if (minViewDate && maxViewDate && fullCols.length) {
|
|
302
557
|
const $xeTable = internalData.xeTable;
|
|
303
558
|
if ($xeTable) {
|
|
304
559
|
const startField = computeStartField.value;
|
|
@@ -313,20 +568,18 @@ export default defineVxeComponent({
|
|
|
313
568
|
const { transform } = treeOpts;
|
|
314
569
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
315
570
|
const ctMaps = {};
|
|
571
|
+
const renderFn = createChartRender(fullCols);
|
|
316
572
|
const handleParseRender = (row) => {
|
|
317
573
|
const rowid = $xeTable.getRowid(row);
|
|
318
574
|
const startValue = XEUtils.get(row, startField);
|
|
319
575
|
const endValue = XEUtils.get(row, endField);
|
|
320
576
|
if (startValue && endValue) {
|
|
321
|
-
const
|
|
322
|
-
const endDate = parseStringDate(endValue);
|
|
323
|
-
const oLeftSize = Math.floor((startDate.getTime() - minViewDate.getTime()) / gapTime);
|
|
324
|
-
const oWidthSize = Math.floor((endDate.getTime() - startDate.getTime()) / gapTime) + 1;
|
|
577
|
+
const { offsetLeftSize, offsetWidthSize } = renderFn(startValue, endValue);
|
|
325
578
|
ctMaps[rowid] = {
|
|
326
579
|
row,
|
|
327
580
|
rowid,
|
|
328
|
-
oLeftSize,
|
|
329
|
-
oWidthSize
|
|
581
|
+
oLeftSize: offsetLeftSize,
|
|
582
|
+
oWidthSize: offsetWidthSize
|
|
330
583
|
};
|
|
331
584
|
}
|
|
332
585
|
};
|
|
@@ -575,11 +828,11 @@ export default defineVxeComponent({
|
|
|
575
828
|
return new Promise(resolve => {
|
|
576
829
|
const { rceTimeout, rceRunTime } = internalData;
|
|
577
830
|
const $xeTable = internalData.xeTable;
|
|
578
|
-
let refreshDelay =
|
|
831
|
+
let refreshDelay = 30;
|
|
579
832
|
if ($xeTable) {
|
|
580
833
|
const { computeResizeOpts } = $xeTable.getComputeMaps();
|
|
581
834
|
const resizeOpts = computeResizeOpts.value;
|
|
582
|
-
refreshDelay = resizeOpts.refreshDelay ||
|
|
835
|
+
refreshDelay = resizeOpts.refreshDelay || refreshDelay;
|
|
583
836
|
}
|
|
584
837
|
if (rceTimeout) {
|
|
585
838
|
clearTimeout(rceTimeout);
|
|
@@ -880,7 +1133,14 @@ export default defineVxeComponent({
|
|
|
880
1133
|
const ganttViewMethods = {
|
|
881
1134
|
refreshData() {
|
|
882
1135
|
handleUpdateData();
|
|
883
|
-
|
|
1136
|
+
handleRecalculateStyle();
|
|
1137
|
+
return nextTick().then(() => {
|
|
1138
|
+
const $xeTable = internalData.xeTable;
|
|
1139
|
+
handleRecalculateStyle();
|
|
1140
|
+
if ($xeTable) {
|
|
1141
|
+
return $xeTable.recalculate();
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
884
1144
|
},
|
|
885
1145
|
updateViewData() {
|
|
886
1146
|
const $xeTable = internalData.xeTable;
|