vxe-gantt 0.0.2 → 4.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 (93) hide show
  1. package/README.md +27 -1
  2. package/es/gantt/src/emits.js +4 -0
  3. package/es/gantt/src/gantt-body.js +103 -0
  4. package/es/gantt/src/gantt-chart.js +77 -0
  5. package/es/gantt/src/gantt-header.js +70 -0
  6. package/es/gantt/src/gantt-view.js +768 -0
  7. package/es/gantt/src/gantt.js +1707 -22
  8. package/es/gantt/src/grid-emits.js +16 -0
  9. package/es/gantt/src/grid-props.js +7 -0
  10. package/es/gantt/src/props.js +2 -0
  11. package/es/gantt/src/table-emits.js +97 -0
  12. package/es/gantt/src/table-props.js +298 -0
  13. package/es/gantt/src/util.js +12 -0
  14. package/es/gantt/style.css +599 -0
  15. package/es/gantt/style.min.css +1 -0
  16. package/es/style.css +1 -0
  17. package/es/style.min.css +1 -0
  18. package/es/ui/index.js +47 -3
  19. package/es/ui/src/dom.js +44 -105
  20. package/es/ui/src/log.js +1 -1
  21. package/es/ui/src/utils.js +18 -17
  22. package/es/ui/src/vn.js +1 -32
  23. package/es/vxe-gantt/style.css +599 -0
  24. package/es/vxe-gantt/style.min.css +1 -0
  25. package/lib/gantt/src/emits.js +8 -0
  26. package/lib/gantt/src/emits.min.js +1 -0
  27. package/lib/gantt/src/gantt-body.js +118 -0
  28. package/lib/gantt/src/gantt-body.min.js +1 -0
  29. package/lib/gantt/src/gantt-chart.js +94 -0
  30. package/lib/gantt/src/gantt-chart.min.js +1 -0
  31. package/lib/gantt/src/gantt-header.js +78 -0
  32. package/lib/gantt/src/gantt-header.min.js +1 -0
  33. package/lib/gantt/src/gantt-view.js +810 -0
  34. package/lib/gantt/src/gantt-view.min.js +1 -0
  35. package/lib/gantt/src/gantt.js +1945 -20
  36. package/lib/gantt/src/gantt.min.js +1 -1
  37. package/lib/gantt/src/grid-emits.js +8 -0
  38. package/lib/gantt/src/grid-emits.min.js +1 -0
  39. package/lib/gantt/src/grid-props.js +24 -0
  40. package/lib/gantt/src/grid-props.min.js +1 -0
  41. package/lib/gantt/src/props.js +13 -0
  42. package/lib/gantt/src/props.min.js +1 -0
  43. package/lib/gantt/src/table-emits.js +7 -0
  44. package/lib/gantt/src/table-emits.min.js +1 -0
  45. package/lib/gantt/src/table-props.js +306 -0
  46. package/lib/gantt/src/table-props.min.js +1 -0
  47. package/lib/gantt/src/util.js +19 -0
  48. package/lib/gantt/src/util.min.js +1 -0
  49. package/lib/gantt/style/style.css +599 -0
  50. package/lib/gantt/style/style.min.css +1 -0
  51. package/lib/index.umd.js +6554 -140
  52. package/lib/index.umd.min.js +1 -1
  53. package/lib/style.css +1 -0
  54. package/lib/style.min.css +1 -0
  55. package/lib/ui/index.js +47 -3
  56. package/lib/ui/index.min.js +1 -1
  57. package/lib/ui/src/dom.js +50 -110
  58. package/lib/ui/src/dom.min.js +1 -1
  59. package/lib/ui/src/log.js +1 -1
  60. package/lib/ui/src/log.min.js +1 -1
  61. package/lib/ui/src/utils.js +24 -20
  62. package/lib/ui/src/utils.min.js +1 -1
  63. package/lib/ui/src/vn.js +1 -43
  64. package/lib/ui/src/vn.min.js +0 -1
  65. package/lib/vxe-gantt/style/style.css +599 -0
  66. package/lib/vxe-gantt/style/style.min.css +1 -0
  67. package/package.json +4 -4
  68. package/packages/gantt/src/emits.ts +7 -0
  69. package/packages/gantt/src/gantt-body.ts +119 -0
  70. package/packages/gantt/src/gantt-chart.ts +97 -0
  71. package/packages/gantt/src/gantt-header.ts +79 -0
  72. package/packages/gantt/src/gantt-view.ts +840 -0
  73. package/packages/gantt/src/gantt.ts +1806 -24
  74. package/packages/gantt/src/grid-emits.ts +19 -0
  75. package/packages/gantt/src/grid-props.ts +23 -0
  76. package/packages/gantt/src/props.ts +13 -0
  77. package/packages/gantt/src/table-emits.ts +109 -0
  78. package/packages/gantt/src/table-props.ts +304 -0
  79. package/packages/gantt/src/util.ts +15 -0
  80. package/packages/ui/index.ts +48 -2
  81. package/packages/ui/src/dom.ts +53 -110
  82. package/packages/ui/src/log.ts +1 -1
  83. package/packages/ui/src/utils.ts +22 -21
  84. package/packages/ui/src/vn.ts +0 -37
  85. package/styles/components/gantt-module/all.scss +1 -0
  86. package/styles/components/gantt-module/gantt-chart.scss +46 -0
  87. package/styles/components/gantt.scss +586 -0
  88. package/styles/helpers/baseMixin.scss +96 -0
  89. package/styles/helpers/baseVar.scss +4 -0
  90. package/styles/helpers/placement.scss +39 -0
  91. package/styles/theme/base.scss +7 -0
  92. package/styles/theme/dark.scss +5 -0
  93. package/styles/theme/light.scss +5 -0
