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.
- package/es/grid/src/grid.js +853 -691
- package/es/index.esm.js +2 -1
- package/es/locale/lang/ar-EG.js +1 -3
- package/es/locale/lang/de-DE.js +1 -3
- package/es/locale/lang/en-US.js +1 -3
- package/es/locale/lang/es-ES.js +1 -3
- package/es/locale/lang/fr-FR.js +1 -3
- package/es/locale/lang/hu-HU.js +1 -3
- package/es/locale/lang/hy-AM.js +1 -3
- package/es/locale/lang/id-ID.js +1 -3
- package/es/locale/lang/it-IT.js +1 -3
- package/es/locale/lang/ja-JP.js +1 -3
- package/es/locale/lang/ko-KR.js +1 -3
- package/es/locale/lang/ms-MY.js +1 -3
- package/es/locale/lang/nb-NO.js +1 -3
- package/es/locale/lang/pt-BR.js +1 -3
- package/es/locale/lang/ru-RU.js +1 -3
- package/es/locale/lang/th-TH.js +1 -3
- package/es/locale/lang/ug-CN.js +1 -3
- package/es/locale/lang/uk-UA.js +1 -3
- package/es/locale/lang/uz-UZ.js +1 -3
- package/es/locale/lang/vi-VN.js +1 -3
- package/es/locale/lang/zh-CHT.js +1 -3
- package/es/locale/lang/zh-CN.js +1 -3
- package/es/style.css +1 -1
- package/es/table/module/edit/mixin.js +1 -31
- package/es/table/module/keyboard/mixin.js +2 -2
- package/es/table/src/columnInfo.js +1 -6
- package/es/table/src/methods.js +10 -28
- package/es/table/src/table.js +3 -22
- package/es/ui/index.js +2 -2
- package/es/ui/src/log.js +1 -1
- package/lib/grid/src/grid.js +952 -806
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.common.js +2 -1
- package/lib/index.umd.js +1950 -3209
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/ar-EG.js +1 -3
- package/lib/locale/lang/ar-EG.min.js +1 -1
- package/lib/locale/lang/ar-EG.umd.js +1 -3
- package/lib/locale/lang/de-DE.js +1 -3
- package/lib/locale/lang/de-DE.min.js +1 -1
- package/lib/locale/lang/de-DE.umd.js +1 -3
- package/lib/locale/lang/en-US.js +1 -3
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +1 -3
- package/lib/locale/lang/es-ES.js +1 -3
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +1 -3
- package/lib/locale/lang/fr-FR.js +1 -3
- package/lib/locale/lang/fr-FR.min.js +1 -1
- package/lib/locale/lang/fr-FR.umd.js +1 -3
- package/lib/locale/lang/hu-HU.js +1 -3
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +1 -3
- package/lib/locale/lang/hy-AM.js +1 -3
- package/lib/locale/lang/hy-AM.min.js +1 -1
- package/lib/locale/lang/hy-AM.umd.js +1 -3
- package/lib/locale/lang/id-ID.js +1 -3
- package/lib/locale/lang/id-ID.min.js +1 -1
- package/lib/locale/lang/id-ID.umd.js +1 -3
- package/lib/locale/lang/it-IT.js +1 -3
- package/lib/locale/lang/it-IT.min.js +1 -1
- package/lib/locale/lang/it-IT.umd.js +1 -3
- package/lib/locale/lang/ja-JP.js +1 -3
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +1 -3
- package/lib/locale/lang/ko-KR.js +1 -3
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +1 -3
- package/lib/locale/lang/ms-MY.js +1 -3
- package/lib/locale/lang/ms-MY.min.js +1 -1
- package/lib/locale/lang/ms-MY.umd.js +1 -3
- package/lib/locale/lang/nb-NO.js +1 -3
- package/lib/locale/lang/nb-NO.min.js +1 -1
- package/lib/locale/lang/nb-NO.umd.js +1 -3
- package/lib/locale/lang/pt-BR.js +1 -3
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +1 -3
- package/lib/locale/lang/ru-RU.js +1 -3
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +1 -3
- package/lib/locale/lang/th-TH.js +1 -3
- package/lib/locale/lang/th-TH.min.js +1 -1
- package/lib/locale/lang/th-TH.umd.js +1 -3
- package/lib/locale/lang/ug-CN.js +1 -3
- package/lib/locale/lang/ug-CN.min.js +1 -1
- package/lib/locale/lang/ug-CN.umd.js +1 -3
- package/lib/locale/lang/uk-UA.js +1 -3
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +1 -3
- package/lib/locale/lang/uz-UZ.js +1 -3
- package/lib/locale/lang/uz-UZ.min.js +1 -1
- package/lib/locale/lang/uz-UZ.umd.js +1 -3
- package/lib/locale/lang/vi-VN.js +1 -3
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/vi-VN.umd.js +1 -3
- package/lib/locale/lang/zh-CHT.js +1 -3
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +1 -3
- package/lib/locale/lang/zh-CN.js +1 -3
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +1 -3
- package/lib/style.css +1 -1
- package/lib/table/module/edit/mixin.js +1 -30
- package/lib/table/module/edit/mixin.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/columnInfo.js +1 -6
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/methods.js +13 -25
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +2 -22
- package/lib/table/src/table.min.js +1 -1
- package/lib/ui/index.js +2 -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/v-x-e-table/index.js +2 -1
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/vxe-colgroup/index.js +2 -1
- package/lib/vxe-colgroup/index.min.js +1 -1
- package/lib/vxe-column/index.js +2 -1
- package/lib/vxe-column/index.min.js +1 -1
- package/lib/vxe-grid/index.js +2 -1
- package/lib/vxe-grid/index.min.js +1 -1
- package/lib/vxe-table/index.js +2 -1
- package/lib/vxe-table/index.min.js +1 -1
- package/lib/vxe-toolbar/index.js +2 -1
- package/lib/vxe-toolbar/index.min.js +1 -1
- package/lib/vxe-ui/index.js +2 -1
- package/lib/vxe-ui/index.min.js +1 -1
- package/lib/vxe-v-x-e-table/index.js +2 -1
- package/lib/vxe-v-x-e-table/index.min.js +1 -1
- package/package.json +1 -1
- package/packages/grid/src/grid.ts +993 -778
- package/packages/locale/lang/ar-EG.ts +1 -3
- package/packages/locale/lang/de-DE.ts +1 -3
- package/packages/locale/lang/en-US.ts +1 -3
- package/packages/locale/lang/es-ES.ts +1 -3
- package/packages/locale/lang/fr-FR.ts +1 -3
- package/packages/locale/lang/hu-HU.ts +1 -3
- package/packages/locale/lang/hy-AM.ts +1 -3
- package/packages/locale/lang/id-ID.ts +1 -3
- package/packages/locale/lang/it-IT.ts +1 -3
- package/packages/locale/lang/ja-JP.ts +1 -3
- package/packages/locale/lang/ko-KR.ts +1 -3
- package/packages/locale/lang/ms-MY.ts +1 -3
- package/packages/locale/lang/nb-NO.ts +1 -3
- package/packages/locale/lang/pt-BR.ts +1 -3
- package/packages/locale/lang/ru-RU.ts +1 -3
- package/packages/locale/lang/th-TH.ts +1 -3
- package/packages/locale/lang/ug-CN.ts +1 -3
- package/packages/locale/lang/uk-UA.ts +1 -3
- package/packages/locale/lang/uz-UZ.ts +1 -3
- package/packages/locale/lang/vi-VN.ts +1 -3
- package/packages/locale/lang/zh-CHT.ts +1 -3
- package/packages/locale/lang/zh-CN.ts +1 -3
- package/packages/table/module/edit/mixin.ts +2 -30
- package/packages/table/module/keyboard/mixin.ts +2 -2
- package/packages/table/src/columnInfo.ts +1 -6
- package/packages/table/src/methods.ts +10 -25
- package/packages/table/src/props.ts +4 -4
- package/packages/table/src/table.ts +3 -22
- package/packages/ui/index.ts +1 -1
- /package/es/{iconfont.1751505157215.ttf → iconfont.1750910486943.ttf} +0 -0
- /package/es/{iconfont.1751505157215.woff → iconfont.1750910486943.woff} +0 -0
- /package/es/{iconfont.1751505157215.woff2 → iconfont.1750910486943.woff2} +0 -0
- /package/lib/{iconfont.1751505157215.ttf → iconfont.1750910486943.ttf} +0 -0
- /package/lib/{iconfont.1751505157215.woff → iconfont.1750910486943.woff} +0 -0
- /package/lib/{iconfont.1751505157215.woff2 → iconfont.1750910486943.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,25 @@ 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, 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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
261
|
+
$xeGrid.initToolbar();
|
|
591
262
|
}
|
|
592
263
|
},
|
|
593
264
|
toolbarConfig(value) {
|
|
265
|
+
const $xeGrid = this;
|
|
594
266
|
if (value) {
|
|
595
|
-
|
|
267
|
+
$xeGrid.initToolbar();
|
|
596
268
|
}
|
|
597
269
|
},
|
|
598
270
|
proxyConfig() {
|
|
599
|
-
this
|
|
271
|
+
const $xeGrid = this;
|
|
272
|
+
$xeGrid.initProxy();
|
|
600
273
|
},
|
|
601
274
|
computeCustomCurrentPageFlag() {
|
|
602
275
|
const $xeGrid = this;
|
|
603
|
-
initPages(
|
|
276
|
+
$xeGrid.initPages('currentPage');
|
|
604
277
|
},
|
|
605
278
|
computeCustomPageSizeFlag() {
|
|
606
279
|
const $xeGrid = this;
|
|
607
|
-
initPages(
|
|
280
|
+
$xeGrid.initPages('pageSize');
|
|
608
281
|
},
|
|
609
282
|
computeCustomTotalFlag() {
|
|
610
283
|
const $xeGrid = this;
|
|
611
|
-
initPages(
|
|
284
|
+
$xeGrid.initPages('total');
|
|
612
285
|
}
|
|
613
286
|
},
|
|
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']);
|
|
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
|
-
|
|
640
|
-
|
|
641
|
-
|
|
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
|
-
|
|
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
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
756
|
-
|
|
757
|
-
|
|
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
|
|
764
|
-
|
|
765
|
-
|
|
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
|
|
775
|
-
const
|
|
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.
|
|
779
|
-
|
|
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
|
|
784
|
-
|
|
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
|
|
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
|
|
528
|
+
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row));
|
|
800
529
|
// 已废弃
|
|
801
530
|
case 'mark_cancel':
|
|
802
|
-
|
|
531
|
+
$xeGrid.triggerPendingEvent(code);
|
|
803
532
|
break;
|
|
804
533
|
case 'remove':
|
|
805
|
-
return
|
|
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 '
|
|
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 === '
|
|
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
|
-
|
|
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
|
-
});
|
|
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:
|
|
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
|
-
|
|
892
|
-
|
|
893
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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
|
|
702
|
+
return $xeGrid.handleDeleteRow(code, 'vxe.grid.deleteSelectRecord', () => {
|
|
959
703
|
if (!removeRecords.length) {
|
|
960
704
|
return $xeTable.remove(selectRecords);
|
|
961
705
|
}
|
|
962
|
-
|
|
706
|
+
reactData.tableLoading = true;
|
|
963
707
|
return Promise.resolve((beforeDelete || ajaxMethods)(...applyArgs))
|
|
964
708
|
.then(rest => {
|
|
965
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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 =
|
|
765
|
+
const body = $xeGrid.getRecordset();
|
|
1022
766
|
const { insertRecords, removeRecords, updateRecords, pendingRecords } = body;
|
|
1023
|
-
const commitParams = { $grid:
|
|
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 =
|
|
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
|
-
|
|
788
|
+
reactData.tableLoading = true;
|
|
1045
789
|
return Promise.resolve((beforeSave || ajaxMethods)(...applyArgs))
|
|
1046
790
|
.then(rest => {
|
|
1047
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
881
|
+
return $xeGrid.commitProxy(params, evnt).then((rest) => {
|
|
1161
882
|
if (code && rest && rest.status && ['query', 'reload', 'delete', 'save'].includes(code)) {
|
|
1162
|
-
|
|
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
|
|
1168
|
-
|
|
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
|
|
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
|
-
}
|
|
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
|
|
1193
|
-
const
|
|
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 (
|
|
1196
|
-
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
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
|
-
|
|
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
|
|
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 (
|
|
1210
|
-
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
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
|
-
|
|
952
|
+
$xeGrid.dispatchEvent('filter-change', params, params.$event);
|
|
1219
953
|
},
|
|
1220
|
-
|
|
954
|
+
submitFormEvent(params) {
|
|
1221
955
|
const $xeGrid = this;
|
|
1222
|
-
const
|
|
1223
|
-
const
|
|
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
|
-
|
|
1229
|
-
|
|
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
|
-
|
|
968
|
+
$xeGrid.dispatchEvent('form-submit', params, params.$event);
|
|
1233
969
|
},
|
|
1234
|
-
|
|
1235
|
-
const
|
|
1236
|
-
const
|
|
1237
|
-
|
|
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
|
-
|
|
1240
|
-
|
|
979
|
+
$xeGrid.commitProxy('reload').then((rest) => {
|
|
980
|
+
$xeGrid.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), $event);
|
|
1241
981
|
});
|
|
1242
982
|
}
|
|
1243
|
-
|
|
983
|
+
$xeGrid.dispatchEvent('form-reset', params, $event);
|
|
1244
984
|
},
|
|
1245
985
|
submitInvalidEvent(params) {
|
|
1246
|
-
|
|
986
|
+
const $xeGrid = this;
|
|
987
|
+
$xeGrid.dispatchEvent('form-submit-invalid', params, params.$event);
|
|
1247
988
|
},
|
|
1248
989
|
collapseEvent(params) {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
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
|
|
1255
|
-
|
|
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
|
-
|
|
1002
|
+
const $xeGrid = this;
|
|
1003
|
+
const reactData = $xeGrid.reactData;
|
|
1004
|
+
return $xeGrid[reactData.isZMax ? 'revert' : 'maximize']();
|
|
1259
1005
|
},
|
|
1260
1006
|
isMaximized() {
|
|
1261
|
-
|
|
1007
|
+
const $xeGrid = this;
|
|
1008
|
+
const reactData = $xeGrid.reactData;
|
|
1009
|
+
return reactData.isZMax;
|
|
1262
1010
|
},
|
|
1263
1011
|
maximize() {
|
|
1264
|
-
|
|
1012
|
+
const $xeGrid = this;
|
|
1013
|
+
return $xeGrid.handleZoom(true);
|
|
1265
1014
|
},
|
|
1266
1015
|
revert() {
|
|
1267
|
-
|
|
1016
|
+
const $xeGrid = this;
|
|
1017
|
+
return $xeGrid.handleZoom();
|
|
1268
1018
|
},
|
|
1269
1019
|
handleZoom(isMax) {
|
|
1270
|
-
const
|
|
1020
|
+
const $xeGrid = this;
|
|
1021
|
+
const reactData = $xeGrid.reactData;
|
|
1022
|
+
const { isZMax } = reactData;
|
|
1271
1023
|
if (isMax ? !isZMax : isZMax) {
|
|
1272
|
-
|
|
1273
|
-
if (
|
|
1274
|
-
|
|
1024
|
+
reactData.isZMax = !isZMax;
|
|
1025
|
+
if (reactData.tZindex < getLastZIndex()) {
|
|
1026
|
+
reactData.tZindex = nextZIndex();
|
|
1275
1027
|
}
|
|
1276
1028
|
}
|
|
1277
|
-
return
|
|
1278
|
-
.then(() =>
|
|
1029
|
+
return $xeGrid.$nextTick()
|
|
1030
|
+
.then(() => $xeGrid.recalculate(true))
|
|
1279
1031
|
.then(() => {
|
|
1280
|
-
setTimeout(() =>
|
|
1281
|
-
return
|
|
1032
|
+
setTimeout(() => $xeGrid.recalculate(true), 15);
|
|
1033
|
+
return reactData.isZMax;
|
|
1282
1034
|
});
|
|
1283
1035
|
},
|
|
1284
1036
|
getProxyInfo() {
|
|
1285
1037
|
const $xeGrid = this;
|
|
1286
|
-
const
|
|
1287
|
-
const
|
|
1288
|
-
|
|
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:
|
|
1292
|
-
form:
|
|
1045
|
+
filter: reactData.filterData,
|
|
1046
|
+
form: $xeGrid.getFormData(),
|
|
1293
1047
|
sort: sortData.length ? sortData[0] : {},
|
|
1294
1048
|
sorts: sortData,
|
|
1295
|
-
pager:
|
|
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
|
|
1304
|
-
const
|
|
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 (
|
|
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
|
};
|