vxe-gantt 0.0.2 → 3.0.0-beta.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.
- package/README.md +18 -24
- package/es/components.js +3 -2
- package/es/gantt/src/gantt-body.js +137 -0
- package/es/gantt/src/gantt-chart.js +125 -0
- package/es/gantt/src/gantt-header.js +97 -0
- package/es/gantt/src/gantt-view.js +820 -0
- package/es/gantt/src/gantt.js +1897 -43
- package/es/gantt/src/util.js +9 -0
- package/es/gantt/style.css +624 -0
- package/es/gantt/style.min.css +1 -0
- package/es/index.esm.js +5 -2
- package/es/style.css +1 -0
- package/es/style.min.css +1 -0
- package/es/ui/index.js +55 -5
- package/es/ui/src/comp.js +1 -2
- package/es/ui/src/dom.js +44 -105
- package/es/ui/src/log.js +3 -2
- package/es/ui/src/utils.js +4 -3
- package/es/ui/src/vn.js +1 -32
- package/es/vxe-gantt/style.css +624 -0
- package/es/vxe-gantt/style.min.css +1 -0
- package/helper/vetur/attributes.json +1 -1
- package/helper/vetur/tags.json +1 -1
- package/lib/components.js +20 -19
- package/lib/components.min.js +1 -1
- package/lib/gantt/index.js +3 -3
- package/lib/gantt/index.min.js +1 -1
- package/lib/gantt/src/gantt-body.js +140 -0
- package/lib/gantt/src/gantt-body.min.js +1 -0
- package/lib/gantt/src/gantt-chart.js +134 -0
- package/lib/gantt/src/gantt-chart.min.js +1 -0
- package/lib/gantt/src/gantt-header.js +97 -0
- package/lib/gantt/src/gantt-header.min.js +1 -0
- package/lib/gantt/src/gantt-view.js +808 -0
- package/lib/gantt/src/gantt-view.min.js +1 -0
- package/lib/gantt/src/gantt.js +2045 -48
- package/lib/gantt/src/gantt.min.js +1 -1
- package/lib/gantt/src/util.js +16 -0
- package/lib/gantt/src/util.min.js +1 -0
- package/lib/gantt/style/style.css +624 -0
- package/lib/gantt/style/style.min.css +1 -0
- package/lib/index.common.js +12 -7
- package/lib/index.umd.js +11484 -235
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -0
- package/lib/style.min.css +1 -0
- package/lib/ui/index.js +54 -14
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/comp.js +3 -2
- package/lib/ui/src/comp.min.js +1 -1
- package/lib/ui/src/dom.js +78 -138
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +4 -3
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/src/utils.js +5 -4
- package/lib/ui/src/utils.min.js +1 -1
- package/lib/ui/src/vn.js +1 -43
- package/lib/ui/src/vn.min.js +0 -1
- package/lib/vxe-gantt/index.js +4 -2
- package/lib/vxe-gantt/index.min.js +1 -1
- package/lib/vxe-gantt/style/style.css +624 -0
- package/lib/vxe-gantt/style/style.min.css +1 -0
- package/lib/vxe-ui/index.js +4 -2
- package/lib/vxe-ui/index.min.js +1 -1
- package/package.json +13 -13
- package/packages/components.ts +8 -5
- package/packages/gantt/index.ts +2 -2
- package/packages/gantt/src/gantt-body.ts +155 -0
- package/packages/gantt/src/gantt-chart.ts +143 -0
- package/packages/gantt/src/gantt-header.ts +109 -0
- package/packages/gantt/src/gantt-view.ts +908 -0
- package/packages/gantt/src/gantt.ts +2048 -46
- package/packages/gantt/src/util.ts +12 -0
- package/packages/index.ts +6 -2
- package/packages/ui/index.ts +56 -4
- package/packages/ui/src/comp.ts +2 -2
- package/packages/ui/src/dom.ts +53 -110
- package/packages/ui/src/log.ts +4 -2
- package/packages/ui/src/utils.ts +5 -3
- package/packages/ui/src/vn.ts +0 -37
- package/styles/components/gantt-module/all.scss +1 -0
- package/styles/components/gantt-module/gantt-chart.scss +65 -0
- package/styles/components/gantt.scss +591 -0
- package/styles/helpers/baseMixin.scss +96 -0
- package/styles/helpers/baseVar.scss +4 -0
- package/styles/helpers/placement.scss +39 -0
- package/styles/theme/base.scss +11 -0
- package/styles/theme/dark.scss +5 -0
- package/styles/theme/light.scss +5 -0
- package/types/all.d.ts +3 -3
- package/types/index.d.ts +2 -2
- package/README.en.md +0 -72
- package/README.ja-JP.md +0 -72
- package/README.zh-TW.md +0 -73
|
@@ -1,87 +1,2089 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropType, VNode, CreateElement, Component } from 'vue'
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
|
-
import {
|
|
3
|
+
import { VxeUI } from '@vxe-ui/core'
|
|
4
4
|
import XEUtils from 'xe-utils'
|
|
5
|
+
import { getLastZIndex, nextZIndex, isEnableConf } from '../../ui/src/utils'
|
|
6
|
+
import { getOffsetHeight, getPaddingTopBottomSize, getDomNode, toCssUnit, addClass, removeClass } from '../../ui/src/dom'
|
|
7
|
+
import { warnLog, errLog } from '../../ui/src/log'
|
|
8
|
+
import GanttViewComponent from './gantt-view'
|
|
9
|
+
import { VxeTable as VxeTableComponent } from 'vxe-table'
|
|
5
10
|
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
11
|
+
import type { ValueOf, VxeFormInstance, VxeFormItemProps, VxePagerInstance, VxePagerDefines, VxeComponentStyleType, VxeComponentSizeType, VxeFormDefines, VxeFormItemPropTypes } from 'vxe-pc-ui'
|
|
12
|
+
import type { VxeTableMethods, VxeToolbarPropTypes, VxeTableProps, VxeTableConstructor, VxeTablePrivateMethods, VxeTableDefines, VxeToolbarInstance, TableInternalData, VxeTablePropTypes, VxeGridPropTypes } from 'vxe-table'
|
|
13
|
+
import type { VxeGanttEmits, GanttReactData, GanttInternalData, VxeGanttPropTypes, VxeGanttViewInstance, VxeGanttDefines } from '../../../types'
|
|
14
|
+
|
|
15
|
+
const { getConfig, getIcon, getI18n, commands, globalMixins, createEvent, globalEvents, GLOBAL_EVENT_KEYS, renderEmptyElement, getSlotVNs } = VxeUI
|
|
16
|
+
|
|
17
|
+
const tableProps = (VxeTableComponent as any).props
|
|
18
|
+
|
|
19
|
+
const tableMethods: VxeTableMethods = {} as VxeTableMethods
|
|
20
|
+
const propKeys = Object.keys(tableProps) as (keyof VxeTableProps)[]
|
|
21
|
+
|
|
22
|
+
const defaultLayouts: VxeGanttPropTypes.Layouts = [['Form'], ['Toolbar', 'Top', 'Gantt', 'Bottom', 'Pager']]
|
|
23
|
+
|
|
24
|
+
function getTableOns (_vm: any) {
|
|
25
|
+
const { $listeners, proxyConfig, proxyOpts } = _vm
|
|
26
|
+
const ons: any = {}
|
|
27
|
+
XEUtils.each($listeners, (cb: any, type: any) => {
|
|
28
|
+
ons[type] = (...args: any[]) => {
|
|
29
|
+
_vm.$emit(type, ...args)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
if (proxyConfig) {
|
|
33
|
+
if (proxyOpts.sort) {
|
|
34
|
+
ons['sort-change'] = _vm.sortChangeEvent
|
|
35
|
+
ons['clear-all-sort'] = _vm.clearAllSortEvent
|
|
36
|
+
}
|
|
37
|
+
if (proxyOpts.filter) {
|
|
38
|
+
ons['filter-change'] = _vm.filterChangeEvent
|
|
39
|
+
ons['clear-all-filter'] = _vm.clearAllFilterEvent
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return ons
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
XEUtils.each((VxeTableComponent as any).methods, (fn, name) => {
|
|
46
|
+
tableMethods[name as keyof VxeTableMethods] = function (this: any, ...args: any[]) {
|
|
47
|
+
const $xeGantt = this
|
|
48
|
+
const $xeTable = $xeGantt.$refs.refTable
|
|
49
|
+
|
|
50
|
+
return $xeTable && $xeTable[name](...args)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
8
53
|
|
|
9
54
|
function createInternalData (): GanttInternalData {
|
|
10
55
|
return {
|
|
56
|
+
resizeTableWidth: 0
|
|
11
57
|
}
|
|
12
58
|
}
|
|
13
59
|
|
|
14
|
-
export default defineVxeComponent({
|
|
60
|
+
export default /* define-vxe-component start */ defineVxeComponent({
|
|
15
61
|
name: 'VxeGantt',
|
|
62
|
+
mixins: [
|
|
63
|
+
globalMixins.sizeMixin
|
|
64
|
+
],
|
|
16
65
|
props: {
|
|
66
|
+
...(tableProps as unknown as {
|
|
67
|
+
border: PropType<VxeTablePropTypes.Border>
|
|
68
|
+
round: PropType<VxeTablePropTypes.Round>
|
|
69
|
+
loading: PropType<VxeTablePropTypes.Loading>
|
|
70
|
+
height: PropType<VxeTablePropTypes.Height>
|
|
71
|
+
minHeight: PropType<VxeTablePropTypes.MinHeight>
|
|
72
|
+
maxHeight: PropType<VxeTablePropTypes.MaxHeight>
|
|
73
|
+
seqConfig: PropType<VxeTablePropTypes.SeqConfig>
|
|
74
|
+
editConfig: PropType<VxeTablePropTypes.EditConfig>
|
|
75
|
+
sortConfig: PropType<VxeTablePropTypes.SortConfig>
|
|
76
|
+
filterConfig: PropType<VxeTablePropTypes.FilterConfig>
|
|
77
|
+
validConfig: PropType<VxeTablePropTypes.ValidConfig>
|
|
78
|
+
editRules: PropType<VxeTablePropTypes.EditRules>
|
|
79
|
+
animat: PropType<VxeTablePropTypes.Animat>
|
|
80
|
+
scrollbarConfig: PropType<VxeTablePropTypes.ScrollbarConfig>
|
|
81
|
+
params: PropType<VxeTablePropTypes.Params>
|
|
82
|
+
}),
|
|
83
|
+
|
|
84
|
+
columns: Array as PropType<VxeGridPropTypes.Columns<any>>,
|
|
85
|
+
pagerConfig: Object as PropType<VxeGridPropTypes.PagerConfig>,
|
|
86
|
+
proxyConfig: Object as PropType<VxeGridPropTypes.ProxyConfig<any>>,
|
|
87
|
+
toolbarConfig: Object as PropType<VxeGridPropTypes.ToolbarConfig>,
|
|
88
|
+
formConfig: Object as PropType<VxeGridPropTypes.FormConfig>,
|
|
89
|
+
zoomConfig: Object as PropType<VxeGridPropTypes.ZoomConfig>,
|
|
90
|
+
|
|
91
|
+
layouts: Array as PropType<VxeGanttPropTypes.Layouts>,
|
|
92
|
+
taskConfig: Object as PropType<VxeGanttPropTypes.TaskConfig>,
|
|
93
|
+
taskViewConfig: Object as PropType<VxeGanttPropTypes.TaskViewConfig>,
|
|
94
|
+
taskBarConfig: Object as PropType<VxeGanttPropTypes.TaskBarConfig>,
|
|
95
|
+
taskSplitConfig: Object as PropType<VxeGanttPropTypes.TaskSplitConfig>,
|
|
17
96
|
size: {
|
|
18
|
-
type: String as PropType<
|
|
97
|
+
type: String as PropType<VxeGridPropTypes.Size>,
|
|
19
98
|
default: () => getConfig().gantt.size || getConfig().size
|
|
20
99
|
}
|
|
21
100
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
setup (props, context) {
|
|
25
|
-
const { emit } = context
|
|
101
|
+
provide () {
|
|
102
|
+
const $xeGantt = this
|
|
26
103
|
|
|
104
|
+
return {
|
|
105
|
+
$xeGantt
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
data () {
|
|
27
109
|
const xID = XEUtils.uniqueId()
|
|
28
110
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
111
|
+
const reactData: GanttReactData = {
|
|
112
|
+
tableLoading: false,
|
|
113
|
+
proxyInited: false,
|
|
114
|
+
isZMax: false,
|
|
115
|
+
tableData: [],
|
|
116
|
+
filterData: [],
|
|
117
|
+
formData: {},
|
|
118
|
+
sortData: [],
|
|
119
|
+
tZindex: 0,
|
|
120
|
+
tablePage: {
|
|
121
|
+
total: 0,
|
|
122
|
+
pageSize: getConfig().pager?.pageSize || 10,
|
|
123
|
+
currentPage: 1
|
|
124
|
+
},
|
|
125
|
+
showLeftView: true,
|
|
126
|
+
showRightView: true
|
|
127
|
+
}
|
|
34
128
|
|
|
35
129
|
const internalData = createInternalData()
|
|
36
130
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
131
|
+
return {
|
|
132
|
+
xID,
|
|
133
|
+
reactData,
|
|
134
|
+
internalData
|
|
40
135
|
}
|
|
136
|
+
},
|
|
137
|
+
computed: {
|
|
138
|
+
...({} as {
|
|
139
|
+
computeSize(): VxeComponentSizeType
|
|
140
|
+
}),
|
|
141
|
+
computeProxyOpts () {
|
|
142
|
+
const $xeGantt = this
|
|
143
|
+
const props = $xeGantt
|
|
41
144
|
|
|
42
|
-
|
|
43
|
-
}
|
|
145
|
+
return XEUtils.merge({}, XEUtils.clone(getConfig().gantt.proxyConfig, true), props.proxyConfig)
|
|
146
|
+
},
|
|
147
|
+
computeIsRespMsg () {
|
|
148
|
+
const $xeGantt = this
|
|
44
149
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
internalData,
|
|
150
|
+
const proxyOpts = $xeGantt.computeProxyOpts as VxeGanttPropTypes.ProxyConfig
|
|
151
|
+
return !!(XEUtils.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg)
|
|
152
|
+
},
|
|
153
|
+
computeIsActiveMsg () {
|
|
154
|
+
const $xeGantt = this
|
|
51
155
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
156
|
+
const proxyOpts = $xeGantt.computeProxyOpts as VxeGanttPropTypes.ProxyConfig
|
|
157
|
+
return XEUtils.isBoolean(proxyOpts.showActionMsg) ? proxyOpts.showActionMsg : !!proxyOpts.showActiveMsg
|
|
158
|
+
},
|
|
159
|
+
computePagerOpts () {
|
|
160
|
+
const $xeGantt = this
|
|
161
|
+
const props = $xeGantt
|
|
55
162
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
163
|
+
return Object.assign({}, getConfig().gantt.pagerConfig, props.pagerConfig)
|
|
164
|
+
},
|
|
165
|
+
computeFormOpts () {
|
|
166
|
+
const $xeGantt = this
|
|
167
|
+
const props = $xeGantt
|
|
168
|
+
|
|
169
|
+
return Object.assign({}, getConfig().gantt.formConfig, props.formConfig)
|
|
170
|
+
},
|
|
171
|
+
computeToolbarOpts () {
|
|
172
|
+
const $xeGantt = this
|
|
173
|
+
const props = $xeGantt
|
|
174
|
+
|
|
175
|
+
return Object.assign({}, getConfig().gantt.toolbarConfig, props.toolbarConfig)
|
|
176
|
+
},
|
|
177
|
+
computeZoomOpts () {
|
|
178
|
+
const $xeGantt = this
|
|
179
|
+
const props = $xeGantt
|
|
180
|
+
|
|
181
|
+
return Object.assign({}, getConfig().gantt.zoomConfig, props.zoomConfig)
|
|
182
|
+
},
|
|
183
|
+
computeTaskOpts () {
|
|
184
|
+
const $xeGantt = this
|
|
185
|
+
const props = $xeGantt
|
|
186
|
+
|
|
187
|
+
return Object.assign({}, getConfig().gantt.taskConfig, props.taskConfig)
|
|
188
|
+
},
|
|
189
|
+
computeTaskViewOpts () {
|
|
190
|
+
const $xeGantt = this
|
|
191
|
+
const props = $xeGantt
|
|
192
|
+
|
|
193
|
+
return Object.assign({}, getConfig().gantt.taskViewConfig, props.taskViewConfig)
|
|
194
|
+
},
|
|
195
|
+
computeTaskBarOpts () {
|
|
196
|
+
const $xeGantt = this
|
|
197
|
+
const props = $xeGantt
|
|
198
|
+
|
|
199
|
+
return Object.assign({}, getConfig().gantt.taskBarConfig, props.taskBarConfig)
|
|
200
|
+
},
|
|
201
|
+
computeTaskSplitOpts () {
|
|
202
|
+
const $xeGantt = this
|
|
203
|
+
const props = $xeGantt
|
|
204
|
+
|
|
205
|
+
return Object.assign({}, getConfig().gantt.taskSplitConfig, props.taskSplitConfig)
|
|
206
|
+
},
|
|
207
|
+
computeTitleField () {
|
|
208
|
+
const $xeGantt = this
|
|
209
|
+
|
|
210
|
+
const taskOpts = $xeGantt.computeTaskOpts as VxeGanttPropTypes.TaskConfig
|
|
211
|
+
return taskOpts.titleField || 'title'
|
|
212
|
+
},
|
|
213
|
+
computeStartField () {
|
|
214
|
+
const $xeGantt = this
|
|
215
|
+
|
|
216
|
+
const taskOpts = $xeGantt.computeTaskOpts as VxeGanttPropTypes.TaskConfig
|
|
217
|
+
return taskOpts.startField || 'start'
|
|
218
|
+
},
|
|
219
|
+
computeEndField () {
|
|
220
|
+
const $xeGantt = this
|
|
221
|
+
|
|
222
|
+
const taskOpts = $xeGantt.computeTaskOpts as VxeGanttPropTypes.TaskConfig
|
|
223
|
+
return taskOpts.endField || 'end'
|
|
224
|
+
},
|
|
225
|
+
computeProgressField () {
|
|
226
|
+
const $xeGantt = this
|
|
227
|
+
|
|
228
|
+
const taskOpts = $xeGantt.computeTaskOpts as VxeGanttPropTypes.TaskConfig
|
|
229
|
+
return taskOpts.progressField || 'progress'
|
|
230
|
+
},
|
|
231
|
+
computeScrollbarOpts () {
|
|
232
|
+
const $xeGantt = this
|
|
233
|
+
const props = $xeGantt
|
|
234
|
+
|
|
235
|
+
return Object.assign({}, getConfig().gantt.scrollbarConfig, props.scrollbarConfig)
|
|
236
|
+
},
|
|
237
|
+
computeScrollbarXToTop () {
|
|
238
|
+
const $xeGantt = this
|
|
239
|
+
|
|
240
|
+
const scrollbarOpts = $xeGantt.computeScrollbarOpts as VxeTablePropTypes.ScrollbarConfig
|
|
241
|
+
return !!(scrollbarOpts.x && scrollbarOpts.x.position === 'top')
|
|
242
|
+
},
|
|
243
|
+
computeScrollbarYToLeft () {
|
|
244
|
+
const $xeGantt = this
|
|
245
|
+
|
|
246
|
+
const scrollbarOpts = $xeGantt.computeScrollbarOpts as VxeTablePropTypes.ScrollbarConfig
|
|
247
|
+
return !!(scrollbarOpts.y && scrollbarOpts.y.position === 'left')
|
|
248
|
+
},
|
|
249
|
+
computeStyles () {
|
|
250
|
+
const $xeGantt = this
|
|
251
|
+
const props = $xeGantt
|
|
252
|
+
const reactData = $xeGantt.reactData
|
|
59
253
|
|
|
60
|
-
|
|
61
|
-
|
|
254
|
+
const { height, maxHeight } = props
|
|
255
|
+
const { isZMax, tZindex } = reactData
|
|
256
|
+
const taskViewOpts = $xeGantt.computeTaskViewOpts as VxeGanttPropTypes.TaskViewConfig
|
|
257
|
+
const { tableStyle } = taskViewOpts
|
|
258
|
+
const taskBarOpts = $xeGantt.computeTaskBarOpts as VxeGanttPropTypes.TaskBarConfig
|
|
259
|
+
const { barStyle } = taskBarOpts
|
|
260
|
+
const stys: VxeComponentStyleType = {}
|
|
261
|
+
if (isZMax) {
|
|
262
|
+
stys.zIndex = tZindex
|
|
263
|
+
} else {
|
|
264
|
+
if (height) {
|
|
265
|
+
stys.height = height === 'auto' || height === '100%' ? '100%' : toCssUnit(height)
|
|
266
|
+
}
|
|
267
|
+
if (maxHeight) {
|
|
268
|
+
stys.maxHeight = maxHeight === 'auto' || maxHeight === '100%' ? '100%' : toCssUnit(maxHeight)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (barStyle) {
|
|
272
|
+
const { bgColor, completedBgColor } = barStyle
|
|
273
|
+
if (bgColor) {
|
|
274
|
+
stys['--vxe-ui-gantt-view-task-bar-background-color'] = bgColor
|
|
275
|
+
}
|
|
276
|
+
if (completedBgColor) {
|
|
277
|
+
stys['--vxe-ui-gantt-view-task-bar-completed-background-color'] = completedBgColor
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (tableStyle) {
|
|
281
|
+
const { width: defTbWidth } = tableStyle
|
|
282
|
+
if (defTbWidth) {
|
|
283
|
+
stys['--vxe-ui-gantt-view-table-default-width'] = toCssUnit(defTbWidth)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return stys
|
|
287
|
+
},
|
|
288
|
+
computeTableExtendProps () {
|
|
289
|
+
const $xeGantt = this
|
|
290
|
+
const props = $xeGantt
|
|
291
|
+
|
|
292
|
+
const rest: any = {}
|
|
293
|
+
const gridProps: any = props
|
|
294
|
+
propKeys.forEach(key => {
|
|
295
|
+
rest[key] = gridProps[key]
|
|
296
|
+
})
|
|
297
|
+
return rest
|
|
298
|
+
},
|
|
299
|
+
computeTableProps () {
|
|
300
|
+
const $xeGantt = this
|
|
301
|
+
const props = $xeGantt
|
|
302
|
+
const reactData = $xeGantt.reactData
|
|
303
|
+
|
|
304
|
+
const { seqConfig, pagerConfig, editConfig, proxyConfig } = props
|
|
305
|
+
const { isZMax, tablePage } = reactData
|
|
306
|
+
const tableExtendProps = $xeGantt.computeTableExtendProps as any
|
|
307
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
308
|
+
const pagerOpts = $xeGantt.computePagerOpts
|
|
309
|
+
const isLoading = $xeGantt.computeIsLoading
|
|
310
|
+
const tProps = Object.assign({}, tableExtendProps)
|
|
311
|
+
if (isZMax) {
|
|
312
|
+
if (tableExtendProps.maxHeight) {
|
|
313
|
+
tProps.maxHeight = '100%'
|
|
314
|
+
} else {
|
|
315
|
+
tProps.height = '100%'
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
319
|
+
tProps.loading = isLoading
|
|
320
|
+
if (pagerConfig && proxyOpts.seq && isEnableConf(pagerOpts)) {
|
|
321
|
+
tProps.seqConfig = Object.assign({}, seqConfig, { startIndex: (tablePage.currentPage - 1) * tablePage.pageSize })
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (editConfig) {
|
|
325
|
+
tProps.editConfig = Object.assign({}, editConfig)
|
|
326
|
+
}
|
|
327
|
+
return tProps
|
|
328
|
+
},
|
|
329
|
+
tableProps () {
|
|
330
|
+
const $xeGantt = this
|
|
331
|
+
|
|
332
|
+
return $xeGantt.computeTableProps
|
|
333
|
+
},
|
|
334
|
+
computeCurrLayoutConf () {
|
|
335
|
+
const $xeGantt = this
|
|
336
|
+
const props = $xeGantt
|
|
337
|
+
|
|
338
|
+
const { layouts } = props
|
|
339
|
+
let confs: VxeGanttPropTypes.Layouts = []
|
|
340
|
+
if (layouts && layouts.length) {
|
|
341
|
+
confs = layouts
|
|
342
|
+
} else {
|
|
343
|
+
confs = getConfig().gantt.layouts || defaultLayouts
|
|
344
|
+
}
|
|
345
|
+
let headKeys: VxeGanttDefines.LayoutKey[] = []
|
|
346
|
+
let bodyKeys: VxeGanttDefines.LayoutKey[] = []
|
|
347
|
+
let footKeys: VxeGanttDefines.LayoutKey[] = []
|
|
348
|
+
if (confs.length) {
|
|
349
|
+
if (XEUtils.isArray(confs[0])) {
|
|
350
|
+
headKeys = confs[0] as VxeGanttDefines.LayoutKey[]
|
|
351
|
+
bodyKeys = (confs[1] || []) as VxeGanttDefines.LayoutKey[]
|
|
352
|
+
footKeys = (confs[2] || []) as VxeGanttDefines.LayoutKey[]
|
|
353
|
+
} else {
|
|
354
|
+
bodyKeys = confs as VxeGanttDefines.LayoutKey[]
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return {
|
|
358
|
+
headKeys,
|
|
359
|
+
bodyKeys,
|
|
360
|
+
footKeys
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
computeCustomCurrentPageFlag () {
|
|
364
|
+
const $xeGantt = this
|
|
365
|
+
|
|
366
|
+
const pagerOpts = $xeGantt.computePagerOpts as VxeGanttPropTypes.PagerConfig
|
|
367
|
+
return pagerOpts.currentPage
|
|
368
|
+
},
|
|
369
|
+
computeCustomPageSizeFlag () {
|
|
370
|
+
const $xeGantt = this
|
|
371
|
+
|
|
372
|
+
const pagerOpts = $xeGantt.computePagerOpts as VxeGanttPropTypes.PagerConfig
|
|
373
|
+
return pagerOpts.pageSize
|
|
374
|
+
},
|
|
375
|
+
computeCustomTotalFlag () {
|
|
376
|
+
const $xeGantt = this
|
|
377
|
+
|
|
378
|
+
const pagerOpts = $xeGantt.computePagerOpts as VxeGanttPropTypes.PagerConfig
|
|
379
|
+
return pagerOpts.total
|
|
380
|
+
},
|
|
381
|
+
computePageCount () {
|
|
382
|
+
const $xeGantt = this
|
|
383
|
+
const reactData = ($xeGantt as any).reactData
|
|
384
|
+
|
|
385
|
+
const { tablePage } = reactData
|
|
386
|
+
return Math.max(Math.ceil(tablePage.total / tablePage.pageSize), 1)
|
|
387
|
+
},
|
|
388
|
+
computeIsLoading () {
|
|
389
|
+
const $xeGantt = this
|
|
390
|
+
const props = $xeGantt
|
|
391
|
+
const reactData = ($xeGantt as any).reactData
|
|
392
|
+
|
|
393
|
+
const { loading, proxyConfig } = props
|
|
394
|
+
const { tableLoading } = reactData
|
|
395
|
+
const proxyOpts = $xeGantt.computeProxyOpts as VxeGanttPropTypes.ProxyConfig
|
|
396
|
+
const { showLoading } = proxyOpts
|
|
397
|
+
return loading || (tableLoading && showLoading && proxyConfig && isEnableConf(proxyOpts))
|
|
398
|
+
},
|
|
399
|
+
computeTableBorder () {
|
|
400
|
+
const $xeGantt = this
|
|
401
|
+
const props = $xeGantt
|
|
402
|
+
|
|
403
|
+
const { border } = props
|
|
404
|
+
if (border === true) {
|
|
405
|
+
return 'full'
|
|
406
|
+
}
|
|
407
|
+
if (border) {
|
|
408
|
+
return border
|
|
409
|
+
}
|
|
410
|
+
return 'default'
|
|
62
411
|
}
|
|
412
|
+
},
|
|
413
|
+
watch: {
|
|
414
|
+
columns () {
|
|
415
|
+
const $xeGantt = this
|
|
416
|
+
const props = $xeGantt
|
|
417
|
+
|
|
418
|
+
$xeGantt.$nextTick(() => $xeGantt.loadColumn(props.columns || []))
|
|
419
|
+
},
|
|
420
|
+
toolbarConfig () {
|
|
421
|
+
const $xeGantt = this
|
|
422
|
+
|
|
423
|
+
$xeGantt.initToolbar()
|
|
424
|
+
},
|
|
425
|
+
computeCustomCurrentPageFlag () {
|
|
426
|
+
const $xeGantt = this
|
|
427
|
+
|
|
428
|
+
$xeGantt.initPages('currentPage')
|
|
429
|
+
},
|
|
430
|
+
computeCustomPageSizeFlag () {
|
|
431
|
+
const $xeGantt = this
|
|
432
|
+
|
|
433
|
+
$xeGantt.initPages('pageSize')
|
|
434
|
+
},
|
|
435
|
+
computeCustomTotalFlag () {
|
|
436
|
+
const $xeGantt = this
|
|
63
437
|
|
|
64
|
-
|
|
438
|
+
$xeGantt.initPages('total')
|
|
439
|
+
},
|
|
440
|
+
proxyConfig () {
|
|
441
|
+
const $xeGantt = this
|
|
442
|
+
|
|
443
|
+
$xeGantt.initProxy()
|
|
65
444
|
}
|
|
445
|
+
},
|
|
446
|
+
methods: {
|
|
447
|
+
...tableMethods,
|
|
448
|
+
dispatchEvent (type: ValueOf<VxeGanttEmits>, params: Record<string, any>, evnt: Event | null) {
|
|
449
|
+
const $xeGantt = this
|
|
450
|
+
|
|
451
|
+
$xeGantt.$emit(type, createEvent(evnt, { $grid: null, $gantt: $xeGantt }, params))
|
|
452
|
+
},
|
|
453
|
+
initToolbar () {
|
|
454
|
+
const $xeGantt = this
|
|
455
|
+
|
|
456
|
+
$xeGantt.$nextTick(() => {
|
|
457
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
458
|
+
const $xeToolbar = $xeGantt.$refs.refToolbar as VxeToolbarInstance
|
|
459
|
+
if ($xeTable && $xeToolbar) {
|
|
460
|
+
$xeTable.connectToolbar($xeToolbar)
|
|
461
|
+
}
|
|
462
|
+
})
|
|
463
|
+
},
|
|
464
|
+
initGanttView () {
|
|
465
|
+
const $xeGantt = this
|
|
466
|
+
|
|
467
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
468
|
+
const $ganttView = $xeGantt.$refs.refGanttView as VxeGanttViewInstance
|
|
469
|
+
if ($xeTable && $ganttView) {
|
|
470
|
+
$xeTable.handleConnectGanttView($ganttView)
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
initPages (propKey?: 'currentPage' | 'pageSize' | 'total') {
|
|
474
|
+
const $xeGantt = this
|
|
475
|
+
const props = $xeGantt
|
|
476
|
+
const reactData = $xeGantt.reactData
|
|
477
|
+
|
|
478
|
+
const { tablePage } = reactData
|
|
479
|
+
const { pagerConfig } = props
|
|
480
|
+
const pagerOpts = $xeGantt.computePagerOpts
|
|
481
|
+
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
482
|
+
if (propKey) {
|
|
483
|
+
if (pagerOpts[propKey]) {
|
|
484
|
+
tablePage[propKey] = XEUtils.toNumber(pagerOpts[propKey])
|
|
485
|
+
}
|
|
486
|
+
} else {
|
|
487
|
+
const { currentPage, pageSize, total } = pagerOpts
|
|
488
|
+
if (currentPage) {
|
|
489
|
+
tablePage.currentPage = currentPage
|
|
490
|
+
}
|
|
491
|
+
if (pageSize) {
|
|
492
|
+
tablePage.pageSize = pageSize
|
|
493
|
+
}
|
|
494
|
+
if (total) {
|
|
495
|
+
tablePage.total = total
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
triggerPendingEvent (code: string) {
|
|
501
|
+
const $xeGantt = this
|
|
502
|
+
|
|
503
|
+
const isActiveMsg = $xeGantt.computeIsActiveMsg
|
|
504
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
505
|
+
const selectRecords = $xeTable.getCheckboxRecords()
|
|
506
|
+
if (selectRecords.length) {
|
|
507
|
+
$xeTable.togglePendingRow(selectRecords)
|
|
508
|
+
$xeGantt.clearCheckboxRow()
|
|
509
|
+
} else {
|
|
510
|
+
if (isActiveMsg) {
|
|
511
|
+
if (VxeUI.modal) {
|
|
512
|
+
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' })
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
getRespMsg (rest: any, defaultMsg: string) {
|
|
518
|
+
const $xeGantt = this
|
|
519
|
+
|
|
520
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
521
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {}
|
|
522
|
+
const messageProp = resConfigs.message
|
|
523
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
524
|
+
let msg
|
|
525
|
+
if (rest && messageProp) {
|
|
526
|
+
msg = XEUtils.isFunction(messageProp) ? messageProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, messageProp)
|
|
527
|
+
}
|
|
528
|
+
return msg || getI18n(defaultMsg)
|
|
529
|
+
},
|
|
530
|
+
handleDeleteRow (code: string, alertKey: string, callback: () => void): Promise<void> {
|
|
531
|
+
const $xeGantt = this
|
|
532
|
+
|
|
533
|
+
const isActiveMsg = $xeGantt.computeIsActiveMsg
|
|
534
|
+
const selectRecords = $xeGantt.getCheckboxRecords()
|
|
535
|
+
if (isActiveMsg) {
|
|
536
|
+
if (selectRecords.length) {
|
|
537
|
+
if (VxeUI.modal) {
|
|
538
|
+
return VxeUI.modal.confirm({ id: `cfm_${code}`, content: getI18n(alertKey), escClosable: true }).then((type) => {
|
|
539
|
+
if (type === 'confirm') {
|
|
540
|
+
return callback()
|
|
541
|
+
}
|
|
542
|
+
})
|
|
543
|
+
}
|
|
544
|
+
} else {
|
|
545
|
+
if (VxeUI.modal) {
|
|
546
|
+
VxeUI.modal.message({ id: `msg_${code}`, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' })
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
} else {
|
|
550
|
+
if (selectRecords.length) {
|
|
551
|
+
callback()
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return Promise.resolve()
|
|
555
|
+
},
|
|
556
|
+
pageChangeEvent (params: VxePagerDefines.PageChangeEventParams) {
|
|
557
|
+
const $xeGantt = this
|
|
558
|
+
const props = $xeGantt
|
|
559
|
+
const reactData = $xeGantt.reactData
|
|
560
|
+
|
|
561
|
+
const { proxyConfig } = props
|
|
562
|
+
const { tablePage } = reactData
|
|
563
|
+
const { $event, currentPage, pageSize } = params
|
|
564
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
565
|
+
tablePage.currentPage = currentPage
|
|
566
|
+
tablePage.pageSize = pageSize
|
|
567
|
+
$xeGantt.dispatchEvent('page-change', params, $event)
|
|
568
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
569
|
+
$xeGantt.commitProxy('query').then((rest) => {
|
|
570
|
+
$xeGantt.dispatchEvent('proxy-query', rest, $event)
|
|
571
|
+
})
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
handleSortEvent (params: VxeTableDefines.SortChangeEventParams) {
|
|
575
|
+
const $xeGantt = this
|
|
576
|
+
const props = $xeGantt
|
|
577
|
+
const reactData = $xeGantt.reactData
|
|
578
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
579
|
+
|
|
580
|
+
const { proxyConfig } = props
|
|
581
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
582
|
+
const sortOpts = $xeTable.computeSortOpts
|
|
583
|
+
// 如果是服务端排序
|
|
584
|
+
if (sortOpts.remote) {
|
|
585
|
+
reactData.sortData = params.sortList
|
|
586
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
587
|
+
reactData.tablePage.currentPage = 1
|
|
588
|
+
$xeGantt.commitProxy('query').then((rest) => {
|
|
589
|
+
$xeGantt.dispatchEvent('proxy-query', rest, params.$event)
|
|
590
|
+
})
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
sortChangeEvent (params: VxeTableDefines.SortChangeEventParams) {
|
|
595
|
+
const $xeGantt = this
|
|
596
|
+
|
|
597
|
+
$xeGantt.handleSortEvent(params)
|
|
598
|
+
$xeGantt.dispatchEvent('sort-change', params, params.$event)
|
|
599
|
+
},
|
|
600
|
+
clearAllSortEvent (params: VxeTableDefines.SortChangeEventParams) {
|
|
601
|
+
const $xeGantt = this
|
|
602
|
+
|
|
603
|
+
$xeGantt.handleSortEvent(params)
|
|
604
|
+
$xeGantt.dispatchEvent('clear-all-sort', params, params.$event)
|
|
605
|
+
},
|
|
606
|
+
handleFilterEvent (params: VxeTableDefines.ClearAllFilterEventParams) {
|
|
607
|
+
const $xeGantt = this
|
|
608
|
+
const props = $xeGantt
|
|
609
|
+
const reactData = $xeGantt.reactData
|
|
610
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
611
|
+
|
|
612
|
+
const { proxyConfig } = props
|
|
613
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
614
|
+
const filterOpts = $xeTable.computeFilterOpts
|
|
615
|
+
// 如果是服务端过滤
|
|
616
|
+
if (filterOpts.remote) {
|
|
617
|
+
reactData.filterData = params.filterList
|
|
618
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
619
|
+
reactData.tablePage.currentPage = 1
|
|
620
|
+
$xeGantt.commitProxy('query').then((rest) => {
|
|
621
|
+
$xeGantt.dispatchEvent('proxy-query', rest, params.$event)
|
|
622
|
+
})
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
filterChangeEvent (params: VxeTableDefines.ClearAllFilterEventParams) {
|
|
627
|
+
const $xeGantt = this
|
|
628
|
+
|
|
629
|
+
$xeGantt.handleFilterEvent(params)
|
|
630
|
+
$xeGantt.dispatchEvent('filter-change', params, params.$event)
|
|
631
|
+
},
|
|
632
|
+
clearAllFilterEvent (params: VxeTableDefines.ClearAllFilterEventParams) {
|
|
633
|
+
const $xeGantt = this
|
|
634
|
+
|
|
635
|
+
$xeGantt.handleFilterEvent(params)
|
|
636
|
+
$xeGantt.dispatchEvent('clear-all-filter', params, params.$event)
|
|
637
|
+
},
|
|
638
|
+
submitFormEvent (params: VxeFormDefines.SubmitEventParams) {
|
|
639
|
+
const $xeGantt = this
|
|
640
|
+
const props = $xeGantt
|
|
641
|
+
const reactData = $xeGantt.reactData
|
|
642
|
+
|
|
643
|
+
const { proxyConfig } = props
|
|
644
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
645
|
+
if (reactData.tableLoading) {
|
|
646
|
+
return
|
|
647
|
+
}
|
|
648
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
649
|
+
$xeGantt.commitProxy('reload').then((rest) => {
|
|
650
|
+
$xeGantt.dispatchEvent('proxy-query', { ...rest, isReload: true }, params.$event)
|
|
651
|
+
})
|
|
652
|
+
}
|
|
653
|
+
$xeGantt.dispatchEvent('form-submit', params, params.$event)
|
|
654
|
+
},
|
|
655
|
+
resetFormEvent (params: VxeFormDefines.ResetEventParams) {
|
|
656
|
+
const $xeGantt = this
|
|
657
|
+
const props = $xeGantt
|
|
658
|
+
|
|
659
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
660
|
+
const { proxyConfig } = props
|
|
661
|
+
const { $event } = params
|
|
662
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
663
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
664
|
+
$xeTable.clearScroll()
|
|
665
|
+
$xeGantt.commitProxy('reload').then((rest) => {
|
|
666
|
+
$xeGantt.dispatchEvent('proxy-query', { ...rest, isReload: true }, $event)
|
|
667
|
+
})
|
|
668
|
+
}
|
|
669
|
+
$xeGantt.dispatchEvent('form-reset', params, $event)
|
|
670
|
+
},
|
|
671
|
+
submitInvalidEvent (params: VxeFormDefines.SubmitInvalidEventParams) {
|
|
672
|
+
const $xeGantt = this
|
|
673
|
+
|
|
674
|
+
$xeGantt.dispatchEvent('form-submit-invalid', params, params.$event)
|
|
675
|
+
},
|
|
676
|
+
collapseEvent (params: VxeFormDefines.CollapseEventParams) {
|
|
677
|
+
const $xeGantt = this
|
|
678
|
+
|
|
679
|
+
const { $event } = params
|
|
680
|
+
$xeGantt.dispatchEvent('form-toggle-collapse', params, $event)
|
|
681
|
+
$xeGantt.dispatchEvent('form-collapse', params, $event)
|
|
682
|
+
},
|
|
683
|
+
handleZoom (isMax?: boolean) {
|
|
684
|
+
const $xeGantt = this
|
|
685
|
+
const reactData = $xeGantt.reactData
|
|
686
|
+
|
|
687
|
+
const { isZMax } = reactData
|
|
688
|
+
if (isMax ? !isZMax : isZMax) {
|
|
689
|
+
reactData.isZMax = !isZMax
|
|
690
|
+
if (reactData.tZindex < getLastZIndex()) {
|
|
691
|
+
reactData.tZindex = nextZIndex()
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return $xeGantt.$nextTick()
|
|
695
|
+
.then(() => $xeGantt.recalculate(true))
|
|
696
|
+
.then(() => {
|
|
697
|
+
setTimeout(() => $xeGantt.recalculate(true), 15)
|
|
698
|
+
return reactData.isZMax
|
|
699
|
+
})
|
|
700
|
+
},
|
|
701
|
+
dragSplitEvent (evnt: MouseEvent) {
|
|
702
|
+
const $xeGantt = this
|
|
703
|
+
|
|
704
|
+
const el = $xeGantt.$refs.refElem as HTMLDivElement
|
|
705
|
+
if (!el) {
|
|
706
|
+
return
|
|
707
|
+
}
|
|
708
|
+
const ganttContainerEl = $xeGantt.$refs.refGanttContainer as HTMLDivElement
|
|
709
|
+
if (!ganttContainerEl) {
|
|
710
|
+
return
|
|
711
|
+
}
|
|
712
|
+
const tableWrapperEl = $xeGantt.$refs.refTableWrapper as HTMLDivElement
|
|
713
|
+
if (!tableWrapperEl) {
|
|
714
|
+
return
|
|
715
|
+
}
|
|
716
|
+
const rsSplitLineEl = $xeGantt.$refs.refResizableSplitTip as HTMLDivElement
|
|
717
|
+
if (!rsSplitLineEl) {
|
|
718
|
+
return
|
|
719
|
+
}
|
|
720
|
+
const taskViewOpts = $xeGantt.computeTaskViewOpts
|
|
721
|
+
const containerRect = ganttContainerEl.getBoundingClientRect()
|
|
722
|
+
const rsSplitTipEl = rsSplitLineEl.children[0] as HTMLDivElement
|
|
723
|
+
const disX = evnt.clientX
|
|
724
|
+
const ganttWidth = ganttContainerEl.clientWidth
|
|
725
|
+
const tableWidth = tableWrapperEl.clientWidth
|
|
726
|
+
const tableMinWidth = (taskViewOpts.tableStyle && XEUtils.toNumber(taskViewOpts.tableStyle.minWidth)) || 80
|
|
727
|
+
let targetTableWidth = tableWidth
|
|
728
|
+
let offsetLeft = -1
|
|
729
|
+
addClass(el, 'is--split-drag')
|
|
730
|
+
|
|
731
|
+
const handleReStyle = (evnt: MouseEvent) => {
|
|
732
|
+
const rsNumLeftEl = rsSplitTipEl.children[0] as HTMLDivElement
|
|
733
|
+
const rsNumRightEl = rsSplitTipEl.children[1] as HTMLDivElement
|
|
734
|
+
let tipHeight = 0
|
|
735
|
+
if (rsNumLeftEl) {
|
|
736
|
+
if (offsetLeft < 0) {
|
|
737
|
+
rsNumLeftEl.textContent = `${targetTableWidth}px`
|
|
738
|
+
rsNumLeftEl.style.display = 'block'
|
|
739
|
+
tipHeight = rsNumLeftEl.offsetHeight
|
|
740
|
+
} else {
|
|
741
|
+
rsNumLeftEl.style.display = 'none'
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (rsNumRightEl) {
|
|
745
|
+
if (offsetLeft < 0) {
|
|
746
|
+
rsNumRightEl.style.display = 'none'
|
|
747
|
+
} else {
|
|
748
|
+
rsNumRightEl.textContent = `${Math.floor(containerRect.width - targetTableWidth)}px`
|
|
749
|
+
rsNumRightEl.style.display = 'block'
|
|
750
|
+
tipHeight = rsNumRightEl.offsetHeight
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
const tipTop = evnt.clientY - containerRect.top - tipHeight / 2
|
|
754
|
+
rsSplitLineEl.style.left = `${targetTableWidth}px`
|
|
755
|
+
rsSplitTipEl.style.top = `${Math.min(containerRect.height - tipHeight - 1, Math.max(1, tipTop))}px`
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
document.onmousemove = (evnt) => {
|
|
759
|
+
evnt.preventDefault()
|
|
760
|
+
offsetLeft = (evnt.clientX - disX)
|
|
761
|
+
targetTableWidth = Math.min(ganttWidth - 80, Math.max(tableMinWidth, tableWidth + offsetLeft))
|
|
762
|
+
handleReStyle(evnt)
|
|
763
|
+
}
|
|
764
|
+
document.onmouseup = () => {
|
|
765
|
+
document.onmousemove = null
|
|
766
|
+
document.onmouseup = null
|
|
767
|
+
rsSplitLineEl.style.display = ''
|
|
768
|
+
tableWrapperEl.style.width = `${targetTableWidth}px`
|
|
769
|
+
removeClass(el, 'is--split-drag')
|
|
770
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
771
|
+
if ($xeTable) {
|
|
772
|
+
$xeTable.recalculate(true)
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
rsSplitLineEl.style.display = 'block'
|
|
776
|
+
handleReStyle(evnt)
|
|
777
|
+
},
|
|
778
|
+
handleSplitLeftViewEvent () {
|
|
779
|
+
const $xeGantt = this
|
|
780
|
+
const reactData = $xeGantt.reactData
|
|
66
781
|
|
|
67
|
-
|
|
782
|
+
reactData.showLeftView = !reactData.showLeftView
|
|
783
|
+
},
|
|
784
|
+
handleSplitRightViewEvent () {
|
|
785
|
+
const $xeGantt = this
|
|
786
|
+
const reactData = $xeGantt.reactData
|
|
68
787
|
|
|
69
|
-
|
|
788
|
+
reactData.showRightView = !reactData.showRightView
|
|
789
|
+
},
|
|
790
|
+
getDefaultFormData () {
|
|
791
|
+
const $xeGantt = this
|
|
792
|
+
|
|
793
|
+
const formOpts = $xeGantt.computeFormOpts
|
|
794
|
+
if (formOpts.items) {
|
|
795
|
+
const fData: any = {}
|
|
796
|
+
formOpts.items.forEach(item => {
|
|
797
|
+
const { field, itemRender } = item
|
|
798
|
+
if (field) {
|
|
799
|
+
let itemValue: any = null
|
|
800
|
+
if (itemRender) {
|
|
801
|
+
const { defaultValue } = itemRender
|
|
802
|
+
if (XEUtils.isFunction(defaultValue)) {
|
|
803
|
+
itemValue = defaultValue({ item })
|
|
804
|
+
} else if (!XEUtils.isUndefined(defaultValue)) {
|
|
805
|
+
itemValue = defaultValue
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
fData[field] = itemValue
|
|
809
|
+
}
|
|
810
|
+
})
|
|
811
|
+
return fData
|
|
812
|
+
}
|
|
813
|
+
return {}
|
|
814
|
+
},
|
|
815
|
+
initProxy () {
|
|
816
|
+
const $xeGantt = this
|
|
817
|
+
const props = $xeGantt
|
|
818
|
+
const reactData = $xeGantt.reactData
|
|
819
|
+
|
|
820
|
+
const { proxyConfig, formConfig } = props
|
|
821
|
+
const { proxyInited } = reactData
|
|
822
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
823
|
+
const formOpts = $xeGantt.computeFormOpts
|
|
824
|
+
if (proxyConfig) {
|
|
825
|
+
if (isEnableConf(formConfig) && proxyOpts.form && formOpts.items) {
|
|
826
|
+
reactData.formData = $xeGantt.getDefaultFormData()
|
|
827
|
+
}
|
|
828
|
+
if (!proxyInited && proxyOpts.autoLoad !== false) {
|
|
829
|
+
reactData.proxyInited = true
|
|
830
|
+
$xeGantt.$nextTick().then(() => $xeGantt.commitProxy('initial')).then((rest) => {
|
|
831
|
+
$xeGantt.dispatchEvent('proxy-query', { ...rest, isInited: true }, new Event('initial'))
|
|
832
|
+
})
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
handleGlobalKeydownEvent (evnt: KeyboardEvent) {
|
|
837
|
+
const $xeGantt = this
|
|
838
|
+
const reactData = $xeGantt.reactData
|
|
839
|
+
|
|
840
|
+
const zoomOpts = $xeGantt.computeZoomOpts
|
|
841
|
+
const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE)
|
|
842
|
+
if (isEsc && reactData.isZMax && zoomOpts.escRestore !== false) {
|
|
843
|
+
$xeGantt.triggerZoomEvent(evnt)
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
getEl () {
|
|
847
|
+
const $xeGantt = this
|
|
848
|
+
|
|
849
|
+
return $xeGantt.$refs.refElem as HTMLDivElement
|
|
850
|
+
},
|
|
851
|
+
/**
|
|
852
|
+
* 提交指令,支持 code 或 button
|
|
853
|
+
* @param {String/Object} code 字符串或对象
|
|
854
|
+
*/
|
|
855
|
+
commitProxy (proxyTarget: string | VxeToolbarPropTypes.ButtonConfig, ...args: any[]): Promise<any> {
|
|
856
|
+
const $xeGantt = this
|
|
857
|
+
const props = $xeGantt
|
|
858
|
+
const reactData = $xeGantt.reactData
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* 已废弃
|
|
862
|
+
* @deprecated
|
|
863
|
+
*/
|
|
864
|
+
const toolbar = (props as any).toolbar
|
|
865
|
+
|
|
866
|
+
const { proxyConfig, toolbarConfig, pagerConfig, editRules, validConfig } = props
|
|
867
|
+
const { tablePage } = reactData
|
|
868
|
+
const isActiveMsg = $xeGantt.computeIsActiveMsg
|
|
869
|
+
const isRespMsg = $xeGantt.computeIsRespMsg
|
|
870
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
871
|
+
const pagerOpts = $xeGantt.computePagerOpts
|
|
872
|
+
const toolbarOpts = $xeGantt.computeToolbarOpts
|
|
873
|
+
const { beforeQuery, afterQuery, beforeDelete, afterDelete, beforeSave, afterSave, ajax = {} } = proxyOpts
|
|
874
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {}
|
|
875
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
876
|
+
let formData = $xeGantt.getFormData()
|
|
877
|
+
let button: VxeToolbarPropTypes.ButtonConfig | null = null
|
|
878
|
+
let code: string | null = null
|
|
879
|
+
if (XEUtils.isString(proxyTarget)) {
|
|
880
|
+
const { buttons } = toolbarOpts
|
|
881
|
+
const matchObj = (toolbarConfig || toolbar) && isEnableConf(toolbarOpts) && buttons ? XEUtils.findTree(buttons, (item) => item.code === proxyTarget, { children: 'dropdowns' }) : null
|
|
882
|
+
button = matchObj ? matchObj.item as any : null
|
|
883
|
+
code = proxyTarget
|
|
884
|
+
} else {
|
|
885
|
+
button = proxyTarget
|
|
886
|
+
code = button.code as string
|
|
887
|
+
}
|
|
888
|
+
const btnParams = button ? button.params : null
|
|
889
|
+
switch (code) {
|
|
890
|
+
case 'insert':
|
|
891
|
+
return $xeTable.insert({})
|
|
892
|
+
case 'insert_edit':
|
|
893
|
+
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true))
|
|
894
|
+
|
|
895
|
+
// 已废弃
|
|
896
|
+
case 'insert_actived':
|
|
897
|
+
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true))
|
|
898
|
+
// 已废弃
|
|
899
|
+
|
|
900
|
+
case 'mark_cancel':
|
|
901
|
+
$xeGantt.triggerPendingEvent(code)
|
|
902
|
+
break
|
|
903
|
+
case 'remove':
|
|
904
|
+
return $xeGantt.handleDeleteRow(code, 'vxe.grid.removeSelectRecord', () => $xeTable.removeCheckboxRow())
|
|
905
|
+
case 'import':
|
|
906
|
+
$xeTable.importData(btnParams)
|
|
907
|
+
break
|
|
908
|
+
case 'open_import':
|
|
909
|
+
$xeTable.openImport(btnParams)
|
|
910
|
+
break
|
|
911
|
+
case 'export':
|
|
912
|
+
$xeTable.exportData(btnParams)
|
|
913
|
+
break
|
|
914
|
+
case 'open_export':
|
|
915
|
+
$xeTable.openExport(btnParams)
|
|
916
|
+
break
|
|
917
|
+
case 'reset_custom':
|
|
918
|
+
$xeTable.resetCustom(true)
|
|
919
|
+
break
|
|
920
|
+
case 'initial':
|
|
921
|
+
case 'reload':
|
|
922
|
+
case 'query': {
|
|
923
|
+
const ajaxMethods = ajax.query
|
|
924
|
+
const querySuccessMethods = ajax.querySuccess
|
|
925
|
+
const queryErrorMethods = ajax.queryError
|
|
926
|
+
if (ajaxMethods) {
|
|
927
|
+
const isInited = code === 'initial'
|
|
928
|
+
const isReload = code === 'reload'
|
|
929
|
+
if (!isInited && reactData.tableLoading) {
|
|
930
|
+
return $xeGantt.$nextTick()
|
|
931
|
+
}
|
|
932
|
+
let sortList: any[] = []
|
|
933
|
+
let filterList: VxeTableDefines.FilterCheckedParams[] = []
|
|
934
|
+
let pageParams: any = {}
|
|
935
|
+
if (pagerConfig) {
|
|
936
|
+
if (isInited || isReload) {
|
|
937
|
+
tablePage.currentPage = 1
|
|
938
|
+
}
|
|
939
|
+
if (isEnableConf(pagerConfig)) {
|
|
940
|
+
pageParams = { ...tablePage }
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (isInited) {
|
|
944
|
+
// 重置代理表单数据
|
|
945
|
+
if (proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form) {
|
|
946
|
+
formData = $xeGantt.getDefaultFormData()
|
|
947
|
+
reactData.formData = formData
|
|
948
|
+
}
|
|
949
|
+
if ($xeTable) {
|
|
950
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
951
|
+
const { tableFullColumn, fullColumnFieldData } = tableInternalData
|
|
952
|
+
const sortOpts = $xeTable.computeSortOpts
|
|
953
|
+
let defaultSort = sortOpts.defaultSort
|
|
954
|
+
tableFullColumn.forEach((column) => {
|
|
955
|
+
column.order = null
|
|
956
|
+
})
|
|
957
|
+
// 如果使用默认排序
|
|
958
|
+
if (defaultSort) {
|
|
959
|
+
if (!XEUtils.isArray(defaultSort)) {
|
|
960
|
+
defaultSort = [defaultSort]
|
|
961
|
+
}
|
|
962
|
+
sortList = defaultSort.map((item) => {
|
|
963
|
+
const { field, order } = item
|
|
964
|
+
const colRest = fullColumnFieldData[field]
|
|
965
|
+
if (colRest) {
|
|
966
|
+
const column = colRest.column
|
|
967
|
+
if (column) {
|
|
968
|
+
column.order = order
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return {
|
|
972
|
+
field,
|
|
973
|
+
property: field,
|
|
974
|
+
order
|
|
975
|
+
}
|
|
976
|
+
})
|
|
977
|
+
}
|
|
978
|
+
filterList = $xeTable.getCheckedFilters()
|
|
979
|
+
}
|
|
980
|
+
} else {
|
|
981
|
+
if ($xeTable) {
|
|
982
|
+
if (isReload) {
|
|
983
|
+
$xeTable.clearAll()
|
|
984
|
+
} else {
|
|
985
|
+
sortList = $xeTable.getSortColumns()
|
|
986
|
+
filterList = $xeTable.getCheckedFilters()
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
const commitParams = {
|
|
991
|
+
$table: $xeTable,
|
|
992
|
+
$grid: null,
|
|
993
|
+
$gantt: $xeGantt,
|
|
994
|
+
code,
|
|
995
|
+
button,
|
|
996
|
+
isInited,
|
|
997
|
+
isReload,
|
|
998
|
+
page: pageParams,
|
|
999
|
+
sort: sortList.length ? sortList[0] : {},
|
|
1000
|
+
sorts: sortList,
|
|
1001
|
+
filters: filterList,
|
|
1002
|
+
form: formData,
|
|
1003
|
+
options: ajaxMethods
|
|
1004
|
+
}
|
|
1005
|
+
reactData.sortData = sortList
|
|
1006
|
+
reactData.filterData = filterList
|
|
1007
|
+
reactData.tableLoading = true
|
|
1008
|
+
const applyArgs = [commitParams].concat(args)
|
|
1009
|
+
return Promise.resolve((beforeQuery || ajaxMethods)(...applyArgs))
|
|
1010
|
+
.then(rest => {
|
|
1011
|
+
let tableData: any[] = []
|
|
1012
|
+
reactData.tableLoading = false
|
|
1013
|
+
if (rest) {
|
|
1014
|
+
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
1015
|
+
const totalProp = resConfigs.total
|
|
1016
|
+
const total = (XEUtils.isFunction(totalProp) ? totalProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, totalProp || 'page.total')) || 0
|
|
1017
|
+
tablePage.total = XEUtils.toNumber(total)
|
|
1018
|
+
const resultProp = resConfigs.result
|
|
1019
|
+
tableData = (XEUtils.isFunction(resultProp) ? resultProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, resultProp || 'result')) || []
|
|
1020
|
+
// 检验当前页码,不能超出当前最大页数
|
|
1021
|
+
const pageCount = Math.max(Math.ceil(total / tablePage.pageSize), 1)
|
|
1022
|
+
if (tablePage.currentPage > pageCount) {
|
|
1023
|
+
tablePage.currentPage = pageCount
|
|
1024
|
+
}
|
|
1025
|
+
} else {
|
|
1026
|
+
const listProp = resConfigs.list
|
|
1027
|
+
tableData = (listProp ? (XEUtils.isFunction(listProp) ? listProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, listProp)) : rest) || []
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
if ($xeTable as any) {
|
|
1031
|
+
$xeTable.loadData(tableData)
|
|
1032
|
+
} else {
|
|
1033
|
+
$xeTable.$nextTick(() => {
|
|
1034
|
+
if ($xeTable) {
|
|
1035
|
+
$xeTable.loadData(tableData)
|
|
1036
|
+
}
|
|
1037
|
+
})
|
|
1038
|
+
}
|
|
1039
|
+
if (afterQuery) {
|
|
1040
|
+
afterQuery(...applyArgs)
|
|
1041
|
+
}
|
|
1042
|
+
if (querySuccessMethods) {
|
|
1043
|
+
querySuccessMethods({ ...commitParams, response: rest })
|
|
1044
|
+
}
|
|
1045
|
+
return { status: true }
|
|
1046
|
+
}).catch((rest) => {
|
|
1047
|
+
reactData.tableLoading = false
|
|
1048
|
+
if (queryErrorMethods) {
|
|
1049
|
+
queryErrorMethods({ ...commitParams, response: rest })
|
|
1050
|
+
}
|
|
1051
|
+
return { status: false }
|
|
1052
|
+
})
|
|
1053
|
+
} else {
|
|
1054
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.query'])
|
|
1055
|
+
}
|
|
1056
|
+
break
|
|
1057
|
+
}
|
|
1058
|
+
case 'delete': {
|
|
1059
|
+
const ajaxMethods = ajax.delete
|
|
1060
|
+
const deleteSuccessMethods = ajax.deleteSuccess
|
|
1061
|
+
const deleteErrorMethods = ajax.deleteError
|
|
1062
|
+
if (ajaxMethods) {
|
|
1063
|
+
const selectRecords = $xeTable.getCheckboxRecords()
|
|
1064
|
+
const removeRecords = selectRecords.filter((row) => !$xeTable.isInsertByRow(row))
|
|
1065
|
+
const body = { removeRecords }
|
|
1066
|
+
const commitParams = {
|
|
1067
|
+
$table: $xeTable,
|
|
1068
|
+
$grid: null,
|
|
1069
|
+
$gantt: $xeGantt,
|
|
1070
|
+
code,
|
|
1071
|
+
button,
|
|
1072
|
+
body,
|
|
1073
|
+
form: formData,
|
|
1074
|
+
options: ajaxMethods
|
|
1075
|
+
}
|
|
1076
|
+
const applyArgs = [commitParams].concat(args)
|
|
1077
|
+
if (selectRecords.length) {
|
|
1078
|
+
return $xeGantt.handleDeleteRow(code, 'vxe.grid.deleteSelectRecord', () => {
|
|
1079
|
+
if (!removeRecords.length) {
|
|
1080
|
+
return $xeTable.remove(selectRecords)
|
|
1081
|
+
}
|
|
1082
|
+
reactData.tableLoading = true
|
|
1083
|
+
return Promise.resolve((beforeDelete || ajaxMethods)(...applyArgs))
|
|
1084
|
+
.then(rest => {
|
|
1085
|
+
reactData.tableLoading = false
|
|
1086
|
+
$xeTable.setPendingRow(removeRecords, false)
|
|
1087
|
+
if (isRespMsg) {
|
|
1088
|
+
// 检测弹窗模块
|
|
1089
|
+
if (!VxeUI.modal) {
|
|
1090
|
+
errLog('vxe.error.reqModule', ['Modal'])
|
|
1091
|
+
}
|
|
1092
|
+
VxeUI.modal.message({ content: $xeGantt.getRespMsg(rest, 'vxe.grid.delSuccess'), status: 'success' })
|
|
1093
|
+
}
|
|
1094
|
+
if (afterDelete) {
|
|
1095
|
+
afterDelete(...applyArgs)
|
|
1096
|
+
} else {
|
|
1097
|
+
$xeGantt.commitProxy('query')
|
|
1098
|
+
}
|
|
1099
|
+
if (deleteSuccessMethods) {
|
|
1100
|
+
deleteSuccessMethods({ ...commitParams, response: rest })
|
|
1101
|
+
}
|
|
1102
|
+
return { status: true }
|
|
1103
|
+
})
|
|
1104
|
+
.catch(rest => {
|
|
1105
|
+
reactData.tableLoading = false
|
|
1106
|
+
if (isRespMsg) {
|
|
1107
|
+
// 检测弹窗模块
|
|
1108
|
+
if (!VxeUI.modal) {
|
|
1109
|
+
errLog('vxe.error.reqModule', ['Modal'])
|
|
1110
|
+
}
|
|
1111
|
+
VxeUI.modal.message({ id: code, content: $xeGantt.getRespMsg(rest, 'vxe.grid.operError'), status: 'error' })
|
|
1112
|
+
}
|
|
1113
|
+
if (deleteErrorMethods) {
|
|
1114
|
+
deleteErrorMethods({ ...commitParams, response: rest })
|
|
1115
|
+
}
|
|
1116
|
+
return { status: false }
|
|
1117
|
+
})
|
|
1118
|
+
})
|
|
1119
|
+
} else {
|
|
1120
|
+
if (isActiveMsg) {
|
|
1121
|
+
// 检测弹窗模块
|
|
1122
|
+
if (!VxeUI.modal) {
|
|
1123
|
+
errLog('vxe.error.reqModule', ['Modal'])
|
|
1124
|
+
}
|
|
1125
|
+
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' })
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
} else {
|
|
1129
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.delete'])
|
|
1130
|
+
}
|
|
1131
|
+
break
|
|
1132
|
+
}
|
|
1133
|
+
case 'save': {
|
|
1134
|
+
const ajaxMethods = ajax.save
|
|
1135
|
+
const saveSuccessMethods = ajax.saveSuccess
|
|
1136
|
+
const saveErrorMethods = ajax.saveError
|
|
1137
|
+
if (ajaxMethods) {
|
|
1138
|
+
const body = $xeGantt.getRecordset()
|
|
1139
|
+
const { insertRecords, removeRecords, updateRecords, pendingRecords } = body
|
|
1140
|
+
const commitParams = {
|
|
1141
|
+
$table: $xeTable,
|
|
1142
|
+
$grid: null,
|
|
1143
|
+
$gantt: $xeGantt,
|
|
1144
|
+
code,
|
|
1145
|
+
button,
|
|
1146
|
+
body,
|
|
1147
|
+
form: formData,
|
|
1148
|
+
options: ajaxMethods
|
|
1149
|
+
}
|
|
1150
|
+
const applyArgs = [commitParams].concat(args)
|
|
1151
|
+
// 排除掉新增且标记为删除的数据
|
|
1152
|
+
if (insertRecords.length) {
|
|
1153
|
+
body.pendingRecords = pendingRecords.filter((row) => insertRecords.indexOf(row) === -1)
|
|
1154
|
+
}
|
|
1155
|
+
// 排除已标记为删除的数据
|
|
1156
|
+
if (pendingRecords.length) {
|
|
1157
|
+
body.insertRecords = insertRecords.filter((row) => pendingRecords.indexOf(row) === -1)
|
|
1158
|
+
}
|
|
1159
|
+
let restPromise: Promise<any> = Promise.resolve()
|
|
1160
|
+
if (editRules) {
|
|
1161
|
+
// 只校验新增和修改的数据
|
|
1162
|
+
restPromise = $xeGantt[validConfig && validConfig.msgMode === 'full' ? 'fullValidate' : 'validate'](body.insertRecords.concat(updateRecords))
|
|
1163
|
+
}
|
|
1164
|
+
return restPromise.then((errMap: any) => {
|
|
1165
|
+
if (errMap) {
|
|
1166
|
+
// 如果校验不通过
|
|
1167
|
+
return
|
|
1168
|
+
}
|
|
1169
|
+
if (body.insertRecords.length || removeRecords.length || updateRecords.length || body.pendingRecords.length) {
|
|
1170
|
+
reactData.tableLoading = true
|
|
1171
|
+
return Promise.resolve((beforeSave || ajaxMethods)(...applyArgs))
|
|
1172
|
+
.then(rest => {
|
|
1173
|
+
reactData.tableLoading = false
|
|
1174
|
+
$xeTable.clearPendingRow()
|
|
1175
|
+
if (isRespMsg) {
|
|
1176
|
+
// 检测弹窗模块
|
|
1177
|
+
if (!VxeUI.modal) {
|
|
1178
|
+
errLog('vxe.error.reqModule', ['Modal'])
|
|
1179
|
+
}
|
|
1180
|
+
VxeUI.modal.message({ content: $xeGantt.getRespMsg(rest, 'vxe.grid.saveSuccess'), status: 'success' })
|
|
1181
|
+
}
|
|
1182
|
+
if (afterSave) {
|
|
1183
|
+
afterSave(...applyArgs)
|
|
1184
|
+
} else {
|
|
1185
|
+
$xeGantt.commitProxy('query')
|
|
1186
|
+
}
|
|
1187
|
+
if (saveSuccessMethods) {
|
|
1188
|
+
saveSuccessMethods({ ...commitParams, response: rest })
|
|
1189
|
+
}
|
|
1190
|
+
return { status: true }
|
|
1191
|
+
})
|
|
1192
|
+
.catch(rest => {
|
|
1193
|
+
reactData.tableLoading = false
|
|
1194
|
+
if (isRespMsg) {
|
|
1195
|
+
// 检测弹窗模块
|
|
1196
|
+
if (!VxeUI.modal) {
|
|
1197
|
+
errLog('vxe.error.reqModule', ['Modal'])
|
|
1198
|
+
}
|
|
1199
|
+
VxeUI.modal.message({ id: code, content: $xeGantt.getRespMsg(rest, 'vxe.grid.operError'), status: 'error' })
|
|
1200
|
+
}
|
|
1201
|
+
if (saveErrorMethods) {
|
|
1202
|
+
saveErrorMethods({ ...commitParams, response: rest })
|
|
1203
|
+
}
|
|
1204
|
+
return { status: false }
|
|
1205
|
+
})
|
|
1206
|
+
} else {
|
|
1207
|
+
if (isActiveMsg) {
|
|
1208
|
+
// 检测弹窗模块
|
|
1209
|
+
if (!VxeUI.modal) {
|
|
1210
|
+
errLog('vxe.error.reqModule', ['Modal'])
|
|
1211
|
+
}
|
|
1212
|
+
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.dataUnchanged'), status: 'info' })
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
})
|
|
1216
|
+
} else {
|
|
1217
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.save'])
|
|
1218
|
+
}
|
|
1219
|
+
break
|
|
1220
|
+
}
|
|
1221
|
+
default: {
|
|
1222
|
+
const gCommandOpts = commands.get(code)
|
|
1223
|
+
if (gCommandOpts) {
|
|
1224
|
+
const tCommandMethod = gCommandOpts.tableCommandMethod || gCommandOpts.commandMethod
|
|
1225
|
+
if (tCommandMethod) {
|
|
1226
|
+
tCommandMethod({ code, button, $grid: null, $table: $xeTable, $gantt: $xeGantt }, ...args)
|
|
1227
|
+
} else {
|
|
1228
|
+
errLog('vxe.error.notCommands', [code])
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return $xeGantt.$nextTick()
|
|
1234
|
+
},
|
|
1235
|
+
getParams () {
|
|
1236
|
+
const $xeGantt = this
|
|
1237
|
+
const props = $xeGantt
|
|
1238
|
+
|
|
1239
|
+
return props.params
|
|
1240
|
+
},
|
|
1241
|
+
zoom () {
|
|
1242
|
+
const $xeGantt = this
|
|
1243
|
+
const reactData = $xeGantt.reactData
|
|
1244
|
+
|
|
1245
|
+
if (reactData.isZMax) {
|
|
1246
|
+
return $xeGantt.revert()
|
|
1247
|
+
}
|
|
1248
|
+
return $xeGantt.maximize()
|
|
1249
|
+
},
|
|
1250
|
+
isMaximized () {
|
|
1251
|
+
const $xeGantt = this
|
|
1252
|
+
const reactData = $xeGantt.reactData
|
|
1253
|
+
|
|
1254
|
+
return reactData.isZMax
|
|
1255
|
+
},
|
|
1256
|
+
maximize () {
|
|
1257
|
+
const $xeGantt = this
|
|
1258
|
+
|
|
1259
|
+
return $xeGantt.handleZoom(true)
|
|
1260
|
+
},
|
|
1261
|
+
revert () {
|
|
1262
|
+
const $xeGantt = this
|
|
1263
|
+
|
|
1264
|
+
return $xeGantt.handleZoom()
|
|
1265
|
+
},
|
|
1266
|
+
getFormData () {
|
|
1267
|
+
const $xeGantt = this
|
|
1268
|
+
const props = $xeGantt
|
|
1269
|
+
const reactData = $xeGantt.reactData
|
|
1270
|
+
|
|
1271
|
+
const { proxyConfig } = props
|
|
1272
|
+
const { formData } = reactData
|
|
1273
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
1274
|
+
const formOpts = $xeGantt.computeFormOpts
|
|
1275
|
+
return proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data
|
|
1276
|
+
},
|
|
1277
|
+
getFormItems (itemIndex?: number): any {
|
|
1278
|
+
const $xeGantt = this
|
|
1279
|
+
const props = $xeGantt
|
|
1280
|
+
|
|
1281
|
+
const formOpts = $xeGantt.computeFormOpts
|
|
1282
|
+
const { formConfig } = props
|
|
1283
|
+
const { items } = formOpts
|
|
1284
|
+
const itemList: VxeFormItemProps[] = []
|
|
1285
|
+
XEUtils.eachTree(formConfig && isEnableConf(formOpts) && items ? items : [], item => {
|
|
1286
|
+
itemList.push(item)
|
|
1287
|
+
}, { children: 'children' })
|
|
1288
|
+
return XEUtils.isUndefined(itemIndex) ? itemList : itemList[itemIndex]
|
|
1289
|
+
},
|
|
1290
|
+
resetForm () {
|
|
1291
|
+
const $xeGantt = this
|
|
1292
|
+
|
|
1293
|
+
const $form = $xeGantt.$refs.refForm as VxeFormInstance
|
|
1294
|
+
if ($form) {
|
|
1295
|
+
return $form.reset()
|
|
1296
|
+
}
|
|
1297
|
+
return $xeGantt.$nextTick()
|
|
1298
|
+
},
|
|
1299
|
+
validateForm () {
|
|
1300
|
+
const $xeGantt = this
|
|
1301
|
+
|
|
1302
|
+
const $form = $xeGantt.$refs.refForm as VxeFormInstance
|
|
1303
|
+
if ($form) {
|
|
1304
|
+
return $form.validate()
|
|
1305
|
+
}
|
|
1306
|
+
return $xeGantt.$nextTick()
|
|
1307
|
+
},
|
|
1308
|
+
validateFormField (field: VxeFormItemPropTypes.Field | VxeFormItemPropTypes.Field[] | VxeFormDefines.ItemInfo | VxeFormDefines.ItemInfo[] | null) {
|
|
1309
|
+
const $xeGantt = this
|
|
1310
|
+
|
|
1311
|
+
const $form = $xeGantt.$refs.refForm as VxeFormInstance
|
|
1312
|
+
if ($form) {
|
|
1313
|
+
return $form.validateField(field)
|
|
1314
|
+
}
|
|
1315
|
+
return $xeGantt.$nextTick()
|
|
1316
|
+
},
|
|
1317
|
+
clearFormValidate (field?: VxeFormItemPropTypes.Field | VxeFormItemPropTypes.Field[] | VxeFormDefines.ItemInfo | VxeFormDefines.ItemInfo[] | null) {
|
|
1318
|
+
const $xeGantt = this
|
|
1319
|
+
|
|
1320
|
+
const $form = $xeGantt.$refs.refForm as VxeFormInstance
|
|
1321
|
+
if ($form) {
|
|
1322
|
+
return $form.clearValidate(field)
|
|
1323
|
+
}
|
|
1324
|
+
return $xeGantt.$nextTick()
|
|
1325
|
+
},
|
|
1326
|
+
homePage () {
|
|
1327
|
+
const $xeGantt = this
|
|
1328
|
+
const reactData = $xeGantt.reactData
|
|
1329
|
+
|
|
1330
|
+
const { tablePage } = reactData
|
|
1331
|
+
tablePage.currentPage = 1
|
|
1332
|
+
return $xeGantt.$nextTick()
|
|
1333
|
+
},
|
|
1334
|
+
homePageByEvent (evnt: Event) {
|
|
1335
|
+
const $xeGantt = this
|
|
1336
|
+
|
|
1337
|
+
const $pager = $xeGantt.$refs.refPager as VxePagerInstance
|
|
1338
|
+
if ($pager) {
|
|
1339
|
+
$pager.homePageByEvent(evnt)
|
|
1340
|
+
}
|
|
1341
|
+
},
|
|
1342
|
+
endPage () {
|
|
1343
|
+
const $xeGantt = this
|
|
1344
|
+
const reactData = $xeGantt.reactData
|
|
1345
|
+
|
|
1346
|
+
const { tablePage } = reactData
|
|
1347
|
+
const pageCount = $xeGantt.computePageCount
|
|
1348
|
+
tablePage.currentPage = pageCount
|
|
1349
|
+
return $xeGantt.$nextTick()
|
|
1350
|
+
},
|
|
1351
|
+
endPageByEvent (evnt: Event) {
|
|
1352
|
+
const $xeGantt = this
|
|
1353
|
+
|
|
1354
|
+
const $pager = $xeGantt.$refs.refPager as VxePagerInstance
|
|
1355
|
+
if ($pager) {
|
|
1356
|
+
$pager.endPageByEvent(evnt)
|
|
1357
|
+
}
|
|
1358
|
+
},
|
|
1359
|
+
setCurrentPage (currentPage: number | string | null | undefined) {
|
|
1360
|
+
const $xeGantt = this
|
|
1361
|
+
const reactData = $xeGantt.reactData
|
|
1362
|
+
|
|
1363
|
+
const { tablePage } = reactData
|
|
1364
|
+
const pageCount = $xeGantt.computePageCount
|
|
1365
|
+
tablePage.currentPage = Math.min(pageCount, Math.max(1, XEUtils.toNumber(currentPage)))
|
|
1366
|
+
return $xeGantt.$nextTick()
|
|
1367
|
+
},
|
|
1368
|
+
setCurrentPageByEvent (evnt: Event, currentPage: number | string | null | undefined) {
|
|
1369
|
+
const $xeGantt = this
|
|
1370
|
+
|
|
1371
|
+
const $pager = $xeGantt.$refs.refPager as VxePagerInstance
|
|
1372
|
+
if ($pager) {
|
|
1373
|
+
$pager.setCurrentPageByEvent(evnt, currentPage)
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
setPageSize (pageSize: number | string | null | undefined) {
|
|
1377
|
+
const $xeGantt = this
|
|
1378
|
+
const reactData = $xeGantt.reactData
|
|
1379
|
+
|
|
1380
|
+
const { tablePage } = reactData
|
|
1381
|
+
tablePage.pageSize = Math.max(1, XEUtils.toNumber(pageSize))
|
|
1382
|
+
return $xeGantt.$nextTick()
|
|
1383
|
+
},
|
|
1384
|
+
setPageSizeByEvent (evnt: Event, pageSize: number | string | null | undefined) {
|
|
1385
|
+
const $xeGantt = this
|
|
1386
|
+
|
|
1387
|
+
const $pager = $xeGantt.$refs.refPager as VxePagerInstance
|
|
1388
|
+
if ($pager) {
|
|
1389
|
+
$pager.setPageSizeByEvent(evnt, pageSize)
|
|
1390
|
+
}
|
|
1391
|
+
},
|
|
1392
|
+
getProxyInfo () {
|
|
1393
|
+
const $xeGantt = this
|
|
1394
|
+
const props = $xeGantt
|
|
1395
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
1396
|
+
const reactData = $xeGantt.reactData
|
|
1397
|
+
|
|
1398
|
+
if (props.proxyConfig) {
|
|
1399
|
+
const { sortData } = reactData
|
|
1400
|
+
return {
|
|
1401
|
+
data: $xeTable ? $xeTable.getFullData() : [],
|
|
1402
|
+
filter: reactData.filterData,
|
|
1403
|
+
form: $xeGantt.getFormData(),
|
|
1404
|
+
sort: sortData.length ? sortData[0] : {},
|
|
1405
|
+
sorts: sortData,
|
|
1406
|
+
pager: reactData.tablePage,
|
|
1407
|
+
pendingRecords: $xeTable ? $xeTable.getPendingRecords() : []
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
return null
|
|
1411
|
+
},
|
|
1412
|
+
refreshTaskView () {
|
|
1413
|
+
const $xeGantt = this
|
|
1414
|
+
|
|
1415
|
+
const $ganttView = $xeGantt.$refs.refGanttView as VxeGanttViewInstance
|
|
1416
|
+
if ($ganttView) {
|
|
1417
|
+
return $ganttView.refreshData()
|
|
1418
|
+
}
|
|
1419
|
+
return $xeGantt.$nextTick()
|
|
1420
|
+
},
|
|
1421
|
+
callSlot (slotFunc: any, params: any, h: CreateElement, vNodes: any) {
|
|
1422
|
+
const $xeGantt = this
|
|
1423
|
+
const slots = $xeGantt.$scopedSlots
|
|
1424
|
+
|
|
1425
|
+
if (slotFunc) {
|
|
1426
|
+
if (XEUtils.isString(slotFunc)) {
|
|
1427
|
+
slotFunc = slots[slotFunc] || null
|
|
1428
|
+
}
|
|
1429
|
+
if (XEUtils.isFunction(slotFunc)) {
|
|
1430
|
+
return getSlotVNs(slotFunc.call(this, params, h, vNodes))
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
return []
|
|
1434
|
+
},
|
|
1435
|
+
/**
|
|
1436
|
+
* 获取需要排除的高度
|
|
1437
|
+
*/
|
|
1438
|
+
getExcludeHeight () {
|
|
1439
|
+
const $xeGantt = this
|
|
1440
|
+
const reactData = $xeGantt.reactData
|
|
1441
|
+
|
|
1442
|
+
const { isZMax } = reactData
|
|
1443
|
+
const el = $xeGantt.$refs.refElem as HTMLDivElement
|
|
1444
|
+
if (el) {
|
|
1445
|
+
const formWrapper = $xeGantt.$refs.refFormWrapper as HTMLDivElement
|
|
1446
|
+
const toolbarWrapper = $xeGantt.$refs.refToolbarWrapper as HTMLDivElement
|
|
1447
|
+
const topWrapper = $xeGantt.$refs.refTopWrapper as HTMLDivElement
|
|
1448
|
+
const bottomWrapper = $xeGantt.$refs.refBottomWrapper as HTMLDivElement
|
|
1449
|
+
const pagerWrapper = $xeGantt.$refs.refPagerWrapper as HTMLDivElement
|
|
1450
|
+
const parentEl = el.parentElement as HTMLElement
|
|
1451
|
+
const parentPaddingSize = isZMax ? 0 : (parentEl ? getPaddingTopBottomSize(parentEl) : 0)
|
|
1452
|
+
return parentPaddingSize + getPaddingTopBottomSize(el) + getOffsetHeight(formWrapper) + getOffsetHeight(toolbarWrapper) + getOffsetHeight(topWrapper) + getOffsetHeight(bottomWrapper) + getOffsetHeight(pagerWrapper)
|
|
1453
|
+
}
|
|
1454
|
+
return 0
|
|
1455
|
+
},
|
|
1456
|
+
getParentHeight () {
|
|
1457
|
+
const $xeGantt = this
|
|
1458
|
+
const reactData = $xeGantt.reactData
|
|
1459
|
+
|
|
1460
|
+
const el = $xeGantt.$refs.refElem as HTMLDivElement
|
|
1461
|
+
if (el) {
|
|
1462
|
+
const parentEl = el.parentElement as HTMLElement
|
|
1463
|
+
return (reactData.isZMax ? getDomNode().visibleHeight : (parentEl ? XEUtils.toNumber(getComputedStyle(parentEl).height) : 0)) - $xeGantt.getExcludeHeight()
|
|
1464
|
+
}
|
|
1465
|
+
return 0
|
|
1466
|
+
},
|
|
1467
|
+
triggerToolbarCommitEvent (params: any, evnt: any) {
|
|
1468
|
+
const $xeGantt = this
|
|
1469
|
+
|
|
1470
|
+
const { code } = params
|
|
1471
|
+
return $xeGantt.commitProxy(params, evnt).then((rest) => {
|
|
1472
|
+
if (code && rest && rest.status && ['query', 'reload', 'delete', 'save'].includes(code)) {
|
|
1473
|
+
$xeGantt.dispatchEvent(code === 'delete' || code === 'save' ? `proxy-${code as 'delete' | 'save'}` : 'proxy-query', { ...rest, isReload: code === 'reload' }, evnt)
|
|
1474
|
+
}
|
|
1475
|
+
})
|
|
1476
|
+
},
|
|
1477
|
+
triggerToolbarBtnEvent (button: any, evnt: any) {
|
|
1478
|
+
const $xeGantt = this
|
|
1479
|
+
|
|
1480
|
+
$xeGantt.triggerToolbarCommitEvent(button, evnt)
|
|
1481
|
+
$xeGantt.dispatchEvent('toolbar-button-click', { code: button.code, button }, evnt)
|
|
1482
|
+
},
|
|
1483
|
+
triggerToolbarTolEvent (tool: any, evnt: any) {
|
|
1484
|
+
const $xeGantt = this
|
|
1485
|
+
|
|
1486
|
+
$xeGantt.triggerToolbarCommitEvent(tool, evnt)
|
|
1487
|
+
$xeGantt.dispatchEvent('toolbar-tool-click', { code: tool.code, tool }, evnt)
|
|
1488
|
+
},
|
|
1489
|
+
triggerZoomEvent (evnt: Event) {
|
|
1490
|
+
const $xeGantt = this
|
|
1491
|
+
const reactData = $xeGantt.reactData
|
|
1492
|
+
|
|
1493
|
+
$xeGantt.zoom()
|
|
1494
|
+
$xeGantt.dispatchEvent('zoom', { type: reactData.isZMax ? 'max' : 'revert' }, evnt)
|
|
1495
|
+
},
|
|
1496
|
+
handleTaskCellClickEvent (evnt: MouseEvent, params: VxeGanttDefines.TaskCellClickParams) {
|
|
1497
|
+
const $xeGantt = this
|
|
1498
|
+
|
|
1499
|
+
$xeGantt.dispatchEvent('task-cell-click', params, evnt)
|
|
1500
|
+
},
|
|
1501
|
+
handleTaskCellDblclickEvent (evnt: MouseEvent, params: VxeGanttDefines.TaskCellClickParams) {
|
|
1502
|
+
const $xeGantt = this
|
|
1503
|
+
|
|
1504
|
+
$xeGantt.dispatchEvent('task-cell-dblclick', params, evnt)
|
|
1505
|
+
},
|
|
1506
|
+
handleTaskBarClickEvent (evnt: MouseEvent, params: VxeGanttDefines.TaskCellClickParams) {
|
|
1507
|
+
const $xeGantt = this
|
|
1508
|
+
|
|
1509
|
+
$xeGantt.dispatchEvent('task-bar-click', params, evnt)
|
|
1510
|
+
},
|
|
1511
|
+
handleTaskBarDblclickEvent (evnt: MouseEvent, params: VxeGanttDefines.TaskCellClickParams) {
|
|
1512
|
+
const $xeGantt = this
|
|
1513
|
+
|
|
1514
|
+
$xeGantt.dispatchEvent('task-bar-dblclick', params, evnt)
|
|
1515
|
+
},
|
|
1516
|
+
loadColumn (columns: any[]) {
|
|
1517
|
+
const $xeGantt = this
|
|
1518
|
+
const slots = $xeGantt.$scopedSlots
|
|
1519
|
+
const $xeTable = $xeGantt.$refs.refTable as VxeTableConstructor & VxeTablePrivateMethods
|
|
1520
|
+
|
|
1521
|
+
XEUtils.eachTree(columns, column => {
|
|
1522
|
+
if (column.slots) {
|
|
1523
|
+
XEUtils.each(column.slots, (func) => {
|
|
1524
|
+
if (!XEUtils.isFunction(func)) {
|
|
1525
|
+
if (!slots[func]) {
|
|
1526
|
+
errLog('vxe.error.notSlot', [func])
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
})
|
|
1530
|
+
}
|
|
1531
|
+
})
|
|
1532
|
+
return $xeTable.loadColumn(columns)
|
|
1533
|
+
},
|
|
1534
|
+
reloadColumn (columns: any[]) {
|
|
1535
|
+
const $xeGantt = this
|
|
1536
|
+
|
|
1537
|
+
$xeGantt.clearAll()
|
|
1538
|
+
return $xeGantt.loadColumn(columns)
|
|
1539
|
+
},
|
|
1540
|
+
getConfigSlot (slotConfigs?: Record<string, any>) {
|
|
1541
|
+
const $xeGantt = this
|
|
1542
|
+
const slots = $xeGantt.$scopedSlots
|
|
1543
|
+
|
|
1544
|
+
const slotConf: Record<string, any> = {}
|
|
1545
|
+
XEUtils.objectMap(slotConfigs, (slotFunc, slotKey) => {
|
|
1546
|
+
if (slotFunc) {
|
|
1547
|
+
if (XEUtils.isString(slotFunc)) {
|
|
1548
|
+
if (slots[slotFunc]) {
|
|
1549
|
+
slotConf[slotKey] = slots[slotFunc]
|
|
1550
|
+
} else {
|
|
1551
|
+
errLog('vxe.error.notSlot', [slotFunc])
|
|
1552
|
+
}
|
|
1553
|
+
} else {
|
|
1554
|
+
slotConf[slotKey] = slotFunc
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
})
|
|
1558
|
+
return slotConf
|
|
1559
|
+
},
|
|
1560
|
+
getToolbarSlots () {
|
|
1561
|
+
const $xeGantt = this
|
|
1562
|
+
const slots = $xeGantt.$scopedSlots
|
|
1563
|
+
|
|
1564
|
+
const toolbarOpts = $xeGantt.computeToolbarOpts
|
|
1565
|
+
const toolbarOptSlots = toolbarOpts.slots
|
|
1566
|
+
const toolbarSlots: {
|
|
1567
|
+
buttons?(params: any): any
|
|
1568
|
+
buttonPrefix?(params: any): any
|
|
1569
|
+
buttonSuffix?(params: any): any
|
|
1570
|
+
tools?(params: any): any
|
|
1571
|
+
toolPrefix?(params: any): any
|
|
1572
|
+
toolSuffix?(params: any): any
|
|
1573
|
+
} = {}
|
|
1574
|
+
if (slots.buttons && (!toolbarOptSlots || toolbarOptSlots.buttons !== 'buttons')) {
|
|
1575
|
+
warnLog('vxe.error.reqProp', ['toolbar-config.slots.buttons'])
|
|
1576
|
+
}
|
|
1577
|
+
if (slots.tools && (!toolbarOptSlots || toolbarOptSlots.tools !== 'tools')) {
|
|
1578
|
+
warnLog('vxe.error.reqProp', ['toolbar-config.slots.tools'])
|
|
1579
|
+
}
|
|
1580
|
+
if (toolbarOptSlots) {
|
|
1581
|
+
const buttonsSlot = $xeGantt.getFuncSlot(toolbarOptSlots, 'buttons')
|
|
1582
|
+
const buttonPrefixSlot = $xeGantt.getFuncSlot(toolbarOptSlots, 'buttonPrefix')
|
|
1583
|
+
const buttonSuffixSlot = $xeGantt.getFuncSlot(toolbarOptSlots, 'buttonSuffix')
|
|
1584
|
+
const toolsSlot = $xeGantt.getFuncSlot(toolbarOptSlots, 'tools')
|
|
1585
|
+
const toolPrefixSlot = $xeGantt.getFuncSlot(toolbarOptSlots, 'toolPrefix')
|
|
1586
|
+
const toolSuffixSlot = $xeGantt.getFuncSlot(toolbarOptSlots, 'toolSuffix')
|
|
1587
|
+
if (buttonsSlot) {
|
|
1588
|
+
toolbarSlots.buttons = buttonsSlot
|
|
1589
|
+
}
|
|
1590
|
+
if (buttonPrefixSlot) {
|
|
1591
|
+
toolbarSlots.buttonPrefix = buttonPrefixSlot
|
|
1592
|
+
}
|
|
1593
|
+
if (buttonSuffixSlot) {
|
|
1594
|
+
toolbarSlots.buttonSuffix = buttonSuffixSlot
|
|
1595
|
+
}
|
|
1596
|
+
if (toolsSlot) {
|
|
1597
|
+
toolbarSlots.tools = toolsSlot
|
|
1598
|
+
}
|
|
1599
|
+
if (toolPrefixSlot) {
|
|
1600
|
+
toolbarSlots.toolPrefix = toolPrefixSlot
|
|
1601
|
+
}
|
|
1602
|
+
if (toolSuffixSlot) {
|
|
1603
|
+
toolbarSlots.toolSuffix = toolSuffixSlot
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
return toolbarSlots
|
|
1607
|
+
},
|
|
1608
|
+
getFuncSlot (optSlots: any, slotKey: any) {
|
|
1609
|
+
const $xeGantt = this
|
|
1610
|
+
const slots = $xeGantt.$scopedSlots
|
|
1611
|
+
|
|
1612
|
+
const funcSlot = optSlots[slotKey]
|
|
1613
|
+
if (funcSlot) {
|
|
1614
|
+
if (XEUtils.isString(funcSlot)) {
|
|
1615
|
+
if (slots[funcSlot]) {
|
|
1616
|
+
return slots[funcSlot]
|
|
1617
|
+
} else {
|
|
1618
|
+
errLog('vxe.error.notSlot', [funcSlot])
|
|
1619
|
+
}
|
|
1620
|
+
} else {
|
|
1621
|
+
return funcSlot
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
return null
|
|
1625
|
+
},
|
|
1626
|
+
|
|
1627
|
+
//
|
|
1628
|
+
// Render
|
|
1629
|
+
//
|
|
1630
|
+
renderDefaultForm (h: CreateElement) {
|
|
1631
|
+
const VxeUIFormComponent = VxeUI.getComponent('VxeForm')
|
|
1632
|
+
|
|
1633
|
+
const $xeGantt = this
|
|
1634
|
+
const props = $xeGantt
|
|
1635
|
+
const slots = $xeGantt.$scopedSlots
|
|
1636
|
+
const reactData = $xeGantt.reactData
|
|
1637
|
+
|
|
1638
|
+
const { proxyConfig, formConfig } = props
|
|
1639
|
+
const { formData } = reactData
|
|
1640
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
1641
|
+
const formOpts = $xeGantt.computeFormOpts
|
|
1642
|
+
if (isEnableConf(formConfig) && formOpts.items && formOpts.items.length) {
|
|
1643
|
+
const formSlots: any = {}
|
|
1644
|
+
if (!(formOpts as any).inited) {
|
|
1645
|
+
(formOpts as any).inited = true
|
|
1646
|
+
const beforeItem = proxyOpts.beforeItem
|
|
1647
|
+
if (proxyOpts && beforeItem) {
|
|
1648
|
+
formOpts.items.forEach((item) => {
|
|
1649
|
+
beforeItem.call($xeGantt, { $grid: $xeGantt, $gantt: null, item })
|
|
1650
|
+
})
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
// 处理插槽
|
|
1654
|
+
formOpts.items.forEach((item) => {
|
|
1655
|
+
XEUtils.each(item.slots, (func) => {
|
|
1656
|
+
if (!XEUtils.isFunction(func)) {
|
|
1657
|
+
if (slots[func]) {
|
|
1658
|
+
formSlots[func] = slots[func]
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
})
|
|
1662
|
+
})
|
|
1663
|
+
return [
|
|
1664
|
+
VxeUIFormComponent
|
|
1665
|
+
? h(VxeUIFormComponent, {
|
|
1666
|
+
props: Object.assign({}, formOpts, {
|
|
1667
|
+
data: proxyConfig && proxyOpts.form ? formData : formOpts.data
|
|
1668
|
+
}),
|
|
1669
|
+
on: {
|
|
1670
|
+
submit: $xeGantt.submitFormEvent,
|
|
1671
|
+
reset: $xeGantt.resetFormEvent,
|
|
1672
|
+
collapse: $xeGantt.collapseEvent,
|
|
1673
|
+
'submit-invalid': $xeGantt.submitInvalidEvent
|
|
1674
|
+
},
|
|
1675
|
+
scopedSlots: formSlots
|
|
1676
|
+
})
|
|
1677
|
+
: renderEmptyElement($xeGantt)
|
|
1678
|
+
]
|
|
1679
|
+
}
|
|
1680
|
+
return []
|
|
1681
|
+
},
|
|
1682
|
+
renderForm (h: CreateElement) {
|
|
1683
|
+
const $xeGantt = this
|
|
1684
|
+
const props = $xeGantt
|
|
1685
|
+
const slots = $xeGantt.$scopedSlots
|
|
1686
|
+
|
|
1687
|
+
const { formConfig } = props
|
|
1688
|
+
const formSlot = slots.form
|
|
1689
|
+
const hasForm = !!(formSlot || isEnableConf(formConfig))
|
|
1690
|
+
|
|
1691
|
+
if (hasForm) {
|
|
1692
|
+
return h('div', {
|
|
1693
|
+
key: 'form',
|
|
1694
|
+
ref: 'refFormWrapper',
|
|
1695
|
+
class: 'vxe-gantt--form-wrapper'
|
|
1696
|
+
}, formSlot ? formSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt }) : $xeGantt.renderDefaultForm(h))
|
|
1697
|
+
}
|
|
1698
|
+
return renderEmptyElement($xeGantt)
|
|
1699
|
+
},
|
|
1700
|
+
renderToolbar (h: CreateElement) {
|
|
1701
|
+
const VxeUIToolbarComponent = VxeUI.getComponent('VxeToolbar')
|
|
1702
|
+
|
|
1703
|
+
const $xeGantt = this
|
|
1704
|
+
const props = $xeGantt
|
|
1705
|
+
const slots = $xeGantt.$scopedSlots
|
|
1706
|
+
|
|
1707
|
+
const { toolbarConfig } = props
|
|
1708
|
+
const toolbarSlot = slots.toolbar
|
|
1709
|
+
const hasToolbar = !!(toolbarSlot || isEnableConf(toolbarConfig) || toolbar)
|
|
1710
|
+
const toolbarOpts = $xeGantt.computeToolbarOpts
|
|
1711
|
+
|
|
1712
|
+
if (hasToolbar) {
|
|
1713
|
+
return h('div', {
|
|
1714
|
+
key: 'toolbar',
|
|
1715
|
+
ref: 'refToolbarWrapper',
|
|
1716
|
+
class: 'vxe-gantt--toolbar-wrapper'
|
|
1717
|
+
}, toolbarSlot
|
|
1718
|
+
? toolbarSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt })
|
|
1719
|
+
: [
|
|
1720
|
+
h(VxeUIToolbarComponent, {
|
|
1721
|
+
props: Object.assign({}, toolbarOpts, { slots: undefined }),
|
|
1722
|
+
ref: 'refToolbar',
|
|
1723
|
+
scopedSlots: $xeGantt.getToolbarSlots()
|
|
1724
|
+
})
|
|
1725
|
+
]
|
|
1726
|
+
)
|
|
1727
|
+
}
|
|
1728
|
+
return renderEmptyElement($xeGantt)
|
|
1729
|
+
},
|
|
1730
|
+
renderTop (h: CreateElement) {
|
|
1731
|
+
const $xeGantt = this
|
|
1732
|
+
const slots = $xeGantt.$scopedSlots
|
|
1733
|
+
|
|
1734
|
+
const topSlot = slots.top
|
|
1735
|
+
return topSlot
|
|
1736
|
+
? h('div', {
|
|
1737
|
+
key: 'top',
|
|
1738
|
+
ref: 'refTopWrapper',
|
|
1739
|
+
class: 'vxe-gantt--top-wrapper'
|
|
1740
|
+
}, topSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt }))
|
|
1741
|
+
: renderEmptyElement($xeGantt)
|
|
1742
|
+
},
|
|
1743
|
+
renderTableLeft (h: CreateElement) {
|
|
1744
|
+
const $xeGantt = this
|
|
1745
|
+
const slots = $xeGantt.$scopedSlots
|
|
1746
|
+
|
|
1747
|
+
const leftSlot = slots.left
|
|
1748
|
+
if (leftSlot) {
|
|
1749
|
+
return h('div', {
|
|
1750
|
+
class: 'vxe-gantt--left-wrapper'
|
|
1751
|
+
}, leftSlot({ $grid: null, $gantt: $xeGantt }))
|
|
1752
|
+
}
|
|
1753
|
+
return renderEmptyElement($xeGantt)
|
|
1754
|
+
},
|
|
1755
|
+
renderTableRight (h: CreateElement) {
|
|
1756
|
+
const $xeGantt = this
|
|
1757
|
+
const slots = $xeGantt.$scopedSlots
|
|
1758
|
+
|
|
1759
|
+
const rightSlot = slots.right
|
|
1760
|
+
if (rightSlot) {
|
|
1761
|
+
return h('div', {
|
|
1762
|
+
class: 'vxe-gantt--right-wrapper'
|
|
1763
|
+
}, rightSlot({ $grid: null, $gantt: $xeGantt }))
|
|
1764
|
+
}
|
|
1765
|
+
return renderEmptyElement($xeGantt)
|
|
1766
|
+
},
|
|
1767
|
+
renderTable (h: CreateElement) {
|
|
1768
|
+
const $xeGantt = this
|
|
1769
|
+
const slots = $xeGantt.$scopedSlots
|
|
1770
|
+
|
|
1771
|
+
const tableProps = $xeGantt.computeTableProps
|
|
70
1772
|
return h('div', {
|
|
71
|
-
|
|
72
|
-
|
|
1773
|
+
class: 'vxe-gantt--table-wrapper'
|
|
1774
|
+
}, [
|
|
1775
|
+
h(VxeTableComponent as Component, {
|
|
1776
|
+
key: 'table',
|
|
1777
|
+
props: tableProps,
|
|
1778
|
+
on: getTableOns($xeGantt),
|
|
1779
|
+
scopedSlots: slots,
|
|
1780
|
+
ref: 'refTable'
|
|
1781
|
+
})
|
|
1782
|
+
])
|
|
1783
|
+
},
|
|
1784
|
+
renderBottom (h: CreateElement) {
|
|
1785
|
+
const $xeGantt = this
|
|
1786
|
+
const slots = $xeGantt.$scopedSlots
|
|
1787
|
+
|
|
1788
|
+
const bottomSlot = slots.bottom
|
|
1789
|
+
return bottomSlot
|
|
1790
|
+
? h('div', {
|
|
1791
|
+
key: 'bottom',
|
|
1792
|
+
ref: 'refBottomWrapper',
|
|
1793
|
+
class: 'vxe-gantt--bottom-wrapper'
|
|
1794
|
+
}, bottomSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt }))
|
|
1795
|
+
: renderEmptyElement($xeGantt)
|
|
1796
|
+
},
|
|
1797
|
+
renderPager (h: CreateElement) {
|
|
1798
|
+
const VxeUIPagerComponent = VxeUI.getComponent('VxePager')
|
|
1799
|
+
|
|
1800
|
+
const $xeGantt = this
|
|
1801
|
+
const props = $xeGantt
|
|
1802
|
+
const slots = $xeGantt.$scopedSlots
|
|
1803
|
+
const reactData = $xeGantt.reactData
|
|
1804
|
+
|
|
1805
|
+
const { proxyConfig, pagerConfig } = props
|
|
1806
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
1807
|
+
const pagerOpts = $xeGantt.computePagerOpts
|
|
1808
|
+
const pagerSlot = slots.pager
|
|
1809
|
+
if ((pagerConfig && isEnableConf(pagerOpts)) || slots.pager) {
|
|
1810
|
+
return h('div', {
|
|
1811
|
+
ref: 'refPagerWrapper',
|
|
1812
|
+
key: 'pager',
|
|
1813
|
+
class: 'vxe-gantt--pager-wrapper'
|
|
1814
|
+
}, pagerSlot
|
|
1815
|
+
? pagerSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt })
|
|
1816
|
+
: [
|
|
1817
|
+
VxeUIPagerComponent
|
|
1818
|
+
? h(VxeUIPagerComponent, {
|
|
1819
|
+
ref: 'refPager',
|
|
1820
|
+
props: {
|
|
1821
|
+
...pagerOpts,
|
|
1822
|
+
...(proxyConfig && isEnableConf(proxyOpts) ? reactData.tablePage : {})
|
|
1823
|
+
},
|
|
1824
|
+
on: {
|
|
1825
|
+
'page-change': $xeGantt.pageChangeEvent
|
|
1826
|
+
},
|
|
1827
|
+
scopedSlots: $xeGantt.getConfigSlot(pagerOpts.slots)
|
|
1828
|
+
})
|
|
1829
|
+
: renderEmptyElement($xeGantt)
|
|
1830
|
+
])
|
|
1831
|
+
}
|
|
1832
|
+
return renderEmptyElement($xeGantt)
|
|
1833
|
+
},
|
|
1834
|
+
/**
|
|
1835
|
+
* 渲染任务视图
|
|
1836
|
+
*/
|
|
1837
|
+
renderTaskView (h: CreateElement) {
|
|
1838
|
+
return h('div', {
|
|
1839
|
+
ref: 'refGanttWrapper',
|
|
1840
|
+
class: 'vxe-gantt--view-wrapper'
|
|
1841
|
+
}, [
|
|
1842
|
+
h(GanttViewComponent, {
|
|
1843
|
+
ref: 'refGanttView'
|
|
1844
|
+
})
|
|
1845
|
+
])
|
|
1846
|
+
},
|
|
1847
|
+
renderSplitBar (h: CreateElement) {
|
|
1848
|
+
const $xeGantt = this
|
|
1849
|
+
const reactData = $xeGantt.reactData
|
|
1850
|
+
|
|
1851
|
+
const { showLeftView, showRightView } = reactData
|
|
1852
|
+
const taskSplitOpts = $xeGantt.computeTaskSplitOpts
|
|
1853
|
+
const { enabled, resize, showCollapseTableButton, showCollapseTaskButton } = taskSplitOpts
|
|
1854
|
+
if (!enabled) {
|
|
1855
|
+
return renderEmptyElement($xeGantt)
|
|
1856
|
+
}
|
|
1857
|
+
const ons: {
|
|
1858
|
+
mousedown?: any
|
|
1859
|
+
} = {}
|
|
1860
|
+
if (resize) {
|
|
1861
|
+
ons.mousedown = $xeGantt.dragSplitEvent
|
|
1862
|
+
}
|
|
1863
|
+
return h('div', {
|
|
1864
|
+
class: ['vxe-gantt--view-split-bar', {
|
|
1865
|
+
'is--resize': resize,
|
|
1866
|
+
on: ons
|
|
1867
|
+
}]
|
|
1868
|
+
}, [
|
|
1869
|
+
h('div', {
|
|
1870
|
+
class: 'vxe-gantt--view-split-bar-handle'
|
|
1871
|
+
}),
|
|
1872
|
+
showCollapseTableButton || showCollapseTaskButton
|
|
1873
|
+
? h('div', {
|
|
1874
|
+
class: 'vxe-gantt--view-split-bar-btn-wrapper'
|
|
1875
|
+
}, [
|
|
1876
|
+
showCollapseTableButton && showRightView
|
|
1877
|
+
? h('div', {
|
|
1878
|
+
class: 'vxe-gantt--view-split-bar-left-btn',
|
|
1879
|
+
on: {
|
|
1880
|
+
click: $xeGantt.handleSplitLeftViewEvent
|
|
1881
|
+
}
|
|
1882
|
+
}, [
|
|
1883
|
+
h('i', {
|
|
1884
|
+
class: showLeftView ? getIcon().GANTT_VIEW_LEFT_OPEN : getIcon().GANTT_VIEW_LEFT_CLOSE
|
|
1885
|
+
})
|
|
1886
|
+
])
|
|
1887
|
+
: renderEmptyElement($xeGantt),
|
|
1888
|
+
showCollapseTaskButton && showLeftView
|
|
1889
|
+
? h('div', {
|
|
1890
|
+
class: 'vxe-gantt--view-split-bar-right-btn',
|
|
1891
|
+
on: {
|
|
1892
|
+
click: $xeGantt.handleSplitRightViewEvent
|
|
1893
|
+
}
|
|
1894
|
+
}, [
|
|
1895
|
+
h('i', {
|
|
1896
|
+
class: showRightView ? getIcon().GANTT_VIEW_RIGHT_OPEN : getIcon().GANTT_VIEW_RIGHT_CLOSE
|
|
1897
|
+
})
|
|
1898
|
+
])
|
|
1899
|
+
: renderEmptyElement($xeGantt)
|
|
1900
|
+
])
|
|
1901
|
+
: renderEmptyElement($xeGantt)
|
|
1902
|
+
])
|
|
1903
|
+
},
|
|
1904
|
+
renderChildLayout (h: CreateElement, layoutKeys: VxeGanttDefines.LayoutKey[]) {
|
|
1905
|
+
const $xeGantt = this
|
|
1906
|
+
|
|
1907
|
+
const childVNs: VNode[] = []
|
|
1908
|
+
layoutKeys.forEach(key => {
|
|
1909
|
+
switch (key) {
|
|
1910
|
+
case 'Form':
|
|
1911
|
+
childVNs.push($xeGantt.renderForm(h))
|
|
1912
|
+
break
|
|
1913
|
+
case 'Toolbar':
|
|
1914
|
+
childVNs.push($xeGantt.renderToolbar(h))
|
|
1915
|
+
break
|
|
1916
|
+
case 'Top':
|
|
1917
|
+
childVNs.push($xeGantt.renderTop(h))
|
|
1918
|
+
break
|
|
1919
|
+
case 'Gantt':
|
|
1920
|
+
childVNs.push(
|
|
1921
|
+
h('div', {
|
|
1922
|
+
ref: 'refGanttContainer',
|
|
1923
|
+
key: 'tv',
|
|
1924
|
+
class: 'vxe-gantt--gantt-container'
|
|
1925
|
+
}, [
|
|
1926
|
+
$xeGantt.renderTableLeft(h),
|
|
1927
|
+
$xeGantt.renderTable(h),
|
|
1928
|
+
$xeGantt.renderSplitBar(h),
|
|
1929
|
+
$xeGantt.renderTaskView(h),
|
|
1930
|
+
$xeGantt.renderTableRight(h),
|
|
1931
|
+
h('div', {
|
|
1932
|
+
ref: 'refResizableSplitTip',
|
|
1933
|
+
class: 'vxe-gantt--resizable-split-tip'
|
|
1934
|
+
}, [
|
|
1935
|
+
h('div', {
|
|
1936
|
+
class: 'vxe-gantt--resizable-split-tip-number'
|
|
1937
|
+
}, [
|
|
1938
|
+
h('div', {
|
|
1939
|
+
class: 'vxe-gantt--resizable-split-number-left'
|
|
1940
|
+
}, '10px'),
|
|
1941
|
+
h('div', {
|
|
1942
|
+
class: 'vxe-gantt--resizable-split-number-right'
|
|
1943
|
+
}, '20px')
|
|
1944
|
+
])
|
|
1945
|
+
])
|
|
1946
|
+
])
|
|
1947
|
+
)
|
|
1948
|
+
break
|
|
1949
|
+
case 'Bottom':
|
|
1950
|
+
childVNs.push($xeGantt.renderBottom(h))
|
|
1951
|
+
break
|
|
1952
|
+
case 'Pager':
|
|
1953
|
+
childVNs.push($xeGantt.renderPager(h))
|
|
1954
|
+
break
|
|
1955
|
+
default:
|
|
1956
|
+
errLog('vxe.error.notProp', [`layouts -> ${key}`])
|
|
1957
|
+
break
|
|
1958
|
+
}
|
|
73
1959
|
})
|
|
1960
|
+
return childVNs
|
|
1961
|
+
},
|
|
1962
|
+
renderLayout (h: CreateElement) {
|
|
1963
|
+
const $xeGantt = this
|
|
1964
|
+
const slots = $xeGantt.$scopedSlots
|
|
1965
|
+
|
|
1966
|
+
const currLayoutConf = $xeGantt.computeCurrLayoutConf
|
|
1967
|
+
const { headKeys, bodyKeys, footKeys } = currLayoutConf
|
|
1968
|
+
const asideLeftSlot = slots.asideLeft || slots['aside-left']
|
|
1969
|
+
const asideRightSlot = slots.asideRight || slots['aside-right']
|
|
1970
|
+
return [
|
|
1971
|
+
h('div', {
|
|
1972
|
+
class: 'vxe-gantt--layout-header-wrapper'
|
|
1973
|
+
}, $xeGantt.renderChildLayout(h, headKeys)),
|
|
1974
|
+
h('div', {
|
|
1975
|
+
class: 'vxe-gantt--layout-body-wrapper'
|
|
1976
|
+
}, [
|
|
1977
|
+
asideLeftSlot
|
|
1978
|
+
? h('div', {
|
|
1979
|
+
class: 'vxe-gantt--layout-aside-left-wrapper'
|
|
1980
|
+
}, asideLeftSlot({}))
|
|
1981
|
+
: renderEmptyElement($xeGantt),
|
|
1982
|
+
h('div', {
|
|
1983
|
+
class: 'vxe-gantt--layout-body-content-wrapper'
|
|
1984
|
+
}, $xeGantt.renderChildLayout(h, bodyKeys)),
|
|
1985
|
+
asideRightSlot
|
|
1986
|
+
? h('div', {
|
|
1987
|
+
class: 'vxe-gantt--layout-aside-right-wrapper'
|
|
1988
|
+
}, asideRightSlot({}))
|
|
1989
|
+
: renderEmptyElement($xeGantt)
|
|
1990
|
+
]),
|
|
1991
|
+
h('div', {
|
|
1992
|
+
class: 'vxe-gantt--layout-footer-wrapper'
|
|
1993
|
+
}, $xeGantt.renderChildLayout(h, footKeys)),
|
|
1994
|
+
h('div', {
|
|
1995
|
+
class: 'vxe-gantt--border-line'
|
|
1996
|
+
})
|
|
1997
|
+
]
|
|
1998
|
+
},
|
|
1999
|
+
renderVN (h: CreateElement): VNode {
|
|
2000
|
+
const $xeGantt = this
|
|
2001
|
+
const props = $xeGantt
|
|
2002
|
+
const reactData = $xeGantt.reactData
|
|
2003
|
+
|
|
2004
|
+
const { showLeftView, showRightView } = reactData
|
|
2005
|
+
const vSize = $xeGantt.computeSize
|
|
2006
|
+
const styles = $xeGantt.computeStyles
|
|
2007
|
+
const isLoading = $xeGantt.computeIsLoading
|
|
2008
|
+
const tableBorder = $xeGantt.computeTableBorder
|
|
2009
|
+
const scrollbarXToTop = $xeGantt.computeScrollbarXToTop
|
|
2010
|
+
const scrollbarYToLeft = $xeGantt.computeScrollbarYToLeft
|
|
2011
|
+
return h('div', {
|
|
2012
|
+
ref: 'refElem',
|
|
2013
|
+
class: ['vxe-gantt', `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
|
|
2014
|
+
[`size--${vSize}`]: vSize,
|
|
2015
|
+
'is--round': props.round,
|
|
2016
|
+
'is--maximize': reactData.isZMax,
|
|
2017
|
+
'is--loading': isLoading,
|
|
2018
|
+
'show--left': showLeftView,
|
|
2019
|
+
'show--right': showRightView
|
|
2020
|
+
}],
|
|
2021
|
+
style: styles
|
|
2022
|
+
}, $xeGantt.renderLayout(h))
|
|
2023
|
+
}
|
|
2024
|
+
},
|
|
2025
|
+
created () {
|
|
2026
|
+
// 使用已安装的组件,如果未安装则不渲染
|
|
2027
|
+
const VxeUIFormComponent = VxeUI.getComponent('VxeForm')
|
|
2028
|
+
const VxeUIPagerComponent = VxeUI.getComponent('VxePager')
|
|
2029
|
+
const VxeUIToolbarComponent = VxeUI.getComponent('VxeToolbar')
|
|
2030
|
+
|
|
2031
|
+
const $xeGantt = this
|
|
2032
|
+
const props = $xeGantt
|
|
2033
|
+
|
|
2034
|
+
const proxyOpts = $xeGantt.computeProxyOpts
|
|
2035
|
+
|
|
2036
|
+
if ((props as any).toolbar) {
|
|
2037
|
+
errLog('vxe.error.delProp', ['grid.toolbar', 'grid.toolbar-config'])
|
|
2038
|
+
}
|
|
2039
|
+
if (props.toolbarConfig && !XEUtils.isObject(props.toolbarConfig)) {
|
|
2040
|
+
errLog('vxe.error.errProp', [`grid.toolbar-config=${props.toolbarConfig}`, 'grid.toolbar-config={}'])
|
|
2041
|
+
}
|
|
2042
|
+
if (proxyOpts.props) {
|
|
2043
|
+
warnLog('vxe.error.delProp', ['proxy-config.props', 'proxy-config.response'])
|
|
74
2044
|
}
|
|
75
2045
|
|
|
76
|
-
|
|
77
|
-
|
|
2046
|
+
$xeGantt.$nextTick(() => {
|
|
2047
|
+
if (props.formConfig) {
|
|
2048
|
+
if (!VxeUIFormComponent) {
|
|
2049
|
+
errLog('vxe.error.reqComp', ['vxe-form'])
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
if (props.pagerConfig) {
|
|
2053
|
+
if (!VxeUIPagerComponent) {
|
|
2054
|
+
errLog('vxe.error.reqComp', ['vxe-pager'])
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
if (props.toolbarConfig) {
|
|
2058
|
+
if (!VxeUIToolbarComponent) {
|
|
2059
|
+
errLog('vxe.error.reqComp', ['vxe-toolbar'])
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
78
2062
|
})
|
|
79
2063
|
|
|
80
|
-
$xeGantt.
|
|
2064
|
+
$xeGantt.initPages()
|
|
2065
|
+
},
|
|
2066
|
+
mounted () {
|
|
2067
|
+
const $xeGantt = this
|
|
2068
|
+
const props = $xeGantt
|
|
81
2069
|
|
|
82
|
-
|
|
2070
|
+
const { columns } = props
|
|
2071
|
+
if (columns && columns.length) {
|
|
2072
|
+
$xeGantt.loadColumn(columns)
|
|
2073
|
+
}
|
|
2074
|
+
$xeGantt.initToolbar()
|
|
2075
|
+
$xeGantt.initProxy()
|
|
2076
|
+
$xeGantt.initGanttView()
|
|
2077
|
+
globalEvents.on($xeGantt, 'keydown', $xeGantt.handleGlobalKeydownEvent)
|
|
83
2078
|
},
|
|
84
|
-
|
|
85
|
-
|
|
2079
|
+
destroyed () {
|
|
2080
|
+
const $xeGantt = this
|
|
2081
|
+
const internalData = $xeGantt.internalData
|
|
2082
|
+
|
|
2083
|
+
globalEvents.off($xeGantt, 'keydown')
|
|
2084
|
+
XEUtils.assign(internalData, createInternalData())
|
|
2085
|
+
},
|
|
2086
|
+
render (this: any, h) {
|
|
2087
|
+
return this.renderVN(h)
|
|
86
2088
|
}
|
|
87
|
-
})
|
|
2089
|
+
}) /* define-vxe-component end */
|