vxe-gantt 3.1.11 → 3.1.13

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 +28 -13
  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 +24 -9
  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 +120 -35
  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 +28 -13
  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 +11 -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] = {
@@ -538,11 +546,13 @@ function handleUpdateData ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewP
538
546
  const handleMinMaxData = (row: any) => {
539
547
  const startValue = XEUtils.get(row, startField)
540
548
  const endValue = XEUtils.get(row, endField)
541
- if (startValue && endValue) {
549
+ if (startValue) {
542
550
  const startDate = parseStringDate($xeGanttView, startValue)
543
551
  if (!minDate || minDate.getTime() > startDate.getTime()) {
544
552
  minDate = startDate
545
553
  }
554
+ }
555
+ if (endValue) {
546
556
  const endDate = parseStringDate($xeGanttView, endValue)
547
557
  if (!maxDate || maxDate.getTime() < endDate.getTime()) {
548
558
  maxDate = endDate
@@ -624,7 +634,9 @@ function updateTaskChart ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPr
624
634
  }
625
635
  const chartRest = rowid ? chartMaps[rowid] : null
626
636
  barEl.style.left = `${getTaskBarLeft(chartRest, viewCellWidth)}px`
627
- barEl.style.width = `${getTaskBarWidth(chartRest, viewCellWidth)}px`
637
+ if (!hasClass(barEl, 'is--milestone')) {
638
+ barEl.style.width = `${getTaskBarWidth(chartRest, viewCellWidth)}px`
639
+ }
628
640
  })
629
641
  }
630
642
  return $xeGanttView.$nextTick()
@@ -734,13 +746,16 @@ function updateStyle ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivat
734
746
  if (colInfoElem) {
735
747
  viewCellWidth = colInfoElem.clientWidth || 40
736
748
  }
737
- let viewTableWidth = viewCellWidth * visibleColumn.length
738
- if (bodyScrollElem) {
739
- const viewWidth = bodyScrollElem.clientWidth
740
- const remainWidth = viewWidth - viewTableWidth
741
- if (remainWidth > 0) {
742
- viewCellWidth += remainWidth / visibleColumn.length
743
- viewTableWidth = viewWidth
749
+ let viewTableWidth = viewCellWidth
750
+ if (visibleColumn.length) {
751
+ viewTableWidth = Math.max(0, viewCellWidth * visibleColumn.length)
752
+ if (bodyScrollElem) {
753
+ const viewWidth = bodyScrollElem.clientWidth
754
+ const remainWidth = viewWidth - viewTableWidth
755
+ if (remainWidth > 0) {
756
+ viewCellWidth += Math.max(0, remainWidth / visibleColumn.length)
757
+ viewTableWidth = viewWidth
758
+ }
744
759
  }
745
760
  }
746
761
  reactData.viewCellWidth = viewCellWidth
@@ -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,14 @@ 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
+ export function hasMilestoneTask (type: string) {
40
+ return type === 'milestone'
41
+ }
42
+
43
+ const taskTypeMaps: Record<string, number> = {
44
+ milestone: 1
45
+ }
46
+ export function gettaskType (type: string) {
47
+ return taskTypeMaps[type] ? type : 'default'
48
+ }
@@ -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 {