vxe-table 3.16.0-beta.0 → 3.16.0-beta.1

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 (35) hide show
  1. package/es/grid/src/grid.js +851 -689
  2. package/es/style.css +1 -1
  3. package/es/table/module/keyboard/mixin.js +2 -2
  4. package/es/table/src/columnInfo.js +1 -1
  5. package/es/table/src/table.js +1 -1
  6. package/es/ui/index.js +2 -2
  7. package/es/ui/src/log.js +1 -1
  8. package/lib/grid/src/grid.js +950 -804
  9. package/lib/grid/src/grid.min.js +1 -1
  10. package/lib/index.umd.js +960 -816
  11. package/lib/index.umd.min.js +1 -1
  12. package/lib/style.css +1 -1
  13. package/lib/table/module/keyboard/mixin.js +2 -2
  14. package/lib/table/module/keyboard/mixin.min.js +1 -1
  15. package/lib/table/src/columnInfo.js +1 -1
  16. package/lib/table/src/columnInfo.min.js +1 -1
  17. package/lib/table/src/table.js +1 -1
  18. package/lib/table/src/table.min.js +1 -1
  19. package/lib/ui/index.js +2 -2
  20. package/lib/ui/index.min.js +1 -1
  21. package/lib/ui/src/log.js +1 -1
  22. package/lib/ui/src/log.min.js +1 -1
  23. package/package.json +1 -1
  24. package/packages/grid/src/grid.ts +991 -776
  25. package/packages/table/module/keyboard/mixin.ts +2 -2
  26. package/packages/table/src/columnInfo.ts +1 -1
  27. package/packages/table/src/props.ts +4 -4
  28. package/packages/table/src/table.ts +1 -1
  29. package/packages/ui/index.ts +1 -1
  30. /package/es/{iconfont.1750770351840.ttf → iconfont.1750910486943.ttf} +0 -0
  31. /package/es/{iconfont.1750770351840.woff → iconfont.1750910486943.woff} +0 -0
  32. /package/es/{iconfont.1750770351840.woff2 → iconfont.1750910486943.woff2} +0 -0
  33. /package/lib/{iconfont.1750770351840.ttf → iconfont.1750910486943.ttf} +0 -0
  34. /package/lib/{iconfont.1750770351840.woff → iconfont.1750910486943.woff} +0 -0
  35. /package/lib/{iconfont.1750770351840.woff2 → iconfont.1750910486943.woff2} +0 -0
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _comp = require("../../ui/src/comp");
7
8
  var _xeUtils = _interopRequireDefault(require("xe-utils"));
8
9
  var _utils = require("../../ui/src/utils");
9
10
  var _dom = require("../../ui/src/dom");
@@ -20,170 +21,13 @@ const {
20
21
  commands,
21
22
  globalEvents,
22
23
  globalMixins,
24
+ createEvent,
25
+ GLOBAL_EVENT_KEYS,
23
26
  renderEmptyElement
24
27
  } = _ui.VxeUI;
25
- const methods = {};
28
+ const tableMethods = {};
26
29
  const propKeys = Object.keys(_props.default);
27
30
  const defaultLayouts = [['Form'], ['Toolbar', 'Top', 'Table', 'Bottom', 'Pager']];
