vxe-gantt 3.1.5 → 3.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 (57) hide show
  1. package/es/gantt/index.js +3 -0
  2. package/es/gantt/src/gantt-body.js +2 -5
  3. package/es/gantt/src/gantt-chart.js +66 -37
  4. package/es/gantt/src/gantt-view.js +34 -13
  5. package/es/gantt/src/gantt.js +71 -6
  6. package/es/gantt/src/static.js +22 -0
  7. package/es/gantt/src/util.js +9 -0
  8. package/es/gantt/style.css +2 -2
  9. package/es/gantt/style.min.css +1 -1
  10. package/es/style.css +1 -1
  11. package/es/style.min.css +1 -1
  12. package/es/ui/index.js +6 -13
  13. package/es/ui/src/depend.js +14 -0
  14. package/es/ui/src/log.js +1 -1
  15. package/es/vxe-gantt/style.css +2 -2
  16. package/es/vxe-gantt/style.min.css +1 -1
  17. package/lib/gantt/index.js +18 -0
  18. package/lib/gantt/index.min.js +1 -1
  19. package/lib/gantt/src/gantt-body.js +2 -5
  20. package/lib/gantt/src/gantt-body.min.js +1 -1
  21. package/lib/gantt/src/gantt-chart.js +42 -22
  22. package/lib/gantt/src/gantt-chart.min.js +1 -1
  23. package/lib/gantt/src/gantt-view.js +29 -11
  24. package/lib/gantt/src/gantt-view.min.js +1 -1
  25. package/lib/gantt/src/gantt.js +89 -6
  26. package/lib/gantt/src/gantt.min.js +1 -1
  27. package/lib/gantt/src/static.js +28 -0
  28. package/lib/gantt/src/static.min.js +1 -0
  29. package/lib/gantt/src/util.js +12 -0
  30. package/lib/gantt/src/util.min.js +1 -1
  31. package/lib/gantt/style/style.css +2 -2
  32. package/lib/gantt/style/style.min.css +1 -1
  33. package/lib/index.umd.js +235 -68
  34. package/lib/index.umd.min.js +1 -1
  35. package/lib/style.css +1 -1
  36. package/lib/style.min.css +1 -1
  37. package/lib/ui/index.js +6 -13
  38. package/lib/ui/index.min.js +1 -1
  39. package/lib/ui/src/depend.js +19 -0
  40. package/lib/ui/src/depend.min.js +1 -0
  41. package/lib/ui/src/log.js +1 -1
  42. package/lib/ui/src/log.min.js +1 -1
  43. package/lib/vxe-gantt/style/style.css +2 -2
  44. package/lib/vxe-gantt/style/style.min.css +1 -1
  45. package/package.json +3 -7
  46. package/packages/gantt/index.ts +4 -0
  47. package/packages/gantt/src/gantt-body.ts +2 -5
  48. package/packages/gantt/src/gantt-chart.ts +66 -37
  49. package/packages/gantt/src/gantt-view.ts +37 -14
  50. package/packages/gantt/src/gantt.ts +89 -17
  51. package/packages/gantt/src/static.ts +21 -0
  52. package/packages/gantt/src/util.ts +12 -0
  53. package/packages/ui/index.ts +5 -12
  54. package/packages/ui/src/depend.ts +14 -0
  55. package/styles/components/gantt-module/gantt-chart.scss +3 -2
  56. package/styles/components/gantt.scss +0 -1
  57. 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 { TableInternalData, TableReactData, VxeTableConstructor, VxeTableMethods, VxeTablePrivateMethods } from 'vxe-table'