@@ -1,58 +1,1743 @@
1
- import { ref, h, reactive, onUnmounted } from 'vue';
1
+ import { h, ref, computed, provide, reactive, onUnmounted, watch, nextTick, onMounted } from 'vue';
2
2
  import { defineVxeComponent } from '../../ui/src/comp';
3
- import { getConfig, createEvent } from '../../ui';
4
3
  import XEUtils from 'xe-utils';
4
+ import { getLastZIndex, nextZIndex, isEnableConf } from '../../ui/src/utils';
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
+ import { warnLog, errLog } from '../../ui/src/log';
12
+ 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'];
5
16
  function createInternalData() {
6
- return {};
17
+ return {
18
+ resizeTableWidth: 0
19
+ };
7
20
  }
8
21
  export default defineVxeComponent({
9
22
  name: 'VxeGantt',
10
- props: {
11
- size: {
12
- type: String,
13
- default: () => getConfig().gantt.size || getConfig().size
14
- }
15
- },
16
- emits: [],
23
+ props: ganttProps,
24
+ emits: ganttEmits,
17
25
  setup(props, context) {
18
- const { emit } = context;
26
+ var _a;
27
+ const { slots, emit } = context;
19
28
  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({
37
+ tableLoading: false,
38
+ proxyInited: false,
39
+ isZMax: false,
40
+ tableData: [],
41
+ filterData: [],
42
+ formData: {},
43
+ sortData: [],
44
+ tZindex: 0,
45
+ tablePage: {
46
+ total: 0,
47
+ pageSize: ((_a = getConfig().pager) === null || _a === void 0 ? void 0 : _a.pageSize) || 10,
48
+ currentPage: 1
49
+ },
50
+ showLeftView: true,
51
+ showRightView: true
52
+ });
53
+ const internalData = createInternalData();
20
54
  const refElem = ref();
21
55
  const refTable = ref();
22
- const reactData = reactive({});
23
- const internalData = createInternalData();
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;
80
+ };
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(() => {
91
+ return XEUtils.merge({}, XEUtils.clone(getConfig().gantt.proxyConfig, true), props.proxyConfig);
92
+ });
93
+ const computeIsRespMsg = computed(() => {
94
+ const proxyOpts = computeProxyOpts.value;
95
+ return !!(XEUtils.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg);
96
+ });
97
+ const computeIsActiveMsg = computed(() => {
98
+ const proxyOpts = computeProxyOpts.value;
99
+ return XEUtils.isBoolean(proxyOpts.showActionMsg) ? proxyOpts.showActionMsg : !!proxyOpts.showActiveMsg;
100
+ });
101
+ const computePagerOpts = computed(() => {
102
+ return Object.assign({}, getConfig().gantt.pagerConfig, props.pagerConfig);
103
+ });
104
+ const computeFormOpts = computed(() => {
105
+ return Object.assign({}, getConfig().gantt.formConfig, props.formConfig);
106
+ });
107
+ const computeToolbarOpts = computed(() => {
108
+ return Object.assign({}, getConfig().gantt.toolbarConfig, props.toolbarConfig);
109
+ });
110
+ const computeZoomOpts = computed(() => {
111
+ return Object.assign({}, getConfig().gantt.zoomConfig, props.zoomConfig);
112
+ });
113
+ const computeTaskOpts = computed(() => {
114
+ return Object.assign({}, getConfig().gantt.taskConfig, props.taskConfig);
115
+ });
116
+ const computeTaskViewOpts = computed(() => {
117
+ return Object.assign({}, getConfig().gantt.taskViewConfig, props.taskViewConfig);
118
+ });
119
+ const computeTaskBarOpts = computed(() => {
120
+ return Object.assign({}, getConfig().gantt.taskBarConfig, props.taskBarConfig);
121
+ });
122
+ const computeTitleField = computed(() => {
123
+ const taskOpts = computeTaskOpts.value;
124
+ 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;
136
+ return taskOpts.progressField || 'progress';
137
+ });
138
+ const computeScrollbarOpts = computed(() => {
139
+ return Object.assign({}, getConfig().gantt.scrollbarConfig, props.scrollbarConfig);
140
+ });
141
+ const computeScrollbarXToTop = computed(() => {
142
+ const scrollbarOpts = computeScrollbarOpts.value;
143
+ return !!(scrollbarOpts.x && scrollbarOpts.x.position === 'top');
144
+ });
145
+ const computeScrollbarYToLeft = computed(() => {
146
+ const scrollbarOpts = computeScrollbarOpts.value;
147
+ return !!(scrollbarOpts.y && scrollbarOpts.y.position === 'left');
148
+ });
149
+ const computeStyles = computed(() => {
150
+ const { height, maxHeight } = props;
151
+ const { isZMax, tZindex } = reactData;
152
+ const stys = {};
153
+ if (isZMax) {
154
+ stys.zIndex = tZindex;
155
+ }
156
+ else {
157
+ if (height) {
158
+ stys.height = height === 'auto' || height === '100%' ? '100%' : toCssUnit(height);
159
+ }
160
+ if (maxHeight) {
161
+ stys.maxHeight = maxHeight === 'auto' || maxHeight === '100%' ? '100%' : toCssUnit(maxHeight);
162
+ }
163
+ }
164
+ return stys;
165
+ });
166
+ const computeTableExtendProps = computed(() => {
167
+ const rest = {};
168
+ tableComponentPropKeys.forEach((key) => {
169
+ rest[key] = props[key];
170
+ });
171
+ return rest;
172
+ });
173
+ const computeTableProps = computed(() => {
174
+ const { seqConfig, pagerConfig, editConfig, proxyConfig } = props;
175
+ 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
+ });
186
+ if (isZMax) {
187
+ if (tableExtendProps.maxHeight) {
188
+ tProps.maxHeight = '100%';
189
+ }
190
+ else {
191
+ tProps.height = '100%';
192
+ }
193
+ }
194
+ if (proxyConfig && isEnableConf(proxyOpts)) {
195
+ tProps.loading = isLoading;
196
+ if (pagerConfig && proxyOpts.seq && isEnableConf(pagerOpts)) {
197
+ tProps.seqConfig = Object.assign({}, seqConfig, { startIndex: (tablePage.currentPage - 1) * tablePage.pageSize });
198
+ }
199
+ }
200
+ if (editConfig) {
201
+ tProps.editConfig = Object.assign({}, editConfig);
202
+ }
203
+ return tProps;
204
+ });
205
+ const computeCurrLayoutConf = computed(() => {
206
+ const { layouts } = props;
207
+ let confs = [];
208
+ if (layouts && layouts.length) {
209
+ confs = layouts;
210
+ }
211
+ else {
212
+ confs = getConfig().gantt.layouts || defaultLayouts;
213
+ }
214
+ let headKeys = [];
215
+ let bodyKeys = [];
216
+ let footKeys = [];
217
+ if (confs.length) {
218
+ if (XEUtils.isArray(confs[0])) {
219
+ headKeys = confs[0];
220
+ bodyKeys = (confs[1] || []);
221
+ footKeys = (confs[2] || []);
222
+ }
223
+ else {
224
+ bodyKeys = confs;
225
+ }
226
+ }
227
+ return {
228
+ headKeys,
229
+ bodyKeys,
230
+ footKeys
231
+ };
232
+ });
233
+ const computeCustomCurrentPageFlag = computed(() => {
234
+ const pagerOpts = computePagerOpts.value;
235
+ return pagerOpts.currentPage;
236
+ });
237
+ const computeCustomPageSizeFlag = computed(() => {
238
+ const pagerOpts = computePagerOpts.value;
239
+ return pagerOpts.pageSize;
240
+ });
241
+ const computeCustomTotalFlag = computed(() => {
242
+ const pagerOpts = computePagerOpts.value;
243
+ return pagerOpts.total;
244
+ });
245
+ const computePageCount = computed(() => {
246
+ const { tablePage } = reactData;
247
+ return Math.max(Math.ceil(tablePage.total / tablePage.pageSize), 1);
248
+ });
249
+ const computeIsLoading = computed(() => {
250
+ const { loading, proxyConfig } = props;
251
+ const { tableLoading } = reactData;
252
+ const proxyOpts = computeProxyOpts.value;
253
+ const { showLoading } = proxyOpts;
254
+ return loading || (tableLoading && showLoading && proxyConfig && isEnableConf(proxyOpts));
255
+ });
256
+ const computeTableBorder = computed(() => {
257
+ const { border } = props;
258
+ if (border === true) {
259
+ return 'full';
260
+ }
261
+ if (border) {
262
+ return border;
263
+ }
264
+ return 'default';
265
+ });
24
266
  const refMaps = {
25
267
  refElem,
26
- refTable
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
27
289
  };
