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