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