28
- const computeMaps = {};
29
290
  const $xeGantt = {
30
291
  xID,
31
- props,
292
+ props: props,
32
293
  context,
33
294
  reactData,
34
295
  internalData,
35
296
  getRefMaps: () => refMaps,
36
297
  getComputeMaps: () => computeMaps
37
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;
314
+ if ($xeTable && $ganttView) {
315
+ $xeTable.handleConnectGanttView($ganttView);
316
+ }
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) => {
326
+ const { tablePage } = reactData;
327
+ const { pagerConfig } = props;
328
+ const pagerOpts = computePagerOpts.value;
329
+ if (pagerConfig && isEnableConf(pagerOpts)) {
330
+ if (propKey) {
331
+ if (pagerOpts[propKey]) {
332
+ tablePage[propKey] = XEUtils.toNumber(pagerOpts[propKey]);
333
+ }
334
+ }
335
+ else {
336
+ const { currentPage, pageSize, total } = pagerOpts;
337
+ if (currentPage) {
338
+ tablePage.currentPage = currentPage;
339
+ }
340
+ if (pageSize) {
341
+ tablePage.pageSize = pageSize;
342
+ }
343
+ if (total) {
344
+ tablePage.total = total;
345
+ }
346
+ }
347
+ }
348
+ };
349
+ const triggerPendingEvent = (code) => {
350
+ const isActiveMsg = computeIsActiveMsg.value;
351
+ const $xeTable = refTable.value;
352
+ const selectRecords = $xeTable ? $xeTable.getCheckboxRecords() : [];
353
+ if (selectRecords.length) {
354
+ if ($xeTable) {
355
+ $xeTable.togglePendingRow(selectRecords);
356
+ }
357
+ $xeGantt.clearCheckboxRow();
358
+ }
359
+ else {
360
+ if (isActiveMsg) {
361
+ if (VxeUI.modal) {
362
+ VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' });
363
+ }
364
+ }
365
+ }
366
+ };
367
+ const getRespMsg = (rest, defaultMsg) => {
368
+ const proxyOpts = computeProxyOpts.value;
369
+ const resConfigs = proxyOpts.response || proxyOpts.props || {};
370
+ const messageProp = resConfigs.message;
371
+ const $xeTable = refTable.value;
372
+ let msg;
373
+ if (rest && messageProp) {
374
+ msg = XEUtils.isFunction(messageProp) ? messageProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, messageProp);
375
+ }
376
+ return msg || getI18n(defaultMsg);
377
+ };
378
+ const handleDeleteRow = (code, alertKey, callback) => {
379
+ const isActiveMsg = computeIsActiveMsg.value;
380
+ const selectRecords = $xeGantt.getCheckboxRecords();
381
+ if (isActiveMsg) {
382
+ if (selectRecords.length) {
383
+ if (VxeUI.modal) {
384
+ return VxeUI.modal.confirm({ id: `cfm_${code}`, content: getI18n(alertKey), escClosable: true }).then((type) => {
385
+ if (type === 'confirm') {
386
+ return callback();
387
+ }
388
+ });
389
+ }
390
+ }
391
+ else {
392
+ if (VxeUI.modal) {
393
+ VxeUI.modal.message({ id: `msg_${code}`, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' });
394
+ }
395
+ }
396
+ }
397
+ else {
398
+ if (selectRecords.length) {
399
+ callback();
400
+ }
401
+ }
402
+ return Promise.resolve();
403
+ };
404
+ const pageChangeEvent = (params) => {
405
+ const { proxyConfig } = props;
406
+ const { tablePage } = reactData;
407
+ const { $event, currentPage, pageSize } = params;
408
+ const proxyOpts = computeProxyOpts.value;
409
+ tablePage.currentPage = currentPage;
410
+ tablePage.pageSize = pageSize;
411
+ $xeGantt.dispatchEvent('page-change', params, $event);
412
+ if (proxyConfig && isEnableConf(proxyOpts)) {
413
+ $xeGantt.commitProxy('query').then((rest) => {
414
+ $xeGantt.dispatchEvent('proxy-query', rest, $event);
415
+ });
416
+ }
417
+ };
418
+ const handleSortEvent = (params) => {
419
+ const $xeTable = refTable.value;
420
+ const { proxyConfig } = props;
421
+ if (!$xeTable) {
422
+ return;
423
+ }
424
+ const { computeSortOpts } = $xeTable.getComputeMaps();
425
+ const proxyOpts = computeProxyOpts.value;
426
+ const sortOpts = computeSortOpts.value;
427
+ // 如果是服务端排序
428
+ if (sortOpts.remote) {
429
+ reactData.sortData = params.sortList;
430
+ if (proxyConfig && isEnableConf(proxyOpts)) {
431
+ reactData.tablePage.currentPage = 1;
432
+ $xeGantt.commitProxy('query').then((rest) => {
433
+ $xeGantt.dispatchEvent('proxy-query', rest, params.$event);
434
+ });
435
+ }
436
+ }
437
+ };
438
+ const sortChangeEvent = (params) => {
439
+ handleSortEvent(params);
440
+ $xeGantt.dispatchEvent('sort-change', params, params.$event);
441
+ };
442
+ const clearAllSortEvent = (params) => {
443
+ handleSortEvent(params);
444
+ $xeGantt.dispatchEvent('clear-all-sort', params, params.$event);
445
+ };
446
+ const handleFilterEvent = (params) => {
447
+ const $xeTable = refTable.value;
448
+ const { proxyConfig } = props;
449
+ if (!$xeTable) {
450
+ return;
451
+ }
452
+ const { computeFilterOpts } = $xeTable.getComputeMaps();
453
+ const proxyOpts = computeProxyOpts.value;
454
+ const filterOpts = computeFilterOpts.value;
455
+ // 如果是服务端过滤
456
+ if (filterOpts.remote) {
457
+ reactData.filterData = params.filterList;
458
+ if (proxyConfig && isEnableConf(proxyOpts)) {
459
+ reactData.tablePage.currentPage = 1;
460
+ $xeGantt.commitProxy('query').then((rest) => {
461
+ $xeGantt.dispatchEvent('proxy-query', rest, params.$event);
462
+ });
463
+ }
464
+ }
465
+ };
466
+ const filterChangeEvent = (params) => {
467
+ handleFilterEvent(params);
468
+ $xeGantt.dispatchEvent('filter-change', params, params.$event);
469
+ };
470
+ const clearAllFilterEvent = (params) => {
471
+ handleFilterEvent(params);
472
+ $xeGantt.dispatchEvent('clear-all-filter', params, params.$event);
473
+ };
474
+ const submitFormEvent = (params) => {
475
+ const { proxyConfig } = props;
476
+ const proxyOpts = computeProxyOpts.value;
477
+ if (reactData.tableLoading) {
478
+ return;
479
+ }
480
+ if (proxyConfig && isEnableConf(proxyOpts)) {
481
+ $xeGantt.commitProxy('reload').then((rest) => {
482
+ $xeGantt.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), params.$event);
483
+ });
484
+ }
485
+ $xeGantt.dispatchEvent('form-submit', params, params.$event);
486
+ };
487
+ const resetFormEvent = (params) => {
488
+ const $xeTable = refTable.value;
489
+ const { proxyConfig } = props;
490
+ const { $event } = params;
491
+ const proxyOpts = computeProxyOpts.value;
492
+ if (proxyConfig && isEnableConf(proxyOpts)) {
493
+ if ($xeTable) {
494
+ $xeTable.clearScroll();
495
+ }
496
+ $xeGantt.commitProxy('reload').then((rest) => {
497
+ $xeGantt.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), $event);
498
+ });
499
+ }
500
+ $xeGantt.dispatchEvent('form-reset', params, $event);
501
+ };
502
+ const submitInvalidEvent = (params) => {
503
+ $xeGantt.dispatchEvent('form-submit-invalid', params, params.$event);
504
+ };
505
+ const collapseEvent = (params) => {
506
+ const { $event } = params;
507
+ $xeGantt.dispatchEvent('form-toggle-collapse', params, $event);
508
+ $xeGantt.dispatchEvent('form-collapse', params, $event);
509
+ };
510
+ const handleZoom = (isMax) => {
511
+ const { isZMax } = reactData;
512
+ if (isMax ? !isZMax : isZMax) {
513
+ reactData.isZMax = !isZMax;
514
+ if (reactData.tZindex < getLastZIndex()) {
515
+ reactData.tZindex = nextZIndex();
516
+ }
517
+ }
518
+ return nextTick()
519
+ .then(() => $xeGantt.recalculate(true))
520
+ .then(() => {
521
+ setTimeout(() => $xeGantt.recalculate(true), 15);
522
+ return reactData.isZMax;
523
+ });
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;
563
+ if (!el) {
564
+ return;
565
+ }
566
+ const ganttContainerEl = refGanttContainer.value;
567
+ if (!ganttContainerEl) {
568
+ return;
569
+ }
570
+ const tableWrapperEl = refTableWrapper.value;
571
+ if (!tableWrapperEl) {
572
+ return;
573
+ }
574
+ const rsSplitLineEl = refResizableSplitTip.value;
575
+ if (!rsSplitLineEl) {
576
+ return;
577
+ }
578
+ const taskViewOpts = computeTaskViewOpts.value;
579
+ const containerRect = ganttContainerEl.getBoundingClientRect();
580
+ const rsSplitTipEl = rsSplitLineEl.children[0];
581
+ const disX = evnt.clientX;
582
+ const ganttWidth = ganttContainerEl.clientWidth;
583
+ const tableWidth = tableWrapperEl.clientWidth;
584
+ const tableMinWidth = (taskViewOpts.tableStyle && XEUtils.toNumber(taskViewOpts.tableStyle.minWidth)) || 80;
585
+ let targetTableWidth = tableWidth;
586
+ let offsetLeft = -1;
587
+ addClass(el, 'is--split-drag');
588
+ const handleReStyle = (evnt) => {
589
+ const rsNumLeftEl = rsSplitTipEl.children[0];
590
+ const rsNumRightEl = rsSplitTipEl.children[1];
591
+ let tipHeight = 0;
592
+ if (rsNumLeftEl) {
593
+ if (offsetLeft < 0) {
594
+ rsNumLeftEl.textContent = `${targetTableWidth}px`;
595
+ rsNumLeftEl.style.display = 'block';
596
+ tipHeight = rsNumLeftEl.offsetHeight;
597
+ }
598
+ else {
599
+ rsNumLeftEl.style.display = 'none';
600
+ }
601
+ }
602
+ if (rsNumRightEl) {
603
+ if (offsetLeft < 0) {
604
+ rsNumRightEl.style.display = 'none';
605
+ }
606
+ else {
607
+ rsNumRightEl.textContent = `${Math.floor(containerRect.width - targetTableWidth)}px`;
608
+ rsNumRightEl.style.display = 'block';
609
+ tipHeight = rsNumRightEl.offsetHeight;
610
+ }
611
+ }
612
+ const tipTop = evnt.clientY - containerRect.top - tipHeight / 2;
613
+ rsSplitLineEl.style.left = `${targetTableWidth}px`;
614
+ rsSplitTipEl.style.top = `${Math.min(containerRect.height - tipHeight - 1, Math.max(1, tipTop))}px`;
615
+ };
616
+ document.onmousemove = (evnt) => {
617
+ evnt.preventDefault();
618
+ offsetLeft = (evnt.clientX - disX);
619
+ targetTableWidth = Math.min(ganttWidth - 80, Math.max(tableMinWidth, tableWidth + offsetLeft));
620
+ handleReStyle(evnt);
621
+ };
622
+ document.onmouseup = () => {
623
+ document.onmousemove = null;
624
+ document.onmouseup = null;
625
+ rsSplitLineEl.style.display = '';
626
+ tableWrapperEl.style.width = `${targetTableWidth}px`;
627
+ removeClass(el, 'is--split-drag');
628
+ const $xeTable = refTable.value;
629
+ if ($xeTable) {
630
+ $xeTable.recalculate(true);
631
+ }
632
+ };
633
+ rsSplitLineEl.style.display = 'block';
634
+ handleReStyle(evnt);
635
+ };
636
+ const handleSplitLeftViewEvent = () => {
637
+ reactData.showLeftView = !reactData.showLeftView;
638
+ };
639
+ const handleSplitRightViewEvent = () => {
640
+ 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;
649
+ if (formOpts.items) {
650
+ const fData = {};
651
+ formOpts.items.forEach(item => {
652
+ const { field, itemRender } = item;
653
+ if (field) {
654
+ let itemValue = null;
655
+ if (itemRender) {
656
+ const { defaultValue } = itemRender;
657
+ if (XEUtils.isFunction(defaultValue)) {
658
+ itemValue = defaultValue({ item });
659
+ }
660
+ else if (!XEUtils.isUndefined(defaultValue)) {
661
+ itemValue = defaultValue;
662
+ }
663
+ }
664
+ fData[field] = itemValue;
665
+ }
666
+ });
667
+ return fData;
668
+ }
669
+ return {};
670
+ };
671
+ const initProxy = () => {
672
+ const { proxyConfig, formConfig } = props;
673
+ 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();
679
+ }
680
+ if (!proxyInited) {
681
+ 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
+ }
687
+ }
688
+ }
689
+ };
690
+ const handleGlobalKeydownEvent = (evnt) => {
691
+ const zoomOpts = computeZoomOpts.value;
692
+ const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
693
+ if (isEsc && reactData.isZMax && zoomOpts.escRestore !== false) {
694
+ $xeGantt.triggerZoomEvent(evnt);
695
+ }
696
+ };
38
697
  const dispatchEvent = (type, params, evnt) => {
39
- emit(type, createEvent(evnt, { $gantt: $xeGantt }, params));
698
+ emit(type, createEvent(evnt, { $grid: null, $gantt: $xeGantt }, params));
40
699
  };
