vxe-gantt 4.0.27 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/gantt/src/emits.js +2 -0
- package/es/gantt/src/gantt-chart.js +28 -18
- package/es/gantt/src/gantt-header.js +18 -6
- package/es/gantt/src/gantt-view.js +307 -47
- package/es/gantt/src/gantt.js +151 -8
- package/es/gantt/src/util.js +11 -0
- package/es/ui/index.js +4 -1
- package/es/ui/src/log.js +1 -1
- package/lib/gantt/src/emits.js +1 -1
- package/lib/gantt/src/emits.min.js +1 -1
- package/lib/gantt/src/gantt-chart.js +36 -16
- package/lib/gantt/src/gantt-chart.min.js +1 -1
- package/lib/gantt/src/gantt-header.js +15 -5
- package/lib/gantt/src/gantt-header.min.js +1 -1
- package/lib/gantt/src/gantt-view.js +357 -50
- package/lib/gantt/src/gantt-view.min.js +1 -1
- package/lib/gantt/src/gantt.js +163 -6
- package/lib/gantt/src/gantt.min.js +1 -1
- package/lib/gantt/src/util.js +12 -0
- package/lib/gantt/src/util.min.js +1 -1
- package/lib/index.umd.js +590 -80
- package/lib/index.umd.min.js +1 -1
- package/lib/ui/index.js +4 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +3 -3
- package/packages/gantt/src/emits.ts +2 -0
- package/packages/gantt/src/gantt-chart.ts +34 -13
- package/packages/gantt/src/gantt-header.ts +15 -6
- package/packages/gantt/src/gantt-view.ts +310 -46
- package/packages/gantt/src/gantt.ts +162 -8
- package/packages/gantt/src/util.ts +13 -0
- package/packages/ui/index.ts +3 -0
|
@@ -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,7 +243,26 @@ export default defineVxeComponent({
|
|
|
231
243
|
return Object.assign({}, getConfig().gantt.taskSplitConfig, props.taskSplitConfig)
|
|
232
244
|
})
|
|
233
245
|
|
|
234
|
-
const
|
|
246
|
+
const computeTaskBarTooltipOpts = computed(() => {
|
|
247
|
+
return Object.assign({}, getConfig().gantt.taskBarTooltipConfig, props.taskBarTooltipConfig)
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
const computeScaleUnit = computed(() => {
|
|
251
|
+
const minScale = computeMinScale.value
|
|
252
|
+
return minScale ? minScale.type : 'date'
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
const computeMinScale = computed(() => {
|
|
256
|
+
const { taskScaleList } = reactData
|
|
257
|
+
return XEUtils.last(taskScaleList)
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
const computeWeekScale = computed(() => {
|
|
261
|
+
const { taskScaleList } = reactData
|
|
262
|
+
return taskScaleList.find(item => item.type === 'week')
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
const computeTaskViewScales = computed(() => {
|
|
235
266
|
const taskViewOpts = computeTaskViewOpts.value
|
|
236
267
|
const { scales } = taskViewOpts
|
|
237
268
|
return scales
|
|
@@ -462,7 +493,11 @@ export default defineVxeComponent({
|
|
|
462
493
|
computeTaskBarDragOpts,
|
|
463
494
|
computeTaskBarResizeOpts,
|
|
464
495
|
computeTaskSplitOpts,
|
|
465
|
-
|
|
496
|
+
computeTaskBarTooltipOpts,
|
|
497
|
+
computeTaskViewScales,
|
|
498
|
+
computeScaleUnit,
|
|
499
|
+
computeMinScale,
|
|
500
|
+
computeWeekScale,
|
|
466
501
|
computeTitleField,
|
|
467
502
|
computeStartField,
|
|
468
503
|
computeEndField,
|
|
@@ -472,6 +507,12 @@ export default defineVxeComponent({
|
|
|
472
507
|
computeScrollbarYToLeft
|
|
473
508
|
}
|
|
474
509
|
|
|
510
|
+
/**
|
|
511
|
+
* 已废弃,保留兼容
|
|
512
|
+
* @deprecated
|
|
513
|
+
*/
|
|
514
|
+
;(computeMaps as any).computeTaskScaleConfs = computeTaskViewScales
|
|
515
|
+
|
|
475
516
|
const $xeGantt = {
|
|
476
517
|
xID,
|
|
477
518
|
props: props as VxeGanttProps,
|
|
@@ -483,7 +524,7 @@ export default defineVxeComponent({
|
|
|
483
524
|
} as VxeGanttConstructor & VxeGanttPrivateMethods
|
|
484
525
|
|
|
485
526
|
const handleTaskScaleConfig = () => {
|
|
486
|
-
const taskScaleConfs =
|
|
527
|
+
const taskScaleConfs = computeTaskViewScales.value
|
|
487
528
|
const taskViewScaleOpts = computeTaskViewScaleOpts.value
|
|
488
529
|
const scaleConfs: VxeGanttDefines.ColumnScaleObj[] = []
|
|
489
530
|
if (taskScaleConfs) {
|
|
@@ -962,6 +1003,18 @@ export default defineVxeComponent({
|
|
|
962
1003
|
emit(type, createEvent(evnt, { $grid: null, $gantt: $xeGantt }, params))
|
|
963
1004
|
}
|
|
964
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
|
+
|
|
965
1018
|
const ganttMethods: GanttMethods = {
|
|
966
1019
|
dispatchEvent,
|
|
967
1020
|
getEl () {
|
|
@@ -1564,6 +1617,25 @@ export default defineVxeComponent({
|
|
|
1564
1617
|
hideTaskView () {
|
|
1565
1618
|
reactData.showRightView = false
|
|
1566
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()
|
|
1567
1639
|
}
|
|
1568
1640
|
}
|
|
1569
1641
|
|
|
@@ -1682,6 +1754,52 @@ export default defineVxeComponent({
|
|
|
1682
1754
|
handleTaskBarDblclickEvent (evnt, params) {
|
|
1683
1755
|
$xeGantt.dispatchEvent('task-bar-dblclick', params, evnt)
|
|
1684
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
|
+
},
|
|
1685
1803
|
handleTaskHeaderContextmenuEvent (evnt, params) {
|
|
1686
1804
|
const $xeTable = refTable.value
|
|
1687
1805
|
if ($xeTable) {
|
|
@@ -2156,10 +2274,13 @@ export default defineVxeComponent({
|
|
|
2156
2274
|
}
|
|
2157
2275
|
|
|
2158
2276
|
const renderLayout = () => {
|
|
2277
|
+
const { barTipStore } = reactData
|
|
2159
2278
|
const currLayoutConf = computeCurrLayoutConf.value
|
|
2160
2279
|
const { headKeys, bodyKeys, footKeys } = currLayoutConf
|
|
2280
|
+
const taskBarTooltipOpts = computeTaskBarTooltipOpts.value
|
|
2161
2281
|
const asideLeftSlot = slots.asideLeft || slots['aside-left']
|
|
2162
2282
|
const asideRightSlot = slots.asideRight || slots['aside-right']
|
|
2283
|
+
const taskBarTooltipSlot = slots.taskBarTooltip || slots['task-bar-tooltip']
|
|
2163
2284
|
return [
|
|
2164
2285
|
h('div', {
|
|
2165
2286
|
class: 'vxe-gantt--layout-header-wrapper'
|
|
@@ -2186,7 +2307,39 @@ export default defineVxeComponent({
|
|
|
2186
2307
|
}, renderChildLayout(footKeys)),
|
|
2187
2308
|
h('div', {
|
|
2188
2309
|
ref: refPopupContainerElem
|
|
2189
|
-
})
|
|
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
|
+
])
|
|
2190
2343
|
]
|
|
2191
2344
|
}
|
|
2192
2345
|
|
|
@@ -2243,8 +2396,9 @@ export default defineVxeComponent({
|
|
|
2243
2396
|
initProxy()
|
|
2244
2397
|
})
|
|
2245
2398
|
|
|
2246
|
-
watch(
|
|
2399
|
+
watch(computeTaskViewScales, () => {
|
|
2247
2400
|
handleTaskScaleConfig()
|
|
2401
|
+
$xeGantt.refreshTaskView()
|
|
2248
2402
|
})
|
|
2249
2403
|
|
|
2250
2404
|
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
|
+
}
|