@@ -60,15 +60,13 @@ export default defineVxeComponent({
60
60
  const taskBarOpts = $xeGantt.computeTaskBarOpts
61
61
  const scaleUnit = $xeGantt.computeScaleUnit
62
62
  const barParams = { $gantt: $xeGantt, row, scaleType: scaleUnit }
63
- const { showProgress, showContent, contentMethod, barStyle, drag, showTooltip } = taskBarOpts
63
+ const { showProgress, showContent, contentMethod, barStyle, move, showTooltip } = taskBarOpts
64
64
  const isBarRowStyle = XEUtils.isFunction(barStyle)
65
65
  const barStyObj = (barStyle ? (isBarRowStyle ? barStyle(barParams) : barStyle) : {}) || {}
66
66
  const { round } = barStyObj
67
67
 
68
68
  const rowRest = fullAllDataRowIdData[rowid] || {}
69
- const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0
70
- const isRsHeight = resizeHeight > 0
71
- const cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
69
+ const cellHeight = resizeHeightFlag ? getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) : 0
72
70
 
73
71
  let title = getStringValue(XEUtils.get(row, titleField))
74
72
  const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
@@ -135,8 +133,7 @@ export default defineVxeComponent({
135
133
  },
136
134
  class: ['vxe-gantt-view--chart-row', {
137
135
  'is--round': round,
138
- 'is--drag': drag,
139
- 'col--rs-height': isRsHeight
136
+ 'is--move': move
140
137
  }],
141
138
  style: {
142
139
  height: `${cellHeight}px`
@@ -154,27 +151,40 @@ export default defineVxeComponent({
154
151
  rowid
155
152
  },
156
153
  on: ons
157
- }, taskBarSlot
158
- ? $xeGantt.callSlot(taskBarSlot, barParams, h)
159
- : [
160
- showProgress
161
- ? h('div', {
162
- class: 'vxe-gantt-view--chart-progress',
163
- style: vpStyle
164
- })
165
- : renderEmptyElement($xeGantt),
166
- showContent
167
- ? h('div', {
168
- class: 'vxe-gantt-view--chart-content'
169
- }, title)
170
- : renderEmptyElement($xeGantt)
171
- ])
154
+ }, $xeGantt.renderGanttTaskBarContent
155
+ ? $xeGantt.renderGanttTaskBarContent(h, ctParams, {
156
+ title,
157
+ vbStyle,
158
+ vpStyle
159
+ })
160
+ : (taskBarSlot
161
+ ? [
162
+ h('div', {
163
+ key: 'cbc',
164
+ class: 'vxe-gantt-view--chart-custom-bar-content'
165
+ }, $xeGantt.callSlot(taskBarSlot, barParams, h))
166
+ ]
167
+ : [
168
+ showProgress
169
+ ? h('div', {
170
+ key: 'vcp',
171
+ class: 'vxe-gantt-view--chart-progress',
172
+ style: vpStyle
173
+ })
174
+ : renderEmptyElement($xeGantt),
175
+ showContent
176
+ ? h('div', {
177
+ key: 'vcc',
178
+ class: 'vxe-gantt-view--chart-content'
179
+ }, title)
180
+ : renderEmptyElement($xeGantt)
181
+ ]))
172
182
  ])
173
183
  },