41
700
  const ganttMethods = {
42
- dispatchEvent
701
+ dispatchEvent,
702
+ getEl() {
703
+ return refElem.value;
704
+ },
705
+ /**
706
+ * 提交指令,支持 code 或 button
707
+ * @param {String/Object} code 字符串或对象
708
+ */
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();
776
+ }
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);
787
+ }
788
+ }
789
+ if (isInited) {
790
+ // 重置代理表单数据
791
+ if (proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form) {
792
+ formData = getDefaultFormData();
793
+ reactData.formData = formData;
794
+ }
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
+ }
825
+ filterList = $xeTable.getCheckedFilters();
826
+ }
827
+ }
828
+ else {
829
+ if ($xeTable) {
830
+ if (isReload) {
831
+ $xeTable.clearAll();
832
+ }
833
+ else {
834
+ sortList = $xeTable.getSortColumns();
835
+ filterList = $xeTable.getCheckedFilters();
836
+ }
837
+ }
838
+ }
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;
872
+ }
873
+ }
874
+ 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) || [];
877
+ }
878
+ }
879
+ if ($xeTable) {
880
+ $xeTable.loadData(tableData);
881
+ }
882
+ else {
883
+ nextTick(() => {
884
+ if ($xeTable) {
885
+ $xeTable.loadData(tableData);
886
+ }
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 };
902
+ });
903
+ }
904
+ else {
905
+ errLog('vxe.error.notFunc', ['proxy-config.ajax.query']);
906
+ }
907
+ break;
908
+ }
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
+ }
959
+ }
960
+ if (deleteErrorMethods) {
961
+ deleteErrorMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
962
+ }
963
+ return { status: false };
964
+ });
965
+ });
966
+ }
967
+ else {
968
+ if (isActiveMsg) {
969
+ if (VxeUI.modal) {
970
+ VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' });
971
+ }
972
+ }
973
+ }
974
+ }
975
+ else {
976
+ errLog('vxe.error.notFunc', ['proxy-config.ajax.delete']);
977
+ }
978
+ break;
979
+ }
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));
1009
+ }
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
+ });
1058
+ }
1059
+ else {
1060
+ errLog('vxe.error.notFunc', ['proxy-config.ajax.save']);
1061
+ }
1062
+ break;
1063
+ }
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
+ }
1075
+ }
1076
+ }
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);
1126
+ }
1127
+ return nextTick();
1128
+ },
1129
+ clearFormValidate(field) {
1130
+ const $form = refForm.value;
1131
+ if ($form) {
1132
+ return $form.clearValidate(field);
1133
+ }
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);
1145
+ }
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);
1157
+ }
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);
1180
+ }
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
+ };
1195
+ }
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;
1223
+ }
1224
+ if (XEUtils.isFunction(slotFunc)) {
1225
+ return getSlotVNs(slotFunc(params));
1226
+ }
1227
+ }
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);
1294
+ }
1295
+ return nextTick();
1296
+ },
1297
+ reloadColumn(columns) {
1298
+ $xeGantt.clearAll();
1299
+ return $xeGantt.loadColumn(columns);
1300
+ }
1301
+ });
1302
+ /**
1303
+ * 渲染表单
1304
+ */
1305
+ const renderForm = () => {
1306
+ const { formConfig, proxyConfig } = props;
1307
+ 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
+ // 处理插槽
1328
+ 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
+ });
1336
+ });
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
+ }
1343
+ }
1344
+ return h('div', {
1345
+ ref: refFormWrapper,
1346
+ key: 'form',
1347
+ class: 'vxe-gantt--form-wrapper'
1348
+ }, slotVNs);
1349
+ }
1350
+ return renderEmptyElement($xeGantt);
1351
+ };
1352
+ /**
1353
+ * 渲染工具栏
1354
+ */
1355
+ const renderToolbar = () => {
1356
+ 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
+ }
1394
+ return h('div', {
1395
+ ref: refToolbarWrapper,
1396
+ key: 'toolbar',
1397
+ class: 'vxe-gantt--toolbar-wrapper'
1398
+ }, slotVNs);
1399
+ }
1400
+ return renderEmptyElement($xeGantt);
1401
+ };
1402
+ /**
1403
+ * 渲染表格顶部区域
1404
+ */
1405
+ const renderTop = () => {
1406
+ const topSlot = slots.top;
1407
+ if (topSlot) {
1408
+ return h('div', {
1409
+ ref: refTopWrapper,
1410
+ key: 'top',
1411
+ class: 'vxe-gantt--top-wrapper'
1412
+ }, topSlot({ $grid: null, $gantt: $xeGantt }));
1413
+ }
1414
+ return renderEmptyElement($xeGantt);
1415
+ };
1416
+ const renderTableLeft = () => {
1417
+ const leftSlot = slots.left;
1418
+ if (leftSlot) {
1419
+ return h('div', {
1420
+ class: 'vxe-gantt--left-wrapper'
1421
+ }, leftSlot({ $grid: null, $gantt: $xeGantt }));
1422
+ }
1423
+ return renderEmptyElement($xeGantt);
1424
+ };
1425
+ const renderTableRight = () => {
1426
+ const rightSlot = slots.right;
1427
+ if (rightSlot) {
1428
+ return h('div', {
1429
+ class: 'vxe-gantt--right-wrapper'
1430
+ }, rightSlot({ $grid: null, $gantt: $xeGantt }));
1431
+ }
1432
+ 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
+ }
1469
+ return h('div', {
1470
+ ref: refTableWrapper,
1471
+ class: 'vxe-gantt--table-wrapper'
1472
+ }, [
1473
+ h(VxeTableComponent, Object.assign(Object.assign({ ref: refTable }, tableProps), tableOns), slotObj)
1474
+ ]);
1475
+ };
1476
+ /**
1477
+ * 渲染表格底部区域
1478
+ */
1479
+ const renderBottom = () => {
1480
+ if (slots.bottom) {
1481
+ return h('div', {
1482
+ ref: refBottomWrapper,
1483
+ key: 'bottom',
1484
+ class: 'vxe-gantt--bottom-wrapper'
1485
+ }, slots.bottom({ $grid: null, $gantt: $xeGantt }));
1486
+ }
1487
+ return renderEmptyElement($xeGantt);
1488
+ };
1489
+ /**
1490
+ * 渲染分页
1491
+ */
1492
+ const renderPager = () => {
1493
+ const { proxyConfig, pagerConfig } = props;
1494
+ const proxyOpts = computeProxyOpts.value;
1495
+ const pagerOpts = computePagerOpts.value;
1496
+ const pagerSlot = slots.pager;
1497
+ if ((pagerConfig && isEnableConf(pagerOpts)) || slots.pager) {
1498
+ return h('div', {
1499
+ ref: refPagerWrapper,
1500
+ key: 'pager',
1501
+ class: 'vxe-gantt--pager-wrapper'
1502
+ }, pagerSlot
1503
+ ? pagerSlot({ $grid: null, $gantt: $xeGantt })
1504
+ : [
1505
+ VxeUIPagerComponent
1506
+ ? h(VxeUIPagerComponent, Object.assign(Object.assign(Object.assign({ ref: refPager }, pagerOpts), (proxyConfig && isEnableConf(proxyOpts) ? reactData.tablePage : {})), { onPageChange: pageChangeEvent }), getConfigSlot(pagerOpts.slots))
1507
+ : renderEmptyElement($xeGantt)
1508
+ ]);
1509
+ }
1510
+ return renderEmptyElement($xeGantt);
1511
+ };
1512
+ /**
1513
+ * 渲染任务视图
1514
+ */
1515
+ const renderTaskView = () => {
1516
+ return h('div', {
1517
+ ref: refGanttWrapper,
1518
+ class: 'vxe-gantt--view-wrapper'
1519
+ }, [
1520
+ h(GanttViewComponent, {
1521
+ ref: refGanttView
1522
+ })
1523
+ ]);
1524
+ };
1525
+ const renderSplitBar = () => {
1526
+ const { showLeftView, showRightView } = reactData;
1527
+ return h('div', {
1528
+ class: 'vxe-gantt--view-split-bar'
1529
+ }, [
1530
+ h('div', {
1531
+ class: 'vxe-gantt--view-split-bar-handle',
1532
+ onMousedown: dragSplitEvent
1533
+ }),
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
+ ])
1558
+ ]);
1559
+ };
1560
+ const renderChildLayout = (layoutKeys) => {
1561
+ const childVNs = [];
1562
+ layoutKeys.forEach(key => {
1563
+ switch (key) {
1564
+ case 'Form':
1565
+ childVNs.push(renderForm());
1566
+ break;
1567
+ case 'Toolbar':
1568
+ childVNs.push(renderToolbar());
1569
+ break;
1570
+ case 'Top':
1571
+ childVNs.push(renderTop());
1572
+ break;
1573
+ case 'Gantt':
1574
+ childVNs.push(h('div', {
1575
+ ref: refGanttContainer,
1576
+ key: 'tv',
1577
+ class: 'vxe-gantt--gantt-container'
1578
+ }, [
1579
+ renderTableLeft(),
1580
+ renderTable(),
1581
+ renderSplitBar(),
1582
+ renderTaskView(),
1583
+ renderTableRight(),
1584
+ h('div', {
1585
+ ref: refResizableSplitTip,
1586
+ class: 'vxe-gantt--resizable-split-tip'
1587
+ }, [
1588
+ h('div', {
1589
+ class: 'vxe-gantt--resizable-split-tip-number'
1590
+ }, [
1591
+ h('div', {
1592
+ class: 'vxe-gantt--resizable-split-number-left'
1593
+ }, '10px'),
1594
+ h('div', {
1595
+ class: 'vxe-gantt--resizable-split-number-right'
1596
+ }, '20px')
1597
+ ])
1598
+ ])
1599
+ ]));
1600
+ break;
1601
+ case 'Bottom':
1602
+ childVNs.push(renderBottom());
1603
+ break;
1604
+ case 'Pager':
1605
+ childVNs.push(renderPager());
1606
+ break;
1607
+ default:
1608
+ errLog('vxe.error.notProp', [`layouts -> ${key}`]);
1609
+ break;
1610
+ }
1611
+ });
1612
+ return childVNs;
1613
+ };
1614
+ const renderLayout = () => {
1615
+ const currLayoutConf = computeCurrLayoutConf.value;
1616
+ const { headKeys, bodyKeys, footKeys } = currLayoutConf;
1617
+ const asideLeftSlot = slots.asideLeft || slots['aside-left'];
1618
+ const asideRightSlot = slots.asideRight || slots['aside-right'];
1619
+ return [
1620
+ h('div', {
1621
+ class: 'vxe-gantt--layout-header-wrapper'
1622
+ }, renderChildLayout(headKeys)),
1623
+ h('div', {
1624
+ class: 'vxe-gantt--layout-body-wrapper'
1625
+ }, [
1626
+ asideLeftSlot
1627
+ ? h('div', {
1628
+ class: 'vxe-gantt--layout-aside-left-wrapper'
1629
+ }, asideLeftSlot({}))
1630
+ : renderEmptyElement($xeGantt),
1631
+ h('div', {
1632
+ class: 'vxe-gantt--layout-body-content-wrapper'
1633
+ }, renderChildLayout(bodyKeys)),
1634
+ asideRightSlot
1635
+ ? h('div', {
1636
+ class: 'vxe-gantt--layout-aside-right-wrapper'
1637
+ }, asideRightSlot({}))
1638
+ : renderEmptyElement($xeGantt)
1639
+ ]),
1640
+ h('div', {
1641
+ class: 'vxe-gantt--layout-footer-wrapper'
1642
+ }, renderChildLayout(footKeys)),
1643
+ h('div', {
1644
+ class: 'vxe-gantt--border-line'
1645
+ })
1646
+ ];
43
1647
  };
