vxe-gantt 4.1.6 → 4.1.8

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 +1 -0
  2. package/es/gantt/src/gantt-body.js +2 -5
  3. package/es/gantt/src/gantt-chart.js +35 -19
  4. package/es/gantt/src/gantt-view.js +27 -9
  5. package/es/gantt/src/gantt.js +63 -2
  6. package/es/gantt/src/static.js +22 -0
  7. package/es/gantt/src/table-emits.js +1 -0
  8. package/es/gantt/src/util.js +9 -0
  9. package/es/gantt/style.css +1 -1
  10. package/es/gantt/style.min.css +1 -1
  11. package/es/style.css +1 -1
  12. package/es/style.min.css +1 -1
  13. package/es/ui/index.js +5 -1
  14. package/es/ui/src/log.js +1 -1
  15. package/es/vxe-gantt/style.css +1 -1
  16. package/es/vxe-gantt/style.min.css +1 -1
  17. package/lib/gantt/index.js +16 -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 +33 -19
  22. package/lib/gantt/src/gantt-chart.min.js +1 -1
  23. package/lib/gantt/src/gantt-view.js +23 -8
  24. package/lib/gantt/src/gantt-view.min.js +1 -1
  25. package/lib/gantt/src/gantt.js +84 -1
  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/table-emits.js +1 -1
  30. package/lib/gantt/src/table-emits.min.js +1 -1
  31. package/lib/gantt/src/util.js +12 -0
  32. package/lib/gantt/src/util.min.js +1 -1
  33. package/lib/gantt/style/style.css +1 -1
  34. package/lib/gantt/style/style.min.css +1 -1
  35. package/lib/index.umd.js +191 -43
  36. package/lib/index.umd.min.js +1 -1
  37. package/lib/style.css +1 -1
  38. package/lib/style.min.css +1 -1
  39. package/lib/ui/index.js +5 -1
  40. package/lib/ui/index.min.js +1 -1
  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 +1 -1
  44. package/lib/vxe-gantt/style/style.min.css +1 -1
  45. package/package.json +3 -3
  46. package/packages/gantt/index.ts +2 -0
  47. package/packages/gantt/src/gantt-body.ts +2 -5
  48. package/packages/gantt/src/gantt-chart.ts +36 -20
  49. package/packages/gantt/src/gantt-view.ts +30 -9
  50. package/packages/gantt/src/gantt.ts +72 -4
  51. package/packages/gantt/src/static.ts +21 -0
  52. package/packages/gantt/src/table-emits.ts +1 -0
  53. package/packages/gantt/src/util.ts +12 -0
  54. package/packages/ui/index.ts +4 -0
  55. package/styles/components/gantt-module/gantt-chart.scss +2 -1
  56. package/styles/components/gantt.scss +0 -1
  57. package/styles/theme/base.scss +2 -0
@@ -5,13 +5,14 @@ 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'
11
12
  import GanttViewComponent from './gantt-view'
12
13
  import { VxeTable as VxeTableComponent } from 'vxe-table'
13
14
 
14
- import type { VxeGanttConstructor, VxeGanttEmits, GanttReactData, GanttInternalData, VxeGanttPropTypes, GanttMethods, GanttPrivateMethods, VxeGanttPrivateMethods, GanttPrivateRef, VxeGanttProps, VxeGanttPrivateComputed, VxeGanttViewInstance, VxeGanttDefines } from '../../../types'
15
+ import type { VxeGanttConstructor, VxeGanttEmits, GanttReactData, GanttInternalData, VxeGanttPropTypes, GanttMethods, GanttPrivateMethods, VxeGanttPrivateMethods, GanttPrivateRef, VxeGanttProps, VxeGanttPrivateComputed, VxeGanttViewInstance, VxeGanttDefines, VxeGanttViewPrivateMethods } from '../../../types'
15
16
  import type { ValueOf, VxeFormEvents, VxeFormInstance, VxeTooltipInstance, VxePagerEvents, VxeFormItemProps, VxePagerInstance, VxeComponentStyleType } from 'vxe-pc-ui'
16
17
  import type { VxeTableMethods, VxeToolbarPropTypes, VxeTableProps, VxeTablePropTypes, VxeTableConstructor, VxeTablePrivateMethods, VxeTableEvents, VxeTableDefines, VxeTableEventProps, VxeToolbarInstance, VxeGridPropTypes, VxeGridDefines } from 'vxe-table'
17
18
 
@@ -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,17 +78,19 @@ 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>,
@@ -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()
@@ -146,7 +156,7 @@ export default defineVxeComponent({
146
156
  const refPager = ref<VxePagerInstance>()
147
157
  const refGanttContainerElem = ref<HTMLDivElement>()
148
158
  const refClassifyWrapperElem = ref<HTMLDivElement>()
149
- const refGanttView = ref<VxeGanttViewInstance>()
159
+ const refGanttView = ref<VxeGanttViewInstance & VxeGanttViewPrivateMethods>()
150
160
 
151
161
  const refPopupContainerElem = ref<HTMLDivElement>()
152
162
 
@@ -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'
@@ -496,6 +510,7 @@ export default defineVxeComponent({
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, lineType, 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, lineType, 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
+ }
@@ -12,6 +12,7 @@ export const tableEmits: VxeTableEmits = [
12
12
  'paste',
13
13
  'copy',
14
14
  'cut',
15
+ 'context-menu',
15
16
 
16
17
  'columns-change',
17
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
+ }
@@ -48,6 +48,10 @@ setConfig({
48
48
  taskBarTooltipConfig: {
49
49
  enterable: true
50
50
  },
51
+ taskLinkConfig: {
52
+ enabled: true,
53
+ showArrow: true
54
+ },
51
55
  taskViewScaleConfig: {
52
56
  year: {
53
57
  valueFormat: ymdFormat
@@ -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%;
@@ -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
  }