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