vxe-gantt 4.0.0-beta.2 → 4.0.0-beta.4

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.
Files changed (41) hide show
  1. package/README.md +2 -2
  2. package/es/gantt/src/gantt-body.js +70 -36
  3. package/es/gantt/src/gantt-chart.js +80 -56
  4. package/es/gantt/src/gantt-view.js +62 -7
  5. package/es/gantt/src/gantt.js +24 -6
  6. package/es/gantt/style.css +37 -3
  7. package/es/gantt/style.min.css +1 -1
  8. package/es/style.css +1 -1
  9. package/es/style.min.css +1 -1
  10. package/es/ui/index.js +7 -2
  11. package/es/ui/src/log.js +1 -1
  12. package/es/vxe-gantt/style.css +37 -3
  13. package/es/vxe-gantt/style.min.css +1 -1
  14. package/lib/gantt/src/gantt-body.js +104 -44
  15. package/lib/gantt/src/gantt-body.min.js +1 -1
  16. package/lib/gantt/src/gantt-chart.js +100 -60
  17. package/lib/gantt/src/gantt-chart.min.js +1 -1
  18. package/lib/gantt/src/gantt-view.js +79 -6
  19. package/lib/gantt/src/gantt-view.min.js +1 -1
  20. package/lib/gantt/src/gantt.js +31 -7
  21. package/lib/gantt/src/gantt.min.js +1 -1
  22. package/lib/gantt/style/style.css +37 -3
  23. package/lib/gantt/style/style.min.css +1 -1
  24. package/lib/index.umd.js +349 -140
  25. package/lib/index.umd.min.js +1 -1
  26. package/lib/style.css +1 -1
  27. package/lib/style.min.css +1 -1
  28. package/lib/ui/index.js +13 -2
  29. package/lib/ui/index.min.js +1 -1
  30. package/lib/ui/src/log.js +1 -1
  31. package/lib/ui/src/log.min.js +1 -1
  32. package/lib/vxe-gantt/style/style.css +37 -3
  33. package/lib/vxe-gantt/style/style.min.css +1 -1
  34. package/package.json +3 -3
  35. package/packages/gantt/src/gantt-body.ts +79 -37
  36. package/packages/gantt/src/gantt-chart.ts +90 -61
  37. package/packages/gantt/src/gantt-view.ts +62 -7
  38. package/packages/gantt/src/gantt.ts +23 -5
  39. package/packages/ui/index.ts +9 -1
  40. package/styles/components/gantt-module/gantt-chart.scss +1 -0
  41. package/styles/components/gantt.scss +43 -8
@@ -5,7 +5,7 @@ import XEUtils from 'xe-utils'
5
5
  import { getCellRestHeight } from './util'
6
6
  import { getStringValue } from '../../ui/src/utils'
7
7
 
8
- import type { VxeTablePropTypes, TableInternalData } from 'vxe-table'
8
+ import type { VxeTableConstructor, VxeTableMethods, VxeTablePrivateMethods } from 'vxe-table'
9
9
  import type { VxeGanttViewConstructor, VxeGanttViewPrivateMethods, VxeGanttConstructor, VxeGanttPrivateMethods } from '../../../types'
10
10
 
11
11
  const { renderEmptyElement } = VxeUI
