vxe-gantt 3.1.12 → 3.1.14

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 (43) hide show
  1. package/es/gantt/src/gantt-chart.js +66 -34
  2. package/es/gantt/src/gantt-view.js +29 -8
  3. package/es/gantt/src/gantt.js +11 -1
  4. package/es/gantt/src/static.js +10 -0
  5. package/es/gantt/src/util.js +9 -0
  6. package/es/gantt/style.css +46 -9
  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 +3 -2
  11. package/es/ui/src/log.js +1 -1
  12. package/es/vxe-gantt/style.css +46 -9
  13. package/es/vxe-gantt/style.min.css +1 -1
  14. package/lib/gantt/src/gantt-chart.js +57 -20
  15. package/lib/gantt/src/gantt-chart.min.js +1 -1
  16. package/lib/gantt/src/gantt-view.js +23 -2
  17. package/lib/gantt/src/gantt-view.min.js +1 -1
  18. package/lib/gantt/src/gantt.js +11 -0
  19. package/lib/gantt/src/gantt.min.js +1 -1
  20. package/lib/gantt/src/static.js +12 -2
  21. package/lib/gantt/src/static.min.js +1 -1
  22. package/lib/gantt/src/util.js +11 -0
  23. package/lib/gantt/src/util.min.js +1 -1
  24. package/lib/gantt/style/style.css +46 -9
  25. package/lib/gantt/style/style.min.css +1 -1
  26. package/lib/index.umd.js +119 -28
  27. package/lib/index.umd.min.js +1 -1
  28. package/lib/style.css +1 -1
  29. package/lib/style.min.css +1 -1
  30. package/lib/ui/index.js +3 -2
  31. package/lib/ui/index.min.js +1 -1
  32. package/lib/ui/src/log.js +1 -1
  33. package/lib/ui/src/log.min.js +1 -1
  34. package/lib/vxe-gantt/style/style.css +46 -9
  35. package/lib/vxe-gantt/style/style.min.css +1 -1
  36. package/package.json +3 -3
  37. package/packages/gantt/src/gantt-chart.ts +72 -34
  38. package/packages/gantt/src/gantt-view.ts +29 -8
  39. package/packages/gantt/src/gantt.ts +13 -0
  40. package/packages/gantt/src/static.ts +10 -0
  41. package/packages/gantt/src/util.ts +10 -0
  42. package/packages/ui/index.ts +2 -1
  43. package/styles/components/gantt-module/gantt-chart.scss +71 -18
@@ -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 } from '../../ui/src/dom'
5
- import { getRefElem, getStandardGapTime, getTaskBarLeft, getTaskBarWidth } from './util'
4
+ import { setScrollTop, setScrollLeft, removeClass, addClass, hasClass } from '../../ui/src/dom'
5
+ import { getRefElem, getStandardGapTime, getTaskBarLeft, getTaskBarWidth, hasMilestoneTask } from './util'
6
6
  import XEUtils from 'xe-utils'
7
7
  import GanttViewHeaderComponent from './gantt-header'
8
8
  import GanttViewBodyComponent from './gantt-body'