174
- renderRows (h: CreateElement, $xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, tableData: any[]) {
184
+ renderTaskRows (h: CreateElement, $xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, tableData: any[]) {
175
185
  const _vm = this
176
186
  const $xeGanttView = _vm.$xeGanttView
177
- const { reactData } = $xeGanttView
187
+ const ganttViewReactData = $xeGanttView.reactData
178
188
 
179
189
  const tableProps = $xeTable
180
190
  const { treeConfig } = tableProps
@@ -186,11 +196,11 @@ export default defineVxeComponent({
186
196
  const { transform } = treeOpts
187
197
  const childrenField = treeOpts.children || treeOpts.childrenField
188
198
 
189
- const { scrollYLoad } = reactData
199
+ const { scrollYLoad } = ganttViewReactData
190
200
 
191
201
  const trVNs: VNode[] = []
192
202
  tableData.forEach((row, $rowIndex) => {
193
- const rowid = $xeTable ? $xeTable.getRowid(row) : ''
203
+ const rowid = $xeTable.getRowid(row)
194
204
  const rowRest = fullAllDataRowIdData[rowid] || {}
195
205
  let rowIndex = $rowIndex
196
206
  let _rowIndex = -1
@@ -208,43 +218,62 @@ export default defineVxeComponent({
208
218
  }
209
219
  // 如果是树形表格
210
220
  if (isExpandTree) {
211
- trVNs.push(..._vm.renderRows(h, $xeTable, rowChildren))
221
+ trVNs.push(..._vm.renderTaskRows(h, $xeTable, rowChildren))
212
222
  }
213
223
  })
214
224
  return trVNs
215
225
  },
216
226
  renderVN (h: CreateElement): VNode {
217
227
  const _vm = this
228
+ const $xeGantt = _vm.$xeGantt
218
229
  const $xeGanttView = _vm.$xeGanttView
219
- const { reactData } = $xeGanttView
230
+ const ganttViewInternalData = $xeGanttView.internalData
231
+ const ganttViewReactData = $xeGanttView.reactData
220
232
 
221
- const $xeTable = $xeGanttView.internalData.xeTable
233
+ const $xeTable = ganttViewInternalData.xeTable
222
234
 
223
- const { tableData } = reactData
235
+ const { tableData } = ganttViewReactData
236
+ const taskLinkOpts = $xeGantt.computeTaskLinkOpts
237
+ const { showArrow } = taskLinkOpts
224
238
 
225
239
  return h('div', {
226
240
  ref: 'refElem',
227
241
  class: 'vxe-gantt-view--chart-wrapper'
228
- }, $xeTable ? _vm.renderRows(h, $xeTable, tableData) : [])
242
+ }, [
243
+ $xeGantt.renderGanttTaskLines
244
+ ? h('div', {
245
+ ref: 'reflineWrapperElem',
246
+ class: ['vxe-gantt-view--chart-line-wrapper', {
247
+ 'show-arrow': showArrow
248
+ }]
249
+ }, $xeTable && isEnableConf(taskLinkOpts) ? $xeGantt.renderGanttTaskLines(h) : [])
250
+ : renderEmptyElement($xeGantt),
251
+ h('div', {
252
+ ref: 'refTaskWrapperElem',
253
+ class: 'vxe-gantt-view--chart-task-wrapper'
254
+ }, $xeTable ? _vm.renderTaskRows(h, $xeTable, tableData) : [])
255
+ ])
229
256
  }
230
257
  },
231
258
  mounted () {
232
259
  const _vm = this
233
260
  const $xeGanttView = _vm.$xeGanttView
234
- const { internalData } = $xeGanttView
261
+ const ganttViewInternalData = $xeGanttView.internalData
235
262
 
236
- const { elemStore } = internalData
263
+ const { elemStore } = ganttViewInternalData
237
264
  const prefix = 'main-chart-'
238
- elemStore[`${prefix}wrapper`] = _vm.$refs.refElem as HTMLDivElement
265
+ elemStore[`${prefix}task-wrapper`] = _vm.$refs.refTaskWrapperElem as HTMLDivElement
266
+ elemStore[`${prefix}line-wrapper`] = _vm.$refs.reflineWrapperElem as HTMLDivElement
239
267
  },
240
268
  destroyed () {
241
269
  const _vm = this
242
270
  const $xeGanttView = _vm.$xeGanttView
243
- const { internalData } = $xeGanttView
271
+ const ganttViewInternalData = $xeGanttView.internalData
244
272
 
245
- const { elemStore } = internalData
273
+ const { elemStore } = ganttViewInternalData
246
274
  const prefix = 'main-chart-'
247
- elemStore[`${prefix}wrapper`] = null
275
+ elemStore[`${prefix}task-wrapper`] = null
276
+ elemStore[`${prefix}line-wrapper`] = null
248
277
  },
249
278
  render (this: any, h) {
250
279
  return this.renderVN(h)
@@ -1,8 +1,8 @@
1
1
  import { VNode, CreateElement } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
3
  import { VxeUI } from '@vxe-ui/core'
4
- import { setScrollTop, setScrollLeft, removeClass, addClass, hasClass } from '../../ui/src/dom'
5
- import { getRefElem, getStandardGapTime } from './util'
4
+ import { setScrollTop, setScrollLeft, removeClass, addClass } from '../../ui/src/dom'
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'
@@ -601,30 +601,37 @@ function calcScrollbar ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPriv
601
601
  }
602
602
  }
603
603
 
604
- function updateChart ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
604
+ function updateTaskChart ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
605
+ const $xeGantt = $xeGanttView.$xeGantt
605
606
  const reactData = $xeGanttView.reactData
606
607
  const internalData = $xeGanttView.internalData
608
+ const ganttInternalData = $xeGantt.internalData
609
+ const $xeTable = internalData.xeTable
607
610
 
611
+ const { dragBarRow } = ganttInternalData
608
612
  const { viewCellWidth } = reactData
609
613
  const { elemStore, chartMaps } = internalData
