vxe-gantt 4.0.27 → 4.1.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.
- package/es/gantt/src/gantt-header.js +11 -2
- package/es/gantt/src/gantt-view.js +302 -45
- package/es/gantt/src/gantt.js +16 -0
- package/es/gantt/src/util.js +11 -0
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/gantt/src/gantt-header.js +9 -1
- package/lib/gantt/src/gantt-header.min.js +1 -1
- package/lib/gantt/src/gantt-view.js +352 -48
- package/lib/gantt/src/gantt-view.min.js +1 -1
- package/lib/gantt/src/gantt.js +20 -0
- 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 +397 -53
- package/lib/index.umd.min.js +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/package.json +3 -3
- package/packages/gantt/src/gantt-header.ts +9 -2
- package/packages/gantt/src/gantt-view.ts +305 -44
- package/packages/gantt/src/gantt.ts +19 -0
- package/packages/gantt/src/util.ts +13 -0
|
@@ -1,8 +1,8 @@
|
|
|
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'
|
|
@@ -13,6 +13,8 @@ import type { VxeGanttViewConstructor, GanttViewReactData, GanttViewPrivateRef,
|
|
|
13
13
|
const { globalEvents } = VxeUI
|
|
14
14
|
|
|
15
15
|
const sourceType = 'gantt'
|
|
16
|
+
const minuteMs = 1000 * 60
|
|
17
|
+
const dayMs = minuteMs * 60 * 24
|
|
16
18
|
|
|
17
19
|
function createInternalData (): GanttViewInternalData {
|
|
18
20
|
return {
|
|
@@ -49,7 +51,7 @@ export default defineVxeComponent({
|
|
|
49
51
|
|
|
50
52
|
const $xeGantt = inject('$xeGantt', {} as (VxeGanttConstructor & VxeGanttPrivateMethods))
|
|
51
53
|
|
|
52
|
-
const { computeTaskOpts, computeStartField, computeEndField, computeScrollbarOpts, computeScrollbarXToTop, computeScrollbarYToLeft } = $xeGantt.getComputeMaps()
|
|
54
|
+
const { computeTaskOpts, computeStartField, computeEndField, computeScrollbarOpts, computeScrollbarXToTop, computeScrollbarYToLeft, computeScaleUnit, computeWeekScale, computeMinScale } = $xeGantt.getComputeMaps()
|
|
53
55
|
|
|
54
56
|
const refElem = ref<HTMLDivElement>()
|
|
55
57
|
|
|
@@ -109,7 +111,73 @@ export default defineVxeComponent({
|
|
|
109
111
|
refElem
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
const computeScaleDateList = computed(() => {
|
|
115
|
+
const { minViewDate, maxViewDate } = reactData
|
|
116
|
+
const minScale = computeMinScale.value
|
|
117
|
+
const dateList: Date[] = []
|
|
118
|
+
if (!minViewDate || !maxViewDate) {
|
|
119
|
+
return dateList
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const startTime = minViewDate.getTime()
|
|
123
|
+
const endTime = maxViewDate.getTime()
|
|
124
|
+
switch (minScale.type) {
|
|
125
|
+
case 'year': {
|
|
126
|
+
let currDate = XEUtils.getWhatYear(minViewDate, 0, 'first')
|
|
127
|
+
while (currDate <= maxViewDate) {
|
|
128
|
+
const itemDate = currDate
|
|
129
|
+
dateList.push(itemDate)
|
|
130
|
+
currDate = XEUtils.getWhatYear(currDate, 1)
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
}
|
|
134
|
+
case 'quarter': {
|
|
135
|
+
let currDate = XEUtils.getWhatQuarter(minViewDate, 0, 'first')
|
|
136
|
+
while (currDate <= maxViewDate) {
|
|
137
|
+
const itemDate = currDate
|
|
138
|
+
dateList.push(itemDate)
|
|
139
|
+
currDate = XEUtils.getWhatQuarter(currDate, 1)
|
|
140
|
+
}
|
|
141
|
+
break
|
|
142
|
+
}
|
|
143
|
+
case 'month': {
|
|
144
|
+
let currDate = XEUtils.getWhatMonth(minViewDate, 0, 'first')
|
|
145
|
+
while (currDate <= maxViewDate) {
|
|
146
|
+
const itemDate = currDate
|
|
147
|
+
dateList.push(itemDate)
|
|
148
|
+
currDate = XEUtils.getWhatMonth(currDate, 1)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
}
|
|
152
|
+
case 'week': {
|
|
153
|
+
let currDate = XEUtils.getWhatWeek(minViewDate, 0, minScale.startDay, minScale.startDay)
|
|
154
|
+
while (currDate <= maxViewDate) {
|
|
155
|
+
const itemDate = currDate
|
|
156
|
+
dateList.push(itemDate)
|
|
157
|
+
currDate = XEUtils.getWhatWeek(currDate, 1)
|
|
158
|
+
}
|
|
159
|
+
break
|
|
160
|
+
}
|
|
161
|
+
case 'day':
|
|
162
|
+
case 'date':
|
|
163
|
+
case 'hour':
|
|
164
|
+
case 'minute':
|
|
165
|
+
case 'second': {
|
|
166
|
+
const gapTime = getStandardGapTime(minScale.type)
|
|
167
|
+
let currTime = startTime
|
|
168
|
+
while (currTime <= endTime) {
|
|
169
|
+
const itemDate = new Date(currTime)
|
|
170
|
+
dateList.push(itemDate)
|
|
171
|
+
currTime += gapTime
|
|
172
|
+
}
|
|
173
|
+
break
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return dateList
|
|
177
|
+
})
|
|
178
|
+
|
|
112
179
|
const computeMaps: GanttViewPrivateComputed = {
|
|
180
|
+
computeScaleDateList
|
|
113
181
|
}
|
|
114
182
|
|
|
115
183
|
const $xeGanttView = {
|
|
@@ -152,37 +220,17 @@ export default defineVxeComponent({
|
|
|
152
220
|
}
|
|
153
221
|
}
|
|
154
222
|
|
|
155
|
-
const
|
|
156
|
-
const ganttProps = $xeGantt.props
|
|
223
|
+
const handleColumnHeader = () => {
|
|
157
224
|
const ganttReactData = $xeGantt.reactData
|
|
158
|
-
const { treeConfig } = ganttProps
|
|
159
225
|
const { taskScaleList } = ganttReactData
|
|
160
|
-
const
|
|
161
|
-
const minScale =
|
|
226
|
+
const scaleUnit = computeScaleUnit.value
|
|
227
|
+
const minScale = computeMinScale.value
|
|
228
|
+
const weekScale = computeWeekScale.value
|
|
229
|
+
const scaleDateList = computeScaleDateList.value
|
|
162
230
|
const fullCols: VxeGanttDefines.ViewColumn[] = []
|
|
163
231
|
const groupCols: VxeGanttDefines.GroupColumn[] = []
|
|
164
|
-
if (minScale && minViewDate && maxViewDate) {
|
|
165
|
-
const minSType = minScale.type
|
|
166
|
-
const weekScale = taskScaleList.find(item => item.type === 'week')
|
|
167
|
-
let gapTime = 1000 * 60 * 60 * 24
|
|
168
|
-
switch (minScale.type) {
|
|
169
|
-
case 'hour':
|
|
170
|
-
gapTime = 1000 * 60 * 60
|
|
171
|
-
break
|
|
172
|
-
case 'minute':
|
|
173
|
-
gapTime = 1000 * 60
|
|
174
|
-
break
|
|
175
|
-
case 'second':
|
|
176
|
-
gapTime = 1000
|
|
177
|
-
break
|
|
178
|
-
default: {
|
|
179
|
-
break
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const currTime = minViewDate.getTime()
|
|
183
|
-
const diffDayNum = maxViewDate.getTime() - minViewDate.getTime()
|
|
184
|
-
const countSize = Math.max(5, Math.floor(diffDayNum / gapTime) + 1)
|
|
185
232
|
|
|
233
|
+
if (minScale && scaleUnit && scaleDateList.length) {
|
|
186
234
|
const renderListMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn[]> = {
|
|
187
235
|
year: [],
|
|
188
236
|
quarter: [],
|
|
@@ -208,7 +256,7 @@ export default defineVxeComponent({
|
|
|
208
256
|
}
|
|
209
257
|
|
|
210
258
|
const handleData = (type: VxeGanttDefines.ColumnScaleType, colMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn>, minCol: VxeGanttDefines.ViewColumn) => {
|
|
211
|
-
if (
|
|
259
|
+
if (minScale.type === type) {
|
|
212
260
|
return
|
|
213
261
|
}
|
|
214
262
|
const currCol = colMaps[type]
|
|
@@ -226,14 +274,15 @@ export default defineVxeComponent({
|
|
|
226
274
|
currGpCol.children.push(minCol)
|
|
227
275
|
}
|
|
228
276
|
}
|
|
229
|
-
|
|
230
|
-
|
|
277
|
+
|
|
278
|
+
for (let i = 0; i < scaleDateList.length; i++) {
|
|
279
|
+
const itemDate = scaleDateList[i]
|
|
231
280
|
const [yyyy, MM, dd, HH, mm, ss] = XEUtils.toDateString(itemDate, 'yyyy-M-d-H-m-s').split('-')
|
|
232
281
|
const e = itemDate.getDay()
|
|
233
282
|
const E = e + 1
|
|
234
283
|
const q = Math.ceil((itemDate.getMonth() + 1) / 3)
|
|
235
284
|
const W = XEUtils.getYearWeek(itemDate, weekScale ? weekScale.startDay : undefined)
|
|
236
|
-
const dateObj: VxeGanttDefines.ScaleDateObj = { yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e }
|
|
285
|
+
const dateObj: VxeGanttDefines.ScaleDateObj = { date: itemDate, yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e }
|
|
237
286
|
const colMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn> = {
|
|
238
287
|
year: {
|
|
239
288
|
field: yyyy,
|
|
@@ -281,7 +330,7 @@ export default defineVxeComponent({
|
|
|
281
330
|
dateObj
|
|
282
331
|
}
|
|
283
332
|
}
|
|
284
|
-
const minCol = colMaps[
|
|
333
|
+
const minCol = colMaps[minScale.type]
|
|
285
334
|
if (minScale.level < 19) {
|
|
286
335
|
handleData('year', colMaps, minCol)
|
|
287
336
|
}
|
|
@@ -311,7 +360,7 @@ export default defineVxeComponent({
|
|
|
311
360
|
}
|
|
312
361
|
|
|
313
362
|
taskScaleList.forEach(scaleItem => {
|
|
314
|
-
if (scaleItem.type ===
|
|
363
|
+
if (scaleItem.type === minScale.type) {
|
|
315
364
|
groupCols.push({
|
|
316
365
|
scaleItem,
|
|
317
366
|
columns: fullCols
|
|
@@ -330,7 +379,214 @@ export default defineVxeComponent({
|
|
|
330
379
|
columns: list
|
|
331
380
|
})
|
|
332
381
|
})
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return {
|
|
385
|
+
fullCols,
|
|
386
|
+
groupCols
|
|
387
|
+
}
|
|
388
|
+
}
|
|
333
389
|
|
|
390
|
+
const createChartRender = (fullCols: VxeGanttDefines.ViewColumn[]) => {
|
|
391
|
+
const { minViewDate } = reactData
|
|
392
|
+
const minScale = computeMinScale.value
|
|
393
|
+
const scaleUnit = computeScaleUnit.value
|
|
394
|
+
const weekScale = computeWeekScale.value
|
|
395
|
+
switch (scaleUnit) {
|
|
396
|
+
case 'year': {
|
|
397
|
+
const indexMaps: Record<string, number> = {}
|
|
398
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
399
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy')
|
|
400
|
+
indexMaps[yyyyMM] = i
|
|
401
|
+
})
|
|
402
|
+
return (startValue: any, endValue: any) => {
|
|
403
|
+
const startDate = parseStringDate(startValue)
|
|
404
|
+
const endDate = parseStringDate(endValue)
|
|
405
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy')
|
|
406
|
+
const startFirstDate = XEUtils.getWhatYear(startDate, 0, 'first')
|
|
407
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy')
|
|
408
|
+
const endFirstDate = XEUtils.getWhatYear(endDate, 0, 'first')
|
|
409
|
+
const dateSize = Math.floor((XEUtils.getWhatYear(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
410
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
411
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
412
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
413
|
+
return {
|
|
414
|
+
offsetLeftSize,
|
|
415
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
case 'quarter': {
|
|
420
|
+
const indexMaps: Record<string, number> = {}
|
|
421
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
422
|
+
const q = XEUtils.toDateString(dateObj.date, 'yyyy-q')
|
|
423
|
+
indexMaps[q] = i
|
|
424
|
+
})
|
|
425
|
+
return (startValue: any, endValue: any) => {
|
|
426
|
+
const startDate = parseStringDate(startValue)
|
|
427
|
+
const endDate = parseStringDate(endValue)
|
|
428
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-q')
|
|
429
|
+
const startFirstDate = XEUtils.getWhatQuarter(startDate, 0, 'first')
|
|
430
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-q')
|
|
431
|
+
const endFirstDate = XEUtils.getWhatQuarter(endDate, 0, 'first')
|
|
432
|
+
const dateSize = Math.floor((XEUtils.getWhatQuarter(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
433
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
434
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
435
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
436
|
+
return {
|
|
437
|
+
offsetLeftSize,
|
|
438
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
case 'month': {
|
|
443
|
+
const indexMaps: Record<string, number> = {}
|
|
444
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
445
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM')
|
|
446
|
+
indexMaps[yyyyMM] = i
|
|
447
|
+
})
|
|
448
|
+
return (startValue: any, endValue: any) => {
|
|
449
|
+
const startDate = parseStringDate(startValue)
|
|
450
|
+
const endDate = parseStringDate(endValue)
|
|
451
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM')
|
|
452
|
+
const startFirstDate = XEUtils.getWhatMonth(startDate, 0, 'first')
|
|
453
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM')
|
|
454
|
+
const endFirstDate = XEUtils.getWhatMonth(endDate, 0, 'first')
|
|
455
|
+
const dateSize = Math.floor((XEUtils.getWhatMonth(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
456
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
457
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
458
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
459
|
+
return {
|
|
460
|
+
offsetLeftSize,
|
|
461
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
case 'week': {
|
|
466
|
+
const indexMaps: Record<string, number> = {}
|
|
467
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
468
|
+
const yyyyW = XEUtils.toDateString(dateObj.date, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
469
|
+
indexMaps[yyyyW] = i
|
|
470
|
+
})
|
|
471
|
+
return (startValue: any, endValue: any) => {
|
|
472
|
+
const startDate = parseStringDate(startValue)
|
|
473
|
+
const endDate = parseStringDate(endValue)
|
|
474
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
475
|
+
const startFirstDate = XEUtils.getWhatWeek(startDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
|
|
476
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
477
|
+
const endFirstDate = XEUtils.getWhatWeek(endDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
|
|
478
|
+
const dateSize = Math.floor((XEUtils.getWhatWeek(endDate, 1, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined).getTime() - endFirstDate.getTime()) / dayMs)
|
|
479
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
480
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
481
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
482
|
+
return {
|
|
483
|
+
offsetLeftSize,
|
|
484
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
case 'day':
|
|
489
|
+
case 'date': {
|
|
490
|
+
const indexMaps: Record<string, number> = {}
|
|
491
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
492
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd')
|
|
493
|
+
indexMaps[yyyyMM] = i
|
|
494
|
+
})
|
|
495
|
+
return (startValue: any, endValue: any) => {
|
|
496
|
+
const startDate = parseStringDate(startValue)
|
|
497
|
+
const endDate = parseStringDate(endValue)
|
|
498
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd')
|
|
499
|
+
const startFirstDate = XEUtils.getWhatDay(startDate, 0, 'first')
|
|
500
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd')
|
|
501
|
+
const endFirstDate = XEUtils.getWhatDay(endDate, 0, 'first')
|
|
502
|
+
const minuteSize = Math.floor((XEUtils.getWhatDay(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
503
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
504
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
505
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
506
|
+
return {
|
|
507
|
+
offsetLeftSize,
|
|
508
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
case 'hour': {
|
|
513
|
+
const indexMaps: Record<string, number> = {}
|
|
514
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
515
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH')
|
|
516
|
+
indexMaps[yyyyMM] = i
|
|
517
|
+
})
|
|
518
|
+
return (startValue: any, endValue: any) => {
|
|
519
|
+
const startDate = parseStringDate(startValue)
|
|
520
|
+
const endDate = parseStringDate(endValue)
|
|
521
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH')
|
|
522
|
+
const startFirstDate = XEUtils.getWhatHours(startDate, 0, 'first')
|
|
523
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH')
|
|
524
|
+
const endFirstDate = XEUtils.getWhatHours(endDate, 0, 'first')
|
|
525
|
+
const minuteSize = Math.floor((XEUtils.getWhatHours(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
526
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
527
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
528
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
529
|
+
return {
|
|
530
|
+
offsetLeftSize,
|
|
531
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
case 'minute': {
|
|
536
|
+
const indexMaps: Record<string, number> = {}
|
|
537
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
538
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH:mm')
|
|
539
|
+
indexMaps[yyyyMM] = i
|
|
540
|
+
})
|
|
541
|
+
return (startValue: any, endValue: any) => {
|
|
542
|
+
const startDate = parseStringDate(startValue)
|
|
543
|
+
const endDate = parseStringDate(endValue)
|
|
544
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH:mm')
|
|
545
|
+
const startFirstDate = XEUtils.getWhatMinutes(startDate, 0, 'first')
|
|
546
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH:mm')
|
|
547
|
+
const endFirstDate = XEUtils.getWhatMinutes(endDate, 0, 'first')
|
|
548
|
+
const minuteSize = Math.floor((XEUtils.getWhatMinutes(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
549
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
550
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
551
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
552
|
+
return {
|
|
553
|
+
offsetLeftSize,
|
|
554
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
case 'second': {
|
|
559
|
+
const gapTime = getStandardGapTime(minScale.type)
|
|
560
|
+
return (startValue: any, endValue: any) => {
|
|
561
|
+
const startDate = parseStringDate(startValue)
|
|
562
|
+
const endDate = parseStringDate(endValue)
|
|
563
|
+
let offsetLeftSize = 0
|
|
564
|
+
let offsetWidthSize = 0
|
|
565
|
+
if (minViewDate) {
|
|
566
|
+
offsetLeftSize = (startDate.getTime() - minViewDate.getTime()) / gapTime
|
|
567
|
+
offsetWidthSize = ((endDate.getTime() - startDate.getTime()) / gapTime) + 1
|
|
568
|
+
}
|
|
569
|
+
return {
|
|
570
|
+
offsetLeftSize,
|
|
571
|
+
offsetWidthSize
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return () => {
|
|
577
|
+
return {
|
|
578
|
+
offsetLeftSize: 0,
|
|
579
|
+
offsetWidthSize: 0
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
const handleParseColumn = () => {
|
|
585
|
+
const ganttProps = $xeGantt.props
|
|
586
|
+
const { treeConfig } = ganttProps
|
|
587
|
+
const { minViewDate, maxViewDate } = reactData
|
|
588
|
+
const { fullCols, groupCols } = handleColumnHeader()
|
|
589
|
+
if (minViewDate && maxViewDate && fullCols.length) {
|
|
334
590
|
const $xeTable = internalData.xeTable
|
|
335
591
|
if ($xeTable) {
|
|
336
592
|
const startField = computeStartField.value
|
|
@@ -346,20 +602,18 @@ export default defineVxeComponent({
|
|
|
346
602
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
347
603
|
|
|
348
604
|
const ctMaps: Record<string, VxeGanttDefines.RowCacheItem> = {}
|
|
605
|
+
const renderFn = createChartRender(fullCols)
|
|
349
606
|
const handleParseRender = (row: any) => {
|
|
350
607
|
const rowid = $xeTable.getRowid(row)
|
|
351
608
|
const startValue = XEUtils.get(row, startField)
|
|
352
609
|
const endValue = XEUtils.get(row, endField)
|
|
353
610
|
if (startValue && endValue) {
|
|
354
|
-
const
|
|
355
|
-
const endDate = parseStringDate(endValue)
|
|
356
|
-
const oLeftSize = Math.floor((startDate.getTime() - minViewDate.getTime()) / gapTime)
|
|
357
|
-
const oWidthSize = Math.floor((endDate.getTime() - startDate.getTime()) / gapTime) + 1
|
|
611
|
+
const { offsetLeftSize, offsetWidthSize } = renderFn(startValue, endValue)
|
|
358
612
|
ctMaps[rowid] = {
|
|
359
613
|
row,
|
|
360
614
|
rowid,
|
|
361
|
-
oLeftSize,
|
|
362
|
-
oWidthSize
|
|
615
|
+
oLeftSize: offsetLeftSize,
|
|
616
|
+
oWidthSize: offsetWidthSize
|
|
363
617
|
}
|
|
364
618
|
}
|
|
365
619
|
}
|
|
@@ -627,11 +881,11 @@ export default defineVxeComponent({
|
|
|
627
881
|
return new Promise<void>(resolve => {
|
|
628
882
|
const { rceTimeout, rceRunTime } = internalData
|
|
629
883
|
const $xeTable = internalData.xeTable
|
|
630
|
-
let refreshDelay =
|
|
884
|
+
let refreshDelay = 30
|
|
631
885
|
if ($xeTable) {
|
|
632
886
|
const { computeResizeOpts } = $xeTable.getComputeMaps()
|
|
633
887
|
const resizeOpts = computeResizeOpts.value
|
|
634
|
-
refreshDelay = resizeOpts.refreshDelay ||
|
|
888
|
+
refreshDelay = resizeOpts.refreshDelay || refreshDelay
|
|
635
889
|
}
|
|
636
890
|
if (rceTimeout) {
|
|
637
891
|
clearTimeout(rceTimeout)
|
|
@@ -956,7 +1210,14 @@ export default defineVxeComponent({
|
|
|
956
1210
|
const ganttViewMethods: VxeGanttViewMethods = {
|
|
957
1211
|
refreshData () {
|
|
958
1212
|
handleUpdateData()
|
|
959
|
-
|
|
1213
|
+
handleRecalculateStyle()
|
|
1214
|
+
return nextTick().then(() => {
|
|
1215
|
+
const $xeTable = internalData.xeTable
|
|
1216
|
+
handleRecalculateStyle()
|
|
1217
|
+
if ($xeTable) {
|
|
1218
|
+
return $xeTable.recalculate()
|
|
1219
|
+
}
|
|
1220
|
+
})
|
|
960
1221
|
},
|
|
961
1222
|
updateViewData () {
|
|
962
1223
|
const $xeTable = internalData.xeTable
|
|
@@ -231,6 +231,21 @@ export default defineVxeComponent({
|
|
|
231
231
|
return Object.assign({}, getConfig().gantt.taskSplitConfig, props.taskSplitConfig)
|
|
232
232
|
})
|
|
233
233
|
|
|
234
|
+
const computeScaleUnit = computed(() => {
|
|
235
|
+
const minScale = computeMinScale.value
|
|
236
|
+
return minScale ? minScale.type : 'date'
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
const computeMinScale = computed(() => {
|
|
240
|
+
const { taskScaleList } = reactData
|
|
241
|
+
return XEUtils.last(taskScaleList)
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
const computeWeekScale = computed(() => {
|
|
245
|
+
const { taskScaleList } = reactData
|
|
246
|
+
return taskScaleList.find(item => item.type === 'week')
|
|
247
|
+
})
|
|
248
|
+
|
|
234
249
|
const computeTaskScaleConfs = computed(() => {
|
|
235
250
|
const taskViewOpts = computeTaskViewOpts.value
|
|
236
251
|
const { scales } = taskViewOpts
|
|
@@ -463,6 +478,9 @@ export default defineVxeComponent({
|
|
|
463
478
|
computeTaskBarResizeOpts,
|
|
464
479
|
computeTaskSplitOpts,
|
|
465
480
|
computeTaskScaleConfs,
|
|
481
|
+
computeScaleUnit,
|
|
482
|
+
computeMinScale,
|
|
483
|
+
computeWeekScale,
|
|
466
484
|
computeTitleField,
|
|
467
485
|
computeStartField,
|
|
468
486
|
computeEndField,
|
|
@@ -2245,6 +2263,7 @@ export default defineVxeComponent({
|
|
|
2245
2263
|
|
|
2246
2264
|
watch(computeTaskScaleConfs, () => {
|
|
2247
2265
|
handleTaskScaleConfig()
|
|
2266
|
+
$xeGantt.refreshTaskView()
|
|
2248
2267
|
})
|
|
2249
2268
|
|
|
2250
2269
|
hooks.forEach((options) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VxeGanttDefines } from '../../../types'
|
|
1
2
|
import type { VxeTableDefines, VxeTablePropTypes } from 'vxe-table'
|
|
2
3
|
|
|
3
4
|
export function getRefElem (refEl: any) {
|
|
@@ -20,3 +21,15 @@ export function getCalcHeight (height: number | 'unset' | undefined | null) {
|
|
|
20
21
|
export function getCellRestHeight (rowRest: VxeTableDefines.RowCacheItem, cellOpts: VxeTablePropTypes.CellConfig, rowOpts: VxeTablePropTypes.RowConfig, defaultRowHeight: number) {
|
|
21
22
|
return rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
export function getStandardGapTime (type: VxeGanttDefines.ColumnScaleType) {
|
|
26
|
+
switch (type) {
|
|
27
|
+
case 'hour':
|
|
28
|
+
return 1000 * 60 * 60
|
|
29
|
+
case 'minute':
|
|
30
|
+
return 1000 * 60
|
|
31
|
+
case 'second':
|
|
32
|
+
return 1000
|
|
33
|
+
}
|
|
34
|
+
return 1000 * 60 * 60 * 24
|
|
35
|
+
}
|