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.
@@ -44,7 +44,7 @@ export default defineVxeComponent({
44
44
  const progressField = computeProgressField.value
45
45
  const taskBarOpts = computeTaskBarOpts.value
46
46
  const barParams = { $gantt: $xeGantt, row }
47
- const { showProgress, showContent, contentMethod, barStyle, drag } = taskBarOpts
47
+ const { showProgress, showContent, contentMethod, barStyle, drag, showTooltip } = taskBarOpts
48
48
  const isBarRowStyle = XEUtils.isFunction(barStyle)
49
49
  const barStyObj = (barStyle ? (isBarRowStyle ? barStyle(barParams) : barStyle) : {}) || {}
50
50
  const { round } = barStyObj
@@ -75,7 +75,38 @@ export default defineVxeComponent({
75
75
  title = getStringValue(contentMethod({ row, title }))
76
76
  }
77
77
 
78
- const ctParams = { source: sourceType, type: viewType, row, $rowIndex, rowIndex, _rowIndex }
78
+ const ctParams = { source: sourceType, type: viewType, row, $rowIndex, rowIndex, _rowIndex, $gantt: $xeGantt }
79
+ const ons: {
80
+ onClick: any
81
+ onDblclick: any
82
+ onMousedown: any
83
+ onMouseover?: any
84
+ onMouseleave?: any
85
+ } = {
86
+ onClick (evnt: MouseEvent) {
87
+ $xeGantt.handleTaskBarClickEvent(evnt, barParams)
88
+ },
89
+ onDblclick (evnt: MouseEvent) {
90
+ $xeGantt.handleTaskBarDblclickEvent(evnt, barParams)
91
+ },
92
+ onMousedown (evnt: MouseEvent) {
93
+ if ($xeGantt.handleTaskBarMousedownEvent) {
94
+ $xeGantt.handleTaskBarMousedownEvent(evnt, barParams)
95
+ }
96
+ }
97
+ }
98
+ if (showTooltip) {
99
+ ons.onMouseover = (evnt: MouseEvent) => {
100
+ const ttParams = Object.assign({ $event: evnt }, ctParams)
101
+ $xeGantt.triggerTaskBarTooltipEvent(evnt, ttParams)
102
+ $xeGantt.dispatchEvent('task-bar-mouseenter', ttParams, evnt)
103
+ }
104
+ ons.onMouseleave = (evnt: MouseEvent) => {
105
+ const ttParams = Object.assign({ $event: evnt }, ctParams)
106
+ $xeGantt.handleTaskBarTooltipLeaveEvent(evnt, ttParams)
107
+ $xeGantt.dispatchEvent('task-bar-mouseleave', ttParams, evnt)
108
+ }
109
+ }
79
110
  return h('div', {
80
111
  key: treeConfig ? rowid : $rowIndex,
81
112
  rowid,
@@ -95,17 +126,7 @@ export default defineVxeComponent({
95
126
  class: taskBarSlot ? 'vxe-gantt-view--chart-custom-bar' : 'vxe-gantt-view--chart-bar',
96
127
  style: vbStyle,
97
128
  rowid,
98
- onClick (evnt: MouseEvent) {
99
- $xeGantt.handleTaskBarClickEvent(evnt, barParams)
100
- },
101
- onDblclick (evnt: MouseEvent) {
102
- $xeGantt.handleTaskBarDblclickEvent(evnt, barParams)
103
- },
104
- onMousedown (evnt: MouseEvent) {
105
- if ($xeGantt.handleTaskBarMousedownEvent) {
106
- $xeGantt.handleTaskBarMousedownEvent(evnt, barParams)
107
- }
108
- }
129
+ ...ons
109
130
  }, taskBarSlot
110
131
  ? $xeGantt.callSlot(taskBarSlot, barParams)
111
132
  : [
@@ -56,19 +56,26 @@ export default defineVxeComponent({
56
56
  })
57
57
  })),
58
58
  h('thead', {}, headerGroups.map(({ scaleItem, columns }, $rowIndex) => {
59
- const { type, titleMethod, headerCellStyle, slots } = scaleItem
59
+ const { type, titleFormat, titleMethod, headerCellStyle, slots } = scaleItem
60
60
  const titleSlot = slots ? slots.title : null
61
- const todayValue = showNowLine && $rowIndex === headerGroups.length - 1 ? todayDateMaps[type] : null
61
+ const isLast = $rowIndex === headerGroups.length - 1
62
+ const todayValue = isLast && showNowLine ? todayDateMaps[type] : null
62
63
  return h('tr', {
63
64
  key: $rowIndex
64
65
  }, columns.map((column, cIndex) => {
65
66
  const { field, childCount, dateObj } = column
66
67
  let label = `${column.title}`
67
- if ($rowIndex < headerGroups.length - 1) {
68
- if (scaleItem.type === 'day') {
69
- label = getI18n(`vxe.gantt.dayss.w${dateObj.e}`)
68
+ if (scaleItem.type === 'day') {
69
+ label = getI18n(`vxe.gantt.dayss.w${dateObj.e}`)
70
+ } else {
71
+ if ($rowIndex) {
72
+ label = getI18n(`vxe.gantt.tSimpleFormat.${type}`, dateObj)
70
73
  } else {
71
- label = getI18n(`vxe.gantt.${!$rowIndex && headerGroups.length > 1 ? 'tFullFormat' : 'tSimpleFormat'}.${type}`, dateObj)
74
+ if (isLast && scaleItem.type === 'week') {
75
+ label = getI18n(`vxe.gantt.tSimpleFormat.${type}`, dateObj)
76
+ } else {
77
+ label = getI18n(`vxe.gantt.tFullFormat.${type}`, dateObj)
78
+ }
72
79
  }
73
80
  }
74
81
  let cellVNs: string | VxeComponentSlotType[] = label
@@ -77,6 +84,8 @@ export default defineVxeComponent({
77
84
  cellVNs = $xeGantt.callSlot(titleSlot, ctParams)
78
85
  } else if (titleMethod) {
79
86
  cellVNs = `${titleMethod(ctParams)}`
87
+ } else if (titleFormat) {
88
+ cellVNs = XEUtils.toDateString(dateObj.date, titleFormat)
80
89
  }
81
90
  let cellStys = {}
82
91
  if (headerCellStyle) {
@@ -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 handleParseColumn = () => {
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 { minViewDate, maxViewDate } = reactData
161
- const minScale = XEUtils.last(taskScaleList)
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 (minSType === type) {
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
- for (let i = 0; i < countSize; i++) {
230
- const itemDate = new Date(currTime + (i * gapTime))
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,14 +330,14 @@ export default defineVxeComponent({
281
330
  dateObj
282
331
  }
283
332
  }
284
- const minCol = colMaps[minSType]
333
+ const minCol = colMaps[minScale.type]
285
334
  if (minScale.level < 19) {
286
335
  handleData('year', colMaps, minCol)
287
336
  }
288
337
  if (minScale.level < 17) {
289
338
  handleData('quarter', colMaps, minCol)
290
339
  }
291
- if (minScale.level < 14) {
340
+ if (minScale.level < 15) {
292
341
  handleData('month', colMaps, minCol)
293
342
  }
294
343
  if (minScale.level < 13) {
@@ -297,7 +346,7 @@ export default defineVxeComponent({
297
346
  if (minScale.level < 11) {
298
347
  handleData('day', colMaps, minCol)
299
348
  }
300
- if (minScale.level < 12) {
349
+ if (minScale.level < 9) {
301
350
  handleData('date', colMaps, minCol)
302
351
  }
303
352
  if (minScale.level < 7) {
@@ -306,12 +355,15 @@ export default defineVxeComponent({
306
355
  if (minScale.level < 5) {
307
356
  handleData('minute', colMaps, minCol)
308
357
  }
358
+ if (minScale.level < 3) {
359
+ handleData('second', colMaps, minCol)
360
+ }
309
361
 
310
362
  fullCols.push(minCol)
311
363
  }
312
364
 
313
365
  taskScaleList.forEach(scaleItem => {
314
- if (scaleItem.type === minSType) {
366
+ if (scaleItem.type === minScale.type) {
315
367
  groupCols.push({
316
368
  scaleItem,
317
369
  columns: fullCols
@@ -330,7 +382,214 @@ export default defineVxeComponent({
330
382
  columns: list
331
383
  })
332
384
  })
385
+ }
386
+
387
+ return {
388
+ fullCols,
389
+ groupCols
390
+ }
391
+ }
392
+
393
+ const createChartRender = (fullCols: VxeGanttDefines.ViewColumn[]) => {
394
+ const { minViewDate } = reactData
395
+ const minScale = computeMinScale.value
396
+ const scaleUnit = computeScaleUnit.value
397
+ const weekScale = computeWeekScale.value
398
+ switch (scaleUnit) {
399
+ case 'year': {
400
+ const indexMaps: Record<string, number> = {}
401
+ fullCols.forEach(({ dateObj }, i) => {
402
+ const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy')
403
+ indexMaps[yyyyMM] = i
404
+ })
405
+ return (startValue: any, endValue: any) => {
406
+ const startDate = parseStringDate(startValue)
407
+ const endDate = parseStringDate(endValue)
408
+ const startStr = XEUtils.toDateString(startDate, 'yyyy')
409
+ const startFirstDate = XEUtils.getWhatYear(startDate, 0, 'first')
410
+ const endStr = XEUtils.toDateString(endDate, 'yyyy')
411
+ const endFirstDate = XEUtils.getWhatYear(endDate, 0, 'first')
412
+ const dateSize = Math.floor((XEUtils.getWhatYear(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
413
+ const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
414
+ const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
415
+ const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
416
+ return {
417
+ offsetLeftSize,
418
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
419
+ }
420
+ }
421
+ }
422
+ case 'quarter': {
423
+ const indexMaps: Record<string, number> = {}
424
+ fullCols.forEach(({ dateObj }, i) => {
425
+ const q = XEUtils.toDateString(dateObj.date, 'yyyy-q')
426
+ indexMaps[q] = i
427
+ })
428
+ return (startValue: any, endValue: any) => {
429
+ const startDate = parseStringDate(startValue)
430
+ const endDate = parseStringDate(endValue)
431
+ const startStr = XEUtils.toDateString(startDate, 'yyyy-q')
432
+ const startFirstDate = XEUtils.getWhatQuarter(startDate, 0, 'first')
433
+ const endStr = XEUtils.toDateString(endDate, 'yyyy-q')
434
+ const endFirstDate = XEUtils.getWhatQuarter(endDate, 0, 'first')
435
+ const dateSize = Math.floor((XEUtils.getWhatQuarter(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
436
+ const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
437
+ const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
438
+ const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
439
+ return {
440
+ offsetLeftSize,
441
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
442
+ }
443
+ }
444
+ }
445
+ case 'month': {
446
+ const indexMaps: Record<string, number> = {}
447
+ fullCols.forEach(({ dateObj }, i) => {
448
+ const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM')
449
+ indexMaps[yyyyMM] = i
450
+ })
451
+ return (startValue: any, endValue: any) => {
452
+ const startDate = parseStringDate(startValue)
453
+ const endDate = parseStringDate(endValue)
454
+ const startStr = XEUtils.toDateString(startDate, 'yyyy-MM')
455
+ const startFirstDate = XEUtils.getWhatMonth(startDate, 0, 'first')
456
+ const endStr = XEUtils.toDateString(endDate, 'yyyy-MM')
457
+ const endFirstDate = XEUtils.getWhatMonth(endDate, 0, 'first')
458
+ const dateSize = Math.floor((XEUtils.getWhatMonth(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
459
+ const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
460
+ const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
461
+ const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
462
+ return {
463
+ offsetLeftSize,
464
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
465
+ }
466
+ }
467
+ }
468
+ case 'week': {
469
+ const indexMaps: Record<string, number> = {}
470
+ fullCols.forEach(({ dateObj }, i) => {
471
+ const yyyyW = XEUtils.toDateString(dateObj.date, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
472
+ indexMaps[yyyyW] = i
473
+ })
474
+ return (startValue: any, endValue: any) => {
475
+ const startDate = parseStringDate(startValue)
476
+ const endDate = parseStringDate(endValue)
477
+ const startStr = XEUtils.toDateString(startDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
478
+ const startFirstDate = XEUtils.getWhatWeek(startDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
479
+ const endStr = XEUtils.toDateString(endDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
480
+ const endFirstDate = XEUtils.getWhatWeek(endDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
481
+ const dateSize = Math.floor((XEUtils.getWhatWeek(endDate, 1, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined).getTime() - endFirstDate.getTime()) / dayMs)
482
+ const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
483
+ const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
484
+ const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
485
+ return {
486
+ offsetLeftSize,
487
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
488
+ }
489
+ }
490
+ }
491
+ case 'day':
492
+ case 'date': {
493
+ const indexMaps: Record<string, number> = {}
494
+ fullCols.forEach(({ dateObj }, i) => {
495
+ const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd')
496
+ indexMaps[yyyyMM] = i
497
+ })
498
+ return (startValue: any, endValue: any) => {
499
+ const startDate = parseStringDate(startValue)
500
+ const endDate = parseStringDate(endValue)
501
+ const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd')
502
+ const startFirstDate = XEUtils.getWhatDay(startDate, 0, 'first')
503
+ const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd')
504
+ const endFirstDate = XEUtils.getWhatDay(endDate, 0, 'first')
505
+ const minuteSize = Math.floor((XEUtils.getWhatDay(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
506
+ const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
507
+ const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
508
+ const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
509
+ return {
510
+ offsetLeftSize,
511
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
512
+ }
513
+ }
514
+ }
515
+ case 'hour': {
516
+ const indexMaps: Record<string, number> = {}
517
+ fullCols.forEach(({ dateObj }, i) => {
518
+ const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH')
519
+ indexMaps[yyyyMM] = i
520
+ })
521
+ return (startValue: any, endValue: any) => {
522
+ const startDate = parseStringDate(startValue)
523
+ const endDate = parseStringDate(endValue)
524
+ const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH')
525
+ const startFirstDate = XEUtils.getWhatHours(startDate, 0, 'first')
526
+ const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH')
527
+ const endFirstDate = XEUtils.getWhatHours(endDate, 0, 'first')
528
+ const minuteSize = Math.floor((XEUtils.getWhatHours(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
529
+ const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
530
+ const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
531
+ const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
532
+ return {
533
+ offsetLeftSize,
534
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
535
+ }
536
+ }
537
+ }
538
+ case 'minute': {
539
+ const indexMaps: Record<string, number> = {}
540
+ fullCols.forEach(({ dateObj }, i) => {
541
+ const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH:mm')
542
+ indexMaps[yyyyMM] = i
543
+ })
544
+ return (startValue: any, endValue: any) => {
545
+ const startDate = parseStringDate(startValue)
546
+ const endDate = parseStringDate(endValue)
547
+ const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH:mm')
548
+ const startFirstDate = XEUtils.getWhatMinutes(startDate, 0, 'first')
549
+ const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH:mm')
550
+ const endFirstDate = XEUtils.getWhatMinutes(endDate, 0, 'first')
551
+ const minuteSize = Math.floor((XEUtils.getWhatMinutes(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
552
+ const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
553
+ const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
554
+ const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
555
+ return {
556
+ offsetLeftSize,
557
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
558
+ }
559
+ }
560
+ }
561
+ case 'second': {
562
+ const gapTime = getStandardGapTime(minScale.type)
563
+ return (startValue: any, endValue: any) => {
564
+ const startDate = parseStringDate(startValue)
565
+ const endDate = parseStringDate(endValue)
566
+ let offsetLeftSize = 0
567
+ let offsetWidthSize = 0
568
+ if (minViewDate) {
569
+ offsetLeftSize = (startDate.getTime() - minViewDate.getTime()) / gapTime
570
+ offsetWidthSize = ((endDate.getTime() - startDate.getTime()) / gapTime) + 1
571
+ }
572
+ return {
573
+ offsetLeftSize,
574
+ offsetWidthSize
575
+ }
576
+ }
577
+ }
578
+ }
579
+ return () => {
580
+ return {
581
+ offsetLeftSize: 0,
582
+ offsetWidthSize: 0
583
+ }
584
+ }
585
+ }
333
586
 
587
+ const handleParseColumn = () => {
588
+ const ganttProps = $xeGantt.props
589
+ const { treeConfig } = ganttProps
590
+ const { minViewDate, maxViewDate } = reactData
591
+ const { fullCols, groupCols } = handleColumnHeader()
592
+ if (minViewDate && maxViewDate && fullCols.length) {
334
593
  const $xeTable = internalData.xeTable
335
594
  if ($xeTable) {
336
595
  const startField = computeStartField.value
@@ -346,20 +605,18 @@ export default defineVxeComponent({
346
605
  const childrenField = treeOpts.children || treeOpts.childrenField
347
606
 
348
607
  const ctMaps: Record<string, VxeGanttDefines.RowCacheItem> = {}
608
+ const renderFn = createChartRender(fullCols)
349
609
  const handleParseRender = (row: any) => {
350
610
  const rowid = $xeTable.getRowid(row)
351
611
  const startValue = XEUtils.get(row, startField)
352
612
  const endValue = XEUtils.get(row, endField)
353
613
  if (startValue && endValue) {
354
- const startDate = parseStringDate(startValue)
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
614
+ const { offsetLeftSize, offsetWidthSize } = renderFn(startValue, endValue)
358
615
  ctMaps[rowid] = {
359
616
  row,
360
617
  rowid,
361
- oLeftSize,
362
- oWidthSize
618
+ oLeftSize: offsetLeftSize,
619
+ oWidthSize: offsetWidthSize
363
620
  }
364
621
  }
365
622
  }
@@ -627,11 +884,11 @@ export default defineVxeComponent({
627
884
  return new Promise<void>(resolve => {
628
885
  const { rceTimeout, rceRunTime } = internalData
629
886
  const $xeTable = internalData.xeTable
630
- let refreshDelay = 50
887
+ let refreshDelay = 30
631
888
  if ($xeTable) {
632
889
  const { computeResizeOpts } = $xeTable.getComputeMaps()
633
890
  const resizeOpts = computeResizeOpts.value
634
- refreshDelay = resizeOpts.refreshDelay || 50
891
+ refreshDelay = resizeOpts.refreshDelay || refreshDelay
635
892
  }
636
893
  if (rceTimeout) {
637
894
  clearTimeout(rceTimeout)
@@ -956,7 +1213,14 @@ export default defineVxeComponent({
956
1213
  const ganttViewMethods: VxeGanttViewMethods = {
957
1214
  refreshData () {
958
1215
  handleUpdateData()
959
- return handleLazyRecalculate()
1216
+ handleRecalculateStyle()
1217
+ return nextTick().then(() => {
1218
+ const $xeTable = internalData.xeTable
1219
+ handleRecalculateStyle()
1220
+ if ($xeTable) {
1221
+ return $xeTable.recalculate()
1222
+ }
1223
+ })
960
1224
  },
961
1225
  updateViewData () {
962
1226
  const $xeTable = internalData.xeTable