610
- const chartWrapper = getRefElem(elemStore['main-chart-wrapper'])
611
- if (chartWrapper) {
614
+ const chartWrapper = getRefElem(elemStore['main-chart-task-wrapper'])
615
+ if (chartWrapper && $xeTable) {
612
616
  XEUtils.arrayEach(chartWrapper.children, (rowEl) => {
613
617
  const barEl = rowEl.children[0] as HTMLDivElement
614
- if (!barEl || hasClass(barEl, 'is--drag')) {
618
+ if (!barEl) {
615
619
  return
616
620
  }
617
621
  const rowid = rowEl.getAttribute('rowid')
618
- const rowRest = rowid ? chartMaps[rowid] : null
619
- barEl.style.left = `${rowRest ? viewCellWidth * rowRest.oLeftSize : 0}px`
620
- barEl.style.width = `${rowRest ? viewCellWidth * rowRest.oWidthSize : 0}px`
622
+ if (dragBarRow && $xeTable.getRowid(dragBarRow) === rowid) {
623
+ return
624
+ }
625
+ const chartRest = rowid ? chartMaps[rowid] : null
626
+ barEl.style.left = `${getTaskBarLeft(chartRest, viewCellWidth)}px`
627
+ barEl.style.width = `${getTaskBarWidth(chartRest, viewCellWidth)}px`
621
628
  })
622
629
  }
623
630
  return $xeGanttView.$nextTick()
624
631
  }
625
632
 
626
633
  function updateStyle ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
627
- const $xeGantt = $xeGanttView.$xeGantt
634
+ const $xeGantt = $xeGanttView.$xeGantt as VxeGanttConstructor & VxeGanttPrivateMethods
628
635
  const reactData = $xeGanttView.reactData
629
636
  const internalData = $xeGanttView.internalData
630
637
 
@@ -636,6 +643,9 @@ function updateStyle ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivat
636
643
  if (!el) {
637
644
  return
638
645
  }
646
+ if (!$xeGantt) {
647
+ return
648
+ }
639
649
 
640
650
  const scrollbarOpts = $xeGantt.computeScrollbarOpts
641
651
  const scrollbarXToTop = $xeGantt.computeScrollbarXToTop
@@ -746,20 +756,26 @@ function updateStyle ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivat
746
756
 
747
757
  reactData.scrollXWidth = viewTableWidth
748
758
 
749
- return updateChart($xeGanttView)
759
+ return Promise.all([
760
+ updateTaskChart($xeGanttView),
761
+ $xeGantt.handleUpdateTaskLink ? $xeGantt.handleUpdateTaskLink($xeGanttView) : null
762
+ ])
750
763
  }
751
764
 
752
765
  function handleRecalculateStyle ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
753
766
  const internalData = $xeGanttView.internalData
767
+ const $xeGantt = $xeGanttView.$xeGantt
754
768
 
755
769
  const el = $xeGanttView.$refs.refElem as HTMLDivElement
756
770
  internalData.rceRunTime = Date.now()
757
771
  if (!el || !el.clientWidth) {
758
772
  return $xeGanttView.$nextTick()
759
773
  }
774
+ if (!$xeGantt) {
775
+ return $xeGanttView.$nextTick()
776
+ }
760
777
  calcScrollbar($xeGanttView)
761
778
  updateStyle($xeGanttView)
762
- updateChart($xeGanttView)
763
779
  return computeScrollLoad($xeGanttView)
764
780
  }
765
781
 
@@ -975,7 +991,7 @@ function updateScrollYSpace ($xeGanttView: VxeGanttViewConstructor & VxeGanttVie
975
991
  scrollYTop = 0
976
992
  }
977
993
 
978
- const bodyChartWrapperElem = getRefElem(elemStore['main-chart-wrapper'])
994
+ const bodyChartWrapperElem = getRefElem(elemStore['main-chart-task-wrapper'])
979
995
  if (bodyTableElem) {
980
996
  bodyTableElem.style.transform = `translate(${reactData.scrollXLeft || 0}px, ${scrollYTop}px)`
981
997
  }
