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