vxe-gantt 4.1.5 → 4.1.7

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 (65) hide show
  1. package/es/gantt/index.js +3 -0
  2. package/es/gantt/src/emits.js +7 -1
  3. package/es/gantt/src/gantt-body.js +2 -5
  4. package/es/gantt/src/gantt-chart.js +64 -35
  5. package/es/gantt/src/gantt-view.js +23 -10
  6. package/es/gantt/src/gantt.js +66 -5
  7. package/es/gantt/src/static.js +22 -0
  8. package/es/gantt/src/table-emits.js +4 -0
  9. package/es/gantt/src/util.js +9 -0
  10. package/es/gantt/style.css +2 -2
  11. package/es/gantt/style.min.css +1 -1
  12. package/es/style.css +1 -1
  13. package/es/style.min.css +1 -1
  14. package/es/ui/index.js +6 -13
  15. package/es/ui/src/depend.js +14 -0
  16. package/es/ui/src/log.js +1 -1
  17. package/es/vxe-gantt/style.css +2 -2
  18. package/es/vxe-gantt/style.min.css +1 -1
  19. package/lib/gantt/index.js +18 -0
  20. package/lib/gantt/index.min.js +1 -1
  21. package/lib/gantt/src/emits.js +1 -1
  22. package/lib/gantt/src/emits.min.js +1 -1
  23. package/lib/gantt/src/gantt-body.js +2 -5
  24. package/lib/gantt/src/gantt-body.min.js +1 -1
  25. package/lib/gantt/src/gantt-chart.js +44 -21
  26. package/lib/gantt/src/gantt-chart.min.js +1 -1
  27. package/lib/gantt/src/gantt-view.js +19 -9
  28. package/lib/gantt/src/gantt-view.min.js +1 -1
  29. package/lib/gantt/src/gantt.js +88 -5
  30. package/lib/gantt/src/gantt.min.js +1 -1
  31. package/lib/gantt/src/static.js +28 -0
  32. package/lib/gantt/src/static.min.js +1 -0
  33. package/lib/gantt/src/table-emits.js +1 -1
  34. package/lib/gantt/src/table-emits.min.js +1 -1
  35. package/lib/gantt/src/util.js +12 -0
  36. package/lib/gantt/src/util.min.js +1 -1
  37. package/lib/gantt/style/style.css +2 -2
  38. package/lib/gantt/style/style.min.css +1 -1
  39. package/lib/index.umd.js +226 -69
  40. package/lib/index.umd.min.js +1 -1
  41. package/lib/style.css +1 -1
  42. package/lib/style.min.css +1 -1
  43. package/lib/ui/index.js +6 -13
  44. package/lib/ui/index.min.js +1 -1
  45. package/lib/ui/src/depend.js +19 -0
  46. package/lib/ui/src/depend.min.js +1 -0
  47. package/lib/ui/src/log.js +1 -1
  48. package/lib/ui/src/log.min.js +1 -1
  49. package/lib/vxe-gantt/style/style.css +2 -2
  50. package/lib/vxe-gantt/style/style.min.css +1 -1
  51. package/package.json +3 -7
  52. package/packages/gantt/index.ts +4 -0
  53. package/packages/gantt/src/emits.ts +7 -1
  54. package/packages/gantt/src/gantt-body.ts +2 -5
  55. package/packages/gantt/src/gantt-chart.ts +65 -36
  56. package/packages/gantt/src/gantt-view.ts +25 -10
  57. package/packages/gantt/src/gantt.ts +74 -6
  58. package/packages/gantt/src/static.ts +21 -0
  59. package/packages/gantt/src/table-emits.ts +5 -0
  60. package/packages/gantt/src/util.ts +12 -0
  61. package/packages/ui/index.ts +5 -12
  62. package/packages/ui/src/depend.ts +14 -0
  63. package/styles/components/gantt-module/gantt-chart.scss +3 -2
  64. package/styles/components/gantt.scss +0 -1
  65. package/styles/theme/base.scss +2 -0
@@ -3,7 +3,7 @@ import { defineVxeComponent } from '../../ui/src/comp'
3
3
  import { VxeUI } from '@vxe-ui/core'