@@ -992,6 +1008,13 @@ function updateScrollYSpace ($xeGanttView: VxeGanttViewConstructor & VxeGanttVie
992
1008
  if (scrollYSpaceEl) {
993
1009
  scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
994
1010
  }
1011
+
1012
+ const lineWrapper = getRefElem(elemStore['main-chart-line-wrapper'])
1013
+ const svgElem = lineWrapper ? lineWrapper.firstElementChild as HTMLDivElement : null
1014
+ if (svgElem) {
1015
+ svgElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
1016
+ }
1017
+
995
1018
  reactData.scrollYTop = scrollYTop
996
1019
  reactData.scrollYHeight = scrollYHeight
997
1020
  reactData.isScrollYBig = isScrollYBig
@@ -1192,7 +1215,7 @@ export default defineVxeComponent({
1192
1215
  tableColumn: [],
1193
1216
  headerGroups: [],
1194
1217
 
1195
- viewCellWidth: 20
1218
+ viewCellWidth: 40
1196
1219
  }
1197
1220
 
1198
1221
  const internalData = createInternalData()
@@ -5,13 +5,14 @@ import XEUtils from 'xe-utils'
5
5
  import { getLastZIndex, nextZIndex, isEnableConf, formatText } from '../../ui/src/utils'
6
6
  import { getOffsetHeight, getPaddingTopBottomSize, getDomNode, toCssUnit, addClass, removeClass } from '../../ui/src/dom'
7
7
  import { getSlotVNs } from '../../ui/src/vn'
8
+ import { getTaskLinkKey } from './util'
8
9
  import { warnLog, errLog } from '../../ui/src/log'
9
10
  import GanttViewComponent from './gantt-view'
10
11
  import { VxeTable as VxeTableComponent } from 'vxe-table'
11
12
 
12
13
  import type { ValueOf, VxeFormInstance, VxeFormItemProps, VxePagerInstance, VxePagerDefines, VxeComponentStyleType, VxeComponentSizeType, VxeFormDefines, VxeFormItemPropTypes } from 'vxe-pc-ui'
13
14
  import type { VxeTableMethods, VxeToolbarPropTypes, VxeTooltipInstance, VxeTableProps, VxeTableConstructor, VxeTablePrivateMethods, VxeTableDefines, TableReactData, VxeToolbarInstance, TableInternalData, VxeTablePropTypes, VxeGridPropTypes, VxeGridDefines } from 'vxe-table'
14
- import type { VxeGanttEmits, GanttReactData, GanttInternalData, VxeGanttPropTypes, VxeGanttViewInstance, VxeGanttDefines, VxeGanttConstructor } from '../../../types'
15
+ import type { VxeGanttEmits, GanttReactData, GanttInternalData, VxeGanttPropTypes, VxeGanttViewInstance, VxeGanttDefines, VxeGanttConstructor, VxeGanttPrivateMethods } from '../../../types'
15
16
 
16
17
  const { getConfig, getIcon, getI18n, commands, globalMixins, createEvent, globalEvents, GLOBAL_EVENT_KEYS, renderEmptyElement } = VxeUI
17
18
 
@@ -74,8 +75,29 @@ XEUtils.each((VxeTableComponent as any).methods, (fn, name) => {
74
75
  }
75
76
  })
76
77
 
78
+ function handleTaskAddLink (item: VxeGanttPropTypes.Link, linkConfs: VxeGanttDefines.LinkConfObj[], fromConfMaps: Record<string, VxeGanttDefines.LinkConfObj[]>, fromKeyMaps: Record<string, VxeGanttDefines.LinkConfObj>, uniqueMaps: Record<string, VxeGanttDefines.LinkConfObj>) {
79
+ if (item) {
80
+ const { type, from, to, lineStatus, lineColor, lineTyle, lineWidth, showArrow } = item
81
+ const tlKey = getTaskLinkKey(from, to)
82
+ if (from && to && !uniqueMaps[tlKey]) {
83
+ let confs = fromConfMaps[from]
84
+ if (!confs) {
85
+ confs = fromConfMaps[from] = []
86
+ }
87
+ const confObj: VxeGanttDefines.LinkConfObj = { type, from, to, lineStatus, lineColor, lineTyle, lineWidth, showArrow }
88
+ confs.push(confObj)
89
+ linkConfs.push(confObj)
90
+ fromKeyMaps[from] = confObj
91
+ uniqueMaps[tlKey] = confObj
92
+ }
93
+ }
94
+ }
95
+
77
96
  function createInternalData (): GanttInternalData {
78
97
  return {
98
+ linkFromConfMaps: {},
99
+ linkFromKeyMaps: {},
100
+ linkUniqueMaps: {},
79
101
  uFoot: false,
80
102
  resizeTableWidth: 0
81
103
  // barTipTimeout: null
@@ -110,22 +132,24 @@ export default /* define-vxe-component start */ defineVxeComponent({
110
132
  params: PropType<VxeTablePropTypes.Params>
111
133
  }),
112
134
 
113
- columns: Array as PropType<VxeGridPropTypes.Columns<any>>,
135
+ columns: Array as PropType<VxeGridPropTypes.Columns>,
114
136
  pagerConfig: Object as PropType<VxeGridPropTypes.PagerConfig>,
115
137
  proxyConfig: Object as PropType<VxeGridPropTypes.ProxyConfig<any>>,
116
138
  toolbarConfig: Object as PropType<VxeGridPropTypes.ToolbarConfig>,
117
139
  formConfig: Object as PropType<VxeGridPropTypes.FormConfig>,
118
140
  zoomConfig: Object as PropType<VxeGridPropTypes.ZoomConfig>,
119
141
 
142
+ links: Array as PropType<VxeGanttPropTypes.Links>,
120
143
  layouts: Array as PropType<VxeGanttPropTypes.Layouts>,
121
144
  taskConfig: Object as PropType<VxeGanttPropTypes.TaskConfig>,
122
145
  taskViewScaleConfig: Object as PropType<VxeGanttPropTypes.TaskViewScaleConfig>,
123
146
  taskViewConfig: Object as PropType<VxeGanttPropTypes.TaskViewConfig>,
147
+ taskLinkConfig: Object as PropType<VxeGanttPropTypes.TaskLinkConfig>,
124
148
  taskBarConfig: Object as PropType<VxeGanttPropTypes.TaskBarConfig>,
125
149
  taskBarTooltipConfig: Object as PropType<VxeGanttPropTypes.TaskBarTooltipConfig>,
126
150
  taskSplitConfig: Object as PropType<VxeGanttPropTypes.TaskSplitConfig>,
127
151
  taskBarResizeConfig: Object as PropType<VxeGanttPropTypes.TaskBarResizeConfig>,
128
- taskBarDragConfig: Object as PropType<VxeGanttPropTypes.TaskBarDragConfig>,
152
+ taskBarMoveConfig: Object as PropType<VxeGanttPropTypes.TaskBarMoveConfig>,
129
153
  size: {
130
154
  type: String as PropType<VxeGridPropTypes.Size>,
131
155
  default: () => getConfig().gantt.size || getConfig().size
@@ -147,6 +171,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
147
171
  tableLoading: false,
148
172
  proxyInited: false,
149
173
  isZMax: false,
174
+ tableLinks: [],
150
175
  tableData: [],
151
176
  filterData: [],
152
177
  formData: {},
@@ -167,7 +192,10 @@ export default /* define-vxe-component start */ defineVxeComponent({
167
192
  content: '',
168
193
  visible: false,
169
194
  params: null
170
- }
195
+ },
196
+
197
+ linkList: [],
198
+ upLinkFlag: 0
171
199
  }
172
200
 
173
201
  const internalData = createInternalData()
@@ -248,11 +276,11 @@ export default /* define-vxe-component start */ defineVxeComponent({
248
276
 
249
277
  return Object.assign({}, getConfig().gantt.taskBarConfig, props.taskBarConfig)
250
278
  },
251
- computeTaskBarDragOpts () {
279
+ computeTaskBarMoveOpts () {
252
280
  const $xeGantt = this
253
281
  const props = $xeGantt
254
282
 
255
- return Object.assign({}, getConfig().gantt.taskBarDragConfig, props.taskBarDragConfig)
283
+ return Object.assign({}, getConfig().gantt.taskBarMoveConfig, props.taskBarMoveConfig)
256
284
  },
257
285
  computeTaskBarResizeOpts () {
258
286
  const $xeGantt = this
@@ -272,6 +300,12 @@ export default /* define-vxe-component start */ defineVxeComponent({
272
300
 
273
301
  return Object.assign({}, getConfig().gantt.taskBarTooltipConfig, props.taskBarTooltipConfig)
274
302
  },
303
+ computeTaskLinkOpts () {
304
+ const $xeGantt = this
305
+ const props = $xeGantt
306
+
307
+ return Object.assign({}, getConfig().gantt.taskLinkConfig, props.taskLinkConfig)
308
+ },
275
309
  computeScaleUnit () {
276
310
  const $xeGantt = this
277
311
 
@@ -679,7 +713,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
679
713
  }
680
714
  },
681
715
  getRespMsg (rest: any, defaultMsg: string) {
682
- const $xeGantt = this
716
+ const $xeGantt = this as unknown as VxeGanttConstructor & VxeGanttPrivateMethods
683
717
 
684
718
  const proxyOpts = $xeGantt.computeProxyOpts
685
719
  const resConfigs = proxyOpts.response || proxyOpts.props || {}
@@ -1187,7 +1221,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
1187
1221
  const commitParams = {
1188
1222
  $table: $xeTable,
1189
1223
  $grid: null,
1190
- $gantt: $xeGantt,
1224
+ $gantt: $xeGantt as unknown as VxeGanttConstructor & VxeGanttPrivateMethods,
1191
1225
  code,
1192
1226
  button,
1193
1227
  isInited,
@@ -1209,7 +1243,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
1209
1243
  let tableData: any[] = []
1210
1244
  reactData.tableLoading = false
1211
1245
  if (rest) {
1212
- const reParams = { data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }
1246
+ const reParams = { data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt as unknown as VxeGanttConstructor & VxeGanttPrivateMethods }
1213
1247
  if (pagerConfig && isEnableConf(pagerOpts)) {
1214
1248
  const totalProp = resConfigs.total
1215
1249
  const total = (XEUtils.isFunction(totalProp) ? totalProp(reParams) : XEUtils.get(rest, totalProp || 'page.total')) || 0
@@ -1278,7 +1312,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
1278
1312
  const commitParams = {
1279
1313
  $table: $xeTable,
1280
1314
  $grid: null,
1281
- $gantt: $xeGantt,
1315
+ $gantt: $xeGantt as unknown as VxeGanttConstructor & VxeGanttPrivateMethods,
1282
1316
  code,
1283
1317
  button,
1284
1318
  filters: filterList,
@@ -1316,7 +1350,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
1316
1350
  const commitParams = {
1317
1351
  $table: $xeTable,
1318
1352
  $grid: null,
1319
- $gantt: $xeGantt,
1353
+ $gantt: $xeGantt as unknown as VxeGanttConstructor & VxeGanttPrivateMethods,
1320
1354
  code,
1321
1355
  button,
1322
1356
  body,
@@ -1393,7 +1427,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
1393
1427
  const commitParams = {
1394
1428
  $table: $xeTable,
1395
1429
  $grid: null,
1396
- $gantt: $xeGantt,
1430
+ $gantt: $xeGantt as unknown as VxeGanttConstructor & VxeGanttPrivateMethods,
1397
1431
  code,
1398
1432
  button,
1399
1433
  body,
@@ -1479,7 +1513,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
1479
1513
  if (gCommandOpts) {
1480
1514
  const tCommandMethod = gCommandOpts.tableCommandMethod || gCommandOpts.commandMethod
1481
1515
  if (tCommandMethod) {
1482
- tCommandMethod({ code, button, $grid: null, $table: $xeTable, $gantt: $xeGantt }, ...args)
1516
+ tCommandMethod({ code, button, $grid: null, $table: $xeTable, $gantt: $xeGantt as unknown as VxeGanttConstructor & VxeGanttPrivateMethods }, ...args)
1483
1517
  } else {
1484
1518
  errLog('vxe.error.notCommands', [code])
1485
1519
  }
@@ -1729,8 +1763,8 @@ export default /* define-vxe-component start */ defineVxeComponent({
1729
1763
  return $xeGantt.$nextTick()
1730
1764
  },
1731
1765
  /**
1732
- * 关闭 bar tooltip
1733
- */
1766
+ * 关闭 bar tooltip
1767
+ */
1734
1768
  closeTaskBarTooltip () {
1735
1769
  const $xeGantt = this
1736
1770
  const reactData = $xeGantt.reactData
@@ -1953,6 +1987,33 @@ export default /* define-vxe-component start */ defineVxeComponent({
1953
1987
  $xeGantt.closeTaskBarTooltip()
1954
1988
  }
1955
1989
  },
1990
+ handleTableLinks () {
1991
+ const $xeGantt = this
1992
+ const reactData = $xeGantt.reactData
1993
+
1994
+ const { linkList } = reactData
1995
+ reactData.tableLinks = linkList.slice(0)
1996
+ },
1997
+ handleTaskAddLink,
1998
+ handleTaskUpdateLinks (links: VxeGanttPropTypes.Links) {
1999
+ const $xeGantt = this
2000
+ const reactData = $xeGantt.reactData
2001
+ const internalData = $xeGantt.internalData
2002
+
2003
+ const linkConfs: VxeGanttDefines.LinkConfObj[] = []
2004
+ const fromConfMaps: Record<string, VxeGanttDefines.LinkConfObj[]> = {}
2005
+ const fromKeyMaps: Record<string, VxeGanttDefines.LinkConfObj> = {}
2006
+ const uniqueMaps: Record<string, VxeGanttDefines.LinkConfObj> = {}
2007
+ XEUtils.each(links || [], item => {
2008
+ handleTaskAddLink(item, linkConfs, fromConfMaps, fromKeyMaps, uniqueMaps)
2009
+ })
2010
+ reactData.linkList = linkConfs
2011
+ internalData.linkFromConfMaps = fromConfMaps
2012
+ internalData.linkFromKeyMaps = fromKeyMaps
2013
+ internalData.linkUniqueMaps = uniqueMaps
2014
+ $xeGantt.handleTableLinks()
2015
+ return $xeGantt.$nextTick()
2016
+ },
1956
2017
  handleTaskHeaderContextmenuEvent (evnt: Event, params: VxeGanttDefines.TaskHeaderContextmenuParams) {
1957
2018
  const $xeGantt = this
1958
2019
  const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
@@ -2260,7 +2321,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
2260
2321
  return renderEmptyElement($xeGantt)
2261
2322
  },
2262
2323
  renderTable (h: CreateElement) {
2263
- const $xeGantt = this
2324
+ const $xeGantt = this as unknown as VxeGanttConstructor & VxeGanttPrivateMethods
2264
2325
  const slots = $xeGantt.$scopedSlots
2265
2326
 
2266
2327
  const tableProps = $xeGantt.computeTableProps
@@ -2271,7 +2332,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
2271
2332
  h(VxeTableComponent as Component, {
2272
2333
  key: 'table',
2273
2334
  props: tableProps,
2274
- on: getTableOns($xeGantt as VxeGanttConstructor),
2335
+ on: getTableOns($xeGantt),
2275
2336
  scopedSlots: slots,
2276
2337
  ref: 'refTable'
2277
2338
  })
@@ -2590,6 +2651,14 @@ export default /* define-vxe-component start */ defineVxeComponent({
2590
2651
  warnLog('vxe.error.notProp', ['expand-config'])
2591
2652
  }
2592
2653
 
2654
+ if (!($xeGantt as unknown as VxeGanttConstructor & VxeGanttPrivateMethods).handleUpdateTaskLink) {
2655
+ if (props.taskLinkConfig) {
2656
+ warnLog('vxe.error.notProp', ['task-link-config'])
2657
+ }
2658
+ if (props.links) {
2659
+ errLog('vxe.error.notProp', ['links'])
2660
+ }
2661
+ }
2593
2662
  $xeGantt.$nextTick(() => {
2594
2663
  if (props.formConfig) {
2595
2664
  if (!VxeUIFormComponent) {
@@ -2608,6 +2677,9 @@ export default /* define-vxe-component start */ defineVxeComponent({
2608
2677
  }
2609
2678
  })
2610
2679
 
2680
+ if (props.links) {
2681
+ $xeGantt.handleTaskUpdateLinks(props.links)
2682
+ }
2611
2683
  $xeGantt.handleTaskScaleConfig()
2612
2684
  $xeGantt.initPages()
2613
2685
  },
@@ -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
+ }
@@ -23,3 +23,15 @@ export function getStandardGapTime (type: VxeGanttDefines.ColumnScaleType) {
23
23
  }
24
24
  return 1000 * 60 * 60 * 24
25
25
  }
26
+
27
+ export function getTaskBarLeft (chartRest: VxeGanttDefines.RowCacheItem | null, viewCellWidth: number) {
28
+ return chartRest ? viewCellWidth * chartRest.oLeftSize : 0
29
+ }
30
+
31
+ export function getTaskBarWidth (chartRest: VxeGanttDefines.RowCacheItem | null, viewCellWidth: number) {
32
+ return Math.max(1, chartRest ? (Math.floor(viewCellWidth * chartRest.oWidthSize) - 1) : 0)
33
+ }
34
+
35
+ export function getTaskLinkKey (from: string | number, to: string | number) {
36
+ return `${from}_${to}`
37
+ }
@@ -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 = 3
109
- const sVersion = 18
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 = 3
6
+ const sVersion = 19
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
+ }