@@ -21,80 +21,109 @@ export default defineVxeComponent({
21
21
 
22
22
  const refElem = ref() as Ref<HTMLDivElement>
23
23
 
24
- const renderVN = () => {
25
- const $xeTable = $xeGanttView.internalData.xeTable
26
-
27
- const tableInternalData = $xeTable ? $xeTable.internalData : {} as TableInternalData
28
- const fullAllDataRowIdData = tableInternalData.fullAllDataRowIdData || {}
29
- let cellOpts: VxeTablePropTypes.CellConfig = {}
30
- let rowOpts : VxeTablePropTypes.RowConfig = {}
31
- let defaultRowHeight = 0
32
- if ($xeTable) {
33
- const { computeCellOpts, computeRowOpts, computeDefaultRowHeight } = $xeTable.getComputeMaps()
34
- cellOpts = computeCellOpts.value
35
- rowOpts = computeRowOpts.value
36
- defaultRowHeight = computeDefaultRowHeight.value
37
- }
24
+ const renderTaskBar = ($xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, row: any, rowid: string, $rowIndex: number) => {
25
+ const tableProps = $xeTable.props
26
+ const { treeConfig } = tableProps
27
+ const tableInternalData = $xeTable.internalData
28
+ const { fullAllDataRowIdData } = tableInternalData
29
+ const { computeCellOpts, computeRowOpts, computeDefaultRowHeight } = $xeTable.getComputeMaps()
30
+ const cellOpts = computeCellOpts.value
31
+ const rowOpts = computeRowOpts.value
32
+ const defaultRowHeight = computeDefaultRowHeight.value
38
33
 
39
- const { tableData } = reactData
40
34
  const titleField = computeTitleField.value
41
35
  const progressField = computeProgressField.value
42
36
  const taskBarOpts = computeTaskBarOpts.value
43
37
  const { showProgress, showContent, contentMethod, barStyle } = taskBarOpts
44
38
  const { round } = barStyle || {}
45
39
 
40
+ const rowRest = fullAllDataRowIdData[rowid] || {}
41
+ const cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
42
+ let title = getStringValue(XEUtils.get(row, titleField))
43
+ const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
44
+
45
+ if (contentMethod) {
46
+ title = getStringValue(contentMethod({ row, title }))
47
+ }
48
+ return h('div', {
49
+ key: treeConfig ? rowid : $rowIndex,
50
+ rowid,
51
+ class: ['vxe-gantt-view--chart-row', {
52
+ 'is--round': round
53
+ }],
54
+ style: {
55
+ height: `${cellHeight}px`
56
+ }
57
+ }, [
58
+ h('div', {
59
+ class: 'vxe-gantt-view--chart-bar',
60
+ rowid,
61
+ onClick (evnt) {
62
+ $xeGantt.handleTaskBarClickEvent(evnt, { row })
63
+ },
64
+ onDblclick (evnt) {
65
+ $xeGantt.handleTaskBarDblclickEvent(evnt, { row })
66
+ }
67
+ }, [
68
+ showProgress
69
+ ? h('div', {
70
+ class: 'vxe-gantt-view--chart-progress',
71
+ style: {
72
+ width: `${progressValue || 0}%`
73
+ }
74
+ })
75
+ : renderEmptyElement($xeGantt),
76
+ showContent
77
+ ? h('div', {
78
+ class: 'vxe-gantt-view--chart-content'
79
+ }, title)
80
+ : renderEmptyElement($xeGantt)
81
+ ])
82
+ ])
83
+ }
84
+
85
+ const renderRows = ($xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, tableData: any[]) => {
86
+ const tableProps = $xeTable.props
87
+ const { treeConfig } = tableProps
88
+ const tableReactData = $xeTable.reactData
89
+ const { treeExpandedFlag } = tableReactData
90
+ const tableInternalData = $xeTable.internalData
91
+ const { treeExpandedMaps } = tableInternalData
92
+ const { computeTreeOpts } = $xeTable.getComputeMaps()
93
+ const treeOpts = computeTreeOpts.value
94
+ const { transform } = treeOpts
95
+ const childrenField = treeOpts.children || treeOpts.childrenField
96
+
97
+ const { scrollYLoad } = reactData
98
+
46
99
  const trVNs: VNode[] = []
47
- tableData.forEach((row, rIndex) => {
100
+ tableData.forEach((row, $rowIndex) => {
48
101
  const rowid = $xeTable ? $xeTable.getRowid(row) : ''
49
- const rowRest = fullAllDataRowIdData[rowid] || {}
50
- const cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
51
- let title = getStringValue(XEUtils.get(row, titleField))
52
- const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
53
- if (contentMethod) {
54
- title = getStringValue(contentMethod({ row, title }))
102
+ trVNs.push(renderTaskBar($xeTable, row, rowid, $rowIndex))
103
+ let isExpandTree = false
104
+ let rowChildren: any[] = []
105
+
106
+ if (treeConfig && !scrollYLoad && !transform) {
107
+ rowChildren = row[childrenField]
108
+ isExpandTree = !!treeExpandedFlag && rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
109
+ }
110
+ // 如果是树形表格
111
+ if (isExpandTree) {
112
+ trVNs.push(...renderRows($xeTable, rowChildren))
55
113
  }
56
- trVNs.push(
57
- h('div', {
58
- key: rIndex,
59
- rowid,
60
- class: ['vxe-gantt-view--chart-row', {
61
- 'is--round': round
62
- }],
63
- style: {
64
- height: `${cellHeight}px`
65
- }
66
- }, [
67
- h('div', {
68
- class: 'vxe-gantt-view--chart-bar',
69
- rowid,
70
- onClick (evnt) {
71
- $xeGantt.handleTaskBarClickEvent(evnt, { row })
72
- },
73
- onDblclick (evnt) {
74
- $xeGantt.handleTaskBarDblclickEvent(evnt, { row })
75
- }
76
- }, [
77
- showProgress
78
- ? h('div', {
79
- class: 'vxe-gantt-view--chart-progress',
80
- style: {
81
- width: `${progressValue || 0}%`
82
- }
83
- })
84
- : renderEmptyElement($xeGantt),
85
- showContent
86
- ? h('div', {
87
- class: 'vxe-gantt-view--chart-content'
88
- }, title)
89
- : renderEmptyElement($xeGantt)
90
- ])
91
- ])
92
- )
93
114
  })
115
+ return trVNs
116
+ }
117
+
118
+ const renderVN = () => {
119
+ const $xeTable = $xeGanttView.internalData.xeTable
120
+
121
+ const { tableData } = reactData
122
+
94
123
  return h('div', {
95
124
  ref: refElem,
96
125
  class: 'vxe-gantt-view--chart-wrapper'
97
- }, trVNs)
126
+ }, $xeTable ? renderRows($xeTable, tableData) : [])
98
127
  }
99
128
 
100
129
  onMounted(() => {
@@ -1,6 +1,6 @@
1
1
  import { h, ref, reactive, nextTick, inject, watch, provide, onMounted, onUnmounted } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
- import { setScrollTop, setScrollLeft } from '../../ui/src/dom'
3
+ import { setScrollTop, setScrollLeft, removeClass, addClass } from '../../ui/src/dom'
4
4
  import { VxeUI } from '@vxe-ui/core'
5
5
  import { getRefElem } from './util'
6
6
  import XEUtils from 'xe-utils'
@@ -131,6 +131,8 @@ export default defineVxeComponent({
131
131
  } as unknown as VxeGanttViewConstructor & VxeGanttViewPrivateMethods
132
132
 
133
133
  const handleParseColumn = () => {
134
+ const ganttProps = $xeGantt.props
135
+ const { treeConfig } = ganttProps
134
136
  const { minViewDate, maxViewDate } = reactData
135
137
  const taskViewOpts = computeTaskViewOpts.value
136
138
  const fullCols: VxeGanttPropTypes.Column[] = []
@@ -182,10 +184,15 @@ export default defineVxeComponent({
182
184
  if ($xeTable) {
183
185
  const startField = computeStartField.value
184
186
  const endField = computeEndField.value
187
+ const { computeTreeOpts } = $xeTable.getComputeMaps()
185
188
  const tableInternalData = $xeTable.internalData
186
- const { afterFullData } = tableInternalData
189
+ const { afterFullData, afterTreeFullData } = tableInternalData
190
+ const treeOpts = computeTreeOpts.value
191
+ const { transform } = treeOpts
192
+ const childrenField = treeOpts.children || treeOpts.childrenField
193
+
187
194
  const ctMaps: Record<string, VxeGanttDefines.RowCacheItem> = {}
188
- afterFullData.forEach(row => {
195
+ const handleParseRender = (row: any) => {
189
196
  const rowid = $xeTable.getRowid(row)
190
197
  const startValue = XEUtils.get(row, startField)
191
198
  const endValue = XEUtils.get(row, endField)
@@ -201,7 +208,13 @@ export default defineVxeComponent({
201
208
  oWidthSize
202
209
  }
203
210
  }
204
- })
211
+ }
212
+
213
+ if (treeConfig) {
214
+ XEUtils.eachTree(afterTreeFullData, handleParseRender, { children: transform ? treeOpts.mapChildrenField : childrenField })
215
+ } else {
216
+ afterFullData.forEach(handleParseRender)
217
+ }
205
218
  internalData.chartMaps = ctMaps
206
219
  }
207
220
  }
@@ -213,6 +226,8 @@ export default defineVxeComponent({
213
226
  }
214
227
 
215
228
  const handleUpdateData = () => {
229
+ const ganttProps = $xeGantt.props
230
+ const { treeConfig } = ganttProps
216
231
  const $xeTable = internalData.xeTable
217
232
  const sdMaps: Record<string, any> = {}
218
233
  const edMaps: Record<string, any> = {}
@@ -221,9 +236,14 @@ export default defineVxeComponent({
221
236
  if ($xeTable) {
222
237
  const startField = computeStartField.value
223
238
  const endField = computeEndField.value
239
+ const { computeTreeOpts } = $xeTable.getComputeMaps()
224
240
  const tableInternalData = $xeTable.internalData
225
- const { afterFullData } = tableInternalData
226
- afterFullData.forEach(row => {
241
+ const { afterFullData, afterTreeFullData } = tableInternalData
242
+ const treeOpts = computeTreeOpts.value
243
+ const { transform } = treeOpts
244
+ const childrenField = treeOpts.children || treeOpts.childrenField
245
+
246
+ const handleMinMaxData = (row: any) => {
227
247
  const startValue = XEUtils.get(row, startField)
228
248
  const endValue = XEUtils.get(row, endField)
229
249
  if (startValue && endValue) {
@@ -236,7 +256,13 @@ export default defineVxeComponent({
236
256
  maxDate = endDate
237
257
  }
238
258
  }
239
- })
259
+ }
260
+
261
+ if (treeConfig) {
262
+ XEUtils.eachTree(afterTreeFullData, handleMinMaxData, { children: transform ? treeOpts.mapChildrenField : childrenField })
263
+ } else {
264
+ afterFullData.forEach(handleMinMaxData)
265
+ }
240
266
  }
241
267
  reactData.minViewDate = minDate
242
268
  reactData.maxViewDate = maxDate
@@ -400,6 +426,7 @@ export default defineVxeComponent({
400
426
  const handleLazyRecalculate = () => {
401
427
  calcScrollbar()
402
428
  updateStyle()
429
+ updateChart()
403
430
  return nextTick()
404
431
  }
405
432
 
@@ -584,6 +611,34 @@ export default defineVxeComponent({
584
611
  const ganttViewPrivateMethods: VxeGanttViewPrivateMethods = {
585
612
  handleUpdateStyle: updateStyle,
586
613
  handleLazyRecalculate,
614
+ handleUpdateCurrentRow (row) {
615
+ const $xeTable = internalData.xeTable
616
+ const el = refElem.value
617
+ if ($xeTable && el) {
618
+ if (row) {
619
+ const tableProps = $xeTable.props
620
+ const { highlightCurrentRow } = tableProps
621
+ const { computeRowOpts } = $xeTable.getComputeMaps()
622
+ const rowOpts = computeRowOpts.value
623
+ if (rowOpts.isCurrent || highlightCurrentRow) {
624
+ XEUtils.arrayEach(el.querySelectorAll(`.vxe-gantt-view--body-row[rowid="${$xeTable.getRowid(row)}"]`), elem => addClass(elem, 'row--current'))
625
+ }
626
+ } else {
627
+ XEUtils.arrayEach(el.querySelectorAll('.vxe-gantt-view--body-row.row--current'), elem => removeClass(elem, 'row--current'))
628
+ }
629
+ }
630
+ },
631
+ handleUpdateHoverRow (row) {
632
+ const $xeTable = internalData.xeTable
633
+ const el = refElem.value
634
+ if ($xeTable && el) {
635
+ if (row) {
636
+ XEUtils.arrayEach(el.querySelectorAll(`.vxe-gantt-view--body-row[rowid="${$xeTable.getRowid(row)}"]`), elem => addClass(elem, 'row--hover'))
637
+ } else {
638
+ XEUtils.arrayEach(el.querySelectorAll('.vxe-gantt-view--body-row.row--hover'), elem => removeClass(elem, 'row--hover'))
639
+ }
640
+ }
641
+ },
587
642
  triggerHeaderScrollEvent (evnt) {
588
643
  const { elemStore, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData
589
644
  if (inVirtualScroll) {
@@ -1397,6 +1397,22 @@ export default defineVxeComponent({
1397
1397
  $xeGantt.dispatchEvent('zoom', { type: reactData.isZMax ? 'max' : 'revert' }, evnt)
1398
1398
  },
1399
1399
  handleTaskCellClickEvent (evnt, params) {
1400
+ const $xeTable = refTable.value
1401
+ if ($xeTable) {
1402
+ const tableProps = $xeTable.props
1403
+ const { highlightCurrentRow } = tableProps
1404
+ const { computeRowOpts } = $xeTable.getComputeMaps()
1405
+ const rowOpts = computeRowOpts.value
1406
+ const { row } = params
1407
+ // 如果是当前行
1408
+ if (rowOpts.isCurrent || highlightCurrentRow) {
1409
+ $xeTable.triggerCurrentRowEvent(evnt, Object.assign({
1410
+ $table: $xeTable,
1411
+ rowIndex: $xeTable.getRowIndex(row),
1412
+ $rowIndex: $xeTable.getVMRowIndex(row)
1413
+ }, params))
1414
+ }
1415
+ }
1400
1416
  $xeGantt.dispatchEvent('task-cell-click', params, evnt)
1401
1417
  },
1402
1418
  handleTaskCellDblclickEvent (evnt, params) {
@@ -1501,7 +1517,8 @@ export default defineVxeComponent({
1501
1517
  const renderToolbar = () => {
1502
1518
  const { toolbarConfig } = props
1503
1519
  const toolbarOpts = computeToolbarOpts.value
1504
- if ((toolbarConfig && isEnableConf(toolbarOpts)) || slots.toolbar) {
1520
+ const toolbarSlot = slots.toolbar
1521
+ if ((toolbarConfig && isEnableConf(toolbarOpts)) || toolbarSlot) {
1505
1522
  let slotVNs: VNode[] = []
1506
1523
  if (slots.toolbar) {
1507
1524
  slotVNs = slots.toolbar({ $grid: null, $gantt: $xeGantt })
@@ -1709,20 +1726,21 @@ export default defineVxeComponent({
1709
1726
  if (!enabled) {
1710
1727
  return renderEmptyElement($xeGantt)
1711
1728
  }
1729
+ const isResize = resize && showLeftView && showRightView
1712
1730
  const ons: {
1713
1731
  onMousedown?: typeof dragSplitEvent
1714
1732
  } = {}
1715
- if (resize) {
1733
+ if (isResize) {
1716
1734
  ons.onMousedown = dragSplitEvent
1717
1735
  }
1718
1736
  return h('div', {
1719
1737
  class: ['vxe-gantt--view-split-bar', {
1720
- 'is--resize': resize,
1721
- ...ons
1738
+ 'is--resize': isResize
1722
1739
  }]
1723
1740
  }, [
1724
1741
  h('div', {
1725
- class: 'vxe-gantt--view-split-bar-handle'
1742
+ class: 'vxe-gantt--view-split-bar-handle',
1743
+ ...ons
1726
1744
  }),
1727
1745
  showCollapseTableButton || showCollapseTaskButton
1728
1746
  ? h('div', {
@@ -1,6 +1,7 @@
1
1
  import { VxeUI } from '@vxe-ui/core'
2
+ import { errLog } from './src/log'
2
3
 
3
- const { setConfig, setIcon } = VxeUI
4
+ const { setConfig, setIcon, checkVersion } = VxeUI
4
5
 
5
6
  VxeUI.ganttVersion = process.env.VUE_APP_VXE_VERSION as string
6
7
 
@@ -61,4 +62,11 @@ setIcon({
61
62
  GANTT_VIEW_RIGHT_CLOSE: iconPrefix + 'arrow-left'
62
63
  })
63
64
 
65
+ if (!checkVersion(VxeUI.tableVersion, 4, 16)) {
66
+ errLog('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, 'vxe-table v4.16+'])
67
+ }
68
+
69
+ export {
70
+ VxeUI
71
+ }
64
72
  export default VxeUI
@@ -41,6 +41,7 @@
41
41
  width: 100%;
42
42
  height: 100%;
43
43
  background-color: rgba(0, 0, 0, 0.1);
44
+ pointer-events: none;
44
45
  }
45
46
  }
46
47
  }
@@ -130,13 +130,6 @@
130
130
  border: var(--vxe-ui-table-border-width) solid var(--vxe-ui-table-border-color);
131
131
  }
132
132
  .vxe-gantt {
133
- &.border--default,
134
- &.border--full,
135
- &.border--outer {
136
- .vxe-gantt-view--header-wrapper {
137
- background-color: var(--vxe-ui-table-header-background-color);
138
- }
139
- }
140
133
  &.border--full {
141
134
  .vxe-gantt-view--header-column,
142
135
  .vxe-gantt-view--body-column,
@@ -203,7 +196,6 @@
203
196
  }
204
197
  }
205
198
  }
206
-
207
199
  &.border--default,
208
200
  &.border--full {
209
201
  .vxe-gantt-view--scroll-y-top-corner {
@@ -256,6 +248,27 @@
256
248
  }
257
249
  }
258
250
  }
251
+ &.border--default,
252
+ &.border--inner {
253
+ .vxe-gantt-view--header-column,
254
+ .vxe-gantt-view--body-column,
255
+ .vxe-gantt-view--footer-column {
256
+ background-image: linear-gradient(var(--vxe-ui-table-border-color), var(--vxe-ui-table-border-color));
257
+ background-repeat: no-repeat;
258
+ background-size: 100% var(--vxe-ui-table-border-width);
259
+ background-position: right bottom;
260
+ }
261
+ }
262
+ &.border--inner {
263
+ .vxe-gantt--border-line {
264
+ border-width: 0 0 1px 0;
265
+ }
266
+ }
267
+ &.border--none {
268
+ .vxe-gantt--border-line {
269
+ display: none;
270
+ }
271
+ }
259
272
  }
260
273
 
261
274
  /*分割条*/
@@ -528,6 +541,9 @@
528
541
  width: var(--vxe-ui-gantt-view-default-cell-width);
529
542
  }
530
543
  }
544
+ .vxe-gantt-view--header-wrapper {
545
+ background-color: var(--vxe-ui-table-header-background-color);
546
+ }
531
547
  .vxe-gantt-view--header-wrapper,
532
548
  .vxe-gantt-view--body-wrapper {
533
549
  overflow: hidden;
@@ -562,6 +578,25 @@
562
578
  white-space: nowrap;
563
579
  }
564
580
 
581
+ // 行高亮
582
+ .vxe-gantt-view--body-row {
583
+ &.row--stripe {
584
+ background-color: var(--vxe-ui-table-row-striped-background-color);
585
+ }
586
+ &.row--current {
587
+ background-color: var(--vxe-ui-table-row-current-background-color);
588
+ }
589
+ &.row--hover {
590
+ background-color: var(--vxe-ui-table-row-hover-background-color);
591
+ &.row--stripe {
592
+ background-color: var(--vxe-ui-table-row-hover-striped-background-color);
593
+ }
594
+ &.row--current {
595
+ background-color: var(--vxe-ui-table-row-hover-current-background-color);
596
+ }
597
+ }
598
+ }
599
+
565
600
  .vxe-gantt-view {
566
601
  &.mode--day {
567
602
  .vxe-gantt-view--header-column {