4
4
  import XEUtils from 'xe-utils'
5
5
  import { getCellRestHeight } from './util'
6
- import { getStringValue } from '../../ui/src/utils'
6
+ import { getStringValue, isEnableConf } from '../../ui/src/utils'
7
7
 
8
8
  import type { VxeComponentStyleType } from 'vxe-pc-ui'
9
9
  import type { VxeTableConstructor, VxeTableMethods, VxeTablePrivateMethods } from 'vxe-table'
@@ -21,10 +21,12 @@ export default defineVxeComponent({
21
21
  const $xeGanttView = inject('$xeGanttView', {} as VxeGanttViewConstructor & VxeGanttViewPrivateMethods)
22
22
 
23
23
  const { internalData: ganttInternalData } = $xeGantt
24
- const { reactData, internalData } = $xeGanttView
25
- const { computeProgressField, computeTitleField, computeTaskBarOpts, computeScaleUnit } = $xeGantt.getComputeMaps()
24
+ const { reactData: ganttViewReactData, internalData: ganttViewInternalData } = $xeGanttView
25
+ const { computeProgressField, computeTitleField, computeTaskBarOpts, computeScaleUnit, computeTaskLinkOpts } = $xeGantt.getComputeMaps()
26
26
 
27
- const refElem = ref() as Ref<HTMLDivElement>
27
+ const refElem = ref<HTMLDivElement>()
28
+ const refTaskWrapperElem = ref() as Ref<HTMLDivElement>
29
+ const reflineWrapperElem = ref() as Ref<HTMLDivElement>
28
30
 
29
31
  const renderTaskBar = ($xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, row: any, rowid: string, rowIndex: number, $rowIndex: number, _rowIndex: number) => {
30
32
  const tableProps = $xeTable.props
@@ -46,15 +48,13 @@ export default defineVxeComponent({
46
48
  const taskBarOpts = computeTaskBarOpts.value
47
49
  const scaleUnit = computeScaleUnit.value
48
50
  const barParams = { $gantt: $xeGantt, row, scaleType: scaleUnit }
49
- const { showProgress, showContent, contentMethod, barStyle, drag, showTooltip } = taskBarOpts
51
+ const { showProgress, showContent, contentMethod, barStyle, move, showTooltip } = taskBarOpts
50
52
  const isBarRowStyle = XEUtils.isFunction(barStyle)
51
53
  const barStyObj = (barStyle ? (isBarRowStyle ? barStyle(barParams) : barStyle) : {}) || {}
52
54
  const { round } = barStyObj
53
55
 
54
56
  const rowRest = fullAllDataRowIdData[rowid] || {}
55
- const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0
56
- const isRsHeight = resizeHeight > 0
57
- const cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
57
+ const cellHeight = resizeHeightFlag ? getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) : 0
58
58
 
59
59
  let title = getStringValue(XEUtils.get(row, titleField))
60
60
  const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
@@ -129,8 +129,7 @@ export default defineVxeComponent({
129
129
  rowid,
130
130
  class: ['vxe-gantt-view--chart-row', {
131
131
  'is--round': round,
132
- 'is--drag': drag,
133
- 'col--rs-height': isRsHeight
132
+ 'is--move': move
134
133
  }],
135
134
  style: {
136
135
  height: `${cellHeight}px`
@@ -144,25 +143,38 @@ export default defineVxeComponent({
144
143
  style: vbStyle,
145
144
  rowid,
146
145
  ...ons
147
- }, taskBarSlot
148
- ? $xeGantt.callSlot(taskBarSlot, barParams)
149
- : [
150
- showProgress
151
- ? h('div', {
152
- class: 'vxe-gantt-view--chart-progress',
153
- style: vpStyle
154
- })
155
- : renderEmptyElement($xeGantt),
156
- showContent
157
- ? h('div', {
158
- class: 'vxe-gantt-view--chart-content'
159
- }, title)
160
- : renderEmptyElement($xeGantt)
161
- ])
146
+ }, $xeGantt.renderGanttTaskBarContent
147
+ ? $xeGantt.renderGanttTaskBarContent(ctParams, {
148
+ title,
149
+ vbStyle,
150
+ vpStyle
151
+ })
152
+ : (taskBarSlot
153
+ ? [
154
+ h('div', {
155
+ key: 'cbc',
156
+ class: 'vxe-gantt-view--chart-custom-bar-content'
157
+ }, $xeGantt.callSlot(taskBarSlot, barParams))
158
+ ]
159
+ : [
160
+ showProgress
161
+ ? h('div', {
162
+ key: 'vcp',
163
+ class: 'vxe-gantt-view--chart-progress',
164
+ style: vpStyle
165
+ })
166
+ : renderEmptyElement($xeGantt),
167
+ showContent
168
+ ? h('div', {
169
+ key: 'vcc',
170
+ class: 'vxe-gantt-view--chart-content'
171
+ }, title)
172
+ : renderEmptyElement($xeGantt)
173
+ ]))
162
174
  ])
163
175
  }
164
176
 
165
- const renderRows = ($xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, tableData: any[]) => {
177
+ const renderTaskRows = ($xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, tableData: any[]) => {
166
178
  const tableProps = $xeTable.props
167
179
  const { treeConfig } = tableProps
168
180
  const tableReactData = $xeTable.reactData
@@ -174,11 +186,11 @@ export default defineVxeComponent({
174
186
  const { transform } = treeOpts
175
187
  const childrenField = treeOpts.children || treeOpts.childrenField
176
188
 
177
- const { scrollYLoad } = reactData
189
+ const { scrollYLoad } = ganttViewReactData
178
190
 
179
191
  const trVNs: VNode[] = []
180
192
  tableData.forEach((row, $rowIndex) => {
181
- const rowid = $xeTable ? $xeTable.getRowid(row) : ''
193
+ const rowid = $xeTable.getRowid(row)
182
194
  const rowRest = fullAllDataRowIdData[rowid] || {}
183
195
  let rowIndex = $rowIndex
184
196
  let _rowIndex = -1
@@ -196,33 +208,50 @@ export default defineVxeComponent({
196
208
  }
197
209
  // 如果是树形表格
198
210
  if (isExpandTree) {
199
- trVNs.push(...renderRows($xeTable, rowChildren))
211
+ trVNs.push(...renderTaskRows($xeTable, rowChildren))
200
212
  }
201
213
  })
202
214
  return trVNs
203
215
  }
204
216
 
205
217
  const renderVN = () => {
206
- const $xeTable = $xeGanttView.internalData.xeTable
218
+ const $xeTable = ganttViewInternalData.xeTable
207
219
 
208
- const { tableData } = reactData
220
+ const { tableData } = ganttViewReactData
221
+ const taskLinkOpts = computeTaskLinkOpts.value
222
+ const { showArrow } = taskLinkOpts
209
223
 
210
224
  return h('div', {
211
225
  ref: refElem,
212
226
  class: 'vxe-gantt-view--chart-wrapper'
213
- }, $xeTable ? renderRows($xeTable, tableData) : [])
227
+ }, [
228
+ $xeGantt.renderGanttTaskLines
229
+ ? h('div', {
230
+ ref: reflineWrapperElem,
231
+ class: ['vxe-gantt-view--chart-line-wrapper', {
232
+ 'show-arrow': showArrow
233
+ }]
234
+ }, $xeTable && isEnableConf(taskLinkOpts) ? $xeGantt.renderGanttTaskLines() : [])
235
+ : renderEmptyElement($xeGantt),
236
+ h('div', {
237
+ ref: refTaskWrapperElem,
238
+ class: 'vxe-gantt-view--chart-task-wrapper'
239
+ }, $xeTable ? renderTaskRows($xeTable, tableData) : [])
240
+ ])
214
241
  }
215
242
 
216
243
  onMounted(() => {
217
- const { elemStore } = internalData
244
+ const { elemStore } = ganttViewInternalData
218
245
  const prefix = 'main-chart-'
219
- elemStore[`${prefix}wrapper`] = refElem
246
+ elemStore[`${prefix}task-wrapper`] = refTaskWrapperElem
247
+ elemStore[`${prefix}line-wrapper`] = reflineWrapperElem
220
248
  })
221
249
 
222
250
  onUnmounted(() => {
223
- const { elemStore } = internalData
251
+ const { elemStore } = ganttViewInternalData
224
252
  const prefix = 'main-chart-'
225
- elemStore[`${prefix}wrapper`] = null
253
+ elemStore[`${prefix}task-wrapper`] = null
254
+ elemStore[`${prefix}line-wrapper`] = null
226
255
  })
227
256
 
228
257
  return renderVN
@@ -2,7 +2,7 @@ import { h, ref, reactive, nextTick, inject, watch, provide, computed, onMounted
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, getStandardGapTime } from './util'
5
+ import { getRefElem, getStandardGapTime, getTaskBarLeft, getTaskBarWidth } from './util'
6
6
  import XEUtils from 'xe-utils'
7
7
  import GanttViewHeaderComponent from './gantt-header'
8
8
  import GanttViewBodyComponent from './gantt-body'
@@ -103,7 +103,7 @@ export default defineVxeComponent({
103
103
  tableColumn: [],
104
104
  headerGroups: [],
105
105
 
106
- viewCellWidth: 20
106
+ viewCellWidth: 40
107
107
  })
108
108
 
109
109
  const internalData = createInternalData()
@@ -745,12 +745,12 @@ export default defineVxeComponent({
745
745
  }
746
746
  }
747
747
 
748
- const updateChart = () => {
748
+ const updateTaskChart = () => {
749
749
  const { dragBarRow } = ganttInternalData
750
750
  const { viewCellWidth } = reactData
751
751
  const { elemStore, chartMaps } = internalData
752
752
  const $xeTable = internalData.xeTable
753
- const chartWrapper = getRefElem(elemStore['main-chart-wrapper'])
753
+ const chartWrapper = getRefElem(elemStore['main-chart-task-wrapper'])
754
754
  if (chartWrapper && $xeTable) {
755
755
  XEUtils.arrayEach(chartWrapper.children, (rowEl) => {
756
756
  const barEl = rowEl.children[0] as HTMLDivElement
@@ -761,9 +761,9 @@ export default defineVxeComponent({
761
761
  if (dragBarRow && $xeTable.getRowid(dragBarRow) === rowid) {
762
762
  return
763
763
  }
764
- const rowRest = rowid ? chartMaps[rowid] : null
765
- barEl.style.left = `${rowRest ? viewCellWidth * rowRest.oLeftSize : 0}px`
766
- barEl.style.width = `${rowRest ? viewCellWidth * rowRest.oWidthSize : 0}px`
764
+ const chartRest = rowid ? chartMaps[rowid] : null
765
+ barEl.style.left = `${getTaskBarLeft(chartRest, viewCellWidth)}px`
766
+ barEl.style.width = `${getTaskBarWidth(chartRest, viewCellWidth)}px`
767
767
  })
768
768
  }
769
769
  return nextTick()
@@ -778,6 +778,9 @@ export default defineVxeComponent({
778
778
  if (!el) {
779
779
  return
780
780
  }
781
+ if (!$xeGantt) {
782
+ return
783
+ }
781
784
 
782
785
  const scrollbarOpts = computeScrollbarOpts.value
783
786
  const scrollbarXToTop = computeScrollbarXToTop.value
@@ -888,7 +891,10 @@ export default defineVxeComponent({
888
891
 
889
892
  reactData.scrollXWidth = viewTableWidth
890
893
 
891
- return updateChart()
894
+ return Promise.all([
895
+ updateTaskChart(),
896
+ $xeGantt.handleUpdateTaskLink ? $xeGantt.handleUpdateTaskLink($xeGanttView) : null
897
+ ])
892
898
  }
893
899
 
894
900
  const handleRecalculateStyle = () => {
@@ -897,9 +903,11 @@ export default defineVxeComponent({
897
903
  if (!el || !el.clientWidth) {
898
904
  return nextTick()
899
905
  }
906
+ if (!$xeGantt) {
907
+ return nextTick()
908
+ }
900
909
  calcScrollbar()
901
910
  updateStyle()
902
- updateChart()
903
911
  return computeScrollLoad()
904
912
  }
905
913
 
@@ -1090,7 +1098,7 @@ export default defineVxeComponent({
1090
1098
  ySpaceHeight = maxYHeight
1091
1099
  }
1092
1100
 
1093
- const bodyChartWrapperElem = getRefElem(elemStore['main-chart-wrapper'])
1101
+ const bodyChartWrapperElem = getRefElem(elemStore['main-chart-task-wrapper'])
1094
1102
  if (bodyTableElem) {
1095
1103
  bodyTableElem.style.transform = `translate(${reactData.scrollXLeft || 0}px, ${scrollYTop}px)`
1096
1104
  }
@@ -1107,6 +1115,13 @@ export default defineVxeComponent({
1107
1115
  if (scrollYSpaceEl) {
1108
1116
  scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
1109
1117
  }
1118
+
1119
+ const lineWrapper = getRefElem(elemStore['main-chart-line-wrapper'])
1120
+ const svgElem = lineWrapper ? lineWrapper.firstElementChild as HTMLDivElement : null
1121
+ if (svgElem) {
1122
+ svgElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
1123
+ }
1124
+
1110
1125
  reactData.scrollYTop = scrollYTop
1111
1126
  reactData.scrollYHeight = scrollYHeight
1112
1127
  reactData.isScrollYBig = isScrollYBig
@@ -5,6 +5,7 @@ import { getLastZIndex, nextZIndex, isEnableConf, formatText } from '../../ui/sr
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'
8
+ import { getTaskLinkKey } from './util'
8
9
  import { ganttEmits } from './emits'
9
10
  import { tableEmits } from './table-emits'
10
11
  import { warnLog, errLog } from '../../ui/src/log'
@@ -26,6 +27,9 @@ const defaultLayouts: VxeGanttPropTypes.Layouts = [['Form'], ['Toolbar', 'Top',
26
27
 
27
28
  function createInternalData (): GanttInternalData {
28
29
  return {
30
+ linkFromConfMaps: {},
31
+ linkFromKeyMaps: {},
32
+ linkUniqueMaps: {},
29
33
  uFoot: false,
30
34
  resizeTableWidth: 0
31
35
  // barTipTimeout: null
@@ -74,22 +78,24 @@ export default defineVxeComponent({
74
78
  params: PropType<VxeTablePropTypes.Params>
75
79
  }),
76
80
 
77
- columns: Array as PropType<VxeGridPropTypes.Columns<any>>,
81
+ columns: Array as PropType<VxeGridPropTypes.Columns>,
78
82
  pagerConfig: Object as PropType<VxeGridPropTypes.PagerConfig>,
79
83
  proxyConfig: Object as PropType<VxeGridPropTypes.ProxyConfig<any>>,
80
84
  toolbarConfig: Object as PropType<VxeGridPropTypes.ToolbarConfig>,
81
85
  formConfig: Object as PropType<VxeGridPropTypes.FormConfig>,
82
86
  zoomConfig: Object as PropType<VxeGridPropTypes.ZoomConfig>,
83
87
 
88
+ links: Array as PropType<VxeGanttPropTypes.Links>,
84
89
  layouts: Array as PropType<VxeGanttPropTypes.Layouts>,
85
90
  taskConfig: Object as PropType<VxeGanttPropTypes.TaskConfig>,
86
91
  taskViewScaleConfig: Object as PropType<VxeGanttPropTypes.TaskViewScaleConfig>,
87
92
  taskViewConfig: Object as PropType<VxeGanttPropTypes.TaskViewConfig>,
93
+ taskLinkConfig: Object as PropType<VxeGanttPropTypes.TaskLinkConfig>,
88
94
  taskBarConfig: Object as PropType<VxeGanttPropTypes.TaskBarConfig>,
89
95
  taskBarTooltipConfig: Object as PropType<VxeGanttPropTypes.TaskBarTooltipConfig>,
90
96
  taskSplitConfig: Object as PropType<VxeGanttPropTypes.TaskSplitConfig>,
91
97
  taskBarResizeConfig: Object as PropType<VxeGanttPropTypes.TaskBarResizeConfig>,
92
- taskBarDragConfig: Object as PropType<VxeGanttPropTypes.TaskBarDragConfig>,
98
+ taskBarMoveConfig: Object as PropType<VxeGanttPropTypes.TaskBarMoveConfig>,
93
99
  size: {
94
100
  type: String as PropType<VxeGridPropTypes.Size>,
95
101
  default: () => getConfig().gantt.size || getConfig().size
@@ -114,6 +120,7 @@ export default defineVxeComponent({
114
120
  tableLoading: false,
115
121
  proxyInited: false,
116
122
  isZMax: false,
123
+ tableLinks: [],
117
124
  tableData: [],
118
125
  filterData: [],
119
126
  formData: {},
@@ -134,7 +141,10 @@ export default defineVxeComponent({
134
141
  content: '',
135
142
  visible: false,
136
143
  params: null
137
- }
144
+ },
145
+
146
+ linkList: [],
147
+ upLinkFlag: 0
138
148
  })
139
149
 
140
150
  const internalData = createInternalData()
@@ -232,8 +242,8 @@ export default defineVxeComponent({
232
242
  return Object.assign({}, getConfig().gantt.taskBarConfig, props.taskBarConfig)
233
243
  })
234
244
 
235
- const computeTaskBarDragOpts = computed(() => {
236
- return Object.assign({}, getConfig().gantt.taskBarDragConfig, props.taskBarDragConfig)
245
+ const computeTaskBarMoveOpts = computed(() => {
246
+ return Object.assign({}, getConfig().gantt.taskBarMoveConfig, props.taskBarMoveConfig)
237
247
  })
238
248
 
239
249
  const computeTaskBarResizeOpts = computed(() => {
@@ -248,6 +258,10 @@ export default defineVxeComponent({
248
258
  return Object.assign({}, getConfig().gantt.taskBarTooltipConfig, props.taskBarTooltipConfig)
249
259
  })
250
260
 
261
+ const computeTaskLinkOpts = computed(() => {
262
+ return Object.assign({}, getConfig().gantt.taskLinkConfig, props.taskLinkConfig)
263
+ })
264
+
251
265
  const computeScaleUnit = computed(() => {
252
266
  const minScale = computeMinScale.value
253
267
  return minScale ? minScale.type : 'date'
@@ -492,10 +506,11 @@ export default defineVxeComponent({
492
506
  computeTaskViewScaleOpts,
493
507
  computeTaskViewOpts,
494
508
  computeTaskBarOpts,
495
- computeTaskBarDragOpts,
509
+ computeTaskBarMoveOpts,
496
510
  computeTaskBarResizeOpts,
497
511
  computeTaskSplitOpts,
498
512
  computeTaskBarTooltipOpts,
513
+ computeTaskLinkOpts,
499
514
  computeTaskViewScales,
500
515
  computeScaleUnit,
501
516
  computeMinScale,
@@ -918,6 +933,45 @@ export default defineVxeComponent({
918
933
  reactData.showRightView = !reactData.showRightView
919
934
  }
920
935
 
936
+ const handleTableLinks = () => {
937
+ const { linkList } = reactData
938
+ reactData.tableLinks = linkList.slice(0)
939
+ }
940
+
941
+ const handleTaskAddLink = (item: VxeGanttPropTypes.Link, linkConfs: VxeGanttDefines.LinkConfObj[], fromConfMaps: Record<string, VxeGanttDefines.LinkConfObj[]>, fromKeyMaps: Record<string, VxeGanttDefines.LinkConfObj>, uniqueMaps: Record<string, VxeGanttDefines.LinkConfObj>) => {
942
+ if (item) {
943
+ const { type, from, to, lineStatus, lineColor, lineTyle, lineWidth, showArrow } = item
944
+ const tlKey = getTaskLinkKey(from, to)
945
+ if (from && to && !uniqueMaps[tlKey]) {
946
+ let confs = fromConfMaps[from]
947
+ if (!confs) {
948
+ confs = fromConfMaps[from] = []
949
+ }
950
+ const confObj: VxeGanttDefines.LinkConfObj = { type, from, to, lineStatus, lineColor, lineTyle, lineWidth, showArrow }
951
+ confs.push(confObj)
952
+ linkConfs.push(confObj)
953
+ fromKeyMaps[from] = confObj
954
+ uniqueMaps[tlKey] = confObj
955
+ }
956
+ }
957
+ }
958
+
959
+ const handleTaskUpdateLinks = (links: VxeGanttPropTypes.Links) => {
960
+ const linkConfs: VxeGanttDefines.LinkConfObj[] = []
961
+ const fromConfMaps: Record<string, VxeGanttDefines.LinkConfObj[]> = {}
962
+ const fromKeyMaps: Record<string, VxeGanttDefines.LinkConfObj> = {}
963
+ const uniqueMaps: Record<string, VxeGanttDefines.LinkConfObj> = {}
964
+ XEUtils.each(links || [], item => {
965
+ handleTaskAddLink(item, linkConfs, fromConfMaps, fromKeyMaps, uniqueMaps)
966
+ })
967
+ reactData.linkList = linkConfs
968
+ internalData.linkFromConfMaps = fromConfMaps
969
+ internalData.linkFromKeyMaps = fromKeyMaps
970
+ internalData.linkUniqueMaps = uniqueMaps
971
+ $xeGantt.handleTableLinks()
972
+ return nextTick()
973
+ }
974
+
921
975
  const tableCompEvents: VxeTableEventProps = {}
922
976
  tableEmits.forEach(name => {
923
977
  const type = XEUtils.camelCase(`on-${name}`) as keyof VxeTableEventProps
@@ -1798,6 +1852,9 @@ export default defineVxeComponent({
1798
1852
  $xeGantt.closeTaskBarTooltip()
1799
1853
  }
1800
1854
  },
1855
+ handleTableLinks,
1856
+ handleTaskAddLink,
1857
+ handleTaskUpdateLinks,
1801
1858
  handleTaskHeaderContextmenuEvent (evnt, params) {
1802
1859
  const $xeTable = refTable.value
1803
1860
  if ($xeTable) {
@@ -2409,10 +2466,21 @@ export default defineVxeComponent({
2409
2466
  }
2410
2467
  })
2411
2468
 
2469
+ if (props.links) {
2470
+ $xeGantt.handleTaskUpdateLinks(props.links)
2471
+ }
2412
2472
  handleTaskScaleConfig()
2413
2473
  initPages()
2414
2474
 
2415
2475
  onMounted(() => {
2476
+ if (!$xeGantt.handleUpdateTaskLink) {
2477
+ if (props.links) {
2478
+ warnLog('vxe.error.notProp', ['links'])
2479
+ }
2480
+ if (props.taskLinkConfig) {
2481
+ warnLog('vxe.error.notProp', ['task-link-config'])
2482
+ }
2483
+ }
2416
2484
  nextTick(() => {
2417
2485
  const { columns } = props
2418
2486
  const proxyOpts = computeProxyOpts.value
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 依赖线枚举类型
3
+ */
4
+ export enum VxeGanttDependencyType {
5
+ /**
6
+ * 结束后才开始,表示一个任务必须在另一个任务开始之前完成
7
+ */
8
+ FinishToStart = 0,
9
+ /**
10
+ * 开始到结束,表示从某个过程的开始到结束的整个过程
11
+ */
12
+ StartToFinish = 1,
13
+ /**
14
+ * 开始后才开始,表示一个活动结束了,另一个活动才能开始,它们之间按先后顺序进行
15
+ */
16
+ StartToStart = 2,
17
+ /**
18
+ * 完成到完成,表示一个任务必须在另一个任务完成之后才能完成
19
+ */
20
+ FinishToFinish = 3
21
+ }
@@ -1,6 +1,10 @@
1
1
  import type { VxeTableEmits } from 'vxe-table'
2
2
 
3
3
  export const tableEmits: VxeTableEmits = [
4
+ 'ready',
5
+ 'init-rendered',
6
+ 'data-rendered',
7
+
4
8
  'update:data',
5
9
  'keydown-start',
6
10
  'keydown',
@@ -8,6 +12,7 @@ export const tableEmits: VxeTableEmits = [
8
12
  'paste',
9
13
  'copy',
10
14
  'cut',
15
+ 'context-menu',
11
16
 
12
17
  'columns-change',
13
18
  'data-change',
@@ -33,3 +33,15 @@ export function getStandardGapTime (type: VxeGanttDefines.ColumnScaleType) {
33
33
  }
34
34
  return 1000 * 60 * 60 * 24
35
35
  }
36
+
37
+ export function getTaskBarLeft (chartRest: VxeGanttDefines.RowCacheItem | null, viewCellWidth: number) {
38
+ return chartRest ? viewCellWidth * chartRest.oLeftSize : 0
39
+ }
40
+
41
+ export function getTaskBarWidth (chartRest: VxeGanttDefines.RowCacheItem | null, viewCellWidth: number) {
42
+ return Math.max(1, chartRest ? (Math.floor(viewCellWidth * chartRest.oWidthSize) - 1) : 0)
43
+ }
44
+
45
+ export function getTaskLinkKey (from: string | number, to: string | number) {
46
+ return `${from}_${to}`
47
+ }
@@ -1,7 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core'
2
- import { errLog } from './src/log'
3
2
 
4
- const { setConfig, setIcon, checkVersion } = VxeUI
3
+ const { setConfig, setIcon } = VxeUI
5
4
 
6
5
  VxeUI.ganttVersion = process.env.VUE_APP_VXE_VERSION as string
7
6
 
@@ -49,6 +48,10 @@ setConfig({
49
48
  taskBarTooltipConfig: {
50
49
  enterable: true
51
50
  },
51
+ taskLinkConfig: {
52
+ enabled: true,
53
+ showArrow: true
54
+ },
52
55
  taskViewScaleConfig: {
53
56
  year: {
54
57
  valueFormat: ymdFormat
@@ -105,16 +108,6 @@ setIcon({
105
108
  GANTT_VIEW_RIGHT_CLOSE: iconPrefix + 'arrow-left'
106
109
  })
107
110
 
108
- const pVersion = 4
109
- const sVersion = 16
110
- if (checkVersion) {
111
- if (!checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
112
- errLog('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])
113
- }
114
- } else {
115
- errLog(`Requires vxe-table v${pVersion}.${sVersion}+`)
116
- }
117
-
118
111
  export {
119
112
  VxeUI
120
113
  }
@@ -0,0 +1,14 @@
1
+ import { VxeUI } from '@vxe-ui/core'
2
+ import { errLog } from './log'
3
+
4
+ export function checkDependVersion () {
5
+ const pVersion = 4
6
+ const sVersion = 17
7
+ if (VxeUI.checkVersion) {
8
+ if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
9
+ errLog('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])
10
+ }
11
+ } else {
12
+ errLog(`Requires vxe-table v${pVersion}.${sVersion}+`)
13
+ }
14
+ }
@@ -1,9 +1,10 @@
1
- .vxe-gantt-view--chart-wrapper {
1
+ .vxe-gantt-view--chart-task-wrapper {
2
2
  position: absolute;
3
3
  top: 0;
4
4
  left: 0;
5
5
  pointer-events: none;
6
6
  }
7
+
7
8
  .vxe-gantt-view--chart-row {
8
9
  position: relative;
9
10
  width: 100%;
@@ -19,7 +20,7 @@
19
20
  }
20
21
  }
21
22
  }
22
- &.is--drag {
23
+ &.is--move {
23
24
  & > .vxe-gantt-view--chart-bar,
24
25
  & > .vxe-gantt-view--chart-custom-bar {
25
26
  user-select: none;
@@ -683,4 +683,3 @@
683
683
  font-size: var(--vxe-ui-font-size-mini);
684
684
  }
685
685
  }
686
-
@@ -8,4 +8,6 @@
8
8
  --vxe-ui-gantt-view-task-bar-border-radius: calc(var(--vxe-ui-gantt-view-split-bar-height) / 2);
9
9
  --vxe-ui-gantt-view-task-bar-background-color: var(--vxe-ui-font-primary-lighten-color);
10
10
  --vxe-ui-gantt-view-task-bar-completed-background-color: var(--vxe-ui-font-primary-color);
11
+ --vxe-ui-gantt-view-task-line-color: var(--vxe-ui-font-primary-color);
12
+ --vxe-ui-gantt-view-task-line-arrow-width: 5;
11
13
  }