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