@@ -462,6 +462,7 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
462
462
  if ($xeTable) {
463
463
  const startField = $xeGantt.computeStartField
464
464
  const endField = $xeGantt.computeEndField
465
+ const typeField = $xeGantt.computeTypeField
465
466
  const tableReactData = $xeTable as unknown as TableReactData
466
467
  const { isRowGroupStatus } = tableReactData
467
468
  const tableInternalData = $xeTable as unknown as TableInternalData
@@ -475,8 +476,15 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
475
476
  const renderFn = createChartRender($xeGanttView, fullCols)
476
477
  const handleParseRender = (row: any) => {
477
478
  const rowid = $xeTable.getRowid(row)
478
- const startValue = XEUtils.get(row, startField)
479
- const endValue = XEUtils.get(row, endField)
479
+ let startValue = XEUtils.get(row, startField)
480
+ let endValue = XEUtils.get(row, endField)
481
+ const isMilestone = hasMilestoneTask(XEUtils.get(row, typeField))
482
+ if (isMilestone) {
483
+ if (!startValue) {
484
+ startValue = endValue
485
+ }
486
+ endValue = startValue
487
+ }
480
488
  if (startValue && endValue) {
481
489
  const { offsetLeftSize, offsetWidthSize } = renderFn(startValue, endValue)
482
490
  ctMaps[rowid] = {
@@ -526,6 +534,7 @@ function handleUpdateData ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewP
526
534
  if ($xeTable) {
527
535
  const startField = $xeGantt.computeStartField
528
536
  const endField = $xeGantt.computeEndField
537
+ const typeField = $xeGantt.computeTypeField
529
538
  const tableReactData = $xeTable as unknown as TableReactData
530
539
  const { isRowGroupStatus } = tableReactData
531
540
  const tableInternalData = $xeTable as unknown as TableInternalData
@@ -536,13 +545,23 @@ function handleUpdateData ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewP
536
545
  const childrenField = treeOpts.children || treeOpts.childrenField
537
546
 
538
547
  const handleMinMaxData = (row: any) => {
539
- const startValue = XEUtils.get(row, startField)
540
- const endValue = XEUtils.get(row, endField)
541
- if (startValue && endValue) {
548
+ let startValue = XEUtils.get(row, startField)
549
+ let endValue = XEUtils.get(row, endField)
550
+ const typeValue = XEUtils.get(row, typeField)
551
+ const isMilestone = hasMilestoneTask(typeValue)
552
+ if (!startValue) {
553
+ startValue = endValue
554
+ }
555
+ if (isMilestone || !endValue) {
556
+ endValue = startValue
557
+ }
558
+ if (startValue) {
542
559
  const startDate = parseStringDate($xeGanttView, startValue)
543
560
  if (!minDate || minDate.getTime() > startDate.getTime()) {
544
561
  minDate = startDate
545
562
  }
563
+ }
564
+ if (endValue) {
546
565
  const endDate = parseStringDate($xeGanttView, endValue)
547
566
  if (!maxDate || maxDate.getTime() < endDate.getTime()) {
548
567
  maxDate = endDate
@@ -624,7 +643,9 @@ function updateTaskChart ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPr
624
643
  }
625
644
  const chartRest = rowid ? chartMaps[rowid] : null
626
645
  barEl.style.left = `${getTaskBarLeft(chartRest, viewCellWidth)}px`
627
- barEl.style.width = `${getTaskBarWidth(chartRest, viewCellWidth)}px`
646
+ if (!hasClass(barEl, 'is--milestone')) {
647
+ barEl.style.width = `${getTaskBarWidth(chartRest, viewCellWidth)}px`
648
+ }
628
649
  })
629
650
  }
630
651
  return $xeGanttView.$nextTick()
@@ -147,6 +147,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
147
147
  taskViewConfig: Object as PropType<VxeGanttPropTypes.TaskViewConfig>,
148
148
  taskLinkConfig: Object as PropType<VxeGanttPropTypes.TaskLinkConfig>,
149
149
  taskBarConfig: Object as PropType<VxeGanttPropTypes.TaskBarConfig>,
150
+ taskBarMilestoneConfig: Object as PropType<VxeGanttPropTypes.TaskBarMilestoneConfig>,
150
151
  taskBarTooltipConfig: Object as PropType<VxeGanttPropTypes.TaskBarTooltipConfig>,
151
152
  taskSplitConfig: Object as PropType<VxeGanttPropTypes.TaskSplitConfig>,
152
153
  taskBarResizeConfig: Object as PropType<VxeGanttPropTypes.TaskBarResizeConfig>,
@@ -295,6 +296,12 @@ export default /* define-vxe-component start */ defineVxeComponent({
295
296
 
296
297
  return Object.assign({}, getConfig().gantt.taskSplitConfig, props.taskSplitConfig)
297
298
  },
299
+ computeTaskBarMilestoneOpts () {
300
+ const $xeGantt = this
301
+ const props = $xeGantt
302
+
303
+ return Object.assign({}, getConfig().gantt.taskBarMilestoneConfig, props.taskBarMilestoneConfig)
304
+ },
298
305
  computeTaskBarTooltipOpts () {
299
306
  const $xeGantt = this
300
307
  const props = $xeGantt
@@ -359,6 +366,12 @@ export default /* define-vxe-component start */ defineVxeComponent({
359
366
  const taskOpts = $xeGantt.computeTaskOpts as VxeGanttPropTypes.TaskConfig
360
367
  return taskOpts.endField || 'end'
361
368
  },
369
+ computeTypeField () {
370
+ const $xeGantt = this
371
+
372
+ const taskOpts = $xeGantt.computeTaskOpts as VxeGanttPropTypes.TaskConfig
373
+ return taskOpts.typeField || 'type'
374
+ },
362
375
  computeProgressField () {
363
376
  const $xeGantt = this
364
377
 
@@ -19,3 +19,13 @@ export enum VxeGanttDependencyType {
19
19
  */
20
20
  FinishToFinish = 3
21
21
  }
22
+
23
+ /**
24
+ * 任务类型
25
+ */
26
+ export enum VxeGanttTaskType {
27
+ /**
28
+ * 里程碑
29
+ */
30
+ Milestone = 'milestone'
31
+ }
@@ -35,3 +35,13 @@ export function getTaskBarWidth (chartRest: VxeGanttDefines.RowCacheItem | null,
35
35
  export function getTaskLinkKey (from: string | number, to: string | number) {
36
36
  return `${from}_${to}`
37
37
  }
38
+
39
+ const taskTypeMaps: Record<string, boolean> = {
40
+ milestone: true
41
+ }
42
+ export function hasMilestoneTask (type: string) {
43
+ return taskTypeMaps[type]
44
+ }
45
+ export function gettaskType (type: string) {
46
+ return taskTypeMaps[type] ? type : 'default'
47
+ }
@@ -105,7 +105,8 @@ setIcon({
105
105
  GANTT_VIEW_LEFT_OPEN: iconPrefix + 'arrow-left',
106
106
  GANTT_VIEW_LEFT_CLOSE: iconPrefix + 'arrow-right',
107
107
  GANTT_VIEW_RIGHT_OPEN: iconPrefix + 'arrow-right',
108
- GANTT_VIEW_RIGHT_CLOSE: iconPrefix + 'arrow-left'
108
+ GANTT_VIEW_RIGHT_CLOSE: iconPrefix + 'arrow-left',
109
+ GANTT_VIEW_TASK_MILESTONE: iconPrefix + 'square-fill rotate45'
109
110
  })
110
111
 
111
112
  export {
@@ -1,3 +1,6 @@
1
+ @use "sass:map";
2
+ @use "sass:list";
3
+
1
4
  .vxe-gantt-view--chart-task-wrapper {
2
5
  position: absolute;
3
6
  top: 0;
@@ -20,12 +23,6 @@
20
23
  }
21
24
  }
22
25
  }
23
- &.is--move {
24
- & > .vxe-gantt-view--chart-bar,
25
- & > .vxe-gantt-view--chart-custom-bar {
26
- user-select: none;
27
- }
28
- }
29
26
  }
30
27
  .vxe-gantt-view--chart-bar,
31
28
  .vxe-gantt-view--chart-custom-bar {
@@ -35,10 +32,12 @@
35
32
  top: 50%;
36
33
  left: 0;
37
34
  transform: translateY(-50%);
38
- color: #ffffff;
39
- background-color: var(--vxe-ui-gantt-view-task-bar-background-color);
40
35
  overflow: hidden;
41
36
  pointer-events: all;
37
+ &.is--default {
38
+ color: #ffffff;
39
+ background-color: var(--vxe-ui-gantt-view-task-bar-background-color);
40
+ }
42
41
  }
43
42
  .vxe-gantt-view--chart-custom-bar-content {
44
43
  width: 100%;
@@ -46,18 +45,23 @@
46
45
  .vxe-gantt-view--chart-bar {
47
46
  align-items: center;
48
47
  height: var(--vxe-ui-gantt-view-chart-bar-height);
49
- &:hover {
50
- &::after {
51
- content: "";
52
- position: absolute;
53
- top: 0;
54
- left: 0;
55
- width: 100%;
56
- height: 100%;
57
- background-color: rgba(0, 0, 0, 0.1);
58
- pointer-events: none;
48
+ &.is--default {
49
+ &:hover {
50
+ &::after {
51
+ content: "";
52
+ position: absolute;
53
+ top: 0;
54
+ left: 0;
55
+ width: 100%;
56
+ height: 100%;
57
+ background-color: rgba(0, 0, 0, 0.1);
58
+ pointer-events: none;
59
+ }
59
60
  }
60
61
  }
62
+ &.is--milestone {
63
+ white-space: nowrap;
64
+ }
61
65
  }
62
66
  .vxe-gantt-view--chart-progress {
63
67
  flex-shrink: 0;
@@ -79,6 +83,55 @@
79
83
  padding: 0 0.6em;
80
84
  }
81
85
 
86
+ $iconThemeList: (
87
+ (
88
+ name: "primary",
89
+ color: var(--vxe-ui-font-primary-color),
90
+ ),
91
+ (
92
+ name: "success",
93
+ color: var(--vxe-ui-status-success-color),
94
+ ),
95
+ (
96
+ name: "info",
97
+ color: var(--vxe-ui-status-info-color),
98
+ ),
99
+ (
100
+ name: "warning",
101
+ color: var(--vxe-ui-status-warning-color),
102
+ ),
103
+ (
104
+ name: "danger",
105
+ color: var(--vxe-ui-status-danger-color),
106
+ ),
107
+ (
108
+ name: "error",
109
+ color: var(--vxe-ui-status-error-color),
110
+ )
111
+ );
112
+ .vxe-gantt-view--chart-milestone-wrapper {
113
+ display: flex;
114
+ flex-direction: row;
115
+ align-items: center;
116
+ }
117
+ .vxe-gantt-view--chart-milestone-icon {
118
+ flex-shrink: 0;
119
+ padding: 0 0.3em;
120
+ color: var(--vxe-ui-font-primary-color);
121
+ @for $index from 0 to list.length($iconThemeList) {
122
+ $item: list.nth($iconThemeList, $index + 1);
123
+ &.theme--#{map.get($item, name)} {
124
+ color: map.get($item, color);
125
+ }
126
+ }
127
+ i {
128
+ display: inline-block;
129
+ }
130
+ }
131
+ .vxe-gantt-view--chart-milestone-content {
132
+ flex-grow: 1;
133
+ }
134
+
82
135
  /*行拖拽*/
83
136
  .vxe-gantt-view--chart-row {
84
137
  &.row--drag-move {