28
- function initPages($xeGrid, propKey) {
29
- const props = $xeGrid;
30
- const reactData = $xeGrid;
31
- const {
32
- tablePage
33
- } = reactData;
34
- const {
35
- pagerConfig
36
- } = props;
37
- const pagerOpts = $xeGrid.computePagerOpts;
38
- if (pagerConfig && (0, _utils.isEnableConf)(pagerOpts)) {
39
- if (propKey) {
40
- if (pagerOpts[propKey]) {
41
- tablePage[propKey] = _xeUtils.default.toNumber(pagerOpts[propKey]);
42
- }
43
- } else {
44
- const {
45
- currentPage,
46
- pageSize,
47
- total
48
- } = pagerOpts;
49
- if (currentPage) {
50
- tablePage.currentPage = currentPage;
51
- }
52
- if (pageSize) {
53
- tablePage.pageSize = pageSize;
54
- }
55
- if (total) {
56
- tablePage.pageSize = total;
57
- }
58
- }
59
- }
60
- }
61
- function renderDefaultForm(h, $xeGrid) {
62
- const VxeUIFormComponent = _ui.VxeUI.getComponent('VxeForm');
63
- const props = $xeGrid;
64
- const slots = $xeGrid.$scopedSlots;
65
- const reactData = $xeGrid;
66
- const {
67
- proxyConfig,
68
- formConfig
69
- } = props;
70
- const {
71
- formData
72
- } = reactData;
73
- const proxyOpts = $xeGrid.computeProxyOpts;
74
- const formOpts = $xeGrid.computeFormOpts;
75
- if ((0, _utils.isEnableConf)(formConfig) && formOpts.items && formOpts.items.length) {
76
- const formSlots = {};
77
- if (!formOpts.inited) {
78
- formOpts.inited = true;
79
- const beforeItem = proxyOpts.beforeItem;
80
- if (proxyOpts && beforeItem) {
81
- formOpts.items.forEach(item => {
82
- beforeItem.call($xeGrid, {
83
- $grid: $xeGrid,
84
- item
85
- });
86
- });
87
- }
88
- }
89
- // 处理插槽
90
- formOpts.items.forEach(item => {
91
- _xeUtils.default.each(item.slots, func => {
92
- if (!_xeUtils.default.isFunction(func)) {
93
- if (slots[func]) {
94
- formSlots[func] = slots[func];
95
- }
96
- }
97
- });
98
- });
99
- return [VxeUIFormComponent ? h(VxeUIFormComponent, {
100
- props: Object.assign({}, formOpts, {
101
- data: proxyConfig && proxyOpts.form ? formData : formOpts.data
102
- }),
103
- on: {
104
- submit: $xeGrid.submitEvent,
105
- reset: $xeGrid.resetEvent,
106
- collapse: $xeGrid.collapseEvent,
107
- 'submit-invalid': $xeGrid.submitInvalidEvent
108
- },
109
- scopedSlots: formSlots
110
- }) : renderEmptyElement($xeGrid)];
111
- }
112
- return [];
113
- }
114
- function getFuncSlot($xeGrid, optSlots, slotKey) {
115
- const slots = $xeGrid.$scopedSlots;
116
- const funcSlot = optSlots[slotKey];
117
- if (funcSlot) {
118
- if (_xeUtils.default.isString(funcSlot)) {
119
- if (slots[funcSlot]) {
120
- return slots[funcSlot];
121
- } else {
122
- (0, _log.errLog)('vxe.error.notSlot', [funcSlot]);
123
- }
124
- } else {
125
- return funcSlot;
126
- }
127
- }
128
- return null;
129
- }
130
- const getConfigSlot = ($xeGrid, slotConfigs) => {
131
- const slots = $xeGrid.$scopedSlots;
132
- const slotConf = {};
133
- _xeUtils.default.objectMap(slotConfigs, (slotFunc, slotKey) => {
134
- if (slotFunc) {
135
- if (_xeUtils.default.isString(slotFunc)) {
136
- if (slots[slotFunc]) {
137
- slotConf[slotKey] = slots[slotFunc];
138
- } else {
139
- (0, _log.errLog)('vxe.error.notSlot', [slotFunc]);
140
- }
141
- } else {
142
- slotConf[slotKey] = slotFunc;
143
- }
144
- }
145
- });
146
- return slotConf;
147
- };
148
- function getToolbarSlots($xeGrid) {
149
- const slots = $xeGrid.$scopedSlots;
150
- const toolbarOpts = $xeGrid.computeToolbarOpts;
151
- const toolbarOptSlots = toolbarOpts.slots;
152
- const toolbarSlots = {};
153
- if (slots.buttons && (!toolbarOptSlots || toolbarOptSlots.buttons !== 'buttons')) {
154
- (0, _log.warnLog)('vxe.error.reqProp', ['toolbar-config.slots.buttons']);
155
- }
156
- if (slots.tools && (!toolbarOptSlots || toolbarOptSlots.tools !== 'tools')) {
157
- (0, _log.warnLog)('vxe.error.reqProp', ['toolbar-config.slots.tools']);
158
- }
159
- if (toolbarOptSlots) {
160
- const buttonsSlot = getFuncSlot($xeGrid, toolbarOptSlots, 'buttons');
161
- const buttonPrefixSlot = getFuncSlot($xeGrid, toolbarOptSlots, 'buttonPrefix');
162
- const buttonSuffixSlot = getFuncSlot($xeGrid, toolbarOptSlots, 'buttonSuffix');
163
- const toolsSlot = getFuncSlot($xeGrid, toolbarOptSlots, 'tools');
164
- const toolPrefixSlot = getFuncSlot($xeGrid, toolbarOptSlots, 'toolPrefix');
165
- const toolSuffixSlot = getFuncSlot($xeGrid, toolbarOptSlots, 'toolSuffix');
166
- if (buttonsSlot) {
167
- toolbarSlots.buttons = buttonsSlot;
168
- }
169
- if (buttonPrefixSlot) {
170
- toolbarSlots.buttonPrefix = buttonPrefixSlot;
171
- }
172
- if (buttonSuffixSlot) {
173
- toolbarSlots.buttonSuffix = buttonSuffixSlot;
174
- }
175
- if (toolsSlot) {
176
- toolbarSlots.tools = toolsSlot;
177
- }
178
- if (toolPrefixSlot) {
179
- toolbarSlots.toolPrefix = toolPrefixSlot;
180
- }
181
- if (toolSuffixSlot) {
182
- toolbarSlots.toolSuffix = toolSuffixSlot;
183
- }
184
- }
185
- return toolbarSlots;
186
- }
187
31
  function getTableOns(_vm) {
188
32
  const {
189
33
  $listeners,
@@ -206,256 +50,47 @@ function getTableOns(_vm) {
206
50
  }
207
51
  return ons;
208
52
  }
209
- function pageChangeEvent($xeGrid, params) {
210
- const props = $xeGrid;
211
- const reactData = $xeGrid;
212
- const {
213
- proxyConfig
214
- } = props;
215
- const {
216
- tablePage
217
- } = reactData;
218
- const {
219
- $event,
220
- currentPage,
221
- pageSize
222
- } = params;
223
- const proxyOpts = $xeGrid.computeProxyOpts;
224
- tablePage.currentPage = currentPage;
225
- tablePage.pageSize = pageSize;
226
- $xeGrid.dispatchEvent('page-change', params, $event);
227
- if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts)) {
228
- $xeGrid.commitProxy('query').then(rest => {
229
- $xeGrid.dispatchEvent('proxy-query', rest, $event);
230
- });
231
- }
232
- }
233
- /**
234
- * 渲染表单
235
- */
236
- function renderForm(h, $xeGrid) {
237
- const slots = $xeGrid.$scopedSlots;
238
- const props = $xeGrid;
239
- const {
240
- formConfig
241
- } = props;
242
- const formSlot = slots.form;
243
- const hasForm = !!(formSlot || (0, _utils.isEnableConf)(formConfig));
244
- if (hasForm) {
245
- return h('div', {
246
- key: 'form',
247
- ref: 'refFormWrapper',
248
- class: 'vxe-grid--form-wrapper'
249
- }, formSlot ? formSlot.call($xeGrid, {
250
- $grid: $xeGrid
251
- }) : renderDefaultForm(h, $xeGrid));
252
- }
253
- return renderEmptyElement($xeGrid);
254
- }
255
- /**
256
- * 渲染工具栏
257
- */
258
- function renderToolbar(h, $xeGrid) {
259
- const slots = $xeGrid.$scopedSlots;
260
- const props = $xeGrid;
261
- const {
262
- toolbarConfig
263
- } = props;
264
- const toolbarSlot = slots.toolbar;
265
- const hasToolbar = !!(toolbarSlot || (0, _utils.isEnableConf)(toolbarConfig) || toolbar);
266
- const toolbarOpts = $xeGrid.computeToolbarOpts;
267
- if (hasToolbar) {
268
- return h('div', {
269
- key: 'toolbar',
270
- ref: 'refToolbarWrapper',
271
- class: 'vxe-grid--toolbar-wrapper'
272
- }, toolbarSlot ? toolbarSlot.call($xeGrid, {
273
- $grid: $xeGrid
274
- }) : [h(_toolbar.default, {
275
- props: Object.assign({}, toolbarOpts, {
276
- slots: undefined
277
- }),
278
- ref: 'xToolbar',
279
- scopedSlots: getToolbarSlots($xeGrid)
280
- })]);
281
- }
282
- return renderEmptyElement($xeGrid);
283
- }
284
- /**
285
- * 渲染表格顶部区域
286
- */
287
- function renderTop(h, $xeGrid) {
288
- const slots = $xeGrid.$scopedSlots;
289
- const topSlot = slots.top;
290
- return topSlot ? h('div', {
291
- key: 'top',
292
- ref: 'refTopWrapper',
293
- class: 'vxe-grid--top-wrapper'
294
- }, topSlot.call($xeGrid, {
295
- $grid: $xeGrid
296
- })) : renderEmptyElement($xeGrid);
297
- }
298
- function renderTableLeft(h, $xeGrid) {
299
- const slots = $xeGrid.$scopedSlots;
300
- const leftSlot = slots.left;
301
- if (leftSlot) {
302
- return h('div', {
303
- class: 'vxe-grid--left-wrapper'
304
- }, leftSlot({
305
- $grid: $xeGrid
306
- }));
307
- }
308
- return renderEmptyElement($xeGrid);
309
- }
310
- function renderTableRight(h, $xeGrid) {
311
- const slots = $xeGrid.$scopedSlots;
312
- const rightSlot = slots.right;
313
- if (rightSlot) {
314
- return h('div', {
315
- class: 'vxe-grid--right-wrapper'
316
- }, rightSlot({
317
- $grid: $xeGrid
318
- }));
319
- }
320
- return renderEmptyElement($xeGrid);
321
- }
322
- /**
323
- * 渲染表格
324
- */
325
- function renderTable(h, $xeGrid) {
326
- const slots = $xeGrid.$scopedSlots;
327
- const tableProps = $xeGrid.computeTableProps;
328
- return h('div', {
329
- class: 'vxe-grid--table-wrapper'
330
- }, [h('vxe-table', {
331
- key: 'table',
332
- props: tableProps,
333
- on: getTableOns($xeGrid),
334
- scopedSlots: slots,
335
- ref: 'xTable'
336
- })]);
337
- }
338
- /**
339
- * 渲染表格底部区域
340
- */
341
- function renderBottom(h, $xeGrid) {
342
- const slots = $xeGrid.$scopedSlots;
343
- const bottomSlot = slots.bottom;
344
- return bottomSlot ? h('div', {
345
- key: 'bottom',
346
- ref: 'refBottomWrapper',
347
- class: 'vxe-grid--bottom-wrapper'
348
- }, bottomSlot.call($xeGrid, {
349
- $grid: $xeGrid
350
- })) : renderEmptyElement($xeGrid);
351
- }
352
- /**
353
- * 渲染分页
354
- */
355
- function renderPager(h, $xeGrid) {
356
- const VxeUIPagerComponent = _ui.VxeUI.getComponent('VxePager');
357
- const props = $xeGrid;
358
- const slots = $xeGrid.$scopedSlots;
359
- const reactData = $xeGrid;
360
- const {
361
- proxyConfig,
362
- pagerConfig
363
- } = props;
364
- const proxyOpts = $xeGrid.computeProxyOpts;
365
- const pagerOpts = $xeGrid.computePagerOpts;
366
- const pagerSlot = slots.pager;
367
- if (pagerConfig && (0, _utils.isEnableConf)(pagerOpts) || slots.pager) {
368
- return h('div', {
369
- ref: 'refPagerWrapper',
370
- key: 'pager',
371
- class: 'vxe-grid--pager-wrapper'
372
- }, pagerSlot ? pagerSlot.call($xeGrid, {
373
- $grid: $xeGrid
374
- }) : [VxeUIPagerComponent ? h(VxeUIPagerComponent, {
375
- ref: 'refPager',
376
- props: Object.assign(Object.assign({}, pagerOpts), proxyConfig && (0, _utils.isEnableConf)(proxyOpts) ? reactData.tablePage : {}),
377
- on: {
378
- 'page-change'(params) {
379
- pageChangeEvent($xeGrid, params);
380
- }
381
- },
382
- scopedSlots: getConfigSlot($xeGrid, pagerOpts.slots)
383
- }) : renderEmptyElement($xeGrid)]);
384
- }
385
- return renderEmptyElement($xeGrid);
386
- }
387
- function renderChildLayout(h, $xeGrid, layoutKeys) {
388
- const childVNs = [];
389
- layoutKeys.forEach(key => {
390
- switch (key) {
391
- case 'Form':
392
- childVNs.push(renderForm(h, $xeGrid));
393
- break;
394
- case 'Toolbar':
395
- childVNs.push(renderToolbar(h, $xeGrid));
396
- break;
397
- case 'Top':
398
- childVNs.push(renderTop(h, $xeGrid));
399
- break;
400
- case 'Table':
401
- childVNs.push(h('div', {
402
- key: 'table',
403
- class: 'vxe-grid--table-container'
404
- }, [renderTableLeft(h, $xeGrid), renderTable(h, $xeGrid), renderTableRight(h, $xeGrid)]));
405
- break;
406
- case 'Bottom':
407
- childVNs.push(renderBottom(h, $xeGrid));
408
- break;
409
- case 'Pager':
410
- childVNs.push(renderPager(h, $xeGrid));
411
- break;
412
- default:
413
- (0, _log.errLog)('vxe.error.notProp', [`layouts -> ${key}`]);
414
- break;
415
- }
416
- });
417
- return childVNs;
418
- }
419
- function renderLayout(h, $xeGrid) {
420
- const slots = $xeGrid.$scopedSlots;
421
- const currLayoutConf = $xeGrid.computeCurrLayoutConf;
422
- const {
423
- headKeys,
424
- bodyKeys,
425
- footKeys
426
- } = currLayoutConf;
427
- const asideLeftSlot = slots.asideLeft || slots['aside-left'];
428
- const asideRightSlot = slots.asideRight || slots['aside-right'];
429
- return [h('div', {
430
- class: 'vxe-grid--layout-header-wrapper'
431
- }, renderChildLayout(h, $xeGrid, headKeys)), h('div', {
432
- class: 'vxe-grid--layout-body-wrapper'
433
- }, [asideLeftSlot ? h('div', {
434
- class: 'vxe-grid--layout-aside-left-wrapper'
435
- }, asideLeftSlot({})) : renderEmptyElement($xeGrid), h('div', {
436
- class: 'vxe-grid--layout-body-content-wrapper'
437
- }, renderChildLayout(h, $xeGrid, bodyKeys)), asideRightSlot ? h('div', {
438
- class: 'vxe-grid--layout-aside-right-wrapper'
439
- }, asideRightSlot({})) : renderEmptyElement($xeGrid)]), h('div', {
440
- class: 'vxe-grid--layout-footer-wrapper'
441
- }, renderChildLayout(h, $xeGrid, footKeys))];
442
- }
443
- Object.keys(_table.default.methods).forEach(name => {
444
- methods[name] = function (...args) {
445
- return this.$refs.xTable && this.$refs.xTable[name](...args);
53
+ _xeUtils.default.each(_table.default.methods, (fn, name) => {
54
+ tableMethods[name] = function (...args) {
55
+ const $xeGrid = this;
56
+ const $xeTable = $xeGrid.$refs.refTable;
57
+ return $xeTable && $xeTable[name](...args);
446
58
  };
447
59
  });
448
- var _default = exports.default = {
60
+ var _default = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
449
61
  name: 'VxeGrid',
450
62
  mixins: [globalMixins.sizeMixin],
451
- props: Object.assign(Object.assign({}, _props.default), {
63
+ props: Object.assign(Object.assign({
64
+ // 以下仅用于类型
65
+ round: {
66
+ type: Boolean,
67
+ default: () => getConfig().table.round
68
+ },
69
+ height: [Number, String],
70
+ minHeight: {
71
+ type: [Number, String],
72
+ default: () => getConfig().table.minHeight
73
+ },
74
+ maxHeight: [Number, String],
75
+ seqConfig: Object,
76
+ sortConfig: Object,
77
+ filterConfig: Object,
78
+ editConfig: [Boolean, Object],
79
+ loading: Boolean,
80
+ validConfig: Object,
81
+ editRules: Object,
82
+ animat: {
83
+ type: Boolean,
84
+ default: () => getConfig().table.animat
85
+ }
86
+ }, _props.default), {
87
+ // 以上仅用于类型
452
88
  layouts: Array,
453
89
  columns: Array,
454
- pagerConfig: [Boolean, Object],
90
+ pagerConfig: Object,
455
91
  proxyConfig: Object,
456
- toolbar: [Boolean, Object],
457
- toolbarConfig: [Boolean, Object],
458
- formConfig: [Boolean, Object],
92
+ toolbarConfig: Object,
93
+ formConfig: Object,
459
94
  zoomConfig: Object,
460
95
  size: {
461
96
  type: String,
@@ -463,14 +98,17 @@ var _default = exports.default = {
463
98
  }
464
99
  }),
465
100
  provide() {
101
+ const $xeGrid = this;
466
102
  return {
467
- $xeGrid: this
103
+ $xeGrid
468
104
  };
469
105
  },
470
106
  data() {
471
107
  var _a;
472
- return {
108
+ const xID = _xeUtils.default.uniqueId();
109
+ const reactData = {
473
110
  tableLoading: false,
111
+ proxyInited: false,
474
112
  isZMax: false,
475
113
  tableData: [],
476
114
  filterData: [],
@@ -483,51 +121,79 @@ var _default = exports.default = {
483
121
  currentPage: 1
484
122
  }
485
123
  };
124
+ return {
125
+ xID,
126
+ reactData
127
+ };
486
128
  },
487
- computed: {
129
+ computed: Object.assign(Object.assign({}, {}), {
488
130
  isRespMsg() {
489
- const {
490
- proxyOpts
491
- } = this;
492
- return _xeUtils.default.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg;
131
+ const $xeGrid = this;
132
+ return $xeGrid.computeIsRespMsg;
133
+ },
134
+ computeIsRespMsg() {
135
+ const $xeGrid = this;
136
+ const proxyOpts = $xeGrid.computeProxyOpts;
137
+ return !!(_xeUtils.default.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg);
493
138
  },
494
139
  isActiveMsg() {
495
- return this.proxyOpts.showActiveMsg;
140
+ const $xeGrid = this;
141
+ return $xeGrid.computeIsActiveMsg;
142
+ },
143
+ computeIsActiveMsg() {
144
+ const $xeGrid = this;
145
+ const proxyOpts = $xeGrid.computeProxyOpts;
146
+ return !!proxyOpts.showActiveMsg;
496
147
  },
497
148
  proxyOpts() {
498
- return this.computeProxyOpts;
149
+ const $xeGrid = this;
150
+ return $xeGrid.computeProxyOpts;
499
151
  },
500
152
  computeProxyOpts() {
501
- return _xeUtils.default.merge({}, _xeUtils.default.clone(getConfig().grid.proxyConfig, true), this.proxyConfig);
153
+ const $xeGrid = this;
154
+ const props = $xeGrid;
155
+ return _xeUtils.default.merge({}, _xeUtils.default.clone(getConfig().grid.proxyConfig, true), props.proxyConfig);
502
156
  },
503
157
  pagerOpts() {
504
- return this.computePagerOpts;
158
+ const $xeGrid = this;
159
+ return $xeGrid.computePagerOpts;
505
160
  },
506
161
  computePagerOpts() {
507
- return Object.assign({}, getConfig().grid.pagerConfig, this.pagerConfig);
162
+ const $xeGrid = this;
163
+ const props = $xeGrid;
164
+ return Object.assign({}, getConfig().grid.pagerConfig, props.pagerConfig);
508
165
  },
509
166
  formOpts() {
510
- return this.computeFormOpts;
167
+ const $xeGrid = this;
168
+ return $xeGrid.computeFormOpts;
511
169
  },
512
170
  computeFormOpts() {
513
- return Object.assign({}, getConfig().grid.formConfig, this.formConfig);
171
+ const $xeGrid = this;
172
+ const props = $xeGrid;
173
+ return Object.assign({}, getConfig().grid.formConfig, props.formConfig);
514
174
  },
515
175
  toolbarOpts() {
516
- return this.computeToolbarOpts;
176
+ const $xeGrid = this;
177
+ return $xeGrid.computeToolbarOpts;
517
178
  },
518
179
  computeToolbarOpts() {
519
- return Object.assign({}, getConfig().grid.toolbarConfig, this.toolbarConfig || this.toolbar);
180
+ const $xeGrid = this;
181
+ const props = $xeGrid;
182
+ return Object.assign({}, getConfig().grid.toolbarConfig, props.toolbarConfig);
520
183
  },
521
184
  zoomOpts() {
522
- return this.computeZoomOpts;
185
+ const $xeGrid = this;
186
+ return $xeGrid.computeZoomOpts;
523
187
  },
524
188
  computeZoomOpts() {
525
- return Object.assign({}, getConfig().grid.zoomConfig, this.zoomConfig);
189
+ const $xeGrid = this;
190
+ const props = $xeGrid;
191
+ return Object.assign({}, getConfig().grid.zoomConfig, props.zoomConfig);
526
192
  },
527
193
  computeStyles() {
528
194
  const $xeGrid = this;
529
195
  const props = $xeGrid;
530
- const reactData = $xeGrid;
196
+ const reactData = $xeGrid.reactData;
531
197
  const {
532
198
  height,
533
199
  maxHeight
@@ -549,26 +215,35 @@ var _default = exports.default = {
549
215
  }
550
216
  return stys;
551
217
  },
552
- tableExtendProps() {
218
+ computeTableExtendProps() {
219
+ const $xeGrid = this;
220
+ const props = $xeGrid;
553
221
  const rest = {};
222
+ const gridProps = props;
554
223
  propKeys.forEach(key => {
555
- rest[key] = this[key];
224
+ rest[key] = gridProps[key];
556
225
  });
557
226
  return rest;
558
227
  },
559
228
  computeTableProps() {
229
+ const $xeGrid = this;
230
+ const props = $xeGrid;
231
+ const reactData = $xeGrid.reactData;
560
232
  const {
561
- isZMax,
562
233
  seqConfig,
563
234
  pagerConfig,
564
235
  loading,
565
236
  editConfig,
566
- proxyConfig,
567
- proxyOpts,
568
- tableExtendProps,
237
+ proxyConfig
238
+ } = props;
239
+ const {
240
+ isZMax,
569
241
  tableLoading,
570
242
  tablePage
571
- } = this;
243
+ } = reactData;
244
+ const tableExtendProps = $xeGrid.computeTableExtendProps;
245
+ const proxyOpts = $xeGrid.computeProxyOpts;
246
+ const pagerOpts = $xeGrid.computePagerOpts;
572
247
  const tProps = Object.assign({}, tableExtendProps);
573
248
  if (isZMax) {
574
249
  if (tableExtendProps.maxHeight) {
@@ -577,9 +252,9 @@ var _default = exports.default = {
577
252
  tProps.height = '100%';
578
253
  }
579
254
  }
580
- if (proxyConfig) {
255
+ if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts)) {
581
256
  tProps.loading = loading || tableLoading;
582
- if (proxyOpts.seq && (0, _utils.isEnableConf)(pagerConfig)) {
257
+ if (pagerConfig && proxyOpts.seq && (0, _utils.isEnableConf)(pagerOpts)) {
583
258
  tProps.seqConfig = Object.assign({}, seqConfig, {
584
259
  startIndex: (tablePage.currentPage - 1) * tablePage.pageSize
585
260
  });
@@ -591,7 +266,8 @@ var _default = exports.default = {
591
266
  return tProps;
592
267
  },
593
268
  tableProps() {
594
- return this.computeTableProps;
269
+ const $xeGrid = this;
270
+ return $xeGrid.computeTableProps;
595
271
  },
596
272
  computeCurrLayoutConf() {
597
273
  const $xeGrid = this;
@@ -638,100 +314,82 @@ var _default = exports.default = {
638
314
  const pagerOpts = $xeGrid.computePagerOpts;
639
315
  return pagerOpts.total;
640
316
  }
641
- },
317
+ }),
642
318
  watch: {
643
319
  columns(value) {
644
- this.$nextTick(() => this.loadColumn(value));
320
+ const $xeGrid = this;
321
+ $xeGrid.$nextTick(() => $xeGrid.loadColumn(value));
645
322
  },
646
323
  toolbar(value) {
324
+ const $xeGrid = this;
647
325
  if (value) {
648
- this.initToolbar();
326
+ $xeGrid.initToolbar();
649
327
  }
650
328
  },
651
329
  toolbarConfig(value) {
330
+ const $xeGrid = this;
652
331
  if (value) {
653
- this.initToolbar();
332
+ $xeGrid.initToolbar();
654
333
  }
655
334
  },
656
335
  proxyConfig() {
657
- this.initProxy();
336
+ const $xeGrid = this;
337
+ $xeGrid.initProxy();
658
338
  },
659
339
  computeCustomCurrentPageFlag() {
660
340
  const $xeGrid = this;
661
- initPages($xeGrid, 'currentPage');
341
+ $xeGrid.initPages('currentPage');
662
342
  },
663
343
  computeCustomPageSizeFlag() {
664
344
  const $xeGrid = this;
665
- initPages($xeGrid, 'pageSize');
345
+ $xeGrid.initPages('pageSize');
666
346
  },
667
347
  computeCustomTotalFlag() {
668
348
  const $xeGrid = this;
669
- initPages($xeGrid, 'total');
349
+ $xeGrid.initPages('total');
670
350
  }
671
351
  },
672
- created() {
673
- const $xeGrid = this;
674
- const props = $xeGrid;
675
- // const { data, formOpts, proxyOpts, proxyConfig } = this
676
- // if (proxyConfig && (data || (proxyOpts.form && formOpts.data))) {
677
- // errLog('vxe.error.errConflicts', ['grid.data', 'grid.proxy-config'])
678
- // }
679
- if (this.toolbar) {
680
- (0, _log.warnLog)('vxe.error.delProp', ['grid.toolbar', 'grid.toolbar-config']);
681
- }
682
- if (this.toolbarConfig && !_xeUtils.default.isObject(this.toolbarConfig)) {
683
- (0, _log.warnLog)('vxe.error.errProp', [`grid.toolbar-config=${this.toolbarConfig}`, 'grid.toolbar-config={}']);
684
- }
685
- // if (proxyOpts.props) {
686
- // warnLog('vxe.error.delProp', ['proxy-config.props', 'proxy-config.response'])
687
- // }
688
- // 使用已安装的组件,如果未安装则不渲染
689
- const VxeUIFormComponent = _ui.VxeUI.getComponent('VxeForm');
690
- const VxeUIPagerComponent = _ui.VxeUI.getComponent('VxePager');
691
- $xeGrid.$nextTick(() => {
692
- if (props.formConfig) {
693
- if (!VxeUIFormComponent) {
694
- (0, _log.errLog)('vxe.error.reqComp', ['vxe-form']);
695
- }
696
- }
697
- if (props.pagerConfig) {
698
- if (!VxeUIPagerComponent) {
699
- (0, _log.errLog)('vxe.error.reqComp', ['vxe-pager']);
352
+ methods: Object.assign(Object.assign({}, tableMethods), {
353
+ dispatchEvent(type, params, evnt) {
354
+ const $xeGrid = this;
355
+ $xeGrid.$emit(type, createEvent(evnt, {
356
+ $grid: $xeGrid
357
+ }, params));
358
+ },
359
+ initPages(propKey) {
360
+ const $xeGrid = this;
361
+ const props = $xeGrid;
362
+ const reactData = $xeGrid.reactData;
363
+ const {
364
+ tablePage
365
+ } = reactData;
366
+ const {
367
+ pagerConfig
368
+ } = props;
369
+ const pagerOpts = $xeGrid.computePagerOpts;
370
+ if (pagerConfig && (0, _utils.isEnableConf)(pagerOpts)) {
371
+ if (propKey) {
372
+ if (pagerOpts[propKey]) {
373
+ tablePage[propKey] = _xeUtils.default.toNumber(pagerOpts[propKey]);
374
+ }
375
+ } else {
376
+ const {
377
+ currentPage,
378
+ pageSize,
379
+ total
380
+ } = pagerOpts;
381
+ if (currentPage) {
382
+ tablePage.currentPage = currentPage;
383
+ }
384
+ if (pageSize) {
385
+ tablePage.pageSize = pageSize;
386
+ }
387
+ if (total) {
388
+ tablePage.pageSize = total;
389
+ }
700
390
  }
701
391
  }
702
- });
703
- initPages($xeGrid);
704
- globalEvents.on(this, 'keydown', this.handleGlobalKeydownEvent);
705
- },
706
- mounted() {
707
- if (this.columns && this.columns.length) {
708
- this.loadColumn(this.columns);
709
- }
710
- this.initToolbar();
711
- this.initProxy();
712
- },
713
- destroyed() {
714
- globalEvents.off(this, 'keydown');
715
- },
716
- render(h) {
717
- const $xeGrid = this;
718
- const props = $xeGrid;
719
- const reactData = $xeGrid;
720
- const vSize = $xeGrid.computeSize;
721
- const styles = $xeGrid.computeStyles;
722
- return h('div', {
723
- ref: 'refElem',
724
- class: ['vxe-grid', {
725
- [`size--${vSize}`]: vSize,
726
- 'is--animat': !!this.animat,
727
- 'is--round': this.round,
728
- 'is--maximize': reactData.isZMax,
729
- 'is--loading': props.loading || reactData.tableLoading
730
- }],
731
- style: styles
732
- }, renderLayout(h, $xeGrid));
733
- },
734
- methods: Object.assign(Object.assign({}, methods), {
392
+ },
735
393
  callSlot(slotFunc, params, h, vNodes) {
736
394
  const $xeGrid = this;
737
395
  const slots = $xeGrid.$scopedSlots;
@@ -754,7 +412,7 @@ var _default = exports.default = {
754
412
  */
755
413
  getExcludeHeight() {
756
414
  const $xeGrid = this;
757
- const reactData = $xeGrid;
415
+ const reactData = $xeGrid.reactData;
758
416
  const {
759
417
  isZMax
760
418
  } = reactData;
@@ -773,7 +431,7 @@ var _default = exports.default = {
773
431
  },
774
432
  getParentHeight() {
775
433
  const $xeGrid = this;
776
- const reactData = $xeGrid;
434
+ const reactData = $xeGrid.reactData;
777
435
  const el = $xeGrid.$refs.refElem;
778
436
  if (el) {
779
437
  const parentEl = el.parentElement;
@@ -782,67 +440,147 @@ var _default = exports.default = {
782
440
  return 0;
783
441
  },
784
442
  initToolbar() {
785
- this.$nextTick(() => {
786
- const {
787
- xTable,
788
- xToolbar
789
- } = this.$refs;
790
- if (xTable && xToolbar) {
791
- xTable.connect(xToolbar);
443
+ const $xeGrid = this;
444
+ $xeGrid.$nextTick(() => {
445
+ const $xeTable = $xeGrid.$refs.refTable;
446
+ const $xeToolbar = $xeGrid.$refs.refToolbar;
447
+ if ($xeTable && $xeToolbar) {
448
+ $xeTable.connect($xeToolbar);
792
449
  }
793
450
  });
794
451
  },
452
+ getDefaultFormData() {
453
+ const $xeGrid = this;
454
+ const formOpts = $xeGrid.computeFormOpts;
455
+ if (formOpts.items) {
456
+ const fData = {};
457
+ formOpts.items.forEach(item => {
458
+ const {
459
+ field,
460
+ itemRender
461
+ } = item;
462
+ if (field) {
463
+ let itemValue = null;
464
+ if (itemRender) {
465
+ const {
466
+ defaultValue
467
+ } = itemRender;
468
+ if (_xeUtils.default.isFunction(defaultValue)) {
469
+ itemValue = defaultValue({
470
+ item
471
+ });
472
+ } else if (!_xeUtils.default.isUndefined(defaultValue)) {
473
+ itemValue = defaultValue;
474
+ }
475
+ }
476
+ fData[field] = itemValue;
477
+ }
478
+ });
479
+ return fData;
480
+ }
481
+ return {};
482
+ },
795
483
  initProxy() {
484
+ const $xeGrid = this;
485
+ const props = $xeGrid;
486
+ const reactData = $xeGrid.reactData;
796
487
  const {
797
- proxyInited,
798
488
  proxyConfig,
799
- proxyOpts,
800
- formConfig,
801
- formOpts
802
- } = this;
489
+ formConfig
490
+ } = props;
491
+ const {
492
+ proxyInited
493
+ } = reactData;
494
+ const proxyOpts = $xeGrid.computeProxyOpts;
495
+ const formOpts = $xeGrid.computeFormOpts;
803
496
  if (proxyConfig) {
804
497
  if ((0, _utils.isEnableConf)(formConfig) && proxyOpts.form && formOpts.items) {
805
- const fData = {};
806
- formOpts.items.forEach(item => {
807
- const {
808
- field,
809
- itemRender
810
- } = item;
811
- if (field) {
812
- let itemValue = null;
813
- if (itemRender) {
814
- const {
815
- defaultValue
816
- } = itemRender;
817
- if (_xeUtils.default.isFunction(defaultValue)) {
818
- itemValue = defaultValue({
819
- item
820
- });
821
- } else if (!_xeUtils.default.isUndefined(defaultValue)) {
822
- itemValue = defaultValue;
823
- }
824
- }
825
- fData[field] = itemValue;
826
- }
827
- });
828
- this.formData = fData;
498
+ reactData.formData = $xeGrid.getDefaultFormData();
829
499
  }
830
500
  if (!proxyInited && proxyOpts.autoLoad !== false) {
831
- this.proxyInited = true;
832
- this.$nextTick().then(() => this.commitProxy('_init')).then(rest => {
833
- this.$emit('proxy-query', Object.assign(Object.assign({}, rest), {
834
- isInited: true,
835
- $grid: this,
836
- $event: new Event('init')
837
- }));
501
+ reactData.proxyInited = true;
502
+ $xeGrid.$nextTick().then(() => $xeGrid.commitProxy('initial')).then(rest => {
503
+ $xeGrid.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), {
504
+ isInited: true
505
+ }), new Event('initial'));
838
506
  });
839
507
  }
840
508
  }
841
509
  },
842
510
  handleGlobalKeydownEvent(evnt) {
843
- const isEsc = evnt.keyCode === 27;
844
- if (isEsc && this.isZMax && this.zoomOpts.escRestore !== false) {
845
- this.triggerZoomEvent(evnt);
511
+ const $xeGrid = this;
512
+ const reactData = $xeGrid.reactData;
513
+ const zoomOpts = $xeGrid.computeZoomOpts;
514
+ const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
515
+ if (isEsc && reactData.isZMax && zoomOpts.escRestore !== false) {
516
+ $xeGrid.triggerZoomEvent(evnt);
517
+ }
518
+ },
519
+ getRespMsg(rest, defaultMsg) {
520
+ const $xeGrid = this;
521
+ const proxyOpts = $xeGrid.computeProxyOpts;
522
+ const resConfigs = proxyOpts.response || proxyOpts.props || {};
523
+ const messageProp = resConfigs.message;
524
+ let msg;
525
+ if (rest && messageProp) {
526
+ msg = _xeUtils.default.isFunction(messageProp) ? messageProp({
527
+ data: rest,
528
+ $grid: $xeGrid
529
+ }) : _xeUtils.default.get(rest, messageProp);
530
+ }
531
+ return msg || getI18n(defaultMsg);
532
+ },
533
+ handleDeleteRow(code, alertKey, callback) {
534
+ const $xeGrid = this;
535
+ const isActiveMsg = $xeGrid.computeIsActiveMsg;
536
+ const selectRecords = $xeGrid.getCheckboxRecords();
537
+ if (isActiveMsg) {
538
+ if (selectRecords.length) {
539
+ if (_ui.VxeUI.modal) {
540
+ return _ui.VxeUI.modal.confirm({
541
+ id: `cfm_${code}`,
542
+ content: getI18n(alertKey),
543
+ escClosable: true
544
+ }).then(type => {
545
+ if (type === 'confirm') {
546
+ return callback();
547
+ }
548
+ });
549
+ }
550
+ } else {
551
+ if (_ui.VxeUI.modal) {
552
+ _ui.VxeUI.modal.message({
553
+ id: `msg_${code}`,
554
+ content: getI18n('vxe.grid.selectOneRecord'),
555
+ status: 'warning'
556
+ });
557
+ }
558
+ }
559
+ } else {
560
+ if (selectRecords.length) {
561
+ callback();
562
+ }
563
+ }
564
+ return Promise.resolve();
565
+ },
566
+ triggerPendingEvent(code) {
567
+ const $xeGrid = this;
568
+ const isActiveMsg = $xeGrid.computeIsActiveMsg;
569
+ const $xeTable = $xeGrid.$refs.refTable;
570
+ const selectRecords = $xeTable.getCheckboxRecords();
571
+ if (selectRecords.length) {
572
+ $xeTable.togglePendingRow(selectRecords);
573
+ $xeGrid.clearCheckboxRow();
574
+ } else {
575
+ if (isActiveMsg) {
576
+ if (_ui.VxeUI.modal) {
577
+ _ui.VxeUI.modal.message({
578
+ id: code,
579
+ content: getI18n('vxe.grid.selectOneRecord'),
580
+ status: 'warning'
581
+ });
582
+ }
583
+ }
846
584
  }
847
585
  },
848
586
  /**
@@ -851,21 +589,28 @@ var _default = exports.default = {
851
589
  */
852
590
  commitProxy(proxyTarget, ...args) {
853
591
  const $xeGrid = this;
854
- const reactData = $xeGrid;
592
+ const props = $xeGrid;
593
+ const reactData = $xeGrid.reactData;
594
+ /**
595
+ * 已废弃
596
+ * @deprecated
597
+ */
598
+ const toolbar = props.toolbar;
855
599
  const {
856
- $refs,
857
- toolbar,
600
+ proxyConfig,
858
601
  toolbarConfig,
859
- toolbarOpts,
860
- proxyOpts,
861
- tablePage,
862
602
  pagerConfig,
863
603
  editRules,
864
- isRespMsg,
865
- isActiveMsg,
866
- validConfig,
867
- pagerOpts
868
- } = this;
604
+ validConfig
605
+ } = props;
606
+ const {
607
+ tablePage
608
+ } = reactData;
609
+ const isActiveMsg = $xeGrid.computeIsActiveMsg;
610
+ const isRespMsg = $xeGrid.computeIsRespMsg;
611
+ const proxyOpts = $xeGrid.computeProxyOpts;
612
+ const pagerOpts = $xeGrid.computePagerOpts;
613
+ const toolbarOpts = $xeGrid.computeToolbarOpts;
869
614
  const {
870
615
  beforeQuery,
871
616
  afterQuery,
@@ -876,16 +621,19 @@ var _default = exports.default = {
876
621
  ajax = {}
877
622
  } = proxyOpts;
878
623
  const resConfigs = proxyOpts.response || proxyOpts.props || {};
879
- const $xeTable = $refs.xTable;
880
- const formData = this.getFormData();
881
- let button;
882
- let code;
624
+ const $xeTable = $xeGrid.$refs.refTable;
625
+ let formData = $xeGrid.getFormData();
626
+ let button = null;
627
+ let code = null;
883
628
  if (_xeUtils.default.isString(proxyTarget)) {
884
- const matchObj = toolbarConfig || toolbar ? _xeUtils.default.findTree(toolbarOpts.buttons, item => item.code === proxyTarget, {
629
+ const {
630
+ buttons
631
+ } = toolbarOpts;
632
+ const matchObj = (toolbarConfig || toolbar) && (0, _utils.isEnableConf)(toolbarOpts) && buttons ? _xeUtils.default.findTree(buttons, item => item.code === proxyTarget, {
885
633
  children: 'dropdowns'
886
634
  }) : null;
887
- code = proxyTarget;
888
635
  button = matchObj ? matchObj.item : null;
636
+ code = proxyTarget;
889
637
  } else {
890
638
  button = proxyTarget;
891
639
  code = button.code;
@@ -905,10 +653,10 @@ var _default = exports.default = {
905
653
  }) => $xeTable.setEditRow(row));
906
654
  // 已废弃
907
655
  case 'mark_cancel':
908
- this.triggerPendingEvent(code);
656
+ $xeGrid.triggerPendingEvent(code);
909
657
  break;
910
658
  case 'remove':
911
- return this.handleDeleteRow(code, 'vxe.grid.removeSelectRecord', () => this.removeCheckboxRow());
659
+ return $xeGrid.handleDeleteRow(code, 'vxe.grid.removeSelectRecord', () => $xeTable.removeCheckboxRow());
912
660
  case 'import':
913
661
  $xeTable.importData(btnParams);
914
662
  break;
@@ -924,7 +672,7 @@ var _default = exports.default = {
924
672
  case 'reset_custom':
925
673
  $xeTable.resetCustom(true);
926
674
  break;
927
- case '_init':
675
+ case 'initial':
928
676
  case 'reload':
929
677
  case 'query':
930
678
  {
@@ -932,7 +680,7 @@ var _default = exports.default = {
932
680
  const querySuccessMethods = ajax.querySuccess;
933
681
  const queryErrorMethods = ajax.queryError;
934
682
  if (ajaxMethods) {
935
- const isInited = code === '_init';
683
+ const isInited = code === 'initial';
936
684
  const isReload = code === 'reload';
937
685
  if (!isInited && reactData.tableLoading) {
938
686
  return $xeGrid.$nextTick();
@@ -949,27 +697,48 @@ var _default = exports.default = {
949
697
  }
950
698
  }
951
699
  if (isInited) {
952
- let defaultSort = null;
700
+ // 重置代理表单数据
701
+ if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts) && proxyOpts.form) {
702
+ formData = $xeGrid.getDefaultFormData();
703
+ reactData.formData = formData;
704
+ }
953
705
  if ($xeTable) {
954
706
  const {
955
- sortOpts
707
+ internalData: tableInternalData
956
708
  } = $xeTable;
957
- defaultSort = sortOpts.defaultSort;
958
- }
959
- // 如果使用默认排序
960
- if (defaultSort) {
961
- if (!_xeUtils.default.isArray(defaultSort)) {
962
- defaultSort = [defaultSort];
963
- }
964
- sortList = defaultSort.map(item => {
965
- return {
966
- field: item.field,
967
- property: item.field,
968
- order: item.order
969
- };
709
+ const {
710
+ tableFullColumn,
711
+ fullColumnFieldData
712
+ } = tableInternalData;
713
+ const sortOpts = $xeTable.computeSortOpts;
714
+ let defaultSort = sortOpts.defaultSort;
715
+ tableFullColumn.forEach(column => {
716
+ column.order = null;
970
717
  });
971
- }
972
- if ($xeTable) {
718
+ // 如果使用默认排序
719
+ if (defaultSort) {
720
+ if (!_xeUtils.default.isArray(defaultSort)) {
721
+ defaultSort = [defaultSort];
722
+ }
723
+ sortList = defaultSort.map(item => {
724
+ const {
725
+ field,
726
+ order
727
+ } = item;
728
+ const colRest = fullColumnFieldData[field];
729
+ if (colRest) {
730
+ const column = colRest.column;
731
+ if (column) {
732
+ column.order = order;
733
+ }
734
+ }
735
+ return {
736
+ field,
737
+ property: field,
738
+ order
739
+ };
740
+ });
741
+ }
973
742
  filterList = $xeTable.getCheckedFilters();
974
743
  }
975
744
  } else {
@@ -987,7 +756,7 @@ var _default = exports.default = {
987
756
  button,
988
757
  isInited,
989
758
  isReload,
990
- $grid: this,
759
+ $grid: $xeGrid,
991
760
  page: pageParams,
992
761
  sort: sortList.length ? sortList[0] : {},
993
762
  sorts: sortList,
@@ -995,25 +764,25 @@ var _default = exports.default = {
995
764
  form: formData,
996
765
  options: ajaxMethods
997
766
  };
998
- this.sortData = sortList;
999
- this.filterData = filterList;
1000
- this.tableLoading = true;
767
+ reactData.sortData = sortList;
768
+ reactData.filterData = filterList;
769
+ reactData.tableLoading = true;
1001
770
  const applyArgs = [commitParams].concat(args);
1002
771
  return Promise.resolve((beforeQuery || ajaxMethods)(...applyArgs)).then(rest => {
1003
772
  let tableData = [];
1004
- this.tableLoading = false;
773
+ reactData.tableLoading = false;
1005
774
  if (rest) {
1006
775
  if (pagerConfig && (0, _utils.isEnableConf)(pagerOpts)) {
1007
776
  const totalProp = resConfigs.total;
1008
777
  const total = (_xeUtils.default.isFunction(totalProp) ? totalProp({
1009
778
  data: rest,
1010
- $grid: this
779
+ $grid: $xeGrid
1011
780
  }) : _xeUtils.default.get(rest, totalProp || 'page.total')) || 0;
1012
781
  tablePage.total = _xeUtils.default.toNumber(total);
1013
782
  const resultProp = resConfigs.result;
1014
783
  tableData = (_xeUtils.default.isFunction(resultProp) ? resultProp({
1015
784
  data: rest,
1016
- $grid: this
785
+ $grid: $xeGrid
1017
786
  }) : _xeUtils.default.get(rest, resultProp || 'result')) || [];
1018
787
  // 检验当前页码,不能超出当前最大页数
1019
788
  const pageCount = Math.max(Math.ceil(total / tablePage.pageSize), 1);
@@ -1024,7 +793,7 @@ var _default = exports.default = {
1024
793
  const listProp = resConfigs.list;
1025
794
  tableData = (listProp ? _xeUtils.default.isFunction(listProp) ? listProp({
1026
795
  data: rest,
1027
- $grid: this
796
+ $grid: $xeGrid
1028
797
  }) : _xeUtils.default.get(rest, listProp) : rest) || [];
1029
798
  }
1030
799
  }
@@ -1049,7 +818,7 @@ var _default = exports.default = {
1049
818
  status: true
1050
819
  };
1051
820
  }).catch(rest => {
1052
- this.tableLoading = false;
821
+ reactData.tableLoading = false;
1053
822
  if (queryErrorMethods) {
1054
823
  queryErrorMethods(Object.assign(Object.assign({}, commitParams), {
1055
824
  response: rest
@@ -1076,7 +845,7 @@ var _default = exports.default = {
1076
845
  removeRecords
1077
846
  };
1078
847
  const commitParams = {
1079
- $grid: this,
848
+ $grid: $xeGrid,
1080
849
  code,
1081
850
  button,
1082
851
  body,
@@ -1085,13 +854,13 @@ var _default = exports.default = {
1085
854
  };
1086
855
  const applyArgs = [commitParams].concat(args);
1087
856
  if (selectRecords.length) {
1088
- return this.handleDeleteRow(code, 'vxe.grid.deleteSelectRecord', () => {
857
+ return $xeGrid.handleDeleteRow(code, 'vxe.grid.deleteSelectRecord', () => {
1089
858
  if (!removeRecords.length) {
1090
859
  return $xeTable.remove(selectRecords);
1091
860
  }
1092
- this.tableLoading = true;
861
+ reactData.tableLoading = true;
1093
862
  return Promise.resolve((beforeDelete || ajaxMethods)(...applyArgs)).then(rest => {
1094
- this.tableLoading = false;
863
+ reactData.tableLoading = false;
1095
864
  $xeTable.setPendingRow(removeRecords, false);
1096
865
  if (isRespMsg) {
1097
866
  // 检测弹窗模块
@@ -1099,14 +868,14 @@ var _default = exports.default = {
1099
868
  (0, _log.errLog)('vxe.error.reqModule', ['Modal']);
1100
869
  }
1101
870
  _ui.VxeUI.modal.message({
1102
- content: this.getRespMsg(rest, 'vxe.grid.delSuccess'),
871
+ content: $xeGrid.getRespMsg(rest, 'vxe.grid.delSuccess'),
1103
872
  status: 'success'
1104
873
  });
1105
874
  }
1106
875
  if (afterDelete) {
1107
876
  afterDelete(...applyArgs);
1108
877
  } else {
1109
- this.commitProxy('query');
878
+ $xeGrid.commitProxy('query');
1110
879
  }
1111
880
  if (deleteSuccessMethods) {
1112
881
  deleteSuccessMethods(Object.assign(Object.assign({}, commitParams), {
@@ -1117,7 +886,7 @@ var _default = exports.default = {
1117
886
  status: true
1118
887
  };
1119
888
  }).catch(rest => {
1120
- this.tableLoading = false;
889
+ reactData.tableLoading = false;
1121
890
  if (isRespMsg) {
1122
891
  // 检测弹窗模块
1123
892
  if (!_ui.VxeUI.modal) {
@@ -1125,7 +894,7 @@ var _default = exports.default = {
1125
894
  }
1126
895
  _ui.VxeUI.modal.message({
1127
896
  id: code,
1128
- content: this.getRespMsg(rest, 'vxe.grid.operError'),
897
+ content: $xeGrid.getRespMsg(rest, 'vxe.grid.operError'),
1129
898
  status: 'error'
1130
899
  });
1131
900
  }
@@ -1163,7 +932,7 @@ var _default = exports.default = {
1163
932
  const saveSuccessMethods = ajax.saveSuccess;
1164
933
  const saveErrorMethods = ajax.saveError;
1165
934
  if (ajaxMethods) {
1166
- const body = this.getRecordset();
935
+ const body = $xeGrid.getRecordset();
1167
936
  const {
1168
937
  insertRecords,
1169
938
  removeRecords,
@@ -1171,7 +940,7 @@ var _default = exports.default = {
1171
940
  pendingRecords
1172
941
  } = body;
1173
942
  const commitParams = {
1174
- $grid: this,
943
+ $grid: $xeGrid,
1175
944
  code,
1176
945
  button,
1177
946
  body,
@@ -1190,7 +959,7 @@ var _default = exports.default = {
1190
959
  let restPromise = Promise.resolve();
1191
960
  if (editRules) {
1192
961
  // 只校验新增和修改的数据
1193
- restPromise = this[validConfig && validConfig.msgMode === 'full' ? 'fullValidate' : 'validate'](body.insertRecords.concat(updateRecords));
962
+ restPromise = $xeGrid[validConfig && validConfig.msgMode === 'full' ? 'fullValidate' : 'validate'](body.insertRecords.concat(updateRecords));
1194
963
  }
1195
964
  return restPromise.then(errMap => {
1196
965
  if (errMap) {
@@ -1198,9 +967,9 @@ var _default = exports.default = {
1198
967
  return;
1199
968
  }
1200
969
  if (body.insertRecords.length || removeRecords.length || updateRecords.length || body.pendingRecords.length) {
1201
- this.tableLoading = true;
970
+ reactData.tableLoading = true;
1202
971
  return Promise.resolve((beforeSave || ajaxMethods)(...applyArgs)).then(rest => {
1203
- this.tableLoading = false;
972
+ reactData.tableLoading = false;
1204
973
  $xeTable.clearPendingRow();
1205
974
  if (isRespMsg) {
1206
975
  // 检测弹窗模块
@@ -1208,14 +977,14 @@ var _default = exports.default = {
1208
977
  (0, _log.errLog)('vxe.error.reqModule', ['Modal']);
1209
978
  }
1210
979
  _ui.VxeUI.modal.message({
1211
- content: this.getRespMsg(rest, 'vxe.grid.saveSuccess'),
980
+ content: $xeGrid.getRespMsg(rest, 'vxe.grid.saveSuccess'),
1212
981
  status: 'success'
1213
982
  });
1214
983
  }
1215
984
  if (afterSave) {
1216
985
  afterSave(...applyArgs);
1217
986
  } else {
1218
- this.commitProxy('query');
987
+ $xeGrid.commitProxy('query');
1219
988
  }
1220
989
  if (saveSuccessMethods) {
1221
990
  saveSuccessMethods(Object.assign(Object.assign({}, commitParams), {
@@ -1226,7 +995,7 @@ var _default = exports.default = {
1226
995
  status: true
1227
996
  };
1228
997
  }).catch(rest => {
1229
- this.tableLoading = false;
998
+ reactData.tableLoading = false;
1230
999
  if (isRespMsg) {
1231
1000
  // 检测弹窗模块
1232
1001
  if (!_ui.VxeUI.modal) {
@@ -1234,7 +1003,7 @@ var _default = exports.default = {
1234
1003
  }
1235
1004
  _ui.VxeUI.modal.message({
1236
1005
  id: code,
1237
- content: this.getRespMsg(rest, 'vxe.grid.operError'),
1006
+ content: $xeGrid.getRespMsg(rest, 'vxe.grid.operError'),
1238
1007
  status: 'error'
1239
1008
  });
1240
1009
  }
@@ -1274,7 +1043,7 @@ var _default = exports.default = {
1274
1043
  gCommandOpts.commandMethod({
1275
1044
  code,
1276
1045
  button,
1277
- $grid: this,
1046
+ $grid: $xeGrid,
1278
1047
  $table: $xeTable
1279
1048
  }, ...args);
1280
1049
  } else {
@@ -1283,66 +1052,34 @@ var _default = exports.default = {
1283
1052
  }
1284
1053
  }
1285
1054
  }
1286
- return this.$nextTick();
1287
- },
1288
- getRespMsg(rest, defaultMsg) {
1289
- const {
1290
- proxyOpts
1291
- } = this;
1292
- const resConfigs = proxyOpts.response || proxyOpts.props || {};
1293
- let msg;
1294
- if (rest && resConfigs.message) {
1295
- msg = _xeUtils.default.get(rest, resConfigs.message);
1296
- }
1297
- return msg || getI18n(defaultMsg);
1298
- },
1299
- handleDeleteRow(code, alertKey, callback) {
1300
- const selectRecords = this.getCheckboxRecords();
1301
- if (this.isActiveMsg) {
1302
- if (selectRecords.length) {
1303
- return _ui.VxeUI.modal.confirm({
1304
- id: `cfm_${code}`,
1305
- content: getI18n(alertKey),
1306
- escClosable: true
1307
- }).then(type => {
1308
- if (type === 'confirm') {
1309
- return callback();
1310
- }
1311
- });
1312
- } else {
1313
- // 检测弹窗模块
1314
- if (!_ui.VxeUI.modal) {
1315
- (0, _log.errLog)('vxe.error.reqModule', ['Modal']);
1316
- }
1317
- _ui.VxeUI.modal.message({
1318
- id: `msg_${code}`,
1319
- content: getI18n('vxe.grid.selectOneRecord'),
1320
- status: 'warning'
1321
- });
1322
- }
1323
- } else {
1324
- if (selectRecords.length) {
1325
- callback();
1326
- }
1327
- }
1328
- return Promise.resolve();
1055
+ return $xeGrid.$nextTick();
1329
1056
  },
1330
1057
  getFormData() {
1058
+ const $xeGrid = this;
1059
+ const props = $xeGrid;
1060
+ const reactData = $xeGrid.reactData;
1061
+ const {
1062
+ proxyConfig
1063
+ } = props;
1331
1064
  const {
1332
- proxyConfig,
1333
- proxyOpts,
1334
- formOpts,
1335
1065
  formData
1336
- } = this;
1066
+ } = reactData;
1067
+ const proxyOpts = $xeGrid.computeProxyOpts;
1068
+ const formOpts = $xeGrid.computeFormOpts;
1337
1069
  return proxyConfig && (0, _utils.isEnableConf)(proxyOpts) && proxyOpts.form ? formData : formOpts.data;
1338
1070
  },
1339
1071
  getFormItems(itemIndex) {
1072
+ const $xeGrid = this;
1073
+ const props = $xeGrid;
1074
+ const formOpts = $xeGrid.computeFormOpts;
1340
1075
  const {
1341
- formConfig,
1342
- formOpts
1343
- } = this;
1076
+ formConfig
1077
+ } = props;
1078
+ const {
1079
+ items
1080
+ } = formOpts;
1344
1081
  const itemList = [];
1345
- _xeUtils.default.eachTree((0, _utils.isEnableConf)(formConfig) && formOpts.items ? formOpts.items : [], item => {
1082
+ _xeUtils.default.eachTree(formConfig && (0, _utils.isEnableConf)(formOpts) && items ? items : [], item => {
1346
1083
  itemList.push(item);
1347
1084
  }, {
1348
1085
  children: 'children'
@@ -1350,210 +1087,215 @@ var _default = exports.default = {
1350
1087
  return _xeUtils.default.isUndefined(itemIndex) ? itemList : itemList[itemIndex];
1351
1088
  },
1352
1089
  triggerToolbarCommitEvent(params, evnt) {
1090
+ const $xeGrid = this;
1353
1091
  const {
1354
1092
  code
1355
1093
  } = params;
1356
- return this.commitProxy(params, evnt).then(rest => {
1094
+ return $xeGrid.commitProxy(params, evnt).then(rest => {
1357
1095
  if (code && rest && rest.status && ['query', 'reload', 'delete', 'save'].includes(code)) {
1358
- this.$emit(code === 'delete' || code === 'save' ? `proxy-${code}` : 'proxy-query', Object.assign(Object.assign({}, rest), {
1359
- isReload: code === 'reload',
1360
- $grid: this,
1361
- $event: evnt
1362
- }));
1096
+ $xeGrid.dispatchEvent(code === 'delete' || code === 'save' ? `proxy-${code}` : 'proxy-query', Object.assign(Object.assign({}, rest), {
1097
+ isReload: code === 'reload'
1098
+ }), evnt);
1363
1099
  }
1364
1100
  });
1365
1101
  },
1366
1102
  triggerToolbarBtnEvent(button, evnt) {
1367
- this.triggerToolbarCommitEvent(button, evnt);
1368
- this.$emit('toolbar-button-click', {
1103
+ const $xeGrid = this;
1104
+ $xeGrid.triggerToolbarCommitEvent(button, evnt);
1105
+ $xeGrid.dispatchEvent('toolbar-button-click', {
1369
1106
  code: button.code,
1370
- button,
1371
- $grid: this,
1372
- $event: evnt
1373
- });
1107
+ button
1108
+ }, evnt);
1374
1109
  },
1375
1110
  triggerToolbarTolEvent(tool, evnt) {
1376
- this.triggerToolbarCommitEvent(tool, evnt);
1377
- this.$emit('toolbar-tool-click', {
1111
+ const $xeGrid = this;
1112
+ $xeGrid.triggerToolbarCommitEvent(tool, evnt);
1113
+ $xeGrid.dispatchEvent('toolbar-tool-click', {
1378
1114
  code: tool.code,
1379
- tool,
1380
- $grid: this,
1381
- $event: evnt
1382
- });
1115
+ tool
1116
+ }, evnt);
1383
1117
  },
1384
- triggerPendingEvent(code) {
1118
+ sortChangeEvent(params) {
1119
+ const $xeGrid = this;
1120
+ const props = $xeGrid;
1121
+ const reactData = $xeGrid.reactData;
1122
+ const $xeTable = $xeGrid.$refs.refTable;
1385
1123
  const {
1386
- isActiveMsg
1387
- } = this;
1388
- const selectRecords = this.getCheckboxRecords();
1389
- if (selectRecords.length) {
1390
- this.togglePendingRow(selectRecords);
1391
- this.clearCheckboxRow();
1392
- } else {
1393
- if (isActiveMsg) {
1394
- // 检测弹窗模块
1395
- if (!_ui.VxeUI.modal) {
1396
- (0, _log.errLog)('vxe.error.reqModule', ['Modal']);
1397
- }
1398
- _ui.VxeUI.modal.message({
1399
- id: code,
1400
- content: getI18n('vxe.grid.selectOneRecord'),
1401
- status: 'warning'
1124
+ proxyConfig
1125
+ } = props;
1126
+ const proxyOpts = $xeGrid.computeProxyOpts;
1127
+ const sortOpts = $xeTable.computeSortOpts;
1128
+ // 如果是服务端排序
1129
+ if (sortOpts.remote) {
1130
+ reactData.sortData = params.sortList;
1131
+ if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts)) {
1132
+ reactData.tablePage.currentPage = 1;
1133
+ $xeGrid.commitProxy('query').then(rest => {
1134
+ $xeGrid.dispatchEvent('proxy-query', rest, params.$event);
1402
1135
  });
1403
1136
  }
1404
1137
  }
1138
+ $xeGrid.dispatchEvent('sort-change', params, params.$event);
1405
1139
  },
1406
- sortChangeEvent(params) {
1140
+ pageChangeEvent(params) {
1141
+ const $xeGrid = this;
1142
+ const props = $xeGrid;
1143
+ const reactData = $xeGrid.reactData;
1407
1144
  const {
1408
- $table,
1409
- column,
1410
- sortList
1145
+ proxyConfig
1146
+ } = props;
1147
+ const {
1148
+ tablePage
1149
+ } = reactData;
1150
+ const {
1151
+ $event,
1152
+ currentPage,
1153
+ pageSize
1411
1154
  } = params;
1412
- const isRemote = _xeUtils.default.isBoolean(column.remoteSort) ? column.remoteSort : $table.sortOpts.remote;
1413
- // 如果是服务端排序
1414
- if (isRemote) {
1415
- this.sortData = sortList;
1416
- if (this.proxyConfig) {
1417
- this.tablePage.currentPage = 1;
1418
- this.commitProxy('query').then(rest => {
1419
- this.$emit('proxy-query', Object.assign(Object.assign({}, rest), {
1420
- $grid: this,
1421
- $event: params.$event
1422
- }));
1423
- });
1424
- }
1155
+ const proxyOpts = $xeGrid.computeProxyOpts;
1156
+ tablePage.currentPage = currentPage;
1157
+ tablePage.pageSize = pageSize;
1158
+ $xeGrid.dispatchEvent('page-change', params, $event);
1159
+ if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts)) {
1160
+ $xeGrid.commitProxy('query').then(rest => {
1161
+ $xeGrid.dispatchEvent('proxy-query', rest, $event);
1162
+ });
1425
1163
  }
1426
- this.$emit('sort-change', Object.assign({
1427
- $grid: this
1428
- }, params));
1429
1164
  },
1430
1165
  filterChangeEvent(params) {
1166
+ const $xeGrid = this;
1167
+ const props = $xeGrid;
1168
+ const reactData = $xeGrid.reactData;
1169
+ const $xeTable = $xeGrid.$refs.refTable;
1431
1170
  const {
1432
- $table,
1433
- filterList
1434
- } = params;
1171
+ proxyConfig
1172
+ } = props;
1173
+ const proxyOpts = $xeGrid.computeProxyOpts;
1174
+ const filterOpts = $xeTable.computeFilterOpts;
1435
1175
  // 如果是服务端过滤
1436
- if ($table.filterOpts.remote) {
1437
- this.filterData = filterList;
1438
- if (this.proxyConfig) {
1439
- this.tablePage.currentPage = 1;
1440
- this.commitProxy('query').then(rest => {
1441
- this.$emit('proxy-query', Object.assign(Object.assign({}, rest), {
1442
- $grid: this,
1443
- $event: params.$event
1444
- }));
1176
+ if (filterOpts.remote) {
1177
+ reactData.filterData = params.filterList;
1178
+ if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts)) {
1179
+ reactData.tablePage.currentPage = 1;
1180
+ $xeGrid.commitProxy('query').then(rest => {
1181
+ $xeGrid.dispatchEvent('proxy-query', rest, params.$event);
1445
1182
  });
1446
1183
  }
1447
1184
  }
1448
- this.$emit('filter-change', Object.assign({
1449
- $grid: this
1450
- }, params));
1185
+ $xeGrid.dispatchEvent('filter-change', params, params.$event);
1451
1186
  },
1452
- submitEvent(params) {
1187
+ submitFormEvent(params) {
1453
1188
  const $xeGrid = this;
1454
- const reactData = $xeGrid;
1189
+ const props = $xeGrid;
1190
+ const reactData = $xeGrid.reactData;
1455
1191
  const {
1456
1192
  proxyConfig
1457
- } = this;
1193
+ } = props;
1194
+ const proxyOpts = $xeGrid.computeProxyOpts;
1458
1195
  if (reactData.tableLoading) {
1459
1196
  return;
1460
1197
  }
1461
- if (proxyConfig) {
1462
- this.commitProxy('reload').then(rest => {
1463
- this.$emit('proxy-query', Object.assign(Object.assign({}, rest), {
1464
- isReload: true,
1465
- $grid: this,
1466
- $event: params.$event
1467
- }));
1198
+ if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts)) {
1199
+ $xeGrid.commitProxy('reload').then(rest => {
1200
+ $xeGrid.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), {
1201
+ isReload: true
1202
+ }), params.$event);
1468
1203
  });
1469
1204
  }
1470
- this.$emit('form-submit', Object.assign({
1471
- $grid: this
1472
- }, params));
1205
+ $xeGrid.dispatchEvent('form-submit', params, params.$event);
1473
1206
  },
1474
- resetEvent(params) {
1207
+ resetFormEvent(params) {
1208
+ const $xeGrid = this;
1209
+ const props = $xeGrid;
1210
+ const $xeTable = $xeGrid.$refs.refTable;
1475
1211
  const {
1476
1212
  proxyConfig
1477
- } = this;
1478
- const $xeTable = this.$refs.xTable;
1479
- if (proxyConfig) {
1213
+ } = props;
1214
+ const {
1215
+ $event
1216
+ } = params;
1217
+ const proxyOpts = $xeGrid.computeProxyOpts;
1218
+ if (proxyConfig && (0, _utils.isEnableConf)(proxyOpts)) {
1480
1219
  $xeTable.clearScroll();
1481
- this.commitProxy('reload').then(rest => {
1482
- this.$emit('proxy-query', Object.assign(Object.assign({}, rest), {
1483
- isReload: true,
1484
- $grid: this,
1485
- $event: params.$event
1486
- }));
1220
+ $xeGrid.commitProxy('reload').then(rest => {
1221
+ $xeGrid.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), {
1222
+ isReload: true
1223
+ }), $event);
1487
1224
  });
1488
1225
  }
1489
- this.$emit('form-reset', Object.assign({
1490
- $grid: this
1491
- }, params));
1226
+ $xeGrid.dispatchEvent('form-reset', params, $event);
1492
1227
  },
1493
1228
  submitInvalidEvent(params) {
1494
- this.$emit('form-submit-invalid', Object.assign({
1495
- $grid: this
1496
- }, params));
1229
+ const $xeGrid = this;
1230
+ $xeGrid.dispatchEvent('form-submit-invalid', params, params.$event);
1497
1231
  },
1498
1232
  collapseEvent(params) {
1499
- this.$nextTick(() => this.recalculate(true));
1500
- this.$emit('form-toggle-collapse', Object.assign({
1501
- $grid: this
1502
- }, params));
1503
- this.$emit('form-collapse', Object.assign({
1504
- $grid: this
1505
- }, params));
1233
+ const $xeGrid = this;
1234
+ const {
1235
+ $event
1236
+ } = params;
1237
+ $xeGrid.dispatchEvent('form-toggle-collapse', params, $event);
1238
+ $xeGrid.dispatchEvent('form-collapse', params, $event);
1506
1239
  },
1507
1240
  triggerZoomEvent(evnt) {
1508
- this.zoom();
1509
- this.$emit('zoom', {
1510
- $grid: this,
1511
- type: this.isZMax ? 'max' : 'revert',
1512
- $event: evnt
1513
- });
1241
+ const $xeGrid = this;
1242
+ const reactData = $xeGrid.reactData;
1243
+ $xeGrid.zoom();
1244
+ $xeGrid.dispatchEvent('zoom', {
1245
+ type: reactData.isZMax ? 'max' : 'revert'
1246
+ }, evnt);
1514
1247
  },
1515
1248
  zoom() {
1516
- return this[this.isZMax ? 'revert' : 'maximize']();
1249
+ const $xeGrid = this;
1250
+ const reactData = $xeGrid.reactData;
1251
+ return $xeGrid[reactData.isZMax ? 'revert' : 'maximize']();
1517
1252
  },
1518
1253
  isMaximized() {
1519
- return this.isZMax;
1254
+ const $xeGrid = this;
1255
+ const reactData = $xeGrid.reactData;
1256
+ return reactData.isZMax;
1520
1257
  },
1521
1258
  maximize() {
1522
- return this.handleZoom(true);
1259
+ const $xeGrid = this;
1260
+ return $xeGrid.handleZoom(true);
1523
1261
  },
1524
1262
  revert() {
1525
- return this.handleZoom();
1263
+ const $xeGrid = this;
1264
+ return $xeGrid.handleZoom();
1526
1265
  },
1527
1266
  handleZoom(isMax) {
1267
+ const $xeGrid = this;
1268
+ const reactData = $xeGrid.reactData;
1528
1269
  const {
1529
1270
  isZMax
1530
- } = this;
1271
+ } = reactData;
1531
1272
  if (isMax ? !isZMax : isZMax) {
1532
- this.isZMax = !isZMax;
1533
- if (this.tZindex < (0, _utils.getLastZIndex)()) {
1534
- this.tZindex = (0, _utils.nextZIndex)();
1273
+ reactData.isZMax = !isZMax;
1274
+ if (reactData.tZindex < (0, _utils.getLastZIndex)()) {
1275
+ reactData.tZindex = (0, _utils.nextZIndex)();
1535
1276
  }
1536
1277
  }
1537
- return this.$nextTick().then(() => this.recalculate(true)).then(() => {
1538
- setTimeout(() => this.recalculate(true), 15);
1539
- return this.isZMax;
1278
+ return $xeGrid.$nextTick().then(() => $xeGrid.recalculate(true)).then(() => {
1279
+ setTimeout(() => $xeGrid.recalculate(true), 15);
1280
+ return reactData.isZMax;
1540
1281
  });
1541
1282
  },
1542
1283
  getProxyInfo() {
1543
1284
  const $xeGrid = this;
1544
- const $xeTable = $xeGrid.$refs.xTable;
1545
- const {
1546
- sortData,
1547
- proxyConfig
1548
- } = this;
1549
- if (proxyConfig) {
1285
+ const props = $xeGrid;
1286
+ const $xeTable = $xeGrid.$refs.refTable;
1287
+ const reactData = $xeGrid.reactData;
1288
+ if (props.proxyConfig) {
1289
+ const {
1290
+ sortData
1291
+ } = reactData;
1550
1292
  return {
1551
1293
  data: $xeTable ? $xeTable.getFullData() : [],
1552
- filter: this.filterData,
1553
- form: this.getFormData(),
1294
+ filter: reactData.filterData,
1295
+ form: $xeGrid.getFormData(),
1554
1296
  sort: sortData.length ? sortData[0] : {},
1555
1297
  sorts: sortData,
1556
- pager: this.tablePage,
1298
+ pager: reactData.tablePage,
1557
1299
  pendingRecords: $xeTable ? $xeTable.getPendingRecords() : []
1558
1300
  };
1559
1301
  }
@@ -1561,15 +1303,13 @@ var _default = exports.default = {
1561
1303
  },
1562
1304
  loadColumn(columns) {
1563
1305
  const $xeGrid = this;
1564
- const $xeTable = $xeGrid.$refs.xTable;
1565
- const {
1566
- $scopedSlots
1567
- } = this;
1306
+ const slots = $xeGrid.$scopedSlots;
1307
+ const $xeTable = $xeGrid.$refs.refTable;
1568
1308
  _xeUtils.default.eachTree(columns, column => {
1569
1309
  if (column.slots) {
1570
1310
  _xeUtils.default.each(column.slots, func => {
1571
1311
  if (!_xeUtils.default.isFunction(func)) {
1572
- if (!$scopedSlots[func]) {
1312
+ if (!slots[func]) {
1573
1313
  (0, _log.errLog)('vxe.error.notSlot', [func]);
1574
1314
  }
1575
1315
  }
@@ -1582,6 +1322,412 @@ var _default = exports.default = {
1582
1322
  const $xeGrid = this;
1583
1323
  $xeGrid.clearAll();
1584
1324
  return $xeGrid.loadColumn(columns);
1325
+ },
1326
+ getConfigSlot(slotConfigs) {
1327
+ const $xeGrid = this;
1328
+ const slots = $xeGrid.$scopedSlots;
1329
+ const slotConf = {};
1330
+ _xeUtils.default.objectMap(slotConfigs, (slotFunc, slotKey) => {
1331
+ if (slotFunc) {
1332
+ if (_xeUtils.default.isString(slotFunc)) {
1333
+ if (slots[slotFunc]) {
1334
+ slotConf[slotKey] = slots[slotFunc];
1335
+ } else {
1336
+ (0, _log.errLog)('vxe.error.notSlot', [slotFunc]);
1337
+ }
1338
+ } else {
1339
+ slotConf[slotKey] = slotFunc;
1340
+ }
1341
+ }
1342
+ });
1343
+ return slotConf;
1344
+ },
1345
+ getToolbarSlots() {
1346
+ const $xeGrid = this;
1347
+ const slots = $xeGrid.$scopedSlots;
1348
+ const toolbarOpts = $xeGrid.computeToolbarOpts;
1349
+ const toolbarOptSlots = toolbarOpts.slots;
1350
+ const toolbarSlots = {};
1351
+ if (slots.buttons && (!toolbarOptSlots || toolbarOptSlots.buttons !== 'buttons')) {
1352
+ (0, _log.warnLog)('vxe.error.reqProp', ['toolbar-config.slots.buttons']);
1353
+ }
1354
+ if (slots.tools && (!toolbarOptSlots || toolbarOptSlots.tools !== 'tools')) {
1355
+ (0, _log.warnLog)('vxe.error.reqProp', ['toolbar-config.slots.tools']);
1356
+ }
1357
+ if (toolbarOptSlots) {
1358
+ const buttonsSlot = $xeGrid.getFuncSlot(toolbarOptSlots, 'buttons');
1359
+ const buttonPrefixSlot = $xeGrid.getFuncSlot(toolbarOptSlots, 'buttonPrefix');
1360
+ const buttonSuffixSlot = $xeGrid.getFuncSlot(toolbarOptSlots, 'buttonSuffix');
1361
+ const toolsSlot = $xeGrid.getFuncSlot(toolbarOptSlots, 'tools');
1362
+ const toolPrefixSlot = $xeGrid.getFuncSlot(toolbarOptSlots, 'toolPrefix');
1363
+ const toolSuffixSlot = $xeGrid.getFuncSlot(toolbarOptSlots, 'toolSuffix');
1364
+ if (buttonsSlot) {
1365
+ toolbarSlots.buttons = buttonsSlot;
1366
+ }
1367
+ if (buttonPrefixSlot) {
1368
+ toolbarSlots.buttonPrefix = buttonPrefixSlot;
1369
+ }
1370
+ if (buttonSuffixSlot) {
1371
+ toolbarSlots.buttonSuffix = buttonSuffixSlot;
1372
+ }
1373
+ if (toolsSlot) {
1374
+ toolbarSlots.tools = toolsSlot;
1375
+ }
1376
+ if (toolPrefixSlot) {
1377
+ toolbarSlots.toolPrefix = toolPrefixSlot;
1378
+ }
1379
+ if (toolSuffixSlot) {
1380
+ toolbarSlots.toolSuffix = toolSuffixSlot;
1381
+ }
1382
+ }
1383
+ return toolbarSlots;
1384
+ },
1385
+ getFuncSlot(optSlots, slotKey) {
1386
+ const $xeGrid = this;
1387
+ const slots = $xeGrid.$scopedSlots;
1388
+ const funcSlot = optSlots[slotKey];
1389
+ if (funcSlot) {
1390
+ if (_xeUtils.default.isString(funcSlot)) {
1391
+ if (slots[funcSlot]) {
1392
+ return slots[funcSlot];
1393
+ } else {
1394
+ (0, _log.errLog)('vxe.error.notSlot', [funcSlot]);
1395
+ }
1396
+ } else {
1397
+ return funcSlot;
1398
+ }
1399
+ }
1400
+ return null;
1401
+ },
1402
+ //
1403
+ // Render
1404
+ //
1405
+ renderDefaultForm(h) {
1406
+ const VxeUIFormComponent = _ui.VxeUI.getComponent('VxeForm');
1407
+ const $xeGrid = this;
1408
+ const props = $xeGrid;
1409
+ const slots = $xeGrid.$scopedSlots;
1410
+ const reactData = $xeGrid.reactData;
1411
+ const {
1412
+ proxyConfig,
1413
+ formConfig
1414
+ } = props;
1415
+ const {
1416
+ formData
1417
+ } = reactData;
1418
+ const proxyOpts = $xeGrid.computeProxyOpts;
1419
+ const formOpts = $xeGrid.computeFormOpts;
1420
+ if ((0, _utils.isEnableConf)(formConfig) && formOpts.items && formOpts.items.length) {
1421
+ const formSlots = {};
1422
+ if (!formOpts.inited) {
1423
+ formOpts.inited = true;
1424
+ const beforeItem = proxyOpts.beforeItem;
1425
+ if (proxyOpts && beforeItem) {
1426
+ formOpts.items.forEach(item => {
1427
+ beforeItem.call($xeGrid, {
1428
+ $grid: $xeGrid,
1429
+ item
1430
+ });
1431
+ });
1432
+ }
1433
+ }
1434
+ // 处理插槽
1435
+ formOpts.items.forEach(item => {
1436
+ _xeUtils.default.each(item.slots, func => {
1437
+ if (!_xeUtils.default.isFunction(func)) {
1438
+ if (slots[func]) {
1439
+ formSlots[func] = slots[func];
1440
+ }
1441
+ }
1442
+ });
1443
+ });
1444
+ return [VxeUIFormComponent ? h(VxeUIFormComponent, {
1445
+ props: Object.assign({}, formOpts, {
1446
+ data: proxyConfig && proxyOpts.form ? formData : formOpts.data
1447
+ }),
1448
+ on: {
1449
+ submit: $xeGrid.submitFormEvent,
1450
+ reset: $xeGrid.resetFormEvent,
1451
+ collapse: $xeGrid.collapseEvent,
1452
+ 'submit-invalid': $xeGrid.submitInvalidEvent
1453
+ },
1454
+ scopedSlots: formSlots
1455
+ }) : renderEmptyElement($xeGrid)];
1456
+ }
1457
+ return [];
1458
+ },
1459
+ renderForm(h) {
1460
+ const $xeGrid = this;
1461
+ const props = $xeGrid;
1462
+ const slots = $xeGrid.$scopedSlots;
1463
+ const {
1464
+ formConfig
1465
+ } = props;
1466
+ const formSlot = slots.form;
1467
+ const hasForm = !!(formSlot || (0, _utils.isEnableConf)(formConfig));
1468
+ if (hasForm) {
1469
+ return h('div', {
1470
+ key: 'form',
1471
+ ref: 'refFormWrapper',
1472
+ class: 'vxe-grid--form-wrapper'
1473
+ }, formSlot ? formSlot.call($xeGrid, {
1474
+ $grid: $xeGrid
1475
+ }) : $xeGrid.renderDefaultForm(h));
1476
+ }
1477
+ return renderEmptyElement($xeGrid);
1478
+ },
1479
+ renderToolbar(h) {
1480
+ const $xeGrid = this;
1481
+ const props = $xeGrid;
1482
+ const slots = $xeGrid.$scopedSlots;
1483
+ const {
1484
+ toolbarConfig
1485
+ } = props;
1486
+ const toolbarSlot = slots.toolbar;
1487
+ const hasToolbar = !!(toolbarSlot || (0, _utils.isEnableConf)(toolbarConfig) || toolbar);
1488
+ const toolbarOpts = $xeGrid.computeToolbarOpts;
1489
+ if (hasToolbar) {
1490
+ return h('div', {
1491
+ key: 'toolbar',
1492
+ ref: 'refToolbarWrapper',
1493
+ class: 'vxe-grid--toolbar-wrapper'
1494
+ }, toolbarSlot ? toolbarSlot.call($xeGrid, {
1495
+ $grid: $xeGrid
1496
+ }) : [h(_toolbar.default, {
1497
+ props: Object.assign({}, toolbarOpts, {
1498
+ slots: undefined
1499
+ }),
1500
+ ref: 'xToolbar',
1501
+ scopedSlots: $xeGrid.getToolbarSlots()
1502
+ })]);
1503
+ }
1504
+ return renderEmptyElement($xeGrid);
1505
+ },
1506
+ renderTop(h) {
1507
+ const $xeGrid = this;
1508
+ const slots = $xeGrid.$scopedSlots;
1509
+ const topSlot = slots.top;
1510
+ return topSlot ? h('div', {
1511
+ key: 'top',
1512
+ ref: 'refTopWrapper',
1513
+ class: 'vxe-grid--top-wrapper'
1514
+ }, topSlot.call($xeGrid, {
1515
+ $grid: $xeGrid
1516
+ })) : renderEmptyElement($xeGrid);
1517
+ },
1518
+ renderTableLeft(h) {
1519
+ const $xeGrid = this;
1520
+ const slots = $xeGrid.$scopedSlots;
1521
+ const leftSlot = slots.left;
1522
+ if (leftSlot) {
1523
+ return h('div', {
1524
+ class: 'vxe-grid--left-wrapper'
1525
+ }, leftSlot({
1526
+ $grid: $xeGrid
1527
+ }));
1528
+ }
1529
+ return renderEmptyElement($xeGrid);
1530
+ },
1531
+ renderTableRight(h) {
1532
+ const $xeGrid = this;
1533
+ const slots = $xeGrid.$scopedSlots;
1534
+ const rightSlot = slots.right;
1535
+ if (rightSlot) {
1536
+ return h('div', {
1537
+ class: 'vxe-grid--right-wrapper'
1538
+ }, rightSlot({
1539
+ $grid: $xeGrid
1540
+ }));
1541
+ }
1542
+ return renderEmptyElement($xeGrid);
1543
+ },
1544
+ renderTable(h) {
1545
+ const $xeGrid = this;
1546
+ const slots = $xeGrid.$scopedSlots;
1547
+ const tableProps = $xeGrid.computeTableProps;
1548
+ return h('div', {
1549
+ class: 'vxe-grid--table-wrapper'
1550
+ }, [h(_table.default, {
1551
+ key: 'table',
1552
+ props: tableProps,
1553
+ on: getTableOns($xeGrid),
1554
+ scopedSlots: slots,
1555
+ ref: 'refTable'
1556
+ })]);
1557
+ },
1558
+ renderBottom(h) {
1559
+ const $xeGrid = this;
1560
+ const slots = $xeGrid.$scopedSlots;
1561
+ const bottomSlot = slots.bottom;
1562
+ return bottomSlot ? h('div', {
1563
+ key: 'bottom',
1564
+ ref: 'refBottomWrapper',
1565
+ class: 'vxe-grid--bottom-wrapper'
1566
+ }, bottomSlot.call($xeGrid, {
1567
+ $grid: $xeGrid
1568
+ })) : renderEmptyElement($xeGrid);
1569
+ },
1570
+ renderPager(h) {
1571
+ const VxeUIPagerComponent = _ui.VxeUI.getComponent('VxePager');
1572
+ const $xeGrid = this;
1573
+ const props = $xeGrid;
1574
+ const slots = $xeGrid.$scopedSlots;
1575
+ const reactData = $xeGrid.reactData;
1576
+ const {
1577
+ proxyConfig,
1578
+ pagerConfig
1579
+ } = props;
1580
+ const proxyOpts = $xeGrid.computeProxyOpts;
1581
+ const pagerOpts = $xeGrid.computePagerOpts;
1582
+ const pagerSlot = slots.pager;
1583
+ if (pagerConfig && (0, _utils.isEnableConf)(pagerOpts) || slots.pager) {
1584
+ return h('div', {
1585
+ ref: 'refPagerWrapper',
1586
+ key: 'pager',
1587
+ class: 'vxe-grid--pager-wrapper'
1588
+ }, pagerSlot ? pagerSlot.call($xeGrid, {
1589
+ $grid: $xeGrid
1590
+ }) : [VxeUIPagerComponent ? h(VxeUIPagerComponent, {
1591
+ ref: 'refPager',
1592
+ props: Object.assign(Object.assign({}, pagerOpts), proxyConfig && (0, _utils.isEnableConf)(proxyOpts) ? reactData.tablePage : {}),
1593
+ on: {
1594
+ 'page-change': $xeGrid.pageChangeEvent
1595
+ },
1596
+ scopedSlots: $xeGrid.getConfigSlot(pagerOpts.slots)
1597
+ }) : renderEmptyElement($xeGrid)]);
1598
+ }
1599
+ return renderEmptyElement($xeGrid);
1600
+ },
1601
+ renderChildLayout(h, layoutKeys) {
1602
+ const $xeGrid = this;
1603
+ const childVNs = [];
1604
+ layoutKeys.forEach(key => {
1605
+ switch (key) {
1606
+ case 'Form':
1607
+ childVNs.push($xeGrid.renderForm(h));
1608
+ break;
1609
+ case 'Toolbar':
1610
+ childVNs.push($xeGrid.renderToolbar(h));
1611
+ break;
1612
+ case 'Top':
1613
+ childVNs.push($xeGrid.renderTop(h));
1614
+ break;
1615
+ case 'Table':
1616
+ childVNs.push(h('div', {
1617
+ key: 'table',
1618
+ class: 'vxe-grid--table-container'
1619
+ }, [$xeGrid.renderTableLeft(h), $xeGrid.renderTable(h), $xeGrid.renderTableRight(h)]));
1620
+ break;
1621
+ case 'Bottom':
1622
+ childVNs.push($xeGrid.renderBottom(h));
1623
+ break;
1624
+ case 'Pager':
1625
+ childVNs.push($xeGrid.renderPager(h));
1626
+ break;
1627
+ default:
1628
+ (0, _log.errLog)('vxe.error.notProp', [`layouts -> ${key}`]);
1629
+ break;
1630
+ }
1631
+ });
1632
+ return childVNs;
1633
+ },
1634
+ renderLayout(h) {
1635
+ const $xeGrid = this;
1636
+ const slots = $xeGrid.$scopedSlots;
1637
+ const currLayoutConf = $xeGrid.computeCurrLayoutConf;
1638
+ const {
1639
+ headKeys,
1640
+ bodyKeys,
1641
+ footKeys
1642
+ } = currLayoutConf;
1643
+ const asideLeftSlot = slots.asideLeft || slots['aside-left'];
1644
+ const asideRightSlot = slots.asideRight || slots['aside-right'];
1645
+ return [h('div', {
1646
+ class: 'vxe-grid--layout-header-wrapper'
1647
+ }, $xeGrid.renderChildLayout(h, headKeys)), h('div', {
1648
+ class: 'vxe-grid--layout-body-wrapper'
1649
+ }, [asideLeftSlot ? h('div', {
1650
+ class: 'vxe-grid--layout-aside-left-wrapper'
1651
+ }, asideLeftSlot({})) : renderEmptyElement($xeGrid), h('div', {
1652
+ class: 'vxe-grid--layout-body-content-wrapper'
1653
+ }, $xeGrid.renderChildLayout(h, bodyKeys)), asideRightSlot ? h('div', {
1654
+ class: 'vxe-grid--layout-aside-right-wrapper'
1655
+ }, asideRightSlot({})) : renderEmptyElement($xeGrid)]), h('div', {
1656
+ class: 'vxe-grid--layout-footer-wrapper'
1657
+ }, $xeGrid.renderChildLayout(h, footKeys))];
1658
+ },
1659
+ renderVN(h) {
1660
+ const $xeGrid = this;
1661
+ const props = $xeGrid;
1662
+ const reactData = $xeGrid.reactData;
1663
+ const vSize = $xeGrid.computeSize;
1664
+ const styles = $xeGrid.computeStyles;
1665
+ return h('div', {
1666
+ ref: 'refElem',
1667
+ class: ['vxe-grid', {
1668
+ [`size--${vSize}`]: vSize,
1669
+ 'is--animat': !!props.animat,
1670
+ 'is--round': props.round,
1671
+ 'is--maximize': reactData.isZMax,
1672
+ 'is--loading': props.loading || reactData.tableLoading
1673
+ }],
1674
+ style: styles
1675
+ }, $xeGrid.renderLayout(h));
1676
+ }
1677
+ }),
1678
+ created() {
1679
+ // 使用已安装的组件,如果未安装则不渲染
1680
+ const VxeUIFormComponent = _ui.VxeUI.getComponent('VxeForm');
1681
+ const VxeUIPagerComponent = _ui.VxeUI.getComponent('VxePager');
1682
+ const $xeGrid = this;
1683
+ const props = $xeGrid;
1684
+ const proxyOpts = $xeGrid.computeProxyOpts;
1685
+ // const { data, formOpts, proxyOpts, proxyConfig } = this
1686
+ // if (proxyConfig && (data || (proxyOpts.form && formOpts.data))) {
1687
+ // errLog('vxe.error.errConflicts', ['grid.data', 'grid.proxy-config'])
1688
+ // }
1689
+ if (props.toolbar) {
1690
+ (0, _log.errLog)('vxe.error.delProp', ['grid.toolbar', 'grid.toolbar-config']);
1691
+ }
1692
+ if (props.toolbarConfig && !_xeUtils.default.isObject(props.toolbarConfig)) {
1693
+ (0, _log.errLog)('vxe.error.errProp', [`grid.toolbar-config=${props.toolbarConfig}`, 'grid.toolbar-config={}']);
1585
1694
  }
1586
- })
1587
- };
1695
+ if (proxyOpts.props) {
1696
+ (0, _log.warnLog)('vxe.error.delProp', ['proxy-config.props', 'proxy-config.response']);
1697
+ }
1698
+ $xeGrid.$nextTick(() => {
1699
+ if (props.formConfig) {
1700
+ if (!VxeUIFormComponent) {
1701
+ (0, _log.errLog)('vxe.error.reqComp', ['vxe-form']);
1702
+ }
1703
+ }
1704
+ if (props.pagerConfig) {
1705
+ if (!VxeUIPagerComponent) {
1706
+ (0, _log.errLog)('vxe.error.reqComp', ['vxe-pager']);
1707
+ }
1708
+ }
1709
+ });
1710
+ $xeGrid.initPages();
1711
+ globalEvents.on($xeGrid, 'keydown', $xeGrid.handleGlobalKeydownEvent);
1712
+ },
1713
+ mounted() {
1714
+ const $xeGrid = this;
1715
+ const props = $xeGrid;
1716
+ const {
1717
+ columns
1718
+ } = props;
1719
+ if (columns && columns.length) {
1720
+ $xeGrid.loadColumn(columns);
1721
+ }
1722
+ $xeGrid.initToolbar();
1723
+ $xeGrid.initProxy();
1724
+ },
1725
+ destroyed() {
1726
+ const $xeGrid = this;
1727
+ globalEvents.off($xeGrid, 'keydown');
1728
+ },
1729
+ render(h) {
1730
+ return this.renderVN(h);
1731
+ }
1732
+ });
1733
+ /* define-vxe-component end */