vxe-gantt 4.1.0 → 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
  : [
@@ -65,15 +65,17 @@ export default defineVxeComponent({
65
65
  }, columns.map((column, cIndex) => {
66
66
  const { field, childCount, dateObj } = column
67
67
  let label = `${column.title}`
68
- if ($rowIndex < headerGroups.length - 1) {
69
- if (scaleItem.type === 'day') {
70
- label = getI18n(`vxe.gantt.dayss.w${dateObj.e}`)
71
- } else {
72
- label = getI18n(`vxe.gantt.${!$rowIndex && headerGroups.length > 1 ? 'tFullFormat' : 'tSimpleFormat'}.${type}`, dateObj)
73
- }
68
+ if (scaleItem.type === 'day') {
69
+ label = getI18n(`vxe.gantt.dayss.w${dateObj.e}`)
74
70
  } else {
75
- if (isLast && scaleItem.type === 'week') {
71
+ if ($rowIndex) {
76
72
  label = getI18n(`vxe.gantt.tSimpleFormat.${type}`, dateObj)
73
+ } else {
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
+ }
77
79
  }
78
80
  }
79
81
  let cellVNs: string | VxeComponentSlotType[] = label
@@ -337,7 +337,7 @@ export default defineVxeComponent({
337
337
  if (minScale.level < 17) {
338
338
  handleData('quarter', colMaps, minCol)
339
339
  }
340
- if (minScale.level < 14) {
340
+ if (minScale.level < 15) {
341
341
  handleData('month', colMaps, minCol)
342
342
  }
343
343
  if (minScale.level < 13) {
@@ -346,7 +346,7 @@ export default defineVxeComponent({
346
346
  if (minScale.level < 11) {
347
347
  handleData('day', colMaps, minCol)
348
348
  }
349
- if (minScale.level < 12) {
349
+ if (minScale.level < 9) {
350
350
  handleData('date', colMaps, minCol)
351
351
  }
352
352
  if (minScale.level < 7) {
@@ -355,6 +355,9 @@ export default defineVxeComponent({
355
355
  if (minScale.level < 5) {
356
356
  handleData('minute', colMaps, minCol)
357
357
  }
358
+ if (minScale.level < 3) {
359
+ handleData('second', colMaps, minCol)
360
+ }
358
361
 
359
362
  fullCols.push(minCol)
360
363
  }
@@ -1,7 +1,7 @@
1
1
  import { h, ref, PropType, computed, provide, reactive, onUnmounted, watch, nextTick, VNode, onMounted } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
3
  import XEUtils from 'xe-utils'
4
- import { getLastZIndex, nextZIndex, isEnableConf } from '../../ui/src/utils'
4
+ import { getLastZIndex, nextZIndex, isEnableConf, formatText } from '../../ui/src/utils'
5
5
  import { getOffsetHeight, getPaddingTopBottomSize, getDomNode, toCssUnit, addClass, removeClass } from '../../ui/src/dom'
6
6
  import { getSlotVNs } from '../../ui/src/vn'
7
7
  import { VxeUI } from '@vxe-ui/core'
@@ -12,7 +12,7 @@ import GanttViewComponent from './gantt-view'
12
12
  import { VxeTable as VxeTableComponent } from 'vxe-table'
13
13
 
14
14
  import type { VxeGanttConstructor, VxeGanttEmits, GanttReactData, GanttInternalData, VxeGanttPropTypes, GanttMethods, GanttPrivateMethods, VxeGanttPrivateMethods, GanttPrivateRef, VxeGanttProps, VxeGanttPrivateComputed, VxeGanttViewInstance, VxeGanttDefines } from '../../../types'
15
- import type { ValueOf, VxeFormEvents, VxeFormInstance, VxePagerEvents, VxeFormItemProps, VxePagerInstance, VxeComponentStyleType } from 'vxe-pc-ui'
15
+ import type { ValueOf, VxeFormEvents, VxeFormInstance, VxeTooltipInstance, VxePagerEvents, VxeFormItemProps, VxePagerInstance, VxeComponentStyleType } from 'vxe-pc-ui'
16
16
  import type { VxeTableMethods, VxeToolbarPropTypes, VxeTableProps, VxeTablePropTypes, VxeTableConstructor, VxeTablePrivateMethods, VxeTableEvents, VxeTableDefines, VxeTableEventProps, VxeToolbarInstance, VxeGridPropTypes, VxeGridDefines } from 'vxe-table'
17
17
 
18
18
  const { getConfig, getIcon, getI18n, commands, hooks, useFns, createEvent, globalEvents, GLOBAL_EVENT_KEYS, renderEmptyElement } = VxeUI
@@ -28,6 +28,7 @@ function createInternalData (): GanttInternalData {
28
28
  return {
29
29
  uFoot: false,
30
30
  resizeTableWidth: 0
31
+ // barTipTimeout: undefined
31
32
  }
32
33
  }
33
34
 
@@ -84,6 +85,7 @@ export default defineVxeComponent({
84
85
  taskViewScaleConfig: Object as PropType<VxeGanttPropTypes.TaskViewScaleConfig>,
85
86
  taskViewConfig: Object as PropType<VxeGanttPropTypes.TaskViewConfig>,
86
87
  taskBarConfig: Object as PropType<VxeGanttPropTypes.TaskBarConfig>,
88
+ taskBarTooltipConfig: Object as PropType<VxeGanttPropTypes.TaskBarTooltipConfig>,
87
89
  taskSplitConfig: Object as PropType<VxeGanttPropTypes.TaskSplitConfig>,
88
90
  taskBarResizeConfig: Object as PropType<VxeGanttPropTypes.TaskBarResizeConfig>,
89
91
  taskBarDragConfig: Object as PropType<VxeGanttPropTypes.TaskBarDragConfig>,
@@ -103,6 +105,7 @@ export default defineVxeComponent({
103
105
  const VxeUIPagerComponent = VxeUI.getComponent('VxePager')
104
106
  const VxeTableComponent = VxeUI.getComponent('VxeTable')
105
107
  const VxeToolbarComponent = VxeUI.getComponent('VxeToolbar')
108
+ const VxeUITooltipComponent = VxeUI.getComponent('VxeTooltip')
106
109
 
107
110
  const { computeSize } = useFns.useSize(props)
108
111
 
@@ -123,7 +126,14 @@ export default defineVxeComponent({
123
126
  },
124
127
  showLeftView: true,
125
128
  showRightView: true,
126
- taskScaleList: []
129
+ taskScaleList: [],
130
+
131
+ barTipStore: {
132
+ row: null,
133
+ content: '',
134
+ visible: false,
135
+ params: null
136
+ }
127
137
  })
128
138
 
129
139
  const internalData = createInternalData()
@@ -147,6 +157,8 @@ export default defineVxeComponent({
147
157
  const refTableWrapper = ref<HTMLDivElement>()
148
158
  const refGanttWrapper = ref<HTMLDivElement>()
149
159
 
160
+ const refTooltip = ref<VxeTooltipInstance>()
161
+
150
162
  const refResizableSplitTip = ref<HTMLDivElement>()
151
163
 
152
164
  const extendTableMethods = <T>(methodKeys: T[]) => {
@@ -231,6 +243,10 @@ export default defineVxeComponent({
231
243
  return Object.assign({}, getConfig().gantt.taskSplitConfig, props.taskSplitConfig)
232
244
  })
233
245
 
246
+ const computeTaskBarTooltipOpts = computed(() => {
247
+ return Object.assign({}, getConfig().gantt.taskBarTooltipConfig, props.taskBarTooltipConfig)
248
+ })
249
+
234
250
  const computeScaleUnit = computed(() => {
235
251
  const minScale = computeMinScale.value
236
252
  return minScale ? minScale.type : 'date'
@@ -246,7 +262,7 @@ export default defineVxeComponent({
246
262
  return taskScaleList.find(item => item.type === 'week')
247
263
  })
248
264
 
249
- const computeTaskScaleConfs = computed(() => {
265
+ const computeTaskViewScales = computed(() => {
250
266
  const taskViewOpts = computeTaskViewOpts.value
251
267
  const { scales } = taskViewOpts
252
268
  return scales
@@ -477,7 +493,8 @@ export default defineVxeComponent({
477
493
  computeTaskBarDragOpts,
478
494
  computeTaskBarResizeOpts,
479
495
  computeTaskSplitOpts,
480
- computeTaskScaleConfs,
496
+ computeTaskBarTooltipOpts,
497
+ computeTaskViewScales,
481
498
  computeScaleUnit,
482
499
  computeMinScale,
483
500
  computeWeekScale,
@@ -490,6 +507,12 @@ export default defineVxeComponent({
490
507
  computeScrollbarYToLeft
491
508
  }
492
509
 
510
+ /**
511
+ * 已废弃,保留兼容
512
+ * @deprecated
513
+ */
514
+ ;(computeMaps as any).computeTaskScaleConfs = computeTaskViewScales
515
+
493
516
  const $xeGantt = {
494
517
  xID,
495
518
  props: props as VxeGanttProps,
@@ -501,7 +524,7 @@ export default defineVxeComponent({
501
524
  } as VxeGanttConstructor & VxeGanttPrivateMethods
502
525
 
503
526
  const handleTaskScaleConfig = () => {
504
- const taskScaleConfs = computeTaskScaleConfs.value
527
+ const taskScaleConfs = computeTaskViewScales.value
505
528
  const taskViewScaleOpts = computeTaskViewScaleOpts.value
506
529
  const scaleConfs: VxeGanttDefines.ColumnScaleObj[] = []
507
530
  if (taskScaleConfs) {
@@ -980,6 +1003,18 @@ export default defineVxeComponent({
980
1003
  emit(type, createEvent(evnt, { $grid: null, $gantt: $xeGantt }, params))
981
1004
  }
982
1005
 
1006
+ const handleTargetEnterEvent = (isClear: boolean) => {
1007
+ const $tooltip = refTooltip.value
1008
+ clearTimeout(internalData.barTipTimeout)
1009
+ if (isClear) {
1010
+ $xeGantt.closeTaskBarTooltip()
1011
+ } else {
1012
+ if ($tooltip && $tooltip.setActived) {
1013
+ $tooltip.setActived(true)
1014
+ }
1015
+ }
1016
+ }
1017
+
983
1018
  const ganttMethods: GanttMethods = {
984
1019
  dispatchEvent,
985
1020
  getEl () {
@@ -1582,6 +1617,25 @@ export default defineVxeComponent({
1582
1617
  hideTaskView () {
1583
1618
  reactData.showRightView = false
1584
1619
  return nextTick()
1620
+ },
1621
+ /**
1622
+ * 关闭 bar tooltip
1623
+ */
1624
+ closeTaskBarTooltip () {
1625
+ const { barTipStore } = reactData
1626
+ const $tooltip = refTooltip.value
1627
+ if (barTipStore.visible) {
1628
+ Object.assign(barTipStore, {
1629
+ row: null,
1630
+ content: null,
1631
+ visible: false,
1632
+ params: {}
1633
+ })
1634
+ if ($tooltip && $tooltip.close) {
1635
+ $tooltip.close()
1636
+ }
1637
+ }
1638
+ return nextTick()
1585
1639
  }
1586
1640
  }
1587
1641
 
@@ -1700,6 +1754,52 @@ export default defineVxeComponent({
1700
1754
  handleTaskBarDblclickEvent (evnt, params) {
1701
1755
  $xeGantt.dispatchEvent('task-bar-dblclick', params, evnt)
1702
1756
  },
1757
+ triggerTaskBarTooltipEvent (evnt, params) {
1758
+ const { barTipStore } = reactData
1759
+ const taskBarTooltipOpts = computeTaskBarTooltipOpts.value
1760
+ const titleField = computeTitleField.value
1761
+ const { contentMethod } = taskBarTooltipOpts
1762
+ const { row } = params
1763
+ let content = formatText(XEUtils.get(row, titleField))
1764
+ if (contentMethod) {
1765
+ content = formatText(contentMethod(params))
1766
+ }
1767
+ handleTargetEnterEvent(barTipStore.row !== row)
1768
+ const tipContent = formatText(content)
1769
+ Object.assign(barTipStore, {
1770
+ row,
1771
+ visible: true,
1772
+ content: tipContent,
1773
+ params
1774
+ })
1775
+ nextTick(() => {
1776
+ const $tooltip = refTooltip.value
1777
+ if ($tooltip) {
1778
+ if ($tooltip.openByEvent) {
1779
+ $tooltip.openByEvent(evnt, evnt.currentTarget, tipContent)
1780
+ } else if ($tooltip.open) {
1781
+ $tooltip.open(evnt.currentTarget, tipContent)
1782
+ }
1783
+ }
1784
+ })
1785
+ },
1786
+ handleTaskBarTooltipLeaveEvent () {
1787
+ const taskBarTooltipOpts = computeTaskBarTooltipOpts.value
1788
+ let $tooltip = refTooltip.value
1789
+ if ($tooltip && $tooltip.setActived) {
1790
+ $tooltip.setActived(false)
1791
+ }
1792
+ if (taskBarTooltipOpts.enterable) {
1793
+ internalData.barTipTimeout = setTimeout(() => {
1794
+ $tooltip = refTooltip.value
1795
+ if ($tooltip && $tooltip.isActived && !$tooltip.isActived()) {
1796
+ $xeGantt.closeTaskBarTooltip()
1797
+ }
1798
+ }, taskBarTooltipOpts.leaveDelay)
1799
+ } else {
1800
+ $xeGantt.closeTaskBarTooltip()
1801
+ }
1802
+ },
1703
1803
  handleTaskHeaderContextmenuEvent (evnt, params) {
1704
1804
  const $xeTable = refTable.value
1705
1805
  if ($xeTable) {
@@ -2174,10 +2274,13 @@ export default defineVxeComponent({
2174
2274
  }
2175
2275
 
2176
2276
  const renderLayout = () => {
2277
+ const { barTipStore } = reactData
2177
2278
  const currLayoutConf = computeCurrLayoutConf.value
2178
2279
  const { headKeys, bodyKeys, footKeys } = currLayoutConf
2280
+ const taskBarTooltipOpts = computeTaskBarTooltipOpts.value
2179
2281
  const asideLeftSlot = slots.asideLeft || slots['aside-left']
2180
2282
  const asideRightSlot = slots.asideRight || slots['aside-right']
2283
+ const taskBarTooltipSlot = slots.taskBarTooltip || slots['task-bar-tooltip']
2181
2284
  return [
2182
2285
  h('div', {
2183
2286
  class: 'vxe-gantt--layout-header-wrapper'
@@ -2204,7 +2307,39 @@ export default defineVxeComponent({
2204
2307
  }, renderChildLayout(footKeys)),
2205
2308
  h('div', {
2206
2309
  ref: refPopupContainerElem
2207
- })
2310
+ }),
2311
+ h('div', {}, [
2312
+ /**
2313
+ * 任务条提示
2314
+ */
2315
+ h(VxeUITooltipComponent, {
2316
+ key: 'gtp',
2317
+ ref: refTooltip,
2318
+ theme: taskBarTooltipOpts.theme,
2319
+ enterable: taskBarTooltipOpts.enterable,
2320
+ enterDelay: taskBarTooltipOpts.enterDelay,
2321
+ leaveDelay: taskBarTooltipOpts.leaveDelay,
2322
+ useHTML: taskBarTooltipOpts.useHTML,
2323
+ width: taskBarTooltipOpts.width,
2324
+ height: taskBarTooltipOpts.height,
2325
+ minWidth: taskBarTooltipOpts.minWidth,
2326
+ minHeight: taskBarTooltipOpts.minHeight,
2327
+ maxWidth: taskBarTooltipOpts.maxWidth,
2328
+ maxHeight: taskBarTooltipOpts.maxHeight,
2329
+ isArrow: false
2330
+ }, taskBarTooltipSlot
2331
+ ? {
2332
+ content: () => {
2333
+ const { row, content: tooltipContent } = barTipStore
2334
+ if (row) {
2335
+ return h('div', {
2336
+ }, taskBarTooltipSlot(Object.assign({ tooltipContent, $gantt: $xeGantt }, barTipStore.params)))
2337
+ }
2338
+ return renderEmptyElement($xeGantt)
2339
+ }
2340
+ }
2341
+ : {})
2342
+ ])
2208
2343
  ]
2209
2344
  }
2210
2345
 
@@ -2261,7 +2396,7 @@ export default defineVxeComponent({
2261
2396
  initProxy()
2262
2397
  })
2263
2398
 
2264
- watch(computeTaskScaleConfs, () => {
2399
+ watch(computeTaskViewScales, () => {
2265
2400
  handleTaskScaleConfig()
2266
2401
  $xeGantt.refreshTaskView()
2267
2402
  })
@@ -43,6 +43,9 @@ setConfig({
43
43
  // beforeSave: null,
44
44
  // afterSave: null
45
45
  },
46
+ taskBarTooltipConfig: {
47
+ enterable: true
48
+ },
46
49
  taskViewScaleConfig: {
47
50
  week: {
48
51
  startDay: 1