vxe-gantt 0.0.2 → 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +18 -24
  2. package/es/components.js +3 -2
  3. package/es/gantt/src/gantt-body.js +137 -0
  4. package/es/gantt/src/gantt-chart.js +125 -0
  5. package/es/gantt/src/gantt-header.js +97 -0
  6. package/es/gantt/src/gantt-view.js +820 -0
  7. package/es/gantt/src/gantt.js +1897 -43
  8. package/es/gantt/src/util.js +9 -0
  9. package/es/gantt/style.css +624 -0
  10. package/es/gantt/style.min.css +1 -0
  11. package/es/index.esm.js +5 -2
  12. package/es/style.css +1 -0
  13. package/es/style.min.css +1 -0
  14. package/es/ui/index.js +55 -5
  15. package/es/ui/src/comp.js +1 -2
  16. package/es/ui/src/dom.js +44 -105
  17. package/es/ui/src/log.js +3 -2
  18. package/es/ui/src/utils.js +4 -3
  19. package/es/ui/src/vn.js +1 -32
  20. package/es/vxe-gantt/style.css +624 -0
  21. package/es/vxe-gantt/style.min.css +1 -0
  22. package/helper/vetur/attributes.json +1 -1
  23. package/helper/vetur/tags.json +1 -1
  24. package/lib/components.js +20 -19
  25. package/lib/components.min.js +1 -1
  26. package/lib/gantt/index.js +3 -3
  27. package/lib/gantt/index.min.js +1 -1
  28. package/lib/gantt/src/gantt-body.js +140 -0
  29. package/lib/gantt/src/gantt-body.min.js +1 -0
  30. package/lib/gantt/src/gantt-chart.js +134 -0
  31. package/lib/gantt/src/gantt-chart.min.js +1 -0
  32. package/lib/gantt/src/gantt-header.js +97 -0
  33. package/lib/gantt/src/gantt-header.min.js +1 -0
  34. package/lib/gantt/src/gantt-view.js +808 -0
  35. package/lib/gantt/src/gantt-view.min.js +1 -0
  36. package/lib/gantt/src/gantt.js +2045 -48
  37. package/lib/gantt/src/gantt.min.js +1 -1
  38. package/lib/gantt/src/util.js +16 -0
  39. package/lib/gantt/src/util.min.js +1 -0
  40. package/lib/gantt/style/style.css +624 -0
  41. package/lib/gantt/style/style.min.css +1 -0
  42. package/lib/index.common.js +12 -7
  43. package/lib/index.umd.js +11484 -235
  44. package/lib/index.umd.min.js +1 -1
  45. package/lib/style.css +1 -0
  46. package/lib/style.min.css +1 -0
  47. package/lib/ui/index.js +54 -14
  48. package/lib/ui/index.min.js +1 -1
  49. package/lib/ui/src/comp.js +3 -2
  50. package/lib/ui/src/comp.min.js +1 -1
  51. package/lib/ui/src/dom.js +78 -138
  52. package/lib/ui/src/dom.min.js +1 -1
  53. package/lib/ui/src/log.js +4 -3
  54. package/lib/ui/src/log.min.js +1 -1
  55. package/lib/ui/src/utils.js +5 -4
  56. package/lib/ui/src/utils.min.js +1 -1
  57. package/lib/ui/src/vn.js +1 -43
  58. package/lib/ui/src/vn.min.js +0 -1
  59. package/lib/vxe-gantt/index.js +4 -2
  60. package/lib/vxe-gantt/index.min.js +1 -1
  61. package/lib/vxe-gantt/style/style.css +624 -0
  62. package/lib/vxe-gantt/style/style.min.css +1 -0
  63. package/lib/vxe-ui/index.js +4 -2
  64. package/lib/vxe-ui/index.min.js +1 -1
  65. package/package.json +13 -13
  66. package/packages/components.ts +8 -5
  67. package/packages/gantt/index.ts +2 -2
  68. package/packages/gantt/src/gantt-body.ts +155 -0
  69. package/packages/gantt/src/gantt-chart.ts +143 -0
  70. package/packages/gantt/src/gantt-header.ts +109 -0
  71. package/packages/gantt/src/gantt-view.ts +908 -0
  72. package/packages/gantt/src/gantt.ts +2048 -46
  73. package/packages/gantt/src/util.ts +12 -0
  74. package/packages/index.ts +6 -2
  75. package/packages/ui/index.ts +56 -4
  76. package/packages/ui/src/comp.ts +2 -2
  77. package/packages/ui/src/dom.ts +53 -110
  78. package/packages/ui/src/log.ts +4 -2
  79. package/packages/ui/src/utils.ts +5 -3
  80. package/packages/ui/src/vn.ts +0 -37
  81. package/styles/components/gantt-module/all.scss +1 -0
  82. package/styles/components/gantt-module/gantt-chart.scss +65 -0
  83. package/styles/components/gantt.scss +591 -0
  84. package/styles/helpers/baseMixin.scss +96 -0
  85. package/styles/helpers/baseVar.scss +4 -0
  86. package/styles/helpers/placement.scss +39 -0
  87. package/styles/theme/base.scss +11 -0
  88. package/styles/theme/dark.scss +5 -0
  89. package/styles/theme/light.scss +5 -0
  90. package/types/all.d.ts +3 -3
  91. package/types/index.d.ts +2 -2
  92. package/README.en.md +0 -72
  93. package/README.ja-JP.md +0 -72
  94. package/README.zh-TW.md +0 -73
@@ -1,61 +1,1915 @@
1
- import { ref, h, reactive, onUnmounted } from 'vue';
2
1
  import { defineVxeComponent } from '../../ui/src/comp';
