vxe-gantt 3.0.27 → 3.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/gantt-chart.js +24 -15
- package/es/gantt/src/gantt-header.js +18 -6
- package/es/gantt/src/gantt-view.js +311 -47
- package/es/gantt/src/gantt.js +170 -7
- package/es/gantt/src/util.js +11 -0
- package/es/ui/index.js +4 -1
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/utils.js +6 -0
- package/lib/gantt/src/gantt-chart.js +30 -15
- 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 +346 -51
- package/lib/gantt/src/gantt-view.min.js +1 -1
- package/lib/gantt/src/gantt.js +168 -5
- 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 +588 -83
- 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/lib/ui/src/utils.js +8 -0
- package/lib/ui/src/utils.min.js +1 -1
- package/package.json +3 -3
- package/packages/gantt/src/gantt-chart.ts +30 -15
- package/packages/gantt/src/gantt-header.ts +15 -6
- package/packages/gantt/src/gantt-view.ts +321 -49
- package/packages/gantt/src/gantt.ts +179 -7
- package/packages/gantt/src/util.ts +13 -0
- package/packages/ui/index.ts +3 -0
- package/packages/ui/src/utils.ts +8 -0
|
@@ -2,7 +2,7 @@ import { VNode, CreateElement } from 'vue'
|
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
3
|
import { VxeUI } from '@vxe-ui/core'
|
|
4
4
|
import { setScrollTop, setScrollLeft, removeClass, addClass } from '../../ui/src/dom'
|
|
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'
|
|
@@ -14,6 +14,8 @@ import type { VxeGanttViewConstructor, GanttViewReactData, VxeGanttDefines, VxeG
|
|
|
14
14
|
const { globalEvents } = VxeUI
|
|
15
15
|
|
|
16
16
|
const sourceType = 'gantt'
|
|
17
|
+
const minuteMs = 1000 * 60
|
|
18
|
+
const dayMs = minuteMs * 60 * 24
|
|
17
19
|
|
|
18
20
|
function createInternalData (): GanttViewInternalData {
|
|
19
21
|
return {
|
|
@@ -76,41 +78,19 @@ function updateTodayData ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPr
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
function
|
|
81
|
+
function handleColumnHeader ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
|
|
80
82
|
const $xeGantt = $xeGanttView.$xeGantt
|
|
81
|
-
const reactData = $xeGanttView.reactData
|
|
82
|
-
const internalData = $xeGanttView.internalData
|
|
83
83
|
|
|
84
|
-
const ganttProps = $xeGantt
|
|
85
84
|
const ganttReactData = $xeGantt.reactData
|
|
86
|
-
const { treeConfig } = ganttProps
|
|
87
85
|
const { taskScaleList } = ganttReactData
|
|
88
|
-
const
|
|
89
|
-
const minScale =
|
|
86
|
+
const scaleUnit = $xeGantt.computeScaleUnit
|
|
87
|
+
const minScale = $xeGantt.computeMinScale
|
|
88
|
+
const weekScale = $xeGantt.computeWeekScale
|
|
89
|
+
const scaleDateList = $xeGanttView.computeScaleDateList
|
|
90
90
|
const fullCols: VxeGanttDefines.ViewColumn[] = []
|
|
91
91
|
const groupCols: VxeGanttDefines.GroupColumn[] = []
|
|
92
|
-
if (minScale && minViewDate && maxViewDate) {
|
|
93
|
-
const minSType = minScale.type
|
|
94
|
-
const weekScale = taskScaleList.find(item => item.type === 'week')
|
|
95
|
-
let gapTime = 1000 * 60 * 60 * 24
|
|
96
|
-
switch (minScale.type) {
|
|
97
|
-
case 'hour':
|
|
98
|
-
gapTime = 1000 * 60 * 60
|
|
99
|
-
break
|
|
100
|
-
case 'minute':
|
|
101
|
-
gapTime = 1000 * 60
|
|
102
|
-
break
|
|
103
|
-
case 'second':
|
|
104
|
-
gapTime = 1000
|
|
105
|
-
break
|
|
106
|
-
default: {
|
|
107
|
-
break
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const currTime = minViewDate.getTime()
|
|
111
|
-
const diffDayNum = maxViewDate.getTime() - minViewDate.getTime()
|
|
112
|
-
const countSize = Math.max(5, Math.floor(diffDayNum / gapTime) + 1)
|
|
113
92
|
|
|
93
|
+
if (minScale && scaleUnit && scaleDateList.length) {
|
|
114
94
|
const renderListMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn[]> = {
|
|
115
95
|
year: [],
|
|
116
96
|
quarter: [],
|
|
@@ -136,7 +116,7 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
136
116
|
}
|
|
137
117
|
|
|
138
118
|
const handleData = (type: VxeGanttDefines.ColumnScaleType, colMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn>, minCol: VxeGanttDefines.ViewColumn) => {
|
|
139
|
-
if (
|
|
119
|
+
if (minScale.type === type) {
|
|
140
120
|
return
|
|
141
121
|
}
|
|
142
122
|
const currCol = colMaps[type]
|
|
@@ -154,14 +134,15 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
154
134
|
currGpCol.children.push(minCol)
|
|
155
135
|
}
|
|
156
136
|
}
|
|
157
|
-
|
|
158
|
-
|
|
137
|
+
|
|
138
|
+
for (let i = 0; i < scaleDateList.length; i++) {
|
|
139
|
+
const itemDate = scaleDateList[i]
|
|
159
140
|
const [yyyy, MM, dd, HH, mm, ss] = XEUtils.toDateString(itemDate, 'yyyy-M-d-H-m-s').split('-')
|
|
160
141
|
const e = itemDate.getDay()
|
|
161
142
|
const E = e + 1
|
|
162
143
|
const q = Math.ceil((itemDate.getMonth() + 1) / 3)
|
|
163
144
|
const W = XEUtils.getYearWeek(itemDate, weekScale ? weekScale.startDay : undefined)
|
|
164
|
-
const dateObj: VxeGanttDefines.ScaleDateObj = { yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e }
|
|
145
|
+
const dateObj: VxeGanttDefines.ScaleDateObj = { date: itemDate, yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e }
|
|
165
146
|
const colMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn> = {
|
|
166
147
|
year: {
|
|
167
148
|
field: yyyy,
|
|
@@ -209,14 +190,14 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
209
190
|
dateObj
|
|
210
191
|
}
|
|
211
192
|
}
|
|
212
|
-
const minCol = colMaps[
|
|
193
|
+
const minCol = colMaps[minScale.type]
|
|
213
194
|
if (minScale.level < 19) {
|
|
214
195
|
handleData('year', colMaps, minCol)
|
|
215
196
|
}
|
|
216
197
|
if (minScale.level < 17) {
|
|
217
198
|
handleData('quarter', colMaps, minCol)
|
|
218
199
|
}
|
|
219
|
-
if (minScale.level <
|
|
200
|
+
if (minScale.level < 15) {
|
|
220
201
|
handleData('month', colMaps, minCol)
|
|
221
202
|
}
|
|
222
203
|
if (minScale.level < 13) {
|
|
@@ -225,7 +206,7 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
225
206
|
if (minScale.level < 11) {
|
|
226
207
|
handleData('day', colMaps, minCol)
|
|
227
208
|
}
|
|
228
|
-
if (minScale.level <
|
|
209
|
+
if (minScale.level < 9) {
|
|
229
210
|
handleData('date', colMaps, minCol)
|
|
230
211
|
}
|
|
231
212
|
if (minScale.level < 7) {
|
|
@@ -234,12 +215,15 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
234
215
|
if (minScale.level < 5) {
|
|
235
216
|
handleData('minute', colMaps, minCol)
|
|
236
217
|
}
|
|
218
|
+
if (minScale.level < 3) {
|
|
219
|
+
handleData('second', colMaps, minCol)
|
|
220
|
+
}
|
|
237
221
|
|
|
238
222
|
fullCols.push(minCol)
|
|
239
223
|
}
|
|
240
224
|
|
|
241
225
|
taskScaleList.forEach(scaleItem => {
|
|
242
|
-
if (scaleItem.type ===
|
|
226
|
+
if (scaleItem.type === minScale.type) {
|
|
243
227
|
groupCols.push({
|
|
244
228
|
scaleItem,
|
|
245
229
|
columns: fullCols
|
|
@@ -258,7 +242,221 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
258
242
|
columns: list
|
|
259
243
|
})
|
|
260
244
|
})
|
|
245
|
+
}
|
|
261
246
|
|
|
247
|
+
return {
|
|
248
|
+
fullCols,
|
|
249
|
+
groupCols
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function createChartRender ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods, fullCols: VxeGanttDefines.ViewColumn[]) {
|
|
254
|
+
const $xeGantt = $xeGanttView.$xeGantt
|
|
255
|
+
const reactData = $xeGanttView.reactData
|
|
256
|
+
|
|
257
|
+
const { minViewDate } = reactData
|
|
258
|
+
const minScale = $xeGantt.computeMinScale
|
|
259
|
+
const scaleUnit = $xeGantt.computeScaleUnit
|
|
260
|
+
const weekScale = $xeGantt.computeWeekScale
|
|
261
|
+
switch (scaleUnit) {
|
|
262
|
+
case 'year': {
|
|
263
|
+
const indexMaps: Record<string, number> = {}
|
|
264
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
265
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy')
|
|
266
|
+
indexMaps[yyyyMM] = i
|
|
267
|
+
})
|
|
268
|
+
return (startValue: any, endValue: any) => {
|
|
269
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
270
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
271
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy')
|
|
272
|
+
const startFirstDate = XEUtils.getWhatYear(startDate, 0, 'first')
|
|
273
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy')
|
|
274
|
+
const endFirstDate = XEUtils.getWhatYear(endDate, 0, 'first')
|
|
275
|
+
const dateSize = Math.floor((XEUtils.getWhatYear(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
276
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
277
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
278
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
279
|
+
return {
|
|
280
|
+
offsetLeftSize,
|
|
281
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
case 'quarter': {
|
|
286
|
+
const indexMaps: Record<string, number> = {}
|
|
287
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
288
|
+
const q = XEUtils.toDateString(dateObj.date, 'yyyy-q')
|
|
289
|
+
indexMaps[q] = i
|
|
290
|
+
})
|
|
291
|
+
return (startValue: any, endValue: any) => {
|
|
292
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
293
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
294
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-q')
|
|
295
|
+
const startFirstDate = XEUtils.getWhatQuarter(startDate, 0, 'first')
|
|
296
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-q')
|
|
297
|
+
const endFirstDate = XEUtils.getWhatQuarter(endDate, 0, 'first')
|
|
298
|
+
const dateSize = Math.floor((XEUtils.getWhatQuarter(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
299
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
300
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
301
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
302
|
+
return {
|
|
303
|
+
offsetLeftSize,
|
|
304
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
case 'month': {
|
|
309
|
+
const indexMaps: Record<string, number> = {}
|
|
310
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
311
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM')
|
|
312
|
+
indexMaps[yyyyMM] = i
|
|
313
|
+
})
|
|
314
|
+
return (startValue: any, endValue: any) => {
|
|
315
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
316
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
317
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM')
|
|
318
|
+
const startFirstDate = XEUtils.getWhatMonth(startDate, 0, 'first')
|
|
319
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM')
|
|
320
|
+
const endFirstDate = XEUtils.getWhatMonth(endDate, 0, 'first')
|
|
321
|
+
const dateSize = Math.floor((XEUtils.getWhatMonth(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
322
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
323
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
324
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
325
|
+
return {
|
|
326
|
+
offsetLeftSize,
|
|
327
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
case 'week': {
|
|
332
|
+
const indexMaps: Record<string, number> = {}
|
|
333
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
334
|
+
const yyyyW = XEUtils.toDateString(dateObj.date, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
335
|
+
indexMaps[yyyyW] = i
|
|
336
|
+
})
|
|
337
|
+
return (startValue: any, endValue: any) => {
|
|
338
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
339
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
340
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
341
|
+
const startFirstDate = XEUtils.getWhatWeek(startDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
|
|
342
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
343
|
+
const endFirstDate = XEUtils.getWhatWeek(endDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
|
|
344
|
+
const dateSize = Math.floor((XEUtils.getWhatWeek(endDate, 1, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined).getTime() - endFirstDate.getTime()) / dayMs)
|
|
345
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
346
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
347
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
348
|
+
return {
|
|
349
|
+
offsetLeftSize,
|
|
350
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
case 'day':
|
|
355
|
+
case 'date': {
|
|
356
|
+
const indexMaps: Record<string, number> = {}
|
|
357
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
358
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd')
|
|
359
|
+
indexMaps[yyyyMM] = i
|
|
360
|
+
})
|
|
361
|
+
return (startValue: any, endValue: any) => {
|
|
362
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
363
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
364
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd')
|
|
365
|
+
const startFirstDate = XEUtils.getWhatDay(startDate, 0, 'first')
|
|
366
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd')
|
|
367
|
+
const endFirstDate = XEUtils.getWhatDay(endDate, 0, 'first')
|
|
368
|
+
const minuteSize = Math.floor((XEUtils.getWhatDay(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
369
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
370
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
371
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
372
|
+
return {
|
|
373
|
+
offsetLeftSize,
|
|
374
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
case 'hour': {
|
|
379
|
+
const indexMaps: Record<string, number> = {}
|
|
380
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
381
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH')
|
|
382
|
+
indexMaps[yyyyMM] = i
|
|
383
|
+
})
|
|
384
|
+
return (startValue: any, endValue: any) => {
|
|
385
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
386
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
387
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH')
|
|
388
|
+
const startFirstDate = XEUtils.getWhatHours(startDate, 0, 'first')
|
|
389
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH')
|
|
390
|
+
const endFirstDate = XEUtils.getWhatHours(endDate, 0, 'first')
|
|
391
|
+
const minuteSize = Math.floor((XEUtils.getWhatHours(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
392
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
393
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
394
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
395
|
+
return {
|
|
396
|
+
offsetLeftSize,
|
|
397
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
case 'minute': {
|
|
402
|
+
const indexMaps: Record<string, number> = {}
|
|
403
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
404
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH:mm')
|
|
405
|
+
indexMaps[yyyyMM] = i
|
|
406
|
+
})
|
|
407
|
+
return (startValue: any, endValue: any) => {
|
|
408
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
409
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
410
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH:mm')
|
|
411
|
+
const startFirstDate = XEUtils.getWhatMinutes(startDate, 0, 'first')
|
|
412
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH:mm')
|
|
413
|
+
const endFirstDate = XEUtils.getWhatMinutes(endDate, 0, 'first')
|
|
414
|
+
const minuteSize = Math.floor((XEUtils.getWhatMinutes(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
415
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
416
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
417
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
418
|
+
return {
|
|
419
|
+
offsetLeftSize,
|
|
420
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
case 'second': {
|
|
425
|
+
const gapTime = getStandardGapTime(minScale.type)
|
|
426
|
+
return (startValue: any, endValue: any) => {
|
|
427
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
428
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
429
|
+
let offsetLeftSize = 0
|
|
430
|
+
let offsetWidthSize = 0
|
|
431
|
+
if (minViewDate) {
|
|
432
|
+
offsetLeftSize = (startDate.getTime() - minViewDate.getTime()) / gapTime
|
|
433
|
+
offsetWidthSize = ((endDate.getTime() - startDate.getTime()) / gapTime) + 1
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
offsetLeftSize,
|
|
437
|
+
offsetWidthSize
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return () => {
|
|
443
|
+
return {
|
|
444
|
+
offsetLeftSize: 0,
|
|
445
|
+
offsetWidthSize: 0
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
|
|
451
|
+
const $xeGantt = $xeGanttView.$xeGantt
|
|
452
|
+
const reactData = $xeGanttView.reactData
|
|
453
|
+
const internalData = $xeGanttView.internalData
|
|
454
|
+
|
|
455
|
+
const ganttProps = $xeGantt
|
|
456
|
+
const { treeConfig } = ganttProps
|
|
457
|
+
const { minViewDate, maxViewDate } = reactData
|
|
458
|
+
const { fullCols, groupCols } = handleColumnHeader($xeGanttView)
|
|
459
|
+
if (minViewDate && maxViewDate) {
|
|
262
460
|
const $xeTable = internalData.xeTable
|
|
263
461
|
if ($xeTable) {
|
|
264
462
|
const startField = $xeGantt.computeStartField
|
|
@@ -273,32 +471,30 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
273
471
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
274
472
|
|
|
275
473
|
const ctMaps: Record<string, VxeGanttDefines.RowCacheItem> = {}
|
|
474
|
+
const renderFn = createChartRender($xeGanttView, fullCols)
|
|
276
475
|
const handleParseRender = (row: any) => {
|
|
277
476
|
const rowid = $xeTable.getRowid(row)
|
|
278
477
|
const startValue = XEUtils.get(row, startField)
|
|
279
478
|
const endValue = XEUtils.get(row, endField)
|
|
280
479
|
if (startValue && endValue) {
|
|
281
|
-
const
|
|
282
|
-
const endDate = parseStringDate($xeGanttView, endValue)
|
|
283
|
-
const oLeftSize = Math.floor((startDate.getTime() - minViewDate.getTime()) / gapTime)
|
|
284
|
-
const oWidthSize = Math.floor((endDate.getTime() - startDate.getTime()) / gapTime) + 1
|
|
480
|
+
const { offsetLeftSize, offsetWidthSize } = renderFn(startValue, endValue)
|
|
285
481
|
ctMaps[rowid] = {
|
|
286
482
|
row,
|
|
287
483
|
rowid,
|
|
288
|
-
oLeftSize,
|
|
289
|
-
oWidthSize
|
|
484
|
+
oLeftSize: offsetLeftSize,
|
|
485
|
+
oWidthSize: offsetWidthSize
|
|
290
486
|
}
|
|
291
487
|
}
|
|
292
488
|
}
|
|
293
489
|
|
|
294
490
|
if (isRowGroupStatus) {
|
|
295
|
-
|
|
491
|
+
// 行分组
|
|
296
492
|
const mapChildrenField = aggregateOpts.mapChildrenField
|
|
297
493
|
if (mapChildrenField) {
|
|
298
494
|
XEUtils.eachTree(afterGroupFullData, handleParseRender, { children: mapChildrenField })
|
|
299
495
|
}
|
|
300
496
|
} else if (treeConfig) {
|
|
301
|
-
|
|
497
|
+
// 树结构
|
|
302
498
|
XEUtils.eachTree(afterTreeFullData, handleParseRender, { children: transform ? treeOpts.mapChildrenField : childrenField })
|
|
303
499
|
} else {
|
|
304
500
|
afterFullData.forEach(handleParseRender)
|
|
@@ -572,10 +768,10 @@ function handleLazyRecalculate ($xeGanttView: VxeGanttViewConstructor & VxeGantt
|
|
|
572
768
|
return new Promise<void>(resolve => {
|
|
573
769
|
const { rceTimeout, rceRunTime } = internalData
|
|
574
770
|
const $xeTable = internalData.xeTable
|
|
575
|
-
let refreshDelay =
|
|
771
|
+
let refreshDelay = 30
|
|
576
772
|
if ($xeTable) {
|
|
577
773
|
const resizeOpts = $xeTable.computeResizeOpts
|
|
578
|
-
refreshDelay = resizeOpts.refreshDelay ||
|
|
774
|
+
refreshDelay = resizeOpts.refreshDelay || refreshDelay
|
|
579
775
|
}
|
|
580
776
|
if (rceTimeout) {
|
|
581
777
|
clearTimeout(rceTimeout)
|
|
@@ -1009,7 +1205,75 @@ export default defineVxeComponent({
|
|
|
1009
1205
|
computed: {
|
|
1010
1206
|
...({} as {
|
|
1011
1207
|
$xeGantt(): (VxeGanttConstructor & VxeGanttPrivateMethods)
|
|
1012
|
-
})
|
|
1208
|
+
}),
|
|
1209
|
+
computeScaleDateList () {
|
|
1210
|
+
const $xeGanttView = this
|
|
1211
|
+
const $xeGantt = $xeGanttView.$xeGantt
|
|
1212
|
+
const reactData = $xeGanttView.reactData
|
|
1213
|
+
|
|
1214
|
+
const { minViewDate, maxViewDate } = reactData
|
|
1215
|
+
const minScale = $xeGantt.computeMinScale
|
|
1216
|
+
const dateList: Date[] = []
|
|
1217
|
+
if (!minViewDate || !maxViewDate) {
|
|
1218
|
+
return dateList
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
const startTime = minViewDate.getTime()
|
|
1222
|
+
const endTime = maxViewDate.getTime()
|
|
1223
|
+
switch (minScale.type) {
|
|
1224
|
+
case 'year': {
|
|
1225
|
+
let currDate = XEUtils.getWhatYear(minViewDate, 0, 'first')
|
|
1226
|
+
while (currDate <= maxViewDate) {
|
|
1227
|
+
const itemDate = currDate
|
|
1228
|
+
dateList.push(itemDate)
|
|
1229
|
+
currDate = XEUtils.getWhatYear(currDate, 1)
|
|
1230
|
+
}
|
|
1231
|
+
break
|
|
1232
|
+
}
|
|
1233
|
+
case 'quarter': {
|
|
1234
|
+
let currDate = XEUtils.getWhatQuarter(minViewDate, 0, 'first')
|
|
1235
|
+
while (currDate <= maxViewDate) {
|
|
1236
|
+
const itemDate = currDate
|
|
1237
|
+
dateList.push(itemDate)
|
|
1238
|
+
currDate = XEUtils.getWhatQuarter(currDate, 1)
|
|
1239
|
+
}
|
|
1240
|
+
break
|
|
1241
|
+
}
|
|
1242
|
+
case 'month': {
|
|
1243
|
+
let currDate = XEUtils.getWhatMonth(minViewDate, 0, 'first')
|
|
1244
|
+
while (currDate <= maxViewDate) {
|
|
1245
|
+
const itemDate = currDate
|
|
1246
|
+
dateList.push(itemDate)
|
|
1247
|
+
currDate = XEUtils.getWhatMonth(currDate, 1)
|
|
1248
|
+
}
|
|
1249
|
+
break
|
|
1250
|
+
}
|
|
1251
|
+
case 'week': {
|
|
1252
|
+
let currDate = XEUtils.getWhatWeek(minViewDate, 0, minScale.startDay, minScale.startDay)
|
|
1253
|
+
while (currDate <= maxViewDate) {
|
|
1254
|
+
const itemDate = currDate
|
|
1255
|
+
dateList.push(itemDate)
|
|
1256
|
+
currDate = XEUtils.getWhatWeek(currDate, 1)
|
|
1257
|
+
}
|
|
1258
|
+
break
|
|
1259
|
+
}
|
|
1260
|
+
case 'day':
|
|
1261
|
+
case 'date':
|
|
1262
|
+
case 'hour':
|
|
1263
|
+
case 'minute':
|
|
1264
|
+
case 'second': {
|
|
1265
|
+
const gapTime = getStandardGapTime(minScale.type)
|
|
1266
|
+
let currTime = startTime
|
|
1267
|
+
while (currTime <= endTime) {
|
|
1268
|
+
const itemDate = new Date(currTime)
|
|
1269
|
+
dateList.push(itemDate)
|
|
1270
|
+
currTime += gapTime
|
|
1271
|
+
}
|
|
1272
|
+
break
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return dateList
|
|
1276
|
+
}
|
|
1013
1277
|
},
|
|
1014
1278
|
methods: {
|
|
1015
1279
|
//
|
|
@@ -1017,9 +1281,17 @@ export default defineVxeComponent({
|
|
|
1017
1281
|
//
|
|
1018
1282
|
refreshData (): Promise<void> {
|
|
1019
1283
|
const $xeGanttView = this
|
|
1284
|
+
const internalData = $xeGanttView.internalData
|
|
1020
1285
|
|
|
1021
1286
|
handleUpdateData($xeGanttView)
|
|
1022
|
-
|
|
1287
|
+
handleRecalculateStyle($xeGanttView)
|
|
1288
|
+
return $xeGanttView.$nextTick().then(() => {
|
|
1289
|
+
const $xeTable = internalData.xeTable
|
|
1290
|
+
handleRecalculateStyle($xeGanttView)
|
|
1291
|
+
if ($xeTable) {
|
|
1292
|
+
return $xeTable.recalculate()
|
|
1293
|
+
}
|
|
1294
|
+
})
|
|
1023
1295
|
},
|
|
1024
1296
|
updateViewData (): Promise<void> {
|
|
1025
1297
|
const $xeGanttView = this
|