44
- const ganttPrivateMethods = {};
45
- Object.assign($xeGantt, ganttMethods, ganttPrivateMethods);
46
1648
  const renderVN = () => {
1649
+ 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;
47
1656
  return h('div', {
48
1657
  ref: refElem,
49
- class: 'vxe-gantt'
50
- });
1658
+ class: ['vxe-gantt', `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
1659
+ [`size--${vSize}`]: vSize,
1660
+ 'is--round': props.round,
1661
+ 'is--maximize': reactData.isZMax,
1662
+ 'is--loading': isLoading,
1663
+ 'show--left': showLeftView,
1664
+ 'show--right': showRightView
1665
+ }],
1666
+ style: styles
1667
+ }, renderLayout());
51
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);
1700
+ }
1701
+ }
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']);
1725
+ }
1726
+ if (columns && columns.length) {
1727
+ $xeGantt.loadColumn(columns);
1728
+ }
1729
+ initToolbar();
1730
+ initProxy();
1731
+ });
1732
+ initGanttView();
1733
+ globalEvents.on($xeGantt, 'keydown', handleGlobalKeydownEvent);
1734
+ });
52
1735
  onUnmounted(() => {
1736
+ globalEvents.off($xeGantt, 'keydown');
53
1737
  XEUtils.assign(internalData, createInternalData());
54
1738
  });
55
1739
  $xeGantt.renderVN = renderVN;
1740
+ provide('$xeGantt', $xeGantt);
56
1741
  return $xeGantt;
57
1742
  },
58
1743
  render() {