vxe-gantt 3.4.2 → 3.4.3
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.
- package/LICENSE +21 -21
- package/README.md +53 -53
- package/es/gantt/src/gantt.js +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/gantt/src/gantt.js +1 -1
- package/lib/gantt/src/gantt.min.js +1 -1
- package/lib/index.umd.js +50 -50
- package/lib/index.umd.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +88 -88
- package/packages/components.ts +22 -22
- package/packages/gantt/index.ts +32 -32
- package/packages/gantt/src/gantt-body.ts +323 -323
- package/packages/gantt/src/gantt-chart.ts +542 -542
- package/packages/gantt/src/gantt-footer.ts +73 -73
- package/packages/gantt/src/gantt-header.ts +162 -162
- package/packages/gantt/src/gantt-view.ts +1954 -1954
- package/packages/gantt/src/gantt.ts +2827 -2827
- package/packages/gantt/src/static.ts +35 -35
- package/packages/gantt/src/util.ts +47 -47
- package/packages/index.ts +8 -8
- package/packages/ui/index.ts +119 -119
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/depend.ts +14 -14
- package/packages/ui/src/dom.ts +196 -196
- package/packages/ui/src/log.ts +8 -8
- package/packages/ui/src/utils.ts +67 -67
- package/packages/ui/src/vn.ts +13 -13
- package/styles/all.scss +3 -3
- package/styles/base.scss +2 -2
- package/styles/components/gantt-module/gantt-chart.scss +261 -261
- package/styles/components/gantt.scss +707 -707
- package/styles/helpers/baseMixin.scss +95 -95
- package/styles/helpers/baseVar.scss +3 -3
- package/styles/helpers/placement.scss +38 -38
- package/styles/theme/base.scss +14 -14
- package/styles/theme/dark.scss +8 -8
- package/styles/theme/light.scss +8 -8
- package/types/all.d.ts +16 -16
- package/types/index.d.ts +4 -4
|
@@ -1,542 +1,542 @@
|
|
|
1
|
-
import { VNode, CreateElement } from 'vue'
|
|
2
|
-
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
|
-
import { VxeUI } from '@vxe-ui/core'
|
|
4
|
-
import XEUtils from 'xe-utils'
|
|
5
|
-
import { getCellRestHeight, hasMilestoneTask, getTaskType, hasSubviewTask } from './util'
|
|
6
|
-
import { getStringValue, isEnableConf, hasEnableConf } from '../../ui/src/utils'
|
|
7
|
-
|
|
8
|
-
import type { VxeComponentStyleType } from 'vxe-pc-ui'
|
|
9
|
-
import type { TableInternalData, TableReactData, VxeTableConstructor, VxeTableMethods, VxeTablePrivateMethods } from 'vxe-table'
|
|
10
|
-
import type { VxeGanttViewConstructor, VxeGanttViewPrivateMethods, VxeGanttConstructor, VxeGanttPrivateMethods } from '../../../types'
|
|
11
|
-
|
|
12
|
-
const { getIcon, renderEmptyElement } = VxeUI
|
|
13
|
-
|
|
14
|
-
const sourceType = 'gantt'
|
|
15
|
-
const viewType = 'chart'
|
|
16
|
-
|
|
17
|
-
export default defineVxeComponent({
|
|
18
|
-
name: 'VxeGanttViewChart',
|
|
19
|
-
inject: {
|
|
20
|
-
$xeGantt: {
|
|
21
|
-
default: null
|
|
22
|
-
},
|
|
23
|
-
$xeGanttView: {
|
|
24
|
-
default: null
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
props: {},
|
|
28
|
-
data () {
|
|
29
|
-
return {}
|
|
30
|
-
},
|
|
31
|
-
computed: {
|
|
32
|
-
...({} as {
|
|
33
|
-
$xeGantt(): (VxeGanttConstructor & VxeGanttPrivateMethods)
|
|
34
|
-
$xeGanttView(): (VxeGanttViewConstructor & VxeGanttViewPrivateMethods)
|
|
35
|
-
})
|
|
36
|
-
},
|
|
37
|
-
methods: {
|
|
38
|
-
//
|
|
39
|
-
// Render
|
|
40
|
-
//
|
|
41
|
-
renderTaskBar (h: CreateElement, $xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, row: any, rowid: string, rowIndex: number, $rowIndex: number, _rowIndex: number, rowChildren: any[], isExpandTree: boolean) {
|
|
42
|
-
const _vm = this
|
|
43
|
-
const $xeGantt = _vm.$xeGantt
|
|
44
|
-
|
|
45
|
-
const tableReactData = $xeTable as unknown as TableReactData
|
|
46
|
-
const { resizeHeightFlag, pendingRowFlag } = tableReactData
|
|
47
|
-
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
48
|
-
const { fullAllDataRowIdData, pendingRowMaps } = tableInternalData
|
|
49
|
-
const cellOpts = $xeTable.computeCellOpts
|
|
50
|
-
const rowOpts = $xeTable.computeRowOpts
|
|
51
|
-
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
52
|
-
const treeOpts = $xeTable.computeTreeOpts
|
|
53
|
-
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
54
|
-
|
|
55
|
-
const ganttProps = $xeGantt
|
|
56
|
-
const ganttReactData = $xeGantt.reactData
|
|
57
|
-
const ganttInternalData = $xeGantt.internalData
|
|
58
|
-
const ganttSlots = $xeGantt.$scopedSlots
|
|
59
|
-
const taskBarSlot = ganttSlots.taskBar || ganttSlots['task-bar']
|
|
60
|
-
const taskBarOverviewSlot = ganttSlots.taskBarOverview || ganttSlots['task-bar-overview']
|
|
61
|
-
|
|
62
|
-
const { treeConfig, taskBarMilestoneConfig, taskBarSubviewConfig } = ganttProps
|
|
63
|
-
const { activeLink, activeBarRowid } = ganttReactData
|
|
64
|
-
const titleField = $xeGantt.computeTitleField
|
|
65
|
-
const progressField = $xeGantt.computeProgressField
|
|
66
|
-
const typeField = $xeGantt.computeTypeField
|
|
67
|
-
const taskBarOpts = $xeGantt.computeTaskBarOpts
|
|
68
|
-
const taskBarMilestoneOpts = $xeGantt.computeTaskBarMilestoneOpts
|
|
69
|
-
const taskBarSubviewOpts = $xeGantt.computeTaskBarSubviewOpts
|
|
70
|
-
const { showOverview, barStyle: subBarStyle } = taskBarSubviewOpts
|
|
71
|
-
const scaleUnit = $xeGantt.computeScaleUnit
|
|
72
|
-
const barParams = { $gantt: $xeGantt, row, scaleType: scaleUnit }
|
|
73
|
-
const { showProgress, showContent, contentMethod, barStyle, moveable, showTooltip } = taskBarOpts
|
|
74
|
-
const isBarRowStyle = XEUtils.isFunction(barStyle)
|
|
75
|
-
const barStyObj = (barStyle ? (isBarRowStyle ? barStyle(barParams) : barStyle) : {}) || {}
|
|
76
|
-
const { round } = barStyObj
|
|
77
|
-
|
|
78
|
-
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
79
|
-
const cellHeight = resizeHeightFlag ? getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) : 0
|
|
80
|
-
|
|
81
|
-
let title = getStringValue(XEUtils.get(row, titleField))
|
|
82
|
-
const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
|
|
83
|
-
const renderTaskType = getTaskType(XEUtils.get(row, typeField))
|
|
84
|
-
|
|
85
|
-
const vbStyle: VxeComponentStyleType = {}
|
|
86
|
-
const vpStyle: VxeComponentStyleType = {
|
|
87
|
-
width: `${progressValue || 0}%`
|
|
88
|
-
}
|
|
89
|
-
if (isBarRowStyle) {
|
|
90
|
-
const { bgColor, completedBgColor } = barStyObj
|
|
91
|
-
if (bgColor) {
|
|
92
|
-
vbStyle.backgroundColor = bgColor
|
|
93
|
-
}
|
|
94
|
-
if (completedBgColor) {
|
|
95
|
-
vpStyle.backgroundColor = completedBgColor
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const ctParams = {
|
|
100
|
-
$gantt: $xeGantt,
|
|
101
|
-
source: sourceType,
|
|
102
|
-
type: viewType,
|
|
103
|
-
scaleType: scaleUnit,
|
|
104
|
-
row,
|
|
105
|
-
$rowIndex,
|
|
106
|
-
rowIndex,
|
|
107
|
-
_rowIndex
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let cbVNs: VNode[] = []
|
|
111
|
-
if ($xeGantt.renderGanttTaskBarContent) {
|
|
112
|
-
cbVNs = $xeGantt.renderGanttTaskBarContent(h, ctParams, {
|
|
113
|
-
$gantt: $xeGantt,
|
|
114
|
-
$table: $xeTable,
|
|
115
|
-
rowid
|
|
116
|
-
})
|
|
117
|
-
} else {
|
|
118
|
-
const isMilestone = !!(hasEnableConf(taskBarMilestoneConfig, taskBarMilestoneOpts) && hasMilestoneTask(renderTaskType))
|
|
119
|
-
const isSubview = !!(hasEnableConf(taskBarSubviewConfig, taskBarSubviewOpts) && hasSubviewTask(renderTaskType))
|
|
120
|
-
|
|
121
|
-
if (contentMethod) {
|
|
122
|
-
title = getStringValue(contentMethod({ row, title, scaleType: scaleUnit }))
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const ctOns: {
|
|
126
|
-
mouseover?: any
|
|
127
|
-
mouseleave?: any
|
|
128
|
-
} = {}
|
|
129
|
-
if (showTooltip) {
|
|
130
|
-
ctOns.mouseover = (evnt: MouseEvent) => {
|
|
131
|
-
const { dragBarRow } = ganttInternalData
|
|
132
|
-
const ttParams = Object.assign({ $event: evnt }, ctParams)
|
|
133
|
-
if (!dragBarRow) {
|
|
134
|
-
$xeGantt.triggerTaskBarTooltipEvent(evnt, ttParams)
|
|
135
|
-
}
|
|
136
|
-
$xeGantt.dispatchEvent('task-bar-mouseenter', ttParams, evnt)
|
|
137
|
-
}
|
|
138
|
-
ctOns.mouseleave = (evnt: MouseEvent) => {
|
|
139
|
-
const { dragBarRow } = ganttInternalData
|
|
140
|
-
const ttParams = Object.assign({ $event: evnt }, ctParams)
|
|
141
|
-
if (!dragBarRow) {
|
|
142
|
-
$xeGantt.handleTaskBarTooltipLeaveEvent(evnt, ttParams)
|
|
143
|
-
}
|
|
144
|
-
$xeGantt.dispatchEvent('task-bar-mouseleave', ttParams, evnt)
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (isSubview && treeConfig && rowChildren && rowChildren.length) {
|
|
149
|
-
if (isExpandTree) {
|
|
150
|
-
if (showOverview) {
|
|
151
|
-
cbVNs.push(
|
|
152
|
-
h('div', {
|
|
153
|
-
key: 'vcso',
|
|
154
|
-
class: 'vxe-gantt-view--chart-subview-wrapper is--overview'
|
|
155
|
-
}, [
|
|
156
|
-
h('div', {
|
|
157
|
-
key: rowid,
|
|
158
|
-
attrs: {
|
|
159
|
-
rowid: rowid
|
|
160
|
-
},
|
|
161
|
-
class: ['vxe-gantt-view--chart-subview-row', {
|
|
162
|
-
'is--progress': showProgress,
|
|
163
|
-
'is--round': round,
|
|
164
|
-
'is--move': moveable
|
|
165
|
-
}]
|
|
166
|
-
}, [
|
|
167
|
-
h('div', {
|
|
168
|
-
attrs: {
|
|
169
|
-
rowid: rowid
|
|
170
|
-
},
|
|
171
|
-
class: [taskBarOverviewSlot ? 'vxe-gantt-view--chart-subview-custom-bar' : 'vxe-gantt-view--chart-subview-bar', `is--${renderTaskType}`]
|
|
172
|
-
}, [
|
|
173
|
-
taskBarOverviewSlot
|
|
174
|
-
? h('div', {
|
|
175
|
-
key: 'cbc',
|
|
176
|
-
class: 'vxe-gantt-view--chart-subview-custom-bar-content-wrapper'
|
|
177
|
-
}, $xeGantt.callSlot(taskBarOverviewSlot, barParams, h))
|
|
178
|
-
: h('div', {
|
|
179
|
-
class: 'vxe-gantt-view--chart-subview-bar-content-wrapper'
|
|
180
|
-
}, [
|
|
181
|
-
showContent
|
|
182
|
-
? h('div', {
|
|
183
|
-
class: 'vxe-gantt-view--chart-content'
|
|
184
|
-
}, title)
|
|
185
|
-
: renderEmptyElement($xeGantt)
|
|
186
|
-
])
|
|
187
|
-
])
|
|
188
|
-
])
|
|
189
|
-
])
|
|
190
|
-
)
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
const cbcVNs: VNode[] = []
|
|
194
|
-
XEUtils.eachTree(rowChildren, childRow => {
|
|
195
|
-
const childBarParams = { $gantt: $xeGantt, row: childRow, scaleType: scaleUnit }
|
|
196
|
-
const childBarStyObj = (barStyle ? (isBarRowStyle ? barStyle(childBarParams) : barStyle) : {}) || {}
|
|
197
|
-
const { round } = childBarStyObj
|
|
198
|
-
|
|
199
|
-
const childRowid = $xeTable.getRowid(childRow)
|
|
200
|
-
let childTitle = getStringValue(XEUtils.get(childRow, titleField))
|
|
201
|
-
const childProgressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(childRow, progressField)))) : 0
|
|
202
|
-
const childRenderTaskType = getTaskType(XEUtils.get(childRow, typeField))
|
|
203
|
-
const isChildSubview = !!(hasEnableConf(taskBarSubviewConfig, taskBarSubviewOpts) && hasSubviewTask(childRenderTaskType))
|
|
204
|
-
|
|
205
|
-
if (isChildSubview) {
|
|
206
|
-
return
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const childVbStyle: VxeComponentStyleType = {}
|
|
210
|
-
const childVpStyle: VxeComponentStyleType = {
|
|
211
|
-
width: `${childProgressValue || 0}%`
|
|
212
|
-
}
|
|
213
|
-
if (isBarRowStyle) {
|
|
214
|
-
const { bgColor, completedBgColor } = childBarStyObj
|
|
215
|
-
if (bgColor) {
|
|
216
|
-
childVbStyle.backgroundColor = bgColor
|
|
217
|
-
}
|
|
218
|
-
if (completedBgColor) {
|
|
219
|
-
childVpStyle.backgroundColor = completedBgColor
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const childCtParams = XEUtils.assign({}, ctParams, {
|
|
224
|
-
row: childRow,
|
|
225
|
-
rowIndex: $xeTable.getRowIndex(childRow),
|
|
226
|
-
$rowIndex: $xeTable.getVMRowIndex(childRow),
|
|
227
|
-
_rowIndex: $xeTable.getVTRowIndex(childRow)
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
if (contentMethod) {
|
|
231
|
-
childTitle = getStringValue(contentMethod({ row: childRow, title: childTitle, scaleType: scaleUnit }))
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
cbcVNs.push(
|
|
235
|
-
h('div', {
|
|
236
|
-
key: childRowid,
|
|
237
|
-
attrs: {
|
|
238
|
-
rowid: childRowid
|
|
239
|
-
},
|
|
240
|
-
class: ['vxe-gantt-view--chart-subview-row', `is--${childRenderTaskType}`, {
|
|
241
|
-
'is--progress': showProgress,
|
|
242
|
-
'is--round': round,
|
|
243
|
-
'is--move': moveable,
|
|
244
|
-
'row--pending': !!pendingRowFlag && !!pendingRowMaps[childRowid]
|
|
245
|
-
}]
|
|
246
|
-
}, [
|
|
247
|
-
h('div', {
|
|
248
|
-
attrs: {
|
|
249
|
-
rowid: childRowid
|
|
250
|
-
},
|
|
251
|
-
class: [taskBarSlot ? 'vxe-gantt-view--chart-subview-custom-bar' : 'vxe-gantt-view--chart-subview-bar', `is--${childRenderTaskType}`],
|
|
252
|
-
style: subBarStyle ? (XEUtils.isFunction(subBarStyle) ? subBarStyle(childCtParams) || undefined : subBarStyle) : undefined,
|
|
253
|
-
on: {
|
|
254
|
-
click (evnt: MouseEvent) {
|
|
255
|
-
evnt.stopPropagation()
|
|
256
|
-
$xeGantt.handleTaskBarClickEvent(evnt, childCtParams)
|
|
257
|
-
},
|
|
258
|
-
dblclick (evnt: MouseEvent) {
|
|
259
|
-
evnt.stopPropagation()
|
|
260
|
-
$xeGantt.handleTaskBarDblclickEvent(evnt, childCtParams)
|
|
261
|
-
},
|
|
262
|
-
mousedown (evnt: MouseEvent) {
|
|
263
|
-
evnt.stopPropagation()
|
|
264
|
-
if ($xeGantt.handleTaskBarMousedownEvent) {
|
|
265
|
-
$xeGantt.handleTaskBarMousedownEvent(evnt, childCtParams)
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}, [
|
|
270
|
-
taskBarSlot
|
|
271
|
-
? h('div', {
|
|
272
|
-
key: 'cbc',
|
|
273
|
-
class: 'vxe-gantt-view--chart-subview-custom-bar-content-wrapper',
|
|
274
|
-
on: ctOns
|
|
275
|
-
}, $xeGantt.callSlot(taskBarSlot, childCtParams, h))
|
|
276
|
-
: h('div', {
|
|
277
|
-
class: 'vxe-gantt-view--chart-subview-bar-content-wrapper',
|
|
278
|
-
on: ctOns
|
|
279
|
-
}, [
|
|
280
|
-
showProgress
|
|
281
|
-
? h('div', {
|
|
282
|
-
class: 'vxe-gantt-view--chart-progress',
|
|
283
|
-
style: childVpStyle
|
|
284
|
-
})
|
|
285
|
-
: renderEmptyElement($xeGantt),
|
|
286
|
-
showContent
|
|
287
|
-
? h('div', {
|
|
288
|
-
class: 'vxe-gantt-view--chart-content'
|
|
289
|
-
}, childTitle)
|
|
290
|
-
: renderEmptyElement($xeGantt)
|
|
291
|
-
])
|
|
292
|
-
])
|
|
293
|
-
])
|
|
294
|
-
)
|
|
295
|
-
}, { children: childrenField })
|
|
296
|
-
|
|
297
|
-
cbVNs.push(
|
|
298
|
-
h('div', {
|
|
299
|
-
key: 'vcsc',
|
|
300
|
-
class: 'vxe-gantt-view--chart-subview-wrapper is--inline'
|
|
301
|
-
}, cbcVNs)
|
|
302
|
-
)
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
if (taskBarSlot) {
|
|
306
|
-
cbVNs.push(
|
|
307
|
-
h('div', {
|
|
308
|
-
key: 'cbc',
|
|
309
|
-
class: 'vxe-gantt-view--chart-custom-bar-content-wrapper',
|
|
310
|
-
on: ctOns
|
|
311
|
-
}, $xeGantt.callSlot(taskBarSlot, barParams, h))
|
|
312
|
-
)
|
|
313
|
-
} else if (isMilestone) {
|
|
314
|
-
const { icon, iconStatus, iconStyle } = taskBarMilestoneOpts
|
|
315
|
-
const tbmParams = { $gantt: $xeGantt, row }
|
|
316
|
-
cbVNs.push(
|
|
317
|
-
h('div', {
|
|
318
|
-
key: 'vcm',
|
|
319
|
-
class: 'vxe-gantt-view--chart-milestone-wrapper',
|
|
320
|
-
on: ctOns
|
|
321
|
-
}, [
|
|
322
|
-
h('div', {
|
|
323
|
-
class: ['vxe-gantt-view--chart-milestone-icon', iconStatus ? `theme--${XEUtils.isFunction(iconStatus) ? iconStatus(tbmParams) : iconStatus}` : ''],
|
|
324
|
-
style: iconStyle ? Object.assign({}, XEUtils.isFunction(iconStyle) ? iconStyle(tbmParams) : iconStyle) : undefined
|
|
325
|
-
}, [
|
|
326
|
-
h('i', {
|
|
327
|
-
class: (icon ? (XEUtils.isFunction(icon) ? icon(tbmParams) : icon) : '') || getIcon().GANTT_VIEW_TASK_MILESTONE
|
|
328
|
-
})
|
|
329
|
-
]),
|
|
330
|
-
showContent
|
|
331
|
-
? h('div', {
|
|
332
|
-
class: 'vxe-gantt-view--chart-milestone-content'
|
|
333
|
-
}, title)
|
|
334
|
-
: renderEmptyElement($xeGantt)
|
|
335
|
-
])
|
|
336
|
-
)
|
|
337
|
-
} else {
|
|
338
|
-
cbVNs.push(
|
|
339
|
-
h('div', {
|
|
340
|
-
key: 'vbc',
|
|
341
|
-
class: 'vxe-gantt-view--chart-bar-content-wrapper',
|
|
342
|
-
on: ctOns
|
|
343
|
-
}, [
|
|
344
|
-
showProgress
|
|
345
|
-
? h('div', {
|
|
346
|
-
class: 'vxe-gantt-view--chart-progress',
|
|
347
|
-
style: vpStyle
|
|
348
|
-
})
|
|
349
|
-
: renderEmptyElement($xeGantt),
|
|
350
|
-
showContent
|
|
351
|
-
? h('div', {
|
|
352
|
-
class: 'vxe-gantt-view--chart-content'
|
|
353
|
-
}, title)
|
|
354
|
-
: renderEmptyElement($xeGantt)
|
|
355
|
-
])
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return h('div', {
|
|
362
|
-
key: rowid,
|
|
363
|
-
attrs: {
|
|
364
|
-
rowid
|
|
365
|
-
},
|
|
366
|
-
class: ['vxe-gantt-view--chart-row', `is--${renderTaskType}`, {
|
|
367
|
-
'is--progress': showProgress,
|
|
368
|
-
'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid],
|
|
369
|
-
'is--round': round,
|
|
370
|
-
'is--move': moveable
|
|
371
|
-
}],
|
|
372
|
-
style: {
|
|
373
|
-
height: `${cellHeight}px`
|
|
374
|
-
},
|
|
375
|
-
on: {
|
|
376
|
-
onDragstart (evnt: DragEvent) {
|
|
377
|
-
if (ganttInternalData.dragBarRow) {
|
|
378
|
-
evnt.preventDefault()
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
contextmenu (evnt: Event) {
|
|
382
|
-
$xeGantt.handleTaskBarContextmenuEvent(evnt, ctParams)
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}, [
|
|
386
|
-
h('div', {
|
|
387
|
-
class: [taskBarSlot ? 'vxe-gantt-view--chart-custom-bar' : 'vxe-gantt-view--chart-bar', `is--${renderTaskType}`, {
|
|
388
|
-
'is--active': activeBarRowid === rowid,
|
|
389
|
-
'active--link': activeLink && (rowid === `${activeLink.from}` || rowid === `${activeLink.to}`)
|
|
390
|
-
}],
|
|
391
|
-
style: vbStyle,
|
|
392
|
-
attrs: {
|
|
393
|
-
rowid
|
|
394
|
-
},
|
|
395
|
-
on: {
|
|
396
|
-
click (evnt: MouseEvent) {
|
|
397
|
-
$xeGantt.handleTaskBarClickEvent(evnt, barParams)
|
|
398
|
-
},
|
|
399
|
-
dblclick (evnt: MouseEvent) {
|
|
400
|
-
$xeGantt.handleTaskBarDblclickEvent(evnt, barParams)
|
|
401
|
-
},
|
|
402
|
-
mousedown (evnt: MouseEvent) {
|
|
403
|
-
if ($xeGantt.handleTaskBarMousedownEvent) {
|
|
404
|
-
$xeGantt.handleTaskBarMousedownEvent(evnt, barParams)
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}, cbVNs)
|
|
409
|
-
])
|
|
410
|
-
},
|
|
411
|
-
renderTaskRows (h: CreateElement, $xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, tableData: any[]) {
|
|
412
|
-
const _vm = this
|
|
413
|
-
const $xeGanttView = _vm.$xeGanttView
|
|
414
|
-
const ganttViewReactData = $xeGanttView.reactData
|
|
415
|
-
|
|
416
|
-
const tableProps = $xeTable
|
|
417
|
-
const { treeConfig } = tableProps
|
|
418
|
-
const tableReactData = $xeTable as unknown as TableReactData
|
|
419
|
-
const { treeExpandedFlag } = tableReactData
|
|
420
|
-
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
421
|
-
const { fullAllDataRowIdData, treeExpandedMaps } = tableInternalData
|
|
422
|
-
const treeOpts = $xeTable.computeTreeOpts
|
|
423
|
-
const { transform } = treeOpts
|
|
424
|
-
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
425
|
-
|
|
426
|
-
const { scrollYLoad } = ganttViewReactData
|
|
427
|
-
|
|
428
|
-
const trVNs: VNode[] = []
|
|
429
|
-
tableData.forEach((row, $rowIndex) => {
|
|
430
|
-
const rowid = $xeTable.getRowid(row)
|
|
431
|
-
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
432
|
-
let rowIndex = $rowIndex
|
|
433
|
-
let _rowIndex = -1
|
|
434
|
-
if (rowRest) {
|
|
435
|
-
rowIndex = rowRest.index
|
|
436
|
-
_rowIndex = rowRest._index
|
|
437
|
-
}
|
|
438
|
-
let isExpandTree = false
|
|
439
|
-
let rowChildren: any[] = []
|
|
440
|
-
|
|
441
|
-
if (treeConfig) {
|
|
442
|
-
rowChildren = row[childrenField]
|
|
443
|
-
isExpandTree = !!treeExpandedFlag && rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
trVNs.push(_vm.renderTaskBar(h, $xeTable, row, rowid, rowIndex, $rowIndex, _rowIndex, rowChildren, isExpandTree))
|
|
447
|
-
// 如果是树形表格
|
|
448
|
-
if (treeConfig && isExpandTree && !scrollYLoad && !transform) {
|
|
449
|
-
trVNs.push(..._vm.renderTaskRows(h, $xeTable, rowChildren))
|
|
450
|
-
}
|
|
451
|
-
})
|
|
452
|
-
return trVNs
|
|
453
|
-
},
|
|
454
|
-
renderVN (h: CreateElement): VNode {
|
|
455
|
-
const _vm = this
|
|
456
|
-
const $xeGantt = _vm.$xeGantt
|
|
457
|
-
const $xeGanttView = _vm.$xeGanttView
|
|
458
|
-
const ganttReactData = $xeGantt.reactData
|
|
459
|
-
const ganttViewInternalData = $xeGanttView.internalData
|
|
460
|
-
const ganttViewReactData = $xeGanttView.reactData
|
|
461
|
-
|
|
462
|
-
const $xeTable = ganttViewInternalData.xeTable
|
|
463
|
-
|
|
464
|
-
const ganttSlots = $xeGantt.$scopedSlots
|
|
465
|
-
|
|
466
|
-
const { dragLinkFromStore } = ganttReactData
|
|
467
|
-
const { tableData } = ganttViewReactData
|
|
468
|
-
const taskLinkOpts = $xeGantt.computeTaskLinkOpts
|
|
469
|
-
const taskBarOpts = $xeGantt.computeTaskBarOpts
|
|
470
|
-
const nowLineLeft = $xeGanttView.computeNowLineLeft
|
|
471
|
-
const { isCurrent, isHover } = taskLinkOpts
|
|
472
|
-
const { linkCreatable } = taskBarOpts
|
|
473
|
-
const taskNowLineSlot = ganttSlots.taskNowLine || ganttSlots['task-now-line']
|
|
474
|
-
|
|
475
|
-
return h('div', {
|
|
476
|
-
ref: 'refElem',
|
|
477
|
-
class: ['vxe-gantt-view--chart-wrapper', {
|
|
478
|
-
'is--cl-drag': dragLinkFromStore.rowid
|
|
479
|
-
}]
|
|
480
|
-
}, [
|
|
481
|
-
nowLineLeft > 0
|
|
482
|
-
? h('div', {
|
|
483
|
-
ref: 'refNowLineElem',
|
|
484
|
-
class: 'vxe-gantt-view--chart-now-line',
|
|
485
|
-
style: {
|
|
486
|
-
left: nowLineLeft + 'px'
|
|
487
|
-
}
|
|
488
|
-
}, taskNowLineSlot ? taskNowLineSlot({}) : [])
|
|
489
|
-
: renderEmptyElement($xeGantt),
|
|
490
|
-
$xeGantt.renderGanttTaskChartBefores
|
|
491
|
-
? h('div', {
|
|
492
|
-
ref: 'refChartBeforeWrapperElem',
|
|
493
|
-
class: ['vxe-gantt-view--chart-before-wrapper', {
|
|
494
|
-
'link--current': isCurrent,
|
|
495
|
-
'link--hover': isHover
|
|
496
|
-
}]
|
|
497
|
-
}, $xeTable && isEnableConf(taskLinkOpts) ? $xeGantt.renderGanttTaskChartBefores(h) : [])
|
|
498
|
-
: renderEmptyElement($xeGantt),
|
|
499
|
-
h('div', {
|
|
500
|
-
ref: 'refTaskWrapperElem',
|
|
501
|
-
class: ['vxe-gantt-view--chart-task-wrapper', {
|
|
502
|
-
'link--current': isCurrent,
|
|
503
|
-
'link--create': linkCreatable
|
|
504
|
-
}]
|
|
505
|
-
}, $xeTable ? _vm.renderTaskRows(h, $xeTable, tableData) : []),
|
|
506
|
-
$xeGantt.renderGanttTaskChartAfters
|
|
507
|
-
? h('div', {
|
|
508
|
-
ref: 'refChartAfterWrapperElem',
|
|
509
|
-
class: 'vxe-gantt-view--chart-after-wrapper'
|
|
510
|
-
}, $xeTable && isEnableConf(taskLinkOpts) ? $xeGantt.renderGanttTaskChartAfters(h) : [])
|
|
511
|
-
: renderEmptyElement($xeGantt)
|
|
512
|
-
])
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
mounted () {
|
|
516
|
-
const _vm = this
|
|
517
|
-
const $xeGanttView = _vm.$xeGanttView
|
|
518
|
-
const ganttViewInternalData = $xeGanttView.internalData
|
|
519
|
-
|
|
520
|
-
const { elemStore } = ganttViewInternalData
|
|
521
|
-
const prefix = 'main-chart-'
|
|
522
|
-
elemStore[`${prefix}now-line`] = _vm.$refs.refNowLineElem as HTMLDivElement
|
|
523
|
-
elemStore[`${prefix}task-wrapper`] = _vm.$refs.refTaskWrapperElem as HTMLDivElement
|
|
524
|
-
elemStore[`${prefix}before-wrapper`] = _vm.$refs.refChartBeforeWrapperElem as HTMLDivElement
|
|
525
|
-
elemStore[`${prefix}after-wrapper`] = _vm.$refs.refChartAfterWrapperElem as HTMLDivElement
|
|
526
|
-
},
|
|
527
|
-
destroyed () {
|
|
528
|
-
const _vm = this
|
|
529
|
-
const $xeGanttView = _vm.$xeGanttView
|
|
530
|
-
const ganttViewInternalData = $xeGanttView.internalData
|
|
531
|
-
|
|
532
|
-
const { elemStore } = ganttViewInternalData
|
|
533
|
-
const prefix = 'main-chart-'
|
|
534
|
-
elemStore[`${prefix}now-line`] = null
|
|
535
|
-
elemStore[`${prefix}task-wrapper`] = null
|
|
536
|
-
elemStore[`${prefix}before-wrapper`] = null
|
|
537
|
-
elemStore[`${prefix}after-wrapper`] = null
|
|
538
|
-
},
|
|
539
|
-
render (this: any, h) {
|
|
540
|
-
return this.renderVN(h)
|
|
541
|
-
}
|
|
542
|
-
})
|
|
1
|
+
import { VNode, CreateElement } from 'vue'
|
|
2
|
+
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
|
+
import { VxeUI } from '@vxe-ui/core'
|
|
4
|
+
import XEUtils from 'xe-utils'
|
|
5
|
+
import { getCellRestHeight, hasMilestoneTask, getTaskType, hasSubviewTask } from './util'
|
|
6
|
+
import { getStringValue, isEnableConf, hasEnableConf } from '../../ui/src/utils'
|
|
7
|
+
|
|
8
|
+
import type { VxeComponentStyleType } from 'vxe-pc-ui'
|
|
9
|
+
import type { TableInternalData, TableReactData, VxeTableConstructor, VxeTableMethods, VxeTablePrivateMethods } from 'vxe-table'
|
|
10
|
+
import type { VxeGanttViewConstructor, VxeGanttViewPrivateMethods, VxeGanttConstructor, VxeGanttPrivateMethods } from '../../../types'
|
|
11
|
+
|
|
12
|
+
const { getIcon, renderEmptyElement } = VxeUI
|
|
13
|
+
|
|
14
|
+
const sourceType = 'gantt'
|
|
15
|
+
const viewType = 'chart'
|
|
16
|
+
|
|
17
|
+
export default defineVxeComponent({
|
|
18
|
+
name: 'VxeGanttViewChart',
|
|
19
|
+
inject: {
|
|
20
|
+
$xeGantt: {
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
$xeGanttView: {
|
|
24
|
+
default: null
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
props: {},
|
|
28
|
+
data () {
|
|
29
|
+
return {}
|
|
30
|
+
},
|
|
31
|
+
computed: {
|
|
32
|
+
...({} as {
|
|
33
|
+
$xeGantt(): (VxeGanttConstructor & VxeGanttPrivateMethods)
|
|
34
|
+
$xeGanttView(): (VxeGanttViewConstructor & VxeGanttViewPrivateMethods)
|
|
35
|
+
})
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
//
|
|
39
|
+
// Render
|
|
40
|
+
//
|
|
41
|
+
renderTaskBar (h: CreateElement, $xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, row: any, rowid: string, rowIndex: number, $rowIndex: number, _rowIndex: number, rowChildren: any[], isExpandTree: boolean) {
|
|
42
|
+
const _vm = this
|
|
43
|
+
const $xeGantt = _vm.$xeGantt
|
|
44
|
+
|
|
45
|
+
const tableReactData = $xeTable as unknown as TableReactData
|
|
46
|
+
const { resizeHeightFlag, pendingRowFlag } = tableReactData
|
|
47
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
48
|
+
const { fullAllDataRowIdData, pendingRowMaps } = tableInternalData
|
|
49
|
+
const cellOpts = $xeTable.computeCellOpts
|
|
50
|
+
const rowOpts = $xeTable.computeRowOpts
|
|
51
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
52
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
53
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
54
|
+
|
|
55
|
+
const ganttProps = $xeGantt
|
|
56
|
+
const ganttReactData = $xeGantt.reactData
|
|
57
|
+
const ganttInternalData = $xeGantt.internalData
|
|
58
|
+
const ganttSlots = $xeGantt.$scopedSlots
|
|
59
|
+
const taskBarSlot = ganttSlots.taskBar || ganttSlots['task-bar']
|
|
60
|
+
const taskBarOverviewSlot = ganttSlots.taskBarOverview || ganttSlots['task-bar-overview']
|
|
61
|
+
|
|
62
|
+
const { treeConfig, taskBarMilestoneConfig, taskBarSubviewConfig } = ganttProps
|
|
63
|
+
const { activeLink, activeBarRowid } = ganttReactData
|
|
64
|
+
const titleField = $xeGantt.computeTitleField
|
|
65
|
+
const progressField = $xeGantt.computeProgressField
|
|
66
|
+
const typeField = $xeGantt.computeTypeField
|
|
67
|
+
const taskBarOpts = $xeGantt.computeTaskBarOpts
|
|
68
|
+
const taskBarMilestoneOpts = $xeGantt.computeTaskBarMilestoneOpts
|
|
69
|
+
const taskBarSubviewOpts = $xeGantt.computeTaskBarSubviewOpts
|
|
70
|
+
const { showOverview, barStyle: subBarStyle } = taskBarSubviewOpts
|
|
71
|
+
const scaleUnit = $xeGantt.computeScaleUnit
|
|
72
|
+
const barParams = { $gantt: $xeGantt, row, scaleType: scaleUnit }
|
|
73
|
+
const { showProgress, showContent, contentMethod, barStyle, moveable, showTooltip } = taskBarOpts
|
|
74
|
+
const isBarRowStyle = XEUtils.isFunction(barStyle)
|
|
75
|
+
const barStyObj = (barStyle ? (isBarRowStyle ? barStyle(barParams) : barStyle) : {}) || {}
|
|
76
|
+
const { round } = barStyObj
|
|
77
|
+
|
|
78
|
+
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
79
|
+
const cellHeight = resizeHeightFlag ? getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) : 0
|
|
80
|
+
|
|
81
|
+
let title = getStringValue(XEUtils.get(row, titleField))
|
|
82
|
+
const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
|
|
83
|
+
const renderTaskType = getTaskType(XEUtils.get(row, typeField))
|
|
84
|
+
|
|
85
|
+
const vbStyle: VxeComponentStyleType = {}
|
|
86
|
+
const vpStyle: VxeComponentStyleType = {
|
|
87
|
+
width: `${progressValue || 0}%`
|
|
88
|
+
}
|
|
89
|
+
if (isBarRowStyle) {
|
|
90
|
+
const { bgColor, completedBgColor } = barStyObj
|
|
91
|
+
if (bgColor) {
|
|
92
|
+
vbStyle.backgroundColor = bgColor
|
|
93
|
+
}
|
|
94
|
+
if (completedBgColor) {
|
|
95
|
+
vpStyle.backgroundColor = completedBgColor
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const ctParams = {
|
|
100
|
+
$gantt: $xeGantt,
|
|
101
|
+
source: sourceType,
|
|
102
|
+
type: viewType,
|
|
103
|
+
scaleType: scaleUnit,
|
|
104
|
+
row,
|
|
105
|
+
$rowIndex,
|
|
106
|
+
rowIndex,
|
|
107
|
+
_rowIndex
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let cbVNs: VNode[] = []
|
|
111
|
+
if ($xeGantt.renderGanttTaskBarContent) {
|
|
112
|
+
cbVNs = $xeGantt.renderGanttTaskBarContent(h, ctParams, {
|
|
113
|
+
$gantt: $xeGantt,
|
|
114
|
+
$table: $xeTable,
|
|
115
|
+
rowid
|
|
116
|
+
})
|
|
117
|
+
} else {
|
|
118
|
+
const isMilestone = !!(hasEnableConf(taskBarMilestoneConfig, taskBarMilestoneOpts) && hasMilestoneTask(renderTaskType))
|
|
119
|
+
const isSubview = !!(hasEnableConf(taskBarSubviewConfig, taskBarSubviewOpts) && hasSubviewTask(renderTaskType))
|
|
120
|
+
|
|
121
|
+
if (contentMethod) {
|
|
122
|
+
title = getStringValue(contentMethod({ row, title, scaleType: scaleUnit }))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const ctOns: {
|
|
126
|
+
mouseover?: any
|
|
127
|
+
mouseleave?: any
|
|
128
|
+
} = {}
|
|
129
|
+
if (showTooltip) {
|
|
130
|
+
ctOns.mouseover = (evnt: MouseEvent) => {
|
|
131
|
+
const { dragBarRow } = ganttInternalData
|
|
132
|
+
const ttParams = Object.assign({ $event: evnt }, ctParams)
|
|
133
|
+
if (!dragBarRow) {
|
|
134
|
+
$xeGantt.triggerTaskBarTooltipEvent(evnt, ttParams)
|
|
135
|
+
}
|
|
136
|
+
$xeGantt.dispatchEvent('task-bar-mouseenter', ttParams, evnt)
|
|
137
|
+
}
|
|
138
|
+
ctOns.mouseleave = (evnt: MouseEvent) => {
|
|
139
|
+
const { dragBarRow } = ganttInternalData
|
|
140
|
+
const ttParams = Object.assign({ $event: evnt }, ctParams)
|
|
141
|
+
if (!dragBarRow) {
|
|
142
|
+
$xeGantt.handleTaskBarTooltipLeaveEvent(evnt, ttParams)
|
|
143
|
+
}
|
|
144
|
+
$xeGantt.dispatchEvent('task-bar-mouseleave', ttParams, evnt)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (isSubview && treeConfig && rowChildren && rowChildren.length) {
|
|
149
|
+
if (isExpandTree) {
|
|
150
|
+
if (showOverview) {
|
|
151
|
+
cbVNs.push(
|
|
152
|
+
h('div', {
|
|
153
|
+
key: 'vcso',
|
|
154
|
+
class: 'vxe-gantt-view--chart-subview-wrapper is--overview'
|
|
155
|
+
}, [
|
|
156
|
+
h('div', {
|
|
157
|
+
key: rowid,
|
|
158
|
+
attrs: {
|
|
159
|
+
rowid: rowid
|
|
160
|
+
},
|
|
161
|
+
class: ['vxe-gantt-view--chart-subview-row', {
|
|
162
|
+
'is--progress': showProgress,
|
|
163
|
+
'is--round': round,
|
|
164
|
+
'is--move': moveable
|
|
165
|
+
}]
|
|
166
|
+
}, [
|
|
167
|
+
h('div', {
|
|
168
|
+
attrs: {
|
|
169
|
+
rowid: rowid
|
|
170
|
+
},
|
|
171
|
+
class: [taskBarOverviewSlot ? 'vxe-gantt-view--chart-subview-custom-bar' : 'vxe-gantt-view--chart-subview-bar', `is--${renderTaskType}`]
|
|
172
|
+
}, [
|
|
173
|
+
taskBarOverviewSlot
|
|
174
|
+
? h('div', {
|
|
175
|
+
key: 'cbc',
|
|
176
|
+
class: 'vxe-gantt-view--chart-subview-custom-bar-content-wrapper'
|
|
177
|
+
}, $xeGantt.callSlot(taskBarOverviewSlot, barParams, h))
|
|
178
|
+
: h('div', {
|
|
179
|
+
class: 'vxe-gantt-view--chart-subview-bar-content-wrapper'
|
|
180
|
+
}, [
|
|
181
|
+
showContent
|
|
182
|
+
? h('div', {
|
|
183
|
+
class: 'vxe-gantt-view--chart-content'
|
|
184
|
+
}, title)
|
|
185
|
+
: renderEmptyElement($xeGantt)
|
|
186
|
+
])
|
|
187
|
+
])
|
|
188
|
+
])
|
|
189
|
+
])
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
const cbcVNs: VNode[] = []
|
|
194
|
+
XEUtils.eachTree(rowChildren, childRow => {
|
|
195
|
+
const childBarParams = { $gantt: $xeGantt, row: childRow, scaleType: scaleUnit }
|
|
196
|
+
const childBarStyObj = (barStyle ? (isBarRowStyle ? barStyle(childBarParams) : barStyle) : {}) || {}
|
|
197
|
+
const { round } = childBarStyObj
|
|
198
|
+
|
|
199
|
+
const childRowid = $xeTable.getRowid(childRow)
|
|
200
|
+
let childTitle = getStringValue(XEUtils.get(childRow, titleField))
|
|
201
|
+
const childProgressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(childRow, progressField)))) : 0
|
|
202
|
+
const childRenderTaskType = getTaskType(XEUtils.get(childRow, typeField))
|
|
203
|
+
const isChildSubview = !!(hasEnableConf(taskBarSubviewConfig, taskBarSubviewOpts) && hasSubviewTask(childRenderTaskType))
|
|
204
|
+
|
|
205
|
+
if (isChildSubview) {
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const childVbStyle: VxeComponentStyleType = {}
|
|
210
|
+
const childVpStyle: VxeComponentStyleType = {
|
|
211
|
+
width: `${childProgressValue || 0}%`
|
|
212
|
+
}
|
|
213
|
+
if (isBarRowStyle) {
|
|
214
|
+
const { bgColor, completedBgColor } = childBarStyObj
|
|
215
|
+
if (bgColor) {
|
|
216
|
+
childVbStyle.backgroundColor = bgColor
|
|
217
|
+
}
|
|
218
|
+
if (completedBgColor) {
|
|
219
|
+
childVpStyle.backgroundColor = completedBgColor
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const childCtParams = XEUtils.assign({}, ctParams, {
|
|
224
|
+
row: childRow,
|
|
225
|
+
rowIndex: $xeTable.getRowIndex(childRow),
|
|
226
|
+
$rowIndex: $xeTable.getVMRowIndex(childRow),
|
|
227
|
+
_rowIndex: $xeTable.getVTRowIndex(childRow)
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
if (contentMethod) {
|
|
231
|
+
childTitle = getStringValue(contentMethod({ row: childRow, title: childTitle, scaleType: scaleUnit }))
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
cbcVNs.push(
|
|
235
|
+
h('div', {
|
|
236
|
+
key: childRowid,
|
|
237
|
+
attrs: {
|
|
238
|
+
rowid: childRowid
|
|
239
|
+
},
|
|
240
|
+
class: ['vxe-gantt-view--chart-subview-row', `is--${childRenderTaskType}`, {
|
|
241
|
+
'is--progress': showProgress,
|
|
242
|
+
'is--round': round,
|
|
243
|
+
'is--move': moveable,
|
|
244
|
+
'row--pending': !!pendingRowFlag && !!pendingRowMaps[childRowid]
|
|
245
|
+
}]
|
|
246
|
+
}, [
|
|
247
|
+
h('div', {
|
|
248
|
+
attrs: {
|
|
249
|
+
rowid: childRowid
|
|
250
|
+
},
|
|
251
|
+
class: [taskBarSlot ? 'vxe-gantt-view--chart-subview-custom-bar' : 'vxe-gantt-view--chart-subview-bar', `is--${childRenderTaskType}`],
|
|
252
|
+
style: subBarStyle ? (XEUtils.isFunction(subBarStyle) ? subBarStyle(childCtParams) || undefined : subBarStyle) : undefined,
|
|
253
|
+
on: {
|
|
254
|
+
click (evnt: MouseEvent) {
|
|
255
|
+
evnt.stopPropagation()
|
|
256
|
+
$xeGantt.handleTaskBarClickEvent(evnt, childCtParams)
|
|
257
|
+
},
|
|
258
|
+
dblclick (evnt: MouseEvent) {
|
|
259
|
+
evnt.stopPropagation()
|
|
260
|
+
$xeGantt.handleTaskBarDblclickEvent(evnt, childCtParams)
|
|
261
|
+
},
|
|
262
|
+
mousedown (evnt: MouseEvent) {
|
|
263
|
+
evnt.stopPropagation()
|
|
264
|
+
if ($xeGantt.handleTaskBarMousedownEvent) {
|
|
265
|
+
$xeGantt.handleTaskBarMousedownEvent(evnt, childCtParams)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}, [
|
|
270
|
+
taskBarSlot
|
|
271
|
+
? h('div', {
|
|
272
|
+
key: 'cbc',
|
|
273
|
+
class: 'vxe-gantt-view--chart-subview-custom-bar-content-wrapper',
|
|
274
|
+
on: ctOns
|
|
275
|
+
}, $xeGantt.callSlot(taskBarSlot, childCtParams, h))
|
|
276
|
+
: h('div', {
|
|
277
|
+
class: 'vxe-gantt-view--chart-subview-bar-content-wrapper',
|
|
278
|
+
on: ctOns
|
|
279
|
+
}, [
|
|
280
|
+
showProgress
|
|
281
|
+
? h('div', {
|
|
282
|
+
class: 'vxe-gantt-view--chart-progress',
|
|
283
|
+
style: childVpStyle
|
|
284
|
+
})
|
|
285
|
+
: renderEmptyElement($xeGantt),
|
|
286
|
+
showContent
|
|
287
|
+
? h('div', {
|
|
288
|
+
class: 'vxe-gantt-view--chart-content'
|
|
289
|
+
}, childTitle)
|
|
290
|
+
: renderEmptyElement($xeGantt)
|
|
291
|
+
])
|
|
292
|
+
])
|
|
293
|
+
])
|
|
294
|
+
)
|
|
295
|
+
}, { children: childrenField })
|
|
296
|
+
|
|
297
|
+
cbVNs.push(
|
|
298
|
+
h('div', {
|
|
299
|
+
key: 'vcsc',
|
|
300
|
+
class: 'vxe-gantt-view--chart-subview-wrapper is--inline'
|
|
301
|
+
}, cbcVNs)
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
if (taskBarSlot) {
|
|
306
|
+
cbVNs.push(
|
|
307
|
+
h('div', {
|
|
308
|
+
key: 'cbc',
|
|
309
|
+
class: 'vxe-gantt-view--chart-custom-bar-content-wrapper',
|
|
310
|
+
on: ctOns
|
|
311
|
+
}, $xeGantt.callSlot(taskBarSlot, barParams, h))
|
|
312
|
+
)
|
|
313
|
+
} else if (isMilestone) {
|
|
314
|
+
const { icon, iconStatus, iconStyle } = taskBarMilestoneOpts
|
|
315
|
+
const tbmParams = { $gantt: $xeGantt, row }
|
|
316
|
+
cbVNs.push(
|
|
317
|
+
h('div', {
|
|
318
|
+
key: 'vcm',
|
|
319
|
+
class: 'vxe-gantt-view--chart-milestone-wrapper',
|
|
320
|
+
on: ctOns
|
|
321
|
+
}, [
|
|
322
|
+
h('div', {
|
|
323
|
+
class: ['vxe-gantt-view--chart-milestone-icon', iconStatus ? `theme--${XEUtils.isFunction(iconStatus) ? iconStatus(tbmParams) : iconStatus}` : ''],
|
|
324
|
+
style: iconStyle ? Object.assign({}, XEUtils.isFunction(iconStyle) ? iconStyle(tbmParams) : iconStyle) : undefined
|
|
325
|
+
}, [
|
|
326
|
+
h('i', {
|
|
327
|
+
class: (icon ? (XEUtils.isFunction(icon) ? icon(tbmParams) : icon) : '') || getIcon().GANTT_VIEW_TASK_MILESTONE
|
|
328
|
+
})
|
|
329
|
+
]),
|
|
330
|
+
showContent
|
|
331
|
+
? h('div', {
|
|
332
|
+
class: 'vxe-gantt-view--chart-milestone-content'
|
|
333
|
+
}, title)
|
|
334
|
+
: renderEmptyElement($xeGantt)
|
|
335
|
+
])
|
|
336
|
+
)
|
|
337
|
+
} else {
|
|
338
|
+
cbVNs.push(
|
|
339
|
+
h('div', {
|
|
340
|
+
key: 'vbc',
|
|
341
|
+
class: 'vxe-gantt-view--chart-bar-content-wrapper',
|
|
342
|
+
on: ctOns
|
|
343
|
+
}, [
|
|
344
|
+
showProgress
|
|
345
|
+
? h('div', {
|
|
346
|
+
class: 'vxe-gantt-view--chart-progress',
|
|
347
|
+
style: vpStyle
|
|
348
|
+
})
|
|
349
|
+
: renderEmptyElement($xeGantt),
|
|
350
|
+
showContent
|
|
351
|
+
? h('div', {
|
|
352
|
+
class: 'vxe-gantt-view--chart-content'
|
|
353
|
+
}, title)
|
|
354
|
+
: renderEmptyElement($xeGantt)
|
|
355
|
+
])
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return h('div', {
|
|
362
|
+
key: rowid,
|
|
363
|
+
attrs: {
|
|
364
|
+
rowid
|
|
365
|
+
},
|
|
366
|
+
class: ['vxe-gantt-view--chart-row', `is--${renderTaskType}`, {
|
|
367
|
+
'is--progress': showProgress,
|
|
368
|
+
'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid],
|
|
369
|
+
'is--round': round,
|
|
370
|
+
'is--move': moveable
|
|
371
|
+
}],
|
|
372
|
+
style: {
|
|
373
|
+
height: `${cellHeight}px`
|
|
374
|
+
},
|
|
375
|
+
on: {
|
|
376
|
+
onDragstart (evnt: DragEvent) {
|
|
377
|
+
if (ganttInternalData.dragBarRow) {
|
|
378
|
+
evnt.preventDefault()
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
contextmenu (evnt: Event) {
|
|
382
|
+
$xeGantt.handleTaskBarContextmenuEvent(evnt, ctParams)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}, [
|
|
386
|
+
h('div', {
|
|
387
|
+
class: [taskBarSlot ? 'vxe-gantt-view--chart-custom-bar' : 'vxe-gantt-view--chart-bar', `is--${renderTaskType}`, {
|
|
388
|
+
'is--active': activeBarRowid === rowid,
|
|
389
|
+
'active--link': activeLink && (rowid === `${activeLink.from}` || rowid === `${activeLink.to}`)
|
|
390
|
+
}],
|
|
391
|
+
style: vbStyle,
|
|
392
|
+
attrs: {
|
|
393
|
+
rowid
|
|
394
|
+
},
|
|
395
|
+
on: {
|
|
396
|
+
click (evnt: MouseEvent) {
|
|
397
|
+
$xeGantt.handleTaskBarClickEvent(evnt, barParams)
|
|
398
|
+
},
|
|
399
|
+
dblclick (evnt: MouseEvent) {
|
|
400
|
+
$xeGantt.handleTaskBarDblclickEvent(evnt, barParams)
|
|
401
|
+
},
|
|
402
|
+
mousedown (evnt: MouseEvent) {
|
|
403
|
+
if ($xeGantt.handleTaskBarMousedownEvent) {
|
|
404
|
+
$xeGantt.handleTaskBarMousedownEvent(evnt, barParams)
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}, cbVNs)
|
|
409
|
+
])
|
|
410
|
+
},
|
|
411
|
+
renderTaskRows (h: CreateElement, $xeTable: VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods, tableData: any[]) {
|
|
412
|
+
const _vm = this
|
|
413
|
+
const $xeGanttView = _vm.$xeGanttView
|
|
414
|
+
const ganttViewReactData = $xeGanttView.reactData
|
|
415
|
+
|
|
416
|
+
const tableProps = $xeTable
|
|
417
|
+
const { treeConfig } = tableProps
|
|
418
|
+
const tableReactData = $xeTable as unknown as TableReactData
|
|
419
|
+
const { treeExpandedFlag } = tableReactData
|
|
420
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
421
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = tableInternalData
|
|
422
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
423
|
+
const { transform } = treeOpts
|
|
424
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
425
|
+
|
|
426
|
+
const { scrollYLoad } = ganttViewReactData
|
|
427
|
+
|
|
428
|
+
const trVNs: VNode[] = []
|
|
429
|
+
tableData.forEach((row, $rowIndex) => {
|
|
430
|
+
const rowid = $xeTable.getRowid(row)
|
|
431
|
+
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
432
|
+
let rowIndex = $rowIndex
|
|
433
|
+
let _rowIndex = -1
|
|
434
|
+
if (rowRest) {
|
|
435
|
+
rowIndex = rowRest.index
|
|
436
|
+
_rowIndex = rowRest._index
|
|
437
|
+
}
|
|
438
|
+
let isExpandTree = false
|
|
439
|
+
let rowChildren: any[] = []
|
|
440
|
+
|
|
441
|
+
if (treeConfig) {
|
|
442
|
+
rowChildren = row[childrenField]
|
|
443
|
+
isExpandTree = !!treeExpandedFlag && rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
trVNs.push(_vm.renderTaskBar(h, $xeTable, row, rowid, rowIndex, $rowIndex, _rowIndex, rowChildren, isExpandTree))
|
|
447
|
+
// 如果是树形表格
|
|
448
|
+
if (treeConfig && isExpandTree && !scrollYLoad && !transform) {
|
|
449
|
+
trVNs.push(..._vm.renderTaskRows(h, $xeTable, rowChildren))
|
|
450
|
+
}
|
|
451
|
+
})
|
|
452
|
+
return trVNs
|
|
453
|
+
},
|
|
454
|
+
renderVN (h: CreateElement): VNode {
|
|
455
|
+
const _vm = this
|
|
456
|
+
const $xeGantt = _vm.$xeGantt
|
|
457
|
+
const $xeGanttView = _vm.$xeGanttView
|
|
458
|
+
const ganttReactData = $xeGantt.reactData
|
|
459
|
+
const ganttViewInternalData = $xeGanttView.internalData
|
|
460
|
+
const ganttViewReactData = $xeGanttView.reactData
|
|
461
|
+
|
|
462
|
+
const $xeTable = ganttViewInternalData.xeTable
|
|
463
|
+
|
|
464
|
+
const ganttSlots = $xeGantt.$scopedSlots
|
|
465
|
+
|
|
466
|
+
const { dragLinkFromStore } = ganttReactData
|
|
467
|
+
const { tableData } = ganttViewReactData
|
|
468
|
+
const taskLinkOpts = $xeGantt.computeTaskLinkOpts
|
|
469
|
+
const taskBarOpts = $xeGantt.computeTaskBarOpts
|
|
470
|
+
const nowLineLeft = $xeGanttView.computeNowLineLeft
|
|
471
|
+
const { isCurrent, isHover } = taskLinkOpts
|
|
472
|
+
const { linkCreatable } = taskBarOpts
|
|
473
|
+
const taskNowLineSlot = ganttSlots.taskNowLine || ganttSlots['task-now-line']
|
|
474
|
+
|
|
475
|
+
return h('div', {
|
|
476
|
+
ref: 'refElem',
|
|
477
|
+
class: ['vxe-gantt-view--chart-wrapper', {
|
|
478
|
+
'is--cl-drag': dragLinkFromStore.rowid
|
|
479
|
+
}]
|
|
480
|
+
}, [
|
|
481
|
+
nowLineLeft > 0
|
|
482
|
+
? h('div', {
|
|
483
|
+
ref: 'refNowLineElem',
|
|
484
|
+
class: 'vxe-gantt-view--chart-now-line',
|
|
485
|
+
style: {
|
|
486
|
+
left: nowLineLeft + 'px'
|
|
487
|
+
}
|
|
488
|
+
}, taskNowLineSlot ? taskNowLineSlot({}) : [])
|
|
489
|
+
: renderEmptyElement($xeGantt),
|
|
490
|
+
$xeGantt.renderGanttTaskChartBefores
|
|
491
|
+
? h('div', {
|
|
492
|
+
ref: 'refChartBeforeWrapperElem',
|
|
493
|
+
class: ['vxe-gantt-view--chart-before-wrapper', {
|
|
494
|
+
'link--current': isCurrent,
|
|
495
|
+
'link--hover': isHover
|
|
496
|
+
}]
|
|
497
|
+
}, $xeTable && isEnableConf(taskLinkOpts) ? $xeGantt.renderGanttTaskChartBefores(h) : [])
|
|
498
|
+
: renderEmptyElement($xeGantt),
|
|
499
|
+
h('div', {
|
|
500
|
+
ref: 'refTaskWrapperElem',
|
|
501
|
+
class: ['vxe-gantt-view--chart-task-wrapper', {
|
|
502
|
+
'link--current': isCurrent,
|
|
503
|
+
'link--create': linkCreatable
|
|
504
|
+
}]
|
|
505
|
+
}, $xeTable ? _vm.renderTaskRows(h, $xeTable, tableData) : []),
|
|
506
|
+
$xeGantt.renderGanttTaskChartAfters
|
|
507
|
+
? h('div', {
|
|
508
|
+
ref: 'refChartAfterWrapperElem',
|
|
509
|
+
class: 'vxe-gantt-view--chart-after-wrapper'
|
|
510
|
+
}, $xeTable && isEnableConf(taskLinkOpts) ? $xeGantt.renderGanttTaskChartAfters(h) : [])
|
|
511
|
+
: renderEmptyElement($xeGantt)
|
|
512
|
+
])
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
mounted () {
|
|
516
|
+
const _vm = this
|
|
517
|
+
const $xeGanttView = _vm.$xeGanttView
|
|
518
|
+
const ganttViewInternalData = $xeGanttView.internalData
|
|
519
|
+
|
|
520
|
+
const { elemStore } = ganttViewInternalData
|
|
521
|
+
const prefix = 'main-chart-'
|
|
522
|
+
elemStore[`${prefix}now-line`] = _vm.$refs.refNowLineElem as HTMLDivElement
|
|
523
|
+
elemStore[`${prefix}task-wrapper`] = _vm.$refs.refTaskWrapperElem as HTMLDivElement
|
|
524
|
+
elemStore[`${prefix}before-wrapper`] = _vm.$refs.refChartBeforeWrapperElem as HTMLDivElement
|
|
525
|
+
elemStore[`${prefix}after-wrapper`] = _vm.$refs.refChartAfterWrapperElem as HTMLDivElement
|
|
526
|
+
},
|
|
527
|
+
destroyed () {
|
|
528
|
+
const _vm = this
|
|
529
|
+
const $xeGanttView = _vm.$xeGanttView
|
|
530
|
+
const ganttViewInternalData = $xeGanttView.internalData
|
|
531
|
+
|
|
532
|
+
const { elemStore } = ganttViewInternalData
|
|
533
|
+
const prefix = 'main-chart-'
|
|
534
|
+
elemStore[`${prefix}now-line`] = null
|
|
535
|
+
elemStore[`${prefix}task-wrapper`] = null
|
|
536
|
+
elemStore[`${prefix}before-wrapper`] = null
|
|
537
|
+
elemStore[`${prefix}after-wrapper`] = null
|
|
538
|
+
},
|
|
539
|
+
render (this: any, h) {
|
|
540
|
+
return this.renderVN(h)
|
|
541
|
+
}
|
|
542
|
+
})
|