3
- import { getConfig, createEvent } from '../../ui';
2
+ import { VxeUI } from '@vxe-ui/core';
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 { warnLog, errLog } from '../../ui/src/log';
7
+ import GanttViewComponent from './gantt-view';
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
+ });
5
41
  function createInternalData() {
6
- return {};
42
+ return {
43
+ resizeTableWidth: 0
44
+ };
7
45
  }
8
- export default defineVxeComponent({
46
+ export default {
9
47
  name: 'VxeGantt',
10
- props: {
11
- size: {
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: {
12
52
  type: String,
13
53
  default: () => getConfig().gantt.size || getConfig().size
14
- }
54
+ } }),
55
+ provide() {
56
+ const $xeGantt = this;
57
+ return {
58
+ $xeGantt
59
+ };
15
60
  },
16
- emits: [],
17
- setup(props, context) {
18
- const { emit } = context;
61
+ data() {
62
+ var _a;
19
63
  const xID = XEUtils.uniqueId();
20
- const refElem = ref();
21
- const refTable = ref();
22
- const reactData = reactive({});
23
- const internalData = createInternalData();
24
- const refMaps = {
25
- refElem,
26
- refTable
64
+ const reactData = {
65
+ tableLoading: false,
66
+ proxyInited: false,
67
+ isZMax: false,
68
+ tableData: [],
69
+ filterData: [],
70
+ formData: {},
71
+ sortData: [],
72
+ tZindex: 0,
73
+ tablePage: {
74
+ total: 0,
75
+ pageSize: ((_a = getConfig().pager) === null || _a === void 0 ? void 0 : _a.pageSize) || 10,
76
+ currentPage: 1
77
+ },
78
+ showLeftView: true,
79
+ showRightView: true
27
80
  };
28
- const computeMaps = {};
29
- const $xeGantt = {
81
+ const internalData = createInternalData();
82
+ return {
30
83
  xID,
31
- props,
32
- context,
33
84
  reactData,
34
- internalData,
35
- getRefMaps: () => refMaps,
36
- getComputeMaps: () => computeMaps
37
- };
38
- const dispatchEvent = (type, params, evnt) => {
39
- emit(type, createEvent(evnt, { $gantt: $xeGantt }, params));
40
- };
41
- const ganttMethods = {
42
- dispatchEvent
85
+ internalData
43
86
  };
44
- const ganttPrivateMethods = {};
45
- Object.assign($xeGantt, ganttMethods, ganttPrivateMethods);
46
- const renderVN = () => {
87
+ },
88
+ computed: Object.assign(Object.assign({}, {}), { computeProxyOpts() {
89
+ const $xeGantt = this;
90
+ const props = $xeGantt;
91
+ return XEUtils.merge({}, XEUtils.clone(getConfig().gantt.proxyConfig, true), props.proxyConfig);
92
+ },
93
+ computeIsRespMsg() {
94
+ const $xeGantt = this;
95
+ const proxyOpts = $xeGantt.computeProxyOpts;
96
+ return !!(XEUtils.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg);
97
+ },
98
+ computeIsActiveMsg() {
99
+ const $xeGantt = this;
100
+ const proxyOpts = $xeGantt.computeProxyOpts;
101
+ return XEUtils.isBoolean(proxyOpts.showActionMsg) ? proxyOpts.showActionMsg : !!proxyOpts.showActiveMsg;
102
+ },
103
+ computePagerOpts() {
104
+ const $xeGantt = this;
105
+ const props = $xeGantt;
106
+ return Object.assign({}, getConfig().gantt.pagerConfig, props.pagerConfig);
107
+ },
108
+ computeFormOpts() {
109
+ const $xeGantt = this;
110
+ const props = $xeGantt;
111
+ return Object.assign({}, getConfig().gantt.formConfig, props.formConfig);
112
+ },
113
+ computeToolbarOpts() {
114
+ const $xeGantt = this;
115
+ const props = $xeGantt;
116
+ return Object.assign({}, getConfig().gantt.toolbarConfig, props.toolbarConfig);
117
+ },
118
+ computeZoomOpts() {
119
+ const $xeGantt = this;
120
+ const props = $xeGantt;
121
+ return Object.assign({}, getConfig().gantt.zoomConfig, props.zoomConfig);
122
+ },
123
+ computeTaskOpts() {
124
+ const $xeGantt = this;
125
+ const props = $xeGantt;
126
+ return Object.assign({}, getConfig().gantt.taskConfig, props.taskConfig);
127
+ },
128
+ computeTaskViewOpts() {
129
+ const $xeGantt = this;
130
+ const props = $xeGantt;
131
+ return Object.assign({}, getConfig().gantt.taskViewConfig, props.taskViewConfig);
132
+ },
133
+ computeTaskBarOpts() {
134
+ const $xeGantt = this;
135
+ const props = $xeGantt;
136
+ return Object.assign({}, getConfig().gantt.taskBarConfig, props.taskBarConfig);
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;
146
+ return taskOpts.titleField || 'title';
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;
161
+ return taskOpts.progressField || 'progress';
162
+ },
163
+ computeScrollbarOpts() {
164
+ const $xeGantt = this;
165
+ const props = $xeGantt;
166
+ return Object.assign({}, getConfig().gantt.scrollbarConfig, props.scrollbarConfig);
167
+ },
168
+ computeScrollbarXToTop() {
169
+ const $xeGantt = this;
170
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
171
+ return !!(scrollbarOpts.x && scrollbarOpts.x.position === 'top');
172
+ },
173
+ computeScrollbarYToLeft() {
174
+ const $xeGantt = this;
175
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
176
+ return !!(scrollbarOpts.y && scrollbarOpts.y.position === 'left');
177
+ },
178
+ computeStyles() {
179
+ const $xeGantt = this;
180
+ const props = $xeGantt;
181
+ const reactData = $xeGantt.reactData;
182
+ const { height, maxHeight } = props;
183
+ const { isZMax, tZindex } = reactData;
184
+ const taskViewOpts = $xeGantt.computeTaskViewOpts;
185
+ const { tableStyle } = taskViewOpts;
186
+ const taskBarOpts = $xeGantt.computeTaskBarOpts;
187
+ const { barStyle } = taskBarOpts;
188
+ const stys = {};
189
+ if (isZMax) {
190
+ stys.zIndex = tZindex;
191
+ }
192
+ else {
193
+ if (height) {
194
+ stys.height = height === 'auto' || height === '100%' ? '100%' : toCssUnit(height);
195
+ }
196
+ if (maxHeight) {
197
+ stys.maxHeight = maxHeight === 'auto' || maxHeight === '100%' ? '100%' : toCssUnit(maxHeight);
198
+ }
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
+ }
215
+ return stys;
216
+ },
217
+ computeTableExtendProps() {
218
+ const $xeGantt = this;
219
+ const props = $xeGantt;
220
+ const rest = {};
221
+ const gridProps = props;
222
+ propKeys.forEach(key => {
223
+ rest[key] = gridProps[key];
224
+ });
225
+ return rest;
226
+ },
227
+ computeTableProps() {
228
+ const $xeGantt = this;
229
+ const props = $xeGantt;
230
+ const reactData = $xeGantt.reactData;
231
+ const { seqConfig, pagerConfig, editConfig, proxyConfig } = props;
232
+ const { isZMax, tablePage } = reactData;
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);
238
+ if (isZMax) {
239
+ if (tableExtendProps.maxHeight) {
240
+ tProps.maxHeight = '100%';
241
+ }
242
+ else {
243
+ tProps.height = '100%';
244
+ }
245
+ }
246
+ if (proxyConfig && isEnableConf(proxyOpts)) {
247
+ tProps.loading = isLoading;
248
+ if (pagerConfig && proxyOpts.seq && isEnableConf(pagerOpts)) {
249
+ tProps.seqConfig = Object.assign({}, seqConfig, { startIndex: (tablePage.currentPage - 1) * tablePage.pageSize });
250
+ }
251
+ }
252
+ if (editConfig) {
253
+ tProps.editConfig = Object.assign({}, editConfig);
254
+ }
255
+ return tProps;
256
+ },
257
+ tableProps() {
258
+ const $xeGantt = this;
259
+ return $xeGantt.computeTableProps;
260
+ },
261
+ computeCurrLayoutConf() {
262
+ const $xeGantt = this;
263
+ const props = $xeGantt;
264
+ const { layouts } = props;
265
+ let confs = [];
266
+ if (layouts && layouts.length) {
267
+ confs = layouts;
268
+ }
269
+ else {
270
+ confs = getConfig().gantt.layouts || defaultLayouts;
271
+ }
272
+ let headKeys = [];
273
+ let bodyKeys = [];
274
+ let footKeys = [];
275
+ if (confs.length) {
276
+ if (XEUtils.isArray(confs[0])) {
277
+ headKeys = confs[0];
278
+ bodyKeys = (confs[1] || []);
279
+ footKeys = (confs[2] || []);
280
+ }
281
+ else {
282
+ bodyKeys = confs;
283
+ }
284
+ }
285
+ return {
286
+ headKeys,
287
+ bodyKeys,
288
+ footKeys
289
+ };
290
+ },
291
+ computeCustomCurrentPageFlag() {
292
+ const $xeGantt = this;
293
+ const pagerOpts = $xeGantt.computePagerOpts;
294
+ return pagerOpts.currentPage;
295
+ },
296
+ computeCustomPageSizeFlag() {
297
+ const $xeGantt = this;
298
+ const pagerOpts = $xeGantt.computePagerOpts;
299
+ return pagerOpts.pageSize;
300
+ },
301
+ computeCustomTotalFlag() {
302
+ const $xeGantt = this;
303
+ const pagerOpts = $xeGantt.computePagerOpts;
304
+ return pagerOpts.total;
305
+ },
306
+ computePageCount() {
307
+ const $xeGantt = this;
308
+ const reactData = $xeGantt.reactData;
309
+ const { tablePage } = reactData;
310
+ return Math.max(Math.ceil(tablePage.total / tablePage.pageSize), 1);
311
+ },
312
+ computeIsLoading() {
313
+ const $xeGantt = this;
314
+ const props = $xeGantt;
315
+ const reactData = $xeGantt.reactData;
316
+ const { loading, proxyConfig } = props;
317
+ const { tableLoading } = reactData;
318
+ const proxyOpts = $xeGantt.computeProxyOpts;
319
+ const { showLoading } = proxyOpts;
320
+ return loading || (tableLoading && showLoading && proxyConfig && isEnableConf(proxyOpts));
321
+ },
322
+ computeTableBorder() {
323
+ const $xeGantt = this;
324
+ const props = $xeGantt;
325
+ const { border } = props;
326
+ if (border === true) {
327
+ return 'full';
328
+ }
329
+ if (border) {
330
+ return border;
331
+ }
332
+ return 'default';
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;
379
+ if ($xeTable && $ganttView) {
380
+ $xeTable.handleConnectGanttView($ganttView);
381
+ }
382
+ },
383
+ initPages(propKey) {
384
+ const $xeGantt = this;
385
+ const props = $xeGantt;
386
+ const reactData = $xeGantt.reactData;
387
+ const { tablePage } = reactData;
388
+ const { pagerConfig } = props;
389
+ const pagerOpts = $xeGantt.computePagerOpts;
390
+ if (pagerConfig && isEnableConf(pagerOpts)) {
391
+ if (propKey) {
392
+ if (pagerOpts[propKey]) {
393
+ tablePage[propKey] = XEUtils.toNumber(pagerOpts[propKey]);
394
+ }
395
+ }
396
+ else {
397
+ const { currentPage, pageSize, total } = pagerOpts;
398
+ if (currentPage) {
399
+ tablePage.currentPage = currentPage;
400
+ }
401
+ if (pageSize) {
402
+ tablePage.pageSize = pageSize;
403
+ }
404
+ if (total) {
405
+ tablePage.total = total;
406
+ }
407
+ }
408
+ }
409
+ },
410
+ triggerPendingEvent(code) {
411
+ const $xeGantt = this;
412
+ const isActiveMsg = $xeGantt.computeIsActiveMsg;
413
+ const $xeTable = $xeGantt.$refs.refTable;
414
+ const selectRecords = $xeTable.getCheckboxRecords();
415
+ if (selectRecords.length) {
416
+ $xeTable.togglePendingRow(selectRecords);
417
+ $xeGantt.clearCheckboxRow();
418
+ }
419
+ else {
420
+ if (isActiveMsg) {
421
+ if (VxeUI.modal) {
422
+ VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' });
423
+ }
424
+ }
425
+ }
426
+ },
427
+ getRespMsg(rest, defaultMsg) {
428
+ const $xeGantt = this;
429
+ const proxyOpts = $xeGantt.computeProxyOpts;
430
+ const resConfigs = proxyOpts.response || proxyOpts.props || {};
431
+ const messageProp = resConfigs.message;
432
+ const $xeTable = $xeGantt.$refs.refTable;
433
+ let msg;
434
+ if (rest && messageProp) {
435
+ msg = XEUtils.isFunction(messageProp) ? messageProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, messageProp);
436
+ }
437
+ return msg || getI18n(defaultMsg);
438
+ },
439
+ handleDeleteRow(code, alertKey, callback) {
440
+ const $xeGantt = this;
441
+ const isActiveMsg = $xeGantt.computeIsActiveMsg;
442
+ const selectRecords = $xeGantt.getCheckboxRecords();
443
+ if (isActiveMsg) {
444
+ if (selectRecords.length) {
445
+ if (VxeUI.modal) {
446
+ return VxeUI.modal.confirm({ id: `cfm_${code}`, content: getI18n(alertKey), escClosable: true }).then((type) => {
447
+ if (type === 'confirm') {
448
+ return callback();
449
+ }
450
+ });
451
+ }
452
+ }
453
+ else {
454
+ if (VxeUI.modal) {
455
+ VxeUI.modal.message({ id: `msg_${code}`, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' });
456
+ }
457
+ }
458
+ }
459
+ else {
460
+ if (selectRecords.length) {
461
+ callback();
462
+ }
463
+ }
464
+ return Promise.resolve();
465
+ },
466
+ pageChangeEvent(params) {
467
+ const $xeGantt = this;
468
+ const props = $xeGantt;
469
+ const reactData = $xeGantt.reactData;
470
+ const { proxyConfig } = props;
471
+ const { tablePage } = reactData;
472
+ const { $event, currentPage, pageSize } = params;
473
+ const proxyOpts = $xeGantt.computeProxyOpts;
474
+ tablePage.currentPage = currentPage;
475
+ tablePage.pageSize = pageSize;
476
+ $xeGantt.dispatchEvent('page-change', params, $event);
477
+ if (proxyConfig && isEnableConf(proxyOpts)) {
478
+ $xeGantt.commitProxy('query').then((rest) => {
479
+ $xeGantt.dispatchEvent('proxy-query', rest, $event);
480
+ });
481
+ }
482
+ },
483
+ handleSortEvent(params) {
484
+ const $xeGantt = this;
485
+ const props = $xeGantt;
486
+ const reactData = $xeGantt.reactData;
487
+ const $xeTable = $xeGantt.$refs.refTable;
488
+ const { proxyConfig } = props;
489
+ const proxyOpts = $xeGantt.computeProxyOpts;
490
+ const sortOpts = $xeTable.computeSortOpts;
491
+ // 如果是服务端排序
492
+ if (sortOpts.remote) {
493
+ reactData.sortData = params.sortList;
494
+ if (proxyConfig && isEnableConf(proxyOpts)) {
495
+ reactData.tablePage.currentPage = 1;
496
+ $xeGantt.commitProxy('query').then((rest) => {
497
+ $xeGantt.dispatchEvent('proxy-query', rest, params.$event);
498
+ });
499
+ }
500
+ }
501
+ },
502
+ sortChangeEvent(params) {
503
+ const $xeGantt = this;
504
+ $xeGantt.handleSortEvent(params);
505
+ $xeGantt.dispatchEvent('sort-change', params, params.$event);
506
+ },
507
+ clearAllSortEvent(params) {
508
+ const $xeGantt = this;
509
+ $xeGantt.handleSortEvent(params);
510
+ $xeGantt.dispatchEvent('clear-all-sort', params, params.$event);
511
+ },
512
+ handleFilterEvent(params) {
513
+ const $xeGantt = this;
514
+ const props = $xeGantt;
515
+ const reactData = $xeGantt.reactData;
516
+ const $xeTable = $xeGantt.$refs.refTable;
517
+ const { proxyConfig } = props;
518
+ const proxyOpts = $xeGantt.computeProxyOpts;
519
+ const filterOpts = $xeTable.computeFilterOpts;
520
+ // 如果是服务端过滤
521
+ if (filterOpts.remote) {
522
+ reactData.filterData = params.filterList;
523
+ if (proxyConfig && isEnableConf(proxyOpts)) {
524
+ reactData.tablePage.currentPage = 1;
525
+ $xeGantt.commitProxy('query').then((rest) => {
526
+ $xeGantt.dispatchEvent('proxy-query', rest, params.$event);
527
+ });
528
+ }
529
+ }
530
+ },
531
+ filterChangeEvent(params) {
532
+ const $xeGantt = this;
533
+ $xeGantt.handleFilterEvent(params);
534
+ $xeGantt.dispatchEvent('filter-change', params, params.$event);
535
+ },
536
+ clearAllFilterEvent(params) {
537
+ const $xeGantt = this;
538
+ $xeGantt.handleFilterEvent(params);
539
+ $xeGantt.dispatchEvent('clear-all-filter', params, params.$event);
540
+ },
541
+ submitFormEvent(params) {
542
+ const $xeGantt = this;
543
+ const props = $xeGantt;
544
+ const reactData = $xeGantt.reactData;
545
+ const { proxyConfig } = props;
546
+ const proxyOpts = $xeGantt.computeProxyOpts;
547
+ if (reactData.tableLoading) {
548
+ return;
549
+ }
550
+ if (proxyConfig && isEnableConf(proxyOpts)) {
551
+ $xeGantt.commitProxy('reload').then((rest) => {
552
+ $xeGantt.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), params.$event);
553
+ });
554
+ }
555
+ $xeGantt.dispatchEvent('form-submit', params, params.$event);
556
+ },
557
+ resetFormEvent(params) {
558
+ const $xeGantt = this;
559
+ const props = $xeGantt;
560
+ const $xeTable = $xeGantt.$refs.refTable;
561
+ const { proxyConfig } = props;
562
+ const { $event } = params;
563
+ const proxyOpts = $xeGantt.computeProxyOpts;
564
+ if (proxyConfig && isEnableConf(proxyOpts)) {
565
+ $xeTable.clearScroll();
566
+ $xeGantt.commitProxy('reload').then((rest) => {
567
+ $xeGantt.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), $event);
568
+ });
569
+ }
570
+ $xeGantt.dispatchEvent('form-reset', params, $event);
571
+ },
572
+ submitInvalidEvent(params) {
573
+ const $xeGantt = this;
574
+ $xeGantt.dispatchEvent('form-submit-invalid', params, params.$event);
575
+ },
576
+ collapseEvent(params) {
577
+ const $xeGantt = this;
578
+ const { $event } = params;
579
+ $xeGantt.dispatchEvent('form-toggle-collapse', params, $event);
580
+ $xeGantt.dispatchEvent('form-collapse', params, $event);
581
+ },
582
+ handleZoom(isMax) {
583
+ const $xeGantt = this;
584
+ const reactData = $xeGantt.reactData;
585
+ const { isZMax } = reactData;
586
+ if (isMax ? !isZMax : isZMax) {
587
+ reactData.isZMax = !isZMax;
588
+ if (reactData.tZindex < getLastZIndex()) {
589
+ reactData.tZindex = nextZIndex();
590
+ }
591
+ }
592
+ return $xeGantt.$nextTick()
593
+ .then(() => $xeGantt.recalculate(true))
594
+ .then(() => {
595
+ setTimeout(() => $xeGantt.recalculate(true), 15);
596
+ return reactData.isZMax;
597
+ });
598
+ },
599
+ dragSplitEvent(evnt) {
600
+ const $xeGantt = this;
601
+ const el = $xeGantt.$refs.refElem;
602
+ if (!el) {
603
+ return;
604
+ }
605
+ const ganttContainerEl = $xeGantt.$refs.refGanttContainer;
606
+ if (!ganttContainerEl) {
607
+ return;
608
+ }
609
+ const tableWrapperEl = $xeGantt.$refs.refTableWrapper;
610
+ if (!tableWrapperEl) {
611
+ return;
612
+ }
613
+ const rsSplitLineEl = $xeGantt.$refs.refResizableSplitTip;
614
+ if (!rsSplitLineEl) {
615
+ return;
616
+ }
617
+ const taskViewOpts = $xeGantt.computeTaskViewOpts;
618
+ const containerRect = ganttContainerEl.getBoundingClientRect();
619
+ const rsSplitTipEl = rsSplitLineEl.children[0];
620
+ const disX = evnt.clientX;
621
+ const ganttWidth = ganttContainerEl.clientWidth;
622
+ const tableWidth = tableWrapperEl.clientWidth;
623
+ const tableMinWidth = (taskViewOpts.tableStyle && XEUtils.toNumber(taskViewOpts.tableStyle.minWidth)) || 80;
624
+ let targetTableWidth = tableWidth;
625
+ let offsetLeft = -1;
626
+ addClass(el, 'is--split-drag');
627
+ const handleReStyle = (evnt) => {
628
+ const rsNumLeftEl = rsSplitTipEl.children[0];
629
+ const rsNumRightEl = rsSplitTipEl.children[1];
630
+ let tipHeight = 0;
631
+ if (rsNumLeftEl) {
632
+ if (offsetLeft < 0) {
633
+ rsNumLeftEl.textContent = `${targetTableWidth}px`;
634
+ rsNumLeftEl.style.display = 'block';
635
+ tipHeight = rsNumLeftEl.offsetHeight;
636
+ }
637
+ else {
638
+ rsNumLeftEl.style.display = 'none';
639
+ }
640
+ }
641
+ if (rsNumRightEl) {
642
+ if (offsetLeft < 0) {
643
+ rsNumRightEl.style.display = 'none';
644
+ }
645
+ else {
646
+ rsNumRightEl.textContent = `${Math.floor(containerRect.width - targetTableWidth)}px`;
647
+ rsNumRightEl.style.display = 'block';
648
+ tipHeight = rsNumRightEl.offsetHeight;
649
+ }
650
+ }
651
+ const tipTop = evnt.clientY - containerRect.top - tipHeight / 2;
652
+ rsSplitLineEl.style.left = `${targetTableWidth}px`;
653
+ rsSplitTipEl.style.top = `${Math.min(containerRect.height - tipHeight - 1, Math.max(1, tipTop))}px`;
654
+ };
655
+ document.onmousemove = (evnt) => {
656
+ evnt.preventDefault();
657
+ offsetLeft = (evnt.clientX - disX);
658
+ targetTableWidth = Math.min(ganttWidth - 80, Math.max(tableMinWidth, tableWidth + offsetLeft));
659
+ handleReStyle(evnt);
660
+ };
661
+ document.onmouseup = () => {
662
+ document.onmousemove = null;
663
+ document.onmouseup = null;
664
+ rsSplitLineEl.style.display = '';
665
+ tableWrapperEl.style.width = `${targetTableWidth}px`;
666
+ removeClass(el, 'is--split-drag');
667
+ const $xeTable = $xeGantt.$refs.refTable;
668
+ if ($xeTable) {
669
+ $xeTable.recalculate(true);
670
+ }
671
+ };
672
+ rsSplitLineEl.style.display = 'block';
673
+ handleReStyle(evnt);
674
+ },
675
+ handleSplitLeftViewEvent() {
676
+ const $xeGantt = this;
677
+ const reactData = $xeGantt.reactData;
678
+ reactData.showLeftView = !reactData.showLeftView;
679
+ },
680
+ handleSplitRightViewEvent() {
681
+ const $xeGantt = this;
682
+ const reactData = $xeGantt.reactData;
683
+ reactData.showRightView = !reactData.showRightView;
684
+ },
685
+ getDefaultFormData() {
686
+ const $xeGantt = this;
687
+ const formOpts = $xeGantt.computeFormOpts;
688
+ if (formOpts.items) {
689
+ const fData = {};
690
+ formOpts.items.forEach(item => {
691
+ const { field, itemRender } = item;
692
+ if (field) {
693
+ let itemValue = null;
694
+ if (itemRender) {
695
+ const { defaultValue } = itemRender;
696
+ if (XEUtils.isFunction(defaultValue)) {
697
+ itemValue = defaultValue({ item });
698
+ }
699
+ else if (!XEUtils.isUndefined(defaultValue)) {
700
+ itemValue = defaultValue;
701
+ }
702
+ }
703
+ fData[field] = itemValue;
704
+ }
705
+ });
706
+ return fData;
707
+ }
708
+ return {};
709
+ },
710
+ initProxy() {
711
+ const $xeGantt = this;
712
+ const props = $xeGantt;
713
+ const reactData = $xeGantt.reactData;
714
+ const { proxyConfig, formConfig } = props;
715
+ const { proxyInited } = reactData;
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();
721
+ }
722
+ if (!proxyInited && proxyOpts.autoLoad !== false) {
723
+ reactData.proxyInited = true;
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
+ });
727
+ }
728
+ }
729
+ },
730
+ handleGlobalKeydownEvent(evnt) {
731
+ const $xeGantt = this;
732
+ const reactData = $xeGantt.reactData;
733
+ const zoomOpts = $xeGantt.computeZoomOpts;
734
+ const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
735
+ if (isEsc && reactData.isZMax && zoomOpts.escRestore !== false) {
736
+ $xeGantt.triggerZoomEvent(evnt);
737
+ }
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;
751
+ /**
752
+ * 已废弃
753
+ * @deprecated
754
+ */
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;
827
+ }
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
+ });
866
+ }
867
+ filterList = $xeTable.getCheckedFilters();
868
+ }
869
+ }
870
+ else {
871
+ if ($xeTable) {
872
+ if (isReload) {
873
+ $xeTable.clearAll();
874
+ }
875
+ else {
876
+ sortList = $xeTable.getSortColumns();
877
+ filterList = $xeTable.getCheckedFilters();
878
+ }
879
+ }
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;
915
+ }
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);
924
+ }
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']);
985
+ }
986
+ VxeUI.modal.message({ content: $xeGantt.getRespMsg(rest, 'vxe.grid.delSuccess'), status: 'success' });
987
+ }
988
+ if (afterDelete) {
989
+ afterDelete(...applyArgs);
990
+ }
991
+ else {
992
+ $xeGantt.commitProxy('query');
993
+ }
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']);
1005
+ }
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
+ });
1013
+ });
1014
+ }
1015
+ else {
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
+ }
1023
+ }
1024
+ }
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']);
1076
+ }
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']);
1096
+ }
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 };
1103
+ });
1104
+ }
1105
+ else {
1106
+ if (isActiveMsg) {
1107
+ // 检测弹窗模块
1108
+ if (!VxeUI.modal) {
1109
+ errLog('vxe.error.reqModule', ['Modal']);
1110
+ }
1111
+ VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.dataUnchanged'), status: 'info' });
1112
+ }
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);
1127
+ }
1128
+ else {
1129
+ errLog('vxe.error.notCommands', [code]);
1130
+ }
1131
+ }
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]);
1395
+ }
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];
1416
+ }
1417
+ else {
1418
+ errLog('vxe.error.notSlot', [slotFunc]);
1419
+ }
1420
+ }
1421
+ else {
1422
+ slotConf[slotKey] = slotFunc;
1423
+ }
1424
+ }
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;
1449
+ }
1450
+ if (buttonPrefixSlot) {
1451
+ toolbarSlots.buttonPrefix = buttonPrefixSlot;
1452
+ }
1453
+ if (buttonSuffixSlot) {
1454
+ toolbarSlots.buttonSuffix = buttonSuffixSlot;
1455
+ }
1456
+ if (toolsSlot) {
1457
+ toolbarSlots.tools = toolsSlot;
1458
+ }
1459
+ if (toolPrefixSlot) {
1460
+ toolbarSlots.toolPrefix = toolPrefixSlot;
1461
+ }
1462
+ if (toolSuffixSlot) {
1463
+ toolbarSlots.toolSuffix = toolSuffixSlot;
1464
+ }
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];
1476
+ }
1477
+ else {
1478
+ errLog('vxe.error.notSlot', [funcSlot]);
1479
+ }
1480
+ }
1481
+ else {
1482
+ return funcSlot;
1483
+ }
1484
+ }
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;
1497
+ const { formData } = reactData;
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) {
1506
+ formOpts.items.forEach((item) => {
1507
+ beforeItem.call($xeGantt, { $grid: $xeGantt, $gantt: null, item });
1508
+ });
1509
+ }
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) {
1548
+ return h('div', {
1549
+ key: 'form',
1550
+ ref: 'refFormWrapper',
1551
+ class: 'vxe-gantt--form-wrapper'
1552
+ }, formSlot ? formSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt }) : $xeGantt.renderDefaultForm(h));
1553
+ }
1554
+ return renderEmptyElement($xeGantt);
1555
+ },
1556
+ renderToolbar(h) {
1557
+ const VxeUIToolbarComponent = VxeUI.getComponent('VxeToolbar');
1558
+ const $xeGantt = this;
1559
+ const props = $xeGantt;
1560
+ const slots = $xeGantt.$scopedSlots;
1561
+ const { toolbarConfig } = props;
1562
+ const toolbarSlot = slots.toolbar;
1563
+ const hasToolbar = !!(toolbarSlot || isEnableConf(toolbarConfig) || toolbar);
1564
+ const toolbarOpts = $xeGantt.computeToolbarOpts;
1565
+ if (hasToolbar) {
1566
+ return h('div', {
1567
+ key: 'toolbar',
1568
+ ref: 'refToolbarWrapper',
1569
+ class: 'vxe-gantt--toolbar-wrapper'
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
+ ]);
1579
+ }
1580
+ return renderEmptyElement($xeGantt);
1581
+ },
1582
+ renderTop(h) {
1583
+ const $xeGantt = this;
1584
+ const slots = $xeGantt.$scopedSlots;
1585
+ const topSlot = slots.top;
1586
+ return topSlot
1587
+ ? h('div', {
1588
+ key: 'top',
1589
+ ref: 'refTopWrapper',
1590
+ class: 'vxe-gantt--top-wrapper'
1591
+ }, topSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt }))
1592
+ : renderEmptyElement($xeGantt);
1593
+ },
1594
+ renderTableLeft(h) {
1595
+ const $xeGantt = this;
1596
+ const slots = $xeGantt.$scopedSlots;
1597
+ const leftSlot = slots.left;
1598
+ if (leftSlot) {
1599
+ return h('div', {
1600
+ class: 'vxe-gantt--left-wrapper'
1601
+ }, leftSlot({ $grid: null, $gantt: $xeGantt }));
1602
+ }
1603
+ return renderEmptyElement($xeGantt);
1604
+ },
1605
+ renderTableRight(h) {
1606
+ const $xeGantt = this;
1607
+ const slots = $xeGantt.$scopedSlots;
1608
+ const rightSlot = slots.right;
1609
+ if (rightSlot) {
1610
+ return h('div', {
1611
+ class: 'vxe-gantt--right-wrapper'
1612
+ }, rightSlot({ $grid: null, $gantt: $xeGantt }));
1613
+ }
1614
+ return renderEmptyElement($xeGantt);
1615
+ },
1616
+ renderTable(h) {
1617
+ const $xeGantt = this;
1618
+ const slots = $xeGantt.$scopedSlots;
1619
+ const tableProps = $xeGantt.computeTableProps;
1620
+ return h('div', {
1621
+ class: 'vxe-gantt--table-wrapper'
1622
+ }, [
1623
+ h(VxeTableComponent, {
1624
+ key: 'table',
1625
+ props: tableProps,
1626
+ on: getTableOns($xeGantt),
1627
+ scopedSlots: slots,
1628
+ ref: 'refTable'
1629
+ })
1630
+ ]);
1631
+ },
1632
+ renderBottom(h) {
1633
+ const $xeGantt = this;
1634
+ const slots = $xeGantt.$scopedSlots;
1635
+ const bottomSlot = slots.bottom;
1636
+ return bottomSlot
1637
+ ? h('div', {
1638
+ key: 'bottom',
1639
+ ref: 'refBottomWrapper',
1640
+ class: 'vxe-gantt--bottom-wrapper'
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;
1650
+ const { proxyConfig, pagerConfig } = props;
1651
+ const proxyOpts = $xeGantt.computeProxyOpts;
1652
+ const pagerOpts = $xeGantt.computePagerOpts;
1653
+ const pagerSlot = slots.pager;
1654
+ if ((pagerConfig && isEnableConf(pagerOpts)) || slots.pager) {
1655
+ return h('div', {
1656
+ ref: 'refPagerWrapper',
1657
+ key: 'pager',
1658
+ class: 'vxe-gantt--pager-wrapper'
1659
+ }, pagerSlot
1660
+ ? pagerSlot.call($xeGantt, { $grid: null, $gantt: $xeGantt })
1661
+ : [
1662
+ VxeUIPagerComponent
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
+ })
1671
+ : renderEmptyElement($xeGantt)
1672
+ ]);
1673
+ }
1674
+ return renderEmptyElement($xeGantt);
1675
+ },
1676
+ /**
1677
+ * 渲染任务视图
1678
+ */
1679
+ renderTaskView(h) {
47
1680
  return h('div', {
48
- ref: refElem,
49
- class: 'vxe-gantt'
1681
+ ref: 'refGanttWrapper',
1682
+ class: 'vxe-gantt--view-wrapper'
1683
+ }, [
1684
+ h(GanttViewComponent, {
1685
+ ref: 'refGanttView'
1686
+ })
1687
+ ]);
1688
+ },
1689
+ renderSplitBar(h) {
1690
+ const $xeGantt = this;
1691
+ const reactData = $xeGantt.reactData;
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
+ }
1702
+ return h('div', {
1703
+ class: ['vxe-gantt--view-split-bar', {
1704
+ 'is--resize': resize,
1705
+ on: ons
1706
+ }]
1707
+ }, [
1708
+ h('div', {
1709
+ class: 'vxe-gantt--view-split-bar-handle'
1710
+ }),
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)
1741
+ ]);
1742
+ },
1743
+ renderChildLayout(h, layoutKeys) {
1744
+ const $xeGantt = this;
1745
+ const childVNs = [];
1746
+ layoutKeys.forEach(key => {
1747
+ switch (key) {
1748
+ case 'Form':
1749
+ childVNs.push($xeGantt.renderForm(h));
1750
+ break;
1751
+ case 'Toolbar':
1752
+ childVNs.push($xeGantt.renderToolbar(h));
1753
+ break;
1754
+ case 'Top':
1755
+ childVNs.push($xeGantt.renderTop(h));
1756
+ break;
1757
+ case 'Gantt':
1758
+ childVNs.push(h('div', {
1759
+ ref: 'refGanttContainer',
1760
+ key: 'tv',
1761
+ class: 'vxe-gantt--gantt-container'
1762
+ }, [
1763
+ $xeGantt.renderTableLeft(h),
1764
+ $xeGantt.renderTable(h),
1765
+ $xeGantt.renderSplitBar(h),
1766
+ $xeGantt.renderTaskView(h),
1767
+ $xeGantt.renderTableRight(h),
1768
+ h('div', {
1769
+ ref: 'refResizableSplitTip',
1770
+ class: 'vxe-gantt--resizable-split-tip'
1771
+ }, [
1772
+ h('div', {
1773
+ class: 'vxe-gantt--resizable-split-tip-number'
1774
+ }, [
1775
+ h('div', {
1776
+ class: 'vxe-gantt--resizable-split-number-left'
1777
+ }, '10px'),
1778
+ h('div', {
1779
+ class: 'vxe-gantt--resizable-split-number-right'
1780
+ }, '20px')
1781
+ ])
1782
+ ])
1783
+ ]));
1784
+ break;
1785
+ case 'Bottom':
1786
+ childVNs.push($xeGantt.renderBottom(h));
1787
+ break;
1788
+ case 'Pager':
1789
+ childVNs.push($xeGantt.renderPager(h));
1790
+ break;
1791
+ default:
1792
+ errLog('vxe.error.notProp', [`layouts -> ${key}`]);
1793
+ break;
1794
+ }
50
1795
  });
51
- };
52
- onUnmounted(() => {
53
- XEUtils.assign(internalData, createInternalData());
1796
+ return childVNs;
1797
+ },
1798
+ renderLayout(h) {
1799
+ const $xeGantt = this;
1800
+ const slots = $xeGantt.$scopedSlots;
1801
+ const currLayoutConf = $xeGantt.computeCurrLayoutConf;
1802
+ const { headKeys, bodyKeys, footKeys } = currLayoutConf;
1803
+ const asideLeftSlot = slots.asideLeft || slots['aside-left'];
1804
+ const asideRightSlot = slots.asideRight || slots['aside-right'];
1805
+ return [
1806
+ h('div', {
1807
+ class: 'vxe-gantt--layout-header-wrapper'
1808
+ }, $xeGantt.renderChildLayout(h, headKeys)),
1809
+ h('div', {
1810
+ class: 'vxe-gantt--layout-body-wrapper'
1811
+ }, [
1812
+ asideLeftSlot
1813
+ ? h('div', {
1814
+ class: 'vxe-gantt--layout-aside-left-wrapper'
1815
+ }, asideLeftSlot({}))
1816
+ : renderEmptyElement($xeGantt),
1817
+ h('div', {
1818
+ class: 'vxe-gantt--layout-body-content-wrapper'
1819
+ }, $xeGantt.renderChildLayout(h, bodyKeys)),
1820
+ asideRightSlot
1821
+ ? h('div', {
1822
+ class: 'vxe-gantt--layout-aside-right-wrapper'
1823
+ }, asideRightSlot({}))
1824
+ : renderEmptyElement($xeGantt)
1825
+ ]),
1826
+ h('div', {
1827
+ class: 'vxe-gantt--layout-footer-wrapper'
1828
+ }, $xeGantt.renderChildLayout(h, footKeys)),
1829
+ h('div', {
1830
+ class: 'vxe-gantt--border-line'
1831
+ })
1832
+ ];
1833
+ },
1834
+ renderVN(h) {
1835
+ const $xeGantt = this;
1836
+ const props = $xeGantt;
1837
+ const reactData = $xeGantt.reactData;
1838
+ const { showLeftView, showRightView } = reactData;
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;
1845
+ return h('div', {
1846
+ ref: 'refElem',
1847
+ class: ['vxe-gantt', `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
1848
+ [`size--${vSize}`]: vSize,
1849
+ 'is--round': props.round,
1850
+ 'is--maximize': reactData.isZMax,
1851
+ 'is--loading': isLoading,
1852
+ 'show--left': showLeftView,
1853
+ 'show--right': showRightView
1854
+ }],
1855
+ style: styles
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']);
1879
+ }
1880
+ }
1881
+ if (props.pagerConfig) {
1882
+ if (!VxeUIPagerComponent) {
1883
+ errLog('vxe.error.reqComp', ['vxe-pager']);
1884
+ }
1885
+ }
1886
+ if (props.toolbarConfig) {
1887
+ if (!VxeUIToolbarComponent) {
1888
+ errLog('vxe.error.reqComp', ['vxe-toolbar']);
1889
+ }
1890
+ }
54
1891
  });
55
- $xeGantt.renderVN = renderVN;
56
- return $xeGantt;
1892
+ $xeGantt.initPages();
57
1893
  },
58
- render() {
59
- 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);
60
1914
  }
61
- });
1915
+ };