vxe-gantt 3.2.8 → 3.3.0

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.
@@ -49,14 +49,15 @@ export default defineVxeComponent({
49
49
  const cellOpts = $xeTable.computeCellOpts
50
50
  const rowOpts = $xeTable.computeRowOpts
51
51
  const defaultRowHeight = $xeTable.computeDefaultRowHeight
52
+ const treeOpts = $xeTable.computeTreeOpts
53
+ const childrenField = treeOpts.children || treeOpts.childrenField
52
54
 
53
55
  const ganttProps = $xeGantt
54
56
  const ganttReactData = $xeGantt.reactData
55
- const ganttInternalData = $xeGantt.internalData
56
57
  const ganttSlots = $xeGantt.$scopedSlots
57
58
  const taskBarSlot = ganttSlots.taskBar || ganttSlots['task-bar']
58
59
 
59
- const { taskBarMilestoneConfig, taskBarSubviewConfig } = ganttProps
60
+ const { treeConfig, taskBarMilestoneConfig, taskBarSubviewConfig } = ganttProps
60
61
  const { activeLink, activeBarRowid } = ganttReactData
61
62
  const titleField = $xeGantt.computeTitleField
62
63
  const progressField = $xeGantt.computeProgressField
@@ -77,8 +78,6 @@ export default defineVxeComponent({
77
78
  let title = getStringValue(XEUtils.get(row, titleField))
78
79
  const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
79
80
  const renderTaskType = getTaskType(XEUtils.get(row, typeField))
80
- const isMilestone = !!(hasEnableConf(taskBarMilestoneConfig, taskBarMilestoneOpts) && hasMilestoneTask(renderTaskType))
81
- const isSubview = !!(hasEnableConf(taskBarSubviewConfig, taskBarSubviewOpts) && hasSubviewTask(renderTaskType))
82
81
 
83
82
  const vbStyle: VxeComponentStyleType = {}
84
83
  const vpStyle: VxeComponentStyleType = {
@@ -94,10 +93,6 @@ export default defineVxeComponent({
94
93
  }
95
94
  }
96
95
 
97
- if (contentMethod) {
98
- title = getStringValue(contentMethod({ row, title, scaleType: scaleUnit }))
99
- }
100
-
101
96
  const ctParams = {
102
97
  $gantt: $xeGantt,
103
98
  source: sourceType,
@@ -108,92 +103,97 @@ export default defineVxeComponent({
108
103
  rowIndex,
109
104
  _rowIndex
110
105
  }
111
- const ctOns: {
112
- mouseover?: any
113
- mouseleave?: any
114
- } = {}
115
- if (showTooltip) {
116
- ctOns.mouseover = (evnt: MouseEvent) => {
117
- const { dragBarRow } = ganttInternalData
118
- const ttParams = Object.assign({ $event: evnt }, ctParams)
119
- if (!dragBarRow) {
120
- $xeGantt.triggerTaskBarTooltipEvent(evnt, ttParams)
121
- }
122
- $xeGantt.dispatchEvent('task-bar-mouseenter', ttParams, evnt)
123
- }
124
- ctOns.mouseleave = (evnt: MouseEvent) => {
125
- const { dragBarRow } = ganttInternalData
126
- const ttParams = Object.assign({ $event: evnt }, ctParams)
127
- if (!dragBarRow) {
128
- $xeGantt.handleTaskBarTooltipLeaveEvent(evnt, ttParams)
129
- }
130
- $xeGantt.dispatchEvent('task-bar-mouseleave', ttParams, evnt)
131
- }
132
- }
133
106
 
134
107
  let cbVNs: VNode[] = []
135
108
  if ($xeGantt.renderGanttTaskBarContent) {
136
109
  cbVNs = $xeGantt.renderGanttTaskBarContent(h, ctParams, {
137
- isMilestone,
138
- title,
139
- vbStyle,
140
- vpStyle,
141
- rowid,
142
- ctOns
110
+ $gantt: $xeGantt,
111
+ $table: $xeTable,
112
+ rowid
143
113
  })
144
- } else if (taskBarSlot) {
145
- cbVNs.push(
146
- h('div', {
147
- key: 'cbc',
148
- class: 'vxe-gantt-view--chart-custom-bar-content-wrapper',
149
- on: ctOns
150
- }, $xeGantt.callSlot(taskBarSlot, barParams, h))
151
- )
152
114
  } else {
153
- if (isSubview && rowChildren && rowChildren.length) {
154
- if (isExpandTree) {
155
- if (taskBarSubviewOpts.showOverview) {
156
- cbVNs.push(
157
- h('div', {
158
- key: 'vcso',
159
- class: ['vxe-gantt-view--chart-subview-wrapper is--overview', {
160
- 'is--round': round,
161
- 'is--move': moveable
162
- }]
163
- }, [
115
+ const isMilestone = !!(hasEnableConf(taskBarMilestoneConfig, taskBarMilestoneOpts) && hasMilestoneTask(renderTaskType))
116
+ const isSubview = !!(hasEnableConf(taskBarSubviewConfig, taskBarSubviewOpts) && hasSubviewTask(renderTaskType))
117
+
118
+ if (contentMethod) {
119
+ title = getStringValue(contentMethod({ row, title, scaleType: scaleUnit }))
120
+ }
121
+
122
+ const ctOns: {
123
+ mouseover?: any
124
+ mouseleave?: any
125
+ } = {}
126
+ if (showTooltip) {
127
+ ctOns.mouseover = (evnt: MouseEvent) => {
128
+ const ttParams = Object.assign({ $event: evnt }, ctParams)
129
+ $xeGantt.dispatchEvent('task-bar-mouseenter', ttParams, evnt)
130
+ }
131
+ ctOns.mouseleave = (evnt: MouseEvent) => {
132
+ const ttParams = Object.assign({ $event: evnt }, ctParams)
133
+ $xeGantt.dispatchEvent('task-bar-mouseleave', ttParams, evnt)
134
+ }
135
+ }
136
+
137
+ if (taskBarSlot) {
138
+ cbVNs.push(
139
+ h('div', {
140
+ key: 'cbc',
141
+ class: 'vxe-gantt-view--chart-custom-bar-content-wrapper',
142
+ on: ctOns
143
+ }, $xeGantt.callSlot(taskBarSlot, barParams, h))
144
+ )
145
+ } else {
146
+ if (isSubview && treeConfig && rowChildren && rowChildren.length) {
147
+ if (isExpandTree) {
148
+ if (taskBarSubviewOpts.showOverview) {
149
+ cbVNs.push(
164
150
  h('div', {
165
- key: rowid,
166
- attrs: {
167
- rowid: rowid
168
- },
169
- class: 'vxe-gantt-view--chart-subview-bar'
151
+ key: 'vcso',
152
+ class: 'vxe-gantt-view--chart-subview-wrapper is--overview'
170
153
  }, [
171
154
  h('div', {
172
- class: 'vxe-gantt-view--chart-subview-bar-content-wrapper'
155
+ key: rowid,
156
+ attrs: {
157
+ rowid: rowid
158
+ },
159
+ class: ['vxe-gantt-view--chart-subview-row', {
160
+ 'is--progress': showProgress,
161
+ 'is--round': round,
162
+ 'is--move': moveable
163
+ }]
173
164
  }, [
174
- showContent
175
- ? h('div', {
176
- class: 'vxe-gantt-view--chart-content'
177
- }, title)
178
- : renderEmptyElement($xeGantt)
165
+ h('div', {
166
+ attrs: {
167
+ rowid: rowid
168
+ },
169
+ class: 'vxe-gantt-view--chart-subview-bar'
170
+ }, [
171
+ h('div', {
172
+ class: 'vxe-gantt-view--chart-subview-bar-content-wrapper'
173
+ }, [
174
+ showContent
175
+ ? h('div', {
176
+ class: 'vxe-gantt-view--chart-content'
177
+ }, title)
178
+ : renderEmptyElement($xeGantt)
179
+ ])
180
+ ])
179
181
  ])
180
182
  ])
181
- ])
182
- )
183
- }
184
- } else {
185
- cbVNs.push(
186
- h('div', {
187
- key: 'vcsc',
188
- class: ['vxe-gantt-view--chart-subview-wrapper is--inline', {
189
- 'is--round': round,
190
- 'is--move': moveable
191
- }]
192
- }, rowChildren.map(childRow => {
183
+ )
184
+ }
185
+ } else {
186
+ const cbcVNs: VNode[] = []
187
+ XEUtils.eachTree(rowChildren, childRow => {
193
188
  const childRowid = $xeTable.getRowid(childRow)
194
189
  let childTitle = getStringValue(XEUtils.get(childRow, titleField))
195
190
  const childProgressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(childRow, progressField)))) : 0
196
191
  const childRenderTaskType = getTaskType(XEUtils.get(childRow, typeField))
192
+ const isChildSubview = !!(hasEnableConf(taskBarSubviewConfig, taskBarSubviewOpts) && hasSubviewTask(childRenderTaskType))
193
+
194
+ if (isChildSubview) {
195
+ return
196
+ }
197
197
 
198
198
  const vpcStyle: VxeComponentStyleType = {
199
199
  width: `${childProgressValue || 0}%`
@@ -209,76 +209,97 @@ export default defineVxeComponent({
209
209
  childTitle = getStringValue(contentMethod({ row: childRow, title: childTitle, scaleType: scaleUnit }))
210
210
  }
211
211
 
212
- return h('div', {
213
- key: childRowid,
214
- attrs: {
215
- rowid: childRowid
216
- },
217
- class: ['vxe-gantt-view--chart-subview-bar', `is--${childRenderTaskType}`]
218
- }, [
212
+ cbcVNs.push(
219
213
  h('div', {
220
- class: 'vxe-gantt-view--chart-subview-bar-content-wrapper'
214
+ key: childRowid,
215
+ attrs: {
216
+ rowid: childRowid
217
+ },
218
+ class: ['vxe-gantt-view--chart-subview-row', `is--${childRenderTaskType}`, {
219
+ 'is--progress': showProgress,
220
+ 'is--round': round,
221
+ 'is--move': moveable,
222
+ 'row--pending': !!pendingRowFlag && !!pendingRowMaps[childRowid]
223
+ }]
221
224
  }, [
222
- showProgress
223
- ? h('div', {
224
- class: 'vxe-gantt-view--chart-progress',
225
- style: vpcStyle
226
- })
227
- : renderEmptyElement($xeGantt),
228
- showContent
229
- ? h('div', {
230
- class: 'vxe-gantt-view--chart-content'
231
- }, childTitle)
232
- : renderEmptyElement($xeGantt)
225
+ h('div', {
226
+ attrs: {
227
+ rowid: childRowid
228
+ },
229
+ class: 'vxe-gantt-view--chart-subview-bar'
230
+ }, [
231
+ h('div', {
232
+ class: 'vxe-gantt-view--chart-subview-bar-content-wrapper'
233
+ }, [
234
+ showProgress
235
+ ? h('div', {
236
+ class: 'vxe-gantt-view--chart-progress',
237
+ style: vpcStyle
238
+ })
239
+ : renderEmptyElement($xeGantt),
240
+ showContent
241
+ ? h('div', {
242
+ class: 'vxe-gantt-view--chart-content'
243
+ }, childTitle)
244
+ : renderEmptyElement($xeGantt)
245
+ ])
246
+ ])
233
247
  ])
234
- ])
235
- }))
248
+ )
249
+ }, { children: childrenField })
250
+
251
+ cbVNs.push(
252
+ h('div', {
253
+ key: 'vcsc',
254
+ class: 'vxe-gantt-view--chart-subview-wrappe is--inliner'
255
+ }, cbcVNs)
256
+ )
257
+ }
258
+ } else if (isMilestone) {
259
+ const { icon, iconStatus, iconStyle } = taskBarMilestoneOpts
260
+ const tbmParams = { $gantt: $xeGantt, row }
261
+ cbVNs.push(
262
+ h('div', {
263
+ key: 'vcm',
264
+ class: 'vxe-gantt-view--chart-milestone-wrapper',
265
+ on: ctOns
266
+ }, [
267
+ h('div', {
268
+ class: ['vxe-gantt-view--chart-milestone-icon', iconStatus ? `theme--${XEUtils.isFunction(iconStatus) ? iconStatus(tbmParams) : iconStatus}` : ''],
269
+ style: iconStyle ? Object.assign({}, XEUtils.isFunction(iconStyle) ? iconStyle(tbmParams) : iconStyle) : undefined
270
+ }, [
271
+ h('i', {
272
+ class: (icon ? (XEUtils.isFunction(icon) ? icon(tbmParams) : icon) : '') || getIcon().GANTT_VIEW_TASK_MILESTONE
273
+ })
274
+ ]),
275
+ showContent
276
+ ? h('div', {
277
+ class: 'vxe-gantt-view--chart-milestone-content'
278
+ }, title)
279
+ : renderEmptyElement($xeGantt)
280
+ ])
236
281
  )
237
- }
238
- } else if (isMilestone) {
239
- const { icon, iconStatus, iconStyle } = taskBarMilestoneOpts
240
- const tbmParams = { $gantt: $xeGantt, row }
241
- cbVNs.push(
242
- h('div', {
243
- key: 'vcm',
244
- class: 'vxe-gantt-view--chart-milestone-wrapper',
245
- on: ctOns
246
- }, [
282
+ } else {
283
+ cbVNs.push(
247
284
  h('div', {
248
- class: ['vxe-gantt-view--chart-milestone-icon', iconStatus ? `theme--${XEUtils.isFunction(iconStatus) ? iconStatus(tbmParams) : iconStatus}` : ''],
249
- style: iconStyle ? Object.assign({}, XEUtils.isFunction(iconStyle) ? iconStyle(tbmParams) : iconStyle) : undefined
285
+ key: 'vbc',
286
+ class: 'vxe-gantt-view--chart-bar-content-wrapper',
287
+ on: ctOns
250
288
  }, [
251
- h('i', {
252
- class: (icon ? (XEUtils.isFunction(icon) ? icon(tbmParams) : icon) : '') || getIcon().GANTT_VIEW_TASK_MILESTONE
253
- })
254
- ]),
255
- showContent
256
- ? h('div', {
257
- class: 'vxe-gantt-view--chart-milestone-content'
258
- }, title)
259
- : renderEmptyElement($xeGantt)
260
- ])
261
- )
262
- } else {
263
- cbVNs.push(
264
- h('div', {
265
- key: 'vbc',
266
- class: 'vxe-gantt-view--chart-bar-content-wrapper',
267
- on: ctOns
268
- }, [
269
- showProgress
270
- ? h('div', {
271
- class: 'vxe-gantt-view--chart-progress',
272
- style: vpStyle
273
- })
274
- : renderEmptyElement($xeGantt),
275
- showContent
276
- ? h('div', {
277
- class: 'vxe-gantt-view--chart-content'
278
- }, title)
279
- : renderEmptyElement($xeGantt)
280
- ])
281
- )
289
+ showProgress
290
+ ? h('div', {
291
+ class: 'vxe-gantt-view--chart-progress',
292
+ style: vpStyle
293
+ })
294
+ : renderEmptyElement($xeGantt),
295
+ showContent
296
+ ? h('div', {
297
+ class: 'vxe-gantt-view--chart-content'
298
+ }, title)
299
+ : renderEmptyElement($xeGantt)
300
+ ])
301
+ )
302
+ }
282
303
  }
283
304
  }
284
305
 
@@ -288,6 +309,7 @@ export default defineVxeComponent({
288
309
  rowid
289
310
  },
290
311
  class: ['vxe-gantt-view--chart-row', `is--${renderTaskType}`, {
312
+ 'is--progress': showProgress,
291
313
  'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid],
292
314
  'is--round': round,
293
315
  'is--move': moveable
@@ -767,8 +767,8 @@ function updateTaskChartStyle ($xeGanttView: VxeGanttViewConstructor & VxeGanttV
767
767
  if (childWrapperEl) {
768
768
  // 行内展示
769
769
  if (hasClass(childWrapperEl, 'is--inline')) {
770
- XEUtils.arrayEach(childWrapperEl.children, (childEl) => {
771
- const childBarEl = childEl as HTMLDivElement
770
+ XEUtils.arrayEach(childWrapperEl.children, (childRowEl) => {
771
+ const childBarEl = childRowEl.children[0] as HTMLDivElement
772
772
  const childRowid = childBarEl.getAttribute('rowid') || ''
773
773
  const childChartRest = childRowid ? chartMaps[childRowid] : null
774
774
  if (childChartRest) {
@@ -790,7 +790,8 @@ function updateTaskChartStyle ($xeGanttView: VxeGanttViewConstructor & VxeGanttV
790
790
  })
791
791
  } else {
792
792
  // 如果展开子任务
793
- const childBarEl = childWrapperEl.firstElementChild as HTMLDivElement
793
+ const childRowEl = childWrapperEl.children[0] as HTMLDivElement
794
+ const childBarEl = childRowEl ? childRowEl.children[0] as HTMLDivElement : null
794
795
  if (childBarEl) {
795
796
  const rowChildren: any[] = row ? row[childrenField] : []
796
797
  const { minSize: minChildLeftSize, maxSize: maxChildLeftSize } = handleSubTaskMinMaxSize($xeGanttView, $xeTable, rowChildren)
@@ -8,13 +8,15 @@
8
8
  pointer-events: none;
9
9
  }
10
10
 
11
- .vxe-gantt-view--chart-row {
11
+ .vxe-gantt-view--chart-row,
12
+ .vxe-gantt-view--chart-subview-row {
12
13
  position: relative;
13
14
  width: 100%;
14
15
  height: 0;
16
+ }
17
+ .vxe-gantt-view--chart-row {
15
18
  &.row--pending {
16
- .vxe-gantt-view--chart-bar,
17
- .vxe-gantt-view--chart-subview-bar {
19
+ .vxe-gantt-view--chart-bar {
18
20
  color: var(--vxe-ui-font-disabled-color);
19
21
  opacity: 0.5;
20
22
  text-decoration: line-through;
@@ -36,7 +38,14 @@
36
38
  }
37
39
  }
38
40
  }
39
- .vxe-gantt-view--chart-subview-wrapper {
41
+ .vxe-gantt-view--chart-subview-row {
42
+ &.row--pending {
43
+ .vxe-gantt-view--chart-subview-bar {
44
+ color: var(--vxe-ui-font-disabled-color);
45
+ opacity: 0.5;
46
+ text-decoration: line-through;
47
+ }
48
+ }
40
49
  &.is--round {
41
50
  & > .vxe-gantt-view--chart-subview-bar {
42
51
  border-radius: var(--vxe-ui-gantt-view-task-bar-border-radius);
@@ -50,10 +59,14 @@
50
59
  }
51
60
  }
52
61
  }
62
+ }
63
+ .vxe-gantt-view--chart-subview-wrapper {
53
64
  &.is--overview {
54
- & > .vxe-gantt-view--chart-subview-bar {
55
- color: #ffffff;
56
- background-color: var(--vxe-ui-gantt-view-task-bar-overview-background-color);
65
+ & > .vxe-gantt-view--chart-subview-row {
66
+ .vxe-gantt-view--chart-subview-bar {
67
+ color: #ffffff;
68
+ background-color: var(--vxe-ui-gantt-view-task-bar-overview-background-color);
69
+ }
57
70
  }
58
71
  }
59
72
  }
@@ -68,15 +81,53 @@
68
81
  left: 0;
69
82
  transform: translateY(-50%);
70
83
  pointer-events: all;
71
- &.is--default {
72
- color: #ffffff;
73
- background-color: var(--vxe-ui-gantt-view-task-bar-background-color);
84
+ }
85
+
86
+ .vxe-gantt-view--chart-row {
87
+ &.is--progress {
88
+ & > .vxe-gantt-view--chart-bar {
89
+ &.is--default {
90
+ color: #ffffff;
91
+ background-color: var(--vxe-ui-gantt-view-task-bar-background-color);
92
+ }
93
+ }
94
+ }
95
+ &:not(.is--progress) {
96
+ & > .vxe-gantt-view--chart-bar {
97
+ &.is--default {
98
+ color: #ffffff;
99
+ background-color: var(--vxe-ui-gantt-view-task-bar-completed-background-color);
100
+ }
101
+ }
102
+ }
103
+ }
104
+ .vxe-gantt-view--chart-subview-row {
105
+ &.is--progress {
106
+ & > .vxe-gantt-view--chart-subview-bar {
107
+ &.is--subview {
108
+ color: #ffffff;
109
+ background-color: var(--vxe-ui-gantt-view-task-bar-overview-background-color);
110
+ }
111
+ &.is--default {
112
+ color: #ffffff;
113
+ background-color: var(--vxe-ui-gantt-view-task-bar-background-color);
114
+ }
115
+ }
74
116
  }
75
- &.is--subview {
76
- color: #ffffff;
77
- background-color: var(--vxe-ui-gantt-view-task-bar-overview-background-color);
117
+ &:not(.is--progress) {
118
+ & > .vxe-gantt-view--chart-subview-bar {
119
+ &.is--subview {
120
+ color: #ffffff;
121
+ background-color: var(--vxe-ui-gantt-view-task-bar-overview-background-color);
122
+ }
123
+ &.is--default {
124
+ color: #ffffff;
125
+ background-color: var(--vxe-ui-gantt-view-task-bar-completed-background-color);
126
+ }
127
+ }
78
128
  }
79
129
  }
130
+
80
131
  .vxe-gantt-view--chart-bar-content-wrapper,
81
132
  .vxe-gantt-view--chart-custom-bar-content-wrapper,
82
133
  .vxe-gantt-view--chart-subview-bar-content-wrapper {
@@ -183,7 +234,8 @@ $iconThemeList: (
183
234
  }
184
235
 
185
236
  /*行拖拽*/
186
- .vxe-gantt-view--chart-row {
237
+ .vxe-gantt-view--chart-row,
238
+ .vxe-gantt-view--chart-subview-row {
187
239
  &.row--drag-move {
188
240
  transition: transform 0.5s ease;
189
241
  }
@@ -8,7 +8,7 @@
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-bar-overview-background-color: var(--vxe-ui-font-primary-darken-color);
11
+ --vxe-ui-gantt-view-task-bar-overview-background-color: var(--vxe-ui-font-disabled-color);
12
12
  --vxe-ui-gantt-view-task-line-color: var(--vxe-ui-font-primary-color);
13
13
  --vxe-ui-gantt-view-task-line-width: 2px;
14
14
  --vxe-ui-gantt-view-task-line-arrow-width: 5;