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