vxe-table 4.18.7 → 4.18.8
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/LICENSE +20 -20
- package/README.en.md +118 -118
- package/README.ja-JP.md +117 -117
- package/README.md +268 -268
- package/README.zh-TW.md +117 -117
- package/es/style.css +1 -1
- package/es/table/src/table.js +85 -78
- package/es/table/src/util.js +6 -0
- package/es/table/style.css +18 -48
- package/es/ui/index.js +1 -1
- package/es/ui/src/dom.js +21 -0
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +18 -48
- package/lib/index.common.js +2 -1
- package/lib/index.umd.js +2762 -2833
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/src/table.js +14 -11
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +6 -0
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +18 -48
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/dom.js +23 -0
- package/lib/ui/src/dom.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-table/style/style.css +18 -48
- 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 +91 -91
- package/packages/colgroup/index.ts +22 -22
- package/packages/column/index.ts +22 -22
- package/packages/components.ts +43 -43
- package/packages/grid/index.ts +18 -18
- package/packages/grid/src/emits.ts +19 -19
- package/packages/grid/src/grid.ts +1768 -1768
- package/packages/grid/src/props.ts +23 -23
- package/packages/index.ts +4 -4
- package/packages/locale/lang/ar-EG.ts +832 -832
- package/packages/locale/lang/de-DE.ts +832 -832
- package/packages/locale/lang/en-US.ts +832 -832
- package/packages/locale/lang/es-ES.ts +832 -832
- package/packages/locale/lang/fr-FR.ts +832 -832
- package/packages/locale/lang/hu-HU.ts +832 -832
- package/packages/locale/lang/hy-AM.ts +832 -832
- package/packages/locale/lang/id-ID.ts +832 -832
- package/packages/locale/lang/it-IT.ts +832 -832
- package/packages/locale/lang/ja-JP.ts +832 -832
- package/packages/locale/lang/ko-KR.ts +832 -832
- package/packages/locale/lang/ms-MY.ts +832 -832
- package/packages/locale/lang/nb-NO.ts +832 -832
- package/packages/locale/lang/pt-BR.ts +832 -832
- package/packages/locale/lang/ru-RU.ts +832 -832
- package/packages/locale/lang/th-TH.ts +832 -832
- package/packages/locale/lang/ug-CN.ts +832 -832
- package/packages/locale/lang/uk-UA.ts +832 -832
- package/packages/locale/lang/uz-UZ.ts +832 -832
- package/packages/locale/lang/vi-VN.ts +832 -832
- package/packages/locale/lang/zh-CHT.ts +832 -832
- package/packages/locale/lang/zh-CN.ts +832 -832
- package/packages/locale/lang/zh-HK.ts +3 -3
- package/packages/locale/lang/zh-MO.ts +3 -3
- package/packages/locale/lang/zh-TC.ts +3 -3
- package/packages/locale/lang/zh-TW.ts +3 -3
- package/packages/table/index.ts +26 -26
- package/packages/table/module/custom/hook.ts +359 -359
- package/packages/table/module/custom/panel.ts +1331 -1331
- package/packages/table/module/edit/hook.ts +1032 -1032
- package/packages/table/module/export/export-panel.ts +567 -567
- package/packages/table/module/export/hook.ts +1654 -1654
- package/packages/table/module/export/import-panel.ts +266 -266
- package/packages/table/module/export/util.ts +24 -24
- package/packages/table/module/filter/hook.ts +468 -468
- package/packages/table/module/filter/panel.ts +301 -301
- package/packages/table/module/keyboard/hook.ts +495 -495
- package/packages/table/module/menu/hook.ts +325 -325
- package/packages/table/module/menu/panel.ts +201 -201
- package/packages/table/module/validator/hook.ts +631 -631
- package/packages/table/render/index.ts +1440 -1440
- package/packages/table/src/body.ts +932 -932
- package/packages/table/src/cell.ts +1290 -1290
- package/packages/table/src/column.ts +190 -190
- package/packages/table/src/columnInfo.ts +225 -225
- package/packages/table/src/emits.ts +123 -123
- package/packages/table/src/footer.ts +368 -368
- package/packages/table/src/group.ts +59 -59
- package/packages/table/src/header.ts +559 -559
- package/packages/table/src/props.ts +324 -324
- package/packages/table/src/store.ts +14 -14
- package/packages/table/src/table.ts +14010 -14004
- package/packages/table/src/use/cell-view.ts +44 -44
- package/packages/table/src/use/index.ts +1 -1
- package/packages/table/src/util.ts +1070 -1064
- package/packages/toolbar/index.ts +18 -18
- package/packages/toolbar/src/toolbar.ts +701 -701
- package/packages/ui/index.ts +530 -530
- package/packages/ui/src/anime.ts +52 -52
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/dom.ts +259 -236
- package/packages/ui/src/log.ts +8 -8
- package/packages/ui/src/utils.ts +56 -56
- package/packages/ui/src/vn.ts +55 -55
- package/packages/v-x-e-table/index.d.ts +4 -4
- package/packages/v-x-e-table/index.ts +4 -4
- package/styles/all.scss +7 -7
- package/styles/base.scss +16 -16
- package/styles/components/grid.scss +89 -89
- package/styles/components/icon.scss +225 -225
- package/styles/components/old-icon.scss +715 -715
- package/styles/components/table-module/all.scss +6 -6
- package/styles/components/table-module/custom.scss +527 -527
- package/styles/components/table-module/export.scss +130 -130
- package/styles/components/table-module/filter.scss +130 -130
- package/styles/components/table-module/menu.scss +81 -81
- package/styles/components/table.scss +2679 -2679
- package/styles/components/toolbar.scss +119 -119
- package/styles/default.scss +2 -2
- package/styles/helpers/baseMixin.scss +95 -95
- package/styles/index.scss +4 -4
- package/styles/modules.scss +5 -5
- package/styles/theme/base.scss +93 -93
- package/styles/theme/dark.scss +49 -49
- package/styles/theme/light.scss +44 -44
- package/styles/variable.scss +43 -43
- package/types/all.d.ts +37 -37
- package/types/index.d.ts +4 -4
- /package/es/{iconfont.1773991907408.ttf → iconfont.1774240404046.ttf} +0 -0
- /package/es/{iconfont.1773991907408.woff → iconfont.1774240404046.woff} +0 -0
- /package/es/{iconfont.1773991907408.woff2 → iconfont.1774240404046.woff2} +0 -0
- /package/lib/{iconfont.1773991907408.ttf → iconfont.1774240404046.ttf} +0 -0
- /package/lib/{iconfont.1773991907408.woff → iconfont.1774240404046.woff} +0 -0
- /package/lib/{iconfont.1773991907408.woff2 → iconfont.1774240404046.woff2} +0 -0
|
@@ -1,1440 +1,1440 @@
|
|
|
1
|
-
import { h, resolveComponent, ComponentOptions } from 'vue'
|
|
2
|
-
import XEUtils from 'xe-utils'
|
|
3
|
-
import { VxeUI } from '../../ui'
|
|
4
|
-
import { getCellValue, setCellValue } from '../../table/src/util'
|
|
5
|
-
import { getFuncText, formatText, isEmptyValue } from '../../ui/src/utils'
|
|
6
|
-
import { getOnName, getModelEvent, getChangeEvent, hasInputType } from '../../ui/src/vn'
|
|
7
|
-
import { errLog } from '../../ui/src/log'
|
|
8
|
-
|
|
9
|
-
import type { VxeGlobalRendererHandles, VxeColumnPropTypes, VxeTableConstructor, VxeTablePrivateMethods, VxeTableDefines } from '../../../types'
|
|
10
|
-
|
|
11
|
-
const { getConfig, renderer, getI18n, getComponent } = VxeUI
|
|
12
|
-
|
|
13
|
-
const componentDefaultModelProp = 'modelValue'
|
|
14
|
-
|
|
15
|
-
const defaultCompProps = {}
|
|
16
|
-
|
|
17
|
-
function handleDefaultValue (value: any, defaultVal: any, initVal: any) {
|
|
18
|
-
return XEUtils.eqNull(value) ? (XEUtils.eqNull(defaultVal) ? initVal : defaultVal) : value
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function parseDate (value: any, props: any) {
|
|
22
|
-
return value && props.valueFormat ? XEUtils.toStringDate(value, props.valueFormat) : value
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getFormatDate (value: any, props: any, defaultFormat: string) {
|
|
26
|
-
const { dateConfig = {} } = props
|
|
27
|
-
return XEUtils.toDateString(parseDate(value, props), dateConfig.labelFormat || defaultFormat)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getLabelFormatDate (value: any, props: any) {
|
|
31
|
-
return getFormatDate(value, props, getI18n(`vxe.input.date.labelFormat.${props.type || 'date'}`))
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 已废弃
|
|
36
|
-
* @deprecated
|
|
37
|
-
*/
|
|
38
|
-
function getOldComponentName (name: string) {
|
|
39
|
-
return `vxe-${name.replace('$', '')}`
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getDefaultComponent ({ name }: any) {
|
|
43
|
-
return getComponent(name)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 已废弃
|
|
48
|
-
* @deprecated
|
|
49
|
-
*/
|
|
50
|
-
function getOldComponent ({ name }: any) {
|
|
51
|
-
return resolveComponent(getOldComponentName(name)) as ComponentOptions
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function updateFilterChangeOption (params: VxeGlobalRendererHandles.RenderTableFilterParams | VxeGlobalRendererHandles.RenderTableFloatingFilterParams, checked: boolean, option: VxeTableDefines.FilterOption) {
|
|
55
|
-
const { $table } = params
|
|
56
|
-
$table.updateFilterOptionStatus(option, checked)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function saveFilterEvent (params: VxeGlobalRendererHandles.RenderTableFilterParams | VxeGlobalRendererHandles.RenderTableFloatingFilterParams) {
|
|
60
|
-
const { $table, column } = params
|
|
61
|
-
$table.saveFilterByEvent(new Event('change'), column)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function getNativeAttrs (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions) {
|
|
65
|
-
let { name, attrs } = renderOpts
|
|
66
|
-
if (name === 'input') {
|
|
67
|
-
attrs = Object.assign({ type: 'text' }, attrs)
|
|
68
|
-
}
|
|
69
|
-
return attrs
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getInputImmediateModel (renderOpts: VxeColumnPropTypes.EditRender) {
|
|
73
|
-
const { name, immediate, props } = renderOpts
|
|
74
|
-
if (!immediate) {
|
|
75
|
-
if (name === 'VxeInput' || name === '$input') {
|
|
76
|
-
const { type } = props || {}
|
|
77
|
-
return !(!type || type === 'text' || type === 'number' || type === 'integer' || type === 'float')
|
|
78
|
-
}
|
|
79
|
-
if (name === 'input' || name === 'textarea' || name === '$textarea') {
|
|
80
|
-
return false
|
|
81
|
-
}
|
|
82
|
-
return true
|
|
83
|
-
}
|
|
84
|
-
return immediate
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function getCellEditProps (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderEditParams, value: any, defaultProps?: any) {
|
|
88
|
-
return XEUtils.assign({ immediate: getInputImmediateModel(renderOpts) }, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value })
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function getCellEditFilterProps (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any, value: any, defaultProps?: any) {
|
|
92
|
-
return XEUtils.assign({}, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value })
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function isImmediateCell (renderOpts: VxeColumnPropTypes.EditRender, params: any) {
|
|
96
|
-
return params.$type === 'cell' || getInputImmediateModel(renderOpts)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function getCellLabelVNs (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any, cellLabel: any, opts?: {
|
|
100
|
-
class?: string
|
|
101
|
-
}) {
|
|
102
|
-
const { placeholder } = renderOpts
|
|
103
|
-
return [
|
|
104
|
-
h('span', {
|
|
105
|
-
class: ['vxe-cell--label', opts ? opts.class : '']
|
|
106
|
-
}, placeholder && isEmptyValue(cellLabel)
|
|
107
|
-
? [
|
|
108
|
-
h('span', {
|
|
109
|
-
class: 'vxe-cell--placeholder'
|
|
110
|
-
}, formatText(getFuncText(placeholder), 1))
|
|
111
|
-
]
|
|
112
|
-
: formatText(cellLabel, 1))
|
|
113
|
-
]
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 原生事件处理
|
|
118
|
-
* @param renderOpts
|
|
119
|
-
* @param params
|
|
120
|
-
* @param modelFunc
|
|
121
|
-
* @param changeFunc
|
|
122
|
-
*/
|
|
123
|
-
function getNativeElementOns (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions | VxeGlobalRendererHandles.RenderTableFilterOptions, params: any, eFns?: {
|
|
124
|
-
model: (evnt: Event) => void
|
|
125
|
-
change?: (evnt: Event) => void
|
|
126
|
-
blur?: (evnt: Event) => void
|
|
127
|
-
}) {
|
|
128
|
-
const { events } = renderOpts
|
|
129
|
-
const modelEvent = getModelEvent(renderOpts)
|
|
130
|
-
const changeEvent = getChangeEvent(renderOpts)
|
|
131
|
-
const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {}
|
|
132
|
-
const isSameEvent = changeEvent === modelEvent
|
|
133
|
-
const ons: any = {}
|
|
134
|
-
if (events) {
|
|
135
|
-
XEUtils.objectEach(events, (func, key: any) => {
|
|
136
|
-
ons[getOnName(key)] = function (...args: any[]) {
|
|
137
|
-
func(params, ...args)
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
if (modelFunc) {
|
|
142
|
-
ons[getOnName(modelEvent)] = function (targetEvnt: any) {
|
|
143
|
-
modelFunc(targetEvnt)
|
|
144
|
-
if (isSameEvent && changeFunc) {
|
|
145
|
-
changeFunc(targetEvnt)
|
|
146
|
-
}
|
|
147
|
-
if (events && events[modelEvent]) {
|
|
148
|
-
events[modelEvent](params, targetEvnt)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (!isSameEvent && changeFunc) {
|
|
153
|
-
ons[getOnName(changeEvent)] = function (evnt: Event) {
|
|
154
|
-
changeFunc(evnt)
|
|
155
|
-
if (events && events[changeEvent]) {
|
|
156
|
-
events[changeEvent](params, evnt)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (blurFunc) {
|
|
161
|
-
ons[getOnName(blurEvent)] = function (evnt: Event) {
|
|
162
|
-
blurFunc(evnt)
|
|
163
|
-
if (events && events[blurEvent]) {
|
|
164
|
-
events[blurEvent](params, evnt)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return ons
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const blurEvent = 'blur'
|
|
172
|
-
const clearEvent = 'clear'
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* 组件事件处理
|
|
176
|
-
* @param renderOpts
|
|
177
|
-
* @param params
|
|
178
|
-
* @param modelFunc
|
|
179
|
-
* @param changeFunc
|
|
180
|
-
*/
|
|
181
|
-
function getComponentOns (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions | VxeGlobalRendererHandles.RenderTableFilterOptions, params: any, eFns?: {
|
|
182
|
-
model: (cellValue: any) => void
|
|
183
|
-
change?: (...args: any[]) => void
|
|
184
|
-
blur?: (...args: any[]) => void
|
|
185
|
-
clear?: (...args: any[]) => void
|
|
186
|
-
}, eventOns?: Record<string, any>) {
|
|
187
|
-
const { events } = renderOpts
|
|
188
|
-
const modelEvent = getModelEvent(renderOpts)
|
|
189
|
-
const changeEvent = getChangeEvent(renderOpts)
|
|
190
|
-
const { model: modelFunc, change: changeFunc, blur: blurFunc, clear: clearFunc } = eFns || {}
|
|
191
|
-
const ons: any = {}
|
|
192
|
-
XEUtils.objectEach(events, (func, key: any) => {
|
|
193
|
-
ons[getOnName(key)] = function (...args: any[]) {
|
|
194
|
-
if (!XEUtils.isFunction(func)) {
|
|
195
|
-
errLog('vxe.error.errFunc', [func])
|
|
196
|
-
}
|
|
197
|
-
func(params, ...args)
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
if (modelFunc) {
|
|
201
|
-
ons[getOnName(modelEvent)] = function (targetEvnt: any) {
|
|
202
|
-
modelFunc(targetEvnt)
|
|
203
|
-
if (events && events[modelEvent]) {
|
|
204
|
-
events[modelEvent](params, targetEvnt)
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (changeFunc) {
|
|
209
|
-
ons[getOnName(changeEvent)] = function (...args: any[]) {
|
|
210
|
-
changeFunc(...args)
|
|
211
|
-
if (events && events[changeEvent]) {
|
|
212
|
-
events[changeEvent](params, ...args)
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (blurFunc) {
|
|
217
|
-
ons[getOnName(blurEvent)] = function (...args: any[]) {
|
|
218
|
-
blurFunc(...args)
|
|
219
|
-
if (events && events[blurEvent]) {
|
|
220
|
-
events[blurEvent](params, ...args)
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (clearFunc) {
|
|
225
|
-
ons[getOnName(clearEvent)] = function (...args: any[]) {
|
|
226
|
-
clearFunc(...args)
|
|
227
|
-
if (events && events[clearEvent]) {
|
|
228
|
-
events[clearEvent](params, ...args)
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return eventOns ? Object.assign(ons, eventOns) : ons
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function getEditOns (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
236
|
-
const { $table, row, column } = params
|
|
237
|
-
const { name } = renderOpts
|
|
238
|
-
const { model } = column
|
|
239
|
-
const isImmediate = isImmediateCell(renderOpts, params)
|
|
240
|
-
return getComponentOns(renderOpts, params, {
|
|
241
|
-
model (cellValue) {
|
|
242
|
-
// 处理 model 值双向绑定
|
|
243
|
-
model.update = true
|
|
244
|
-
model.value = cellValue
|
|
245
|
-
if (isImmediate) {
|
|
246
|
-
setCellValue(row, column, cellValue)
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
change (eventParams) {
|
|
250
|
-
// 处理 change 事件相关逻辑
|
|
251
|
-
if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
|
|
252
|
-
const cellValue = eventParams.value
|
|
253
|
-
model.update = true
|
|
254
|
-
model.value = cellValue
|
|
255
|
-
$table.updateStatus(params, cellValue)
|
|
256
|
-
} else {
|
|
257
|
-
$table.updateStatus(params)
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
blur () {
|
|
261
|
-
if (isImmediate) {
|
|
262
|
-
$table.handleCellRuleUpdateStatus('blur', params)
|
|
263
|
-
} else {
|
|
264
|
-
$table.handleCellRuleUpdateStatus('blur', params, model.value)
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function getFilterOns (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFilterParams, option: VxeTableDefines.FilterOption) {
|
|
271
|
-
return getComponentOns(renderOpts, params, {
|
|
272
|
-
model (value: any) {
|
|
273
|
-
// 处理 model 值双向绑定
|
|
274
|
-
option.data = value
|
|
275
|
-
},
|
|
276
|
-
change () {
|
|
277
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
278
|
-
},
|
|
279
|
-
blur () {
|
|
280
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function getFloatingFilterOns (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFloatingFilterParams, option: VxeTableDefines.FilterOption) {
|
|
286
|
-
const { $table, column } = params
|
|
287
|
-
if (hasInputType(renderOpts)) {
|
|
288
|
-
return getComponentOns(renderOpts, params, {
|
|
289
|
-
model (value: any) {
|
|
290
|
-
// 处理 model 值双向绑定
|
|
291
|
-
option.data = value
|
|
292
|
-
},
|
|
293
|
-
change () {
|
|
294
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
295
|
-
},
|
|
296
|
-
clear () {
|
|
297
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
298
|
-
saveFilterEvent(params)
|
|
299
|
-
},
|
|
300
|
-
blur () {
|
|
301
|
-
$table.saveFilterByEvent(new Event('change'), column)
|
|
302
|
-
}
|
|
303
|
-
}, renderOpts.name === 'VxeNumberInput'
|
|
304
|
-
? {
|
|
305
|
-
[getOnName('plus-number')] () {
|
|
306
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
307
|
-
saveFilterEvent(params)
|
|
308
|
-
},
|
|
309
|
-
[getOnName('minus-number')] () {
|
|
310
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
311
|
-
saveFilterEvent(params)
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
: {})
|
|
315
|
-
}
|
|
316
|
-
return getComponentOns(renderOpts, params, {
|
|
317
|
-
model (value: any) {
|
|
318
|
-
// 处理 model 值双向绑定
|
|
319
|
-
option.data = value
|
|
320
|
-
},
|
|
321
|
-
clear () {
|
|
322
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
323
|
-
$table.saveFilterByEvent(new Event('change'), column)
|
|
324
|
-
},
|
|
325
|
-
change () {
|
|
326
|
-
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
327
|
-
$table.saveFilterByEvent(new Event('change'), column)
|
|
328
|
-
}
|
|
329
|
-
})
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function getNativeEditOns (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
333
|
-
const { $table, row, column } = params
|
|
334
|
-
const { model } = column
|
|
335
|
-
return getNativeElementOns(renderOpts, params, {
|
|
336
|
-
model (evnt) {
|
|
337
|
-
// 处理 model 值双向绑定
|
|
338
|
-
const targetEl = evnt.target as HTMLInputElement
|
|
339
|
-
if (targetEl) {
|
|
340
|
-
const cellValue = targetEl.value
|
|
341
|
-
if (isImmediateCell(renderOpts, params)) {
|
|
342
|
-
setCellValue(row, column, cellValue)
|
|
343
|
-
} else {
|
|
344
|
-
model.update = true
|
|
345
|
-
model.value = cellValue
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
change (evnt) {
|
|
350
|
-
// 处理 change 事件相关逻辑
|
|
351
|
-
const targetEl = evnt.target as HTMLInputElement
|
|
352
|
-
if (targetEl) {
|
|
353
|
-
const cellValue = targetEl.value
|
|
354
|
-
$table.updateStatus(params, cellValue)
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
blur (evnt) {
|
|
358
|
-
const targetEl = evnt.target as HTMLInputElement
|
|
359
|
-
if (targetEl) {
|
|
360
|
-
const cellValue = targetEl.value
|
|
361
|
-
$table.updateStatus(params, cellValue)
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
})
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function getNativeFilterOns (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: any, option: any) {
|
|
368
|
-
return getNativeElementOns(renderOpts, params, {
|
|
369
|
-
model (evnt) {
|
|
370
|
-
// 处理 model 值双向绑定
|
|
371
|
-
const targetEl = evnt.target as HTMLInputElement
|
|
372
|
-
if (targetEl) {
|
|
373
|
-
option.data = targetEl.value
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
change () {
|
|
377
|
-
updateFilterChangeOption(params, !XEUtils.eqNull(option.data), option)
|
|
378
|
-
},
|
|
379
|
-
blur () {
|
|
380
|
-
updateFilterChangeOption(params, !XEUtils.eqNull(option.data), option)
|
|
381
|
-
}
|
|
382
|
-
})
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* 单元格可编辑渲染-原生的标签
|
|
387
|
-
* input、textarea、select
|
|
388
|
-
*/
|
|
389
|
-
function nativeEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
390
|
-
const { row, column } = params
|
|
391
|
-
const { name } = renderOpts
|
|
392
|
-
const cellValue = isImmediateCell(renderOpts, params) ? getCellValue(row, column) : column.model.value
|
|
393
|
-
return [
|
|
394
|
-
h(`${name}`, {
|
|
395
|
-
class: `vxe-default-${name}`,
|
|
396
|
-
...getNativeAttrs(renderOpts),
|
|
397
|
-
value: cellValue,
|
|
398
|
-
...getNativeEditOns(renderOpts, params)
|
|
399
|
-
})
|
|
400
|
-
]
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function buttonCellRender (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions, params: any) {
|
|
404
|
-
return [
|
|
405
|
-
h(getDefaultComponent(renderOpts), {
|
|
406
|
-
...getCellEditProps(renderOpts, params, null),
|
|
407
|
-
...getComponentOns(renderOpts, params)
|
|
408
|
-
})
|
|
409
|
-
]
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
function defaultEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
413
|
-
const { row, column } = params
|
|
414
|
-
const cellValue = getCellValue(row, column)
|
|
415
|
-
return [
|
|
416
|
-
h(getDefaultComponent(renderOpts), {
|
|
417
|
-
...getCellEditProps(renderOpts, params, cellValue),
|
|
418
|
-
...getEditOns(renderOpts, params)
|
|
419
|
-
})
|
|
420
|
-
]
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function checkboxEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
424
|
-
const { row, column } = params
|
|
425
|
-
const cellValue = getCellValue(row, column)
|
|
426
|
-
return [
|
|
427
|
-
h(getDefaultComponent(renderOpts), {
|
|
428
|
-
...getCellEditProps(renderOpts, params, cellValue),
|
|
429
|
-
...getEditOns(renderOpts, params)
|
|
430
|
-
})
|
|
431
|
-
]
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
function radioAndCheckboxGroupEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
435
|
-
const { options } = renderOpts
|
|
436
|
-
const { row, column } = params
|
|
437
|
-
const cellValue = getCellValue(row, column)
|
|
438
|
-
return [
|
|
439
|
-
h(getDefaultComponent(renderOpts), {
|
|
440
|
-
options,
|
|
441
|
-
...getCellEditProps(renderOpts, params, cellValue),
|
|
442
|
-
...getEditOns(renderOpts, params)
|
|
443
|
-
})
|
|
444
|
-
]
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* 已废弃
|
|
449
|
-
* @deprecated
|
|
450
|
-
*/
|
|
451
|
-
function oldEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
452
|
-
const { row, column } = params
|
|
453
|
-
const cellValue = getCellValue(row, column)
|
|
454
|
-
return [
|
|
455
|
-
h(getOldComponent(renderOpts), {
|
|
456
|
-
...getCellEditProps(renderOpts, params, cellValue),
|
|
457
|
-
...getEditOns(renderOpts, params)
|
|
458
|
-
})
|
|
459
|
-
]
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* 已废弃
|
|
464
|
-
* @deprecated
|
|
465
|
-
*/
|
|
466
|
-
function oldButtonEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
467
|
-
return [
|
|
468
|
-
h(getComponent('vxe-button'), {
|
|
469
|
-
...getCellEditProps(renderOpts, params, null),
|
|
470
|
-
...getComponentOns(renderOpts, params)
|
|
471
|
-
})
|
|
472
|
-
]
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* 已废弃
|
|
477
|
-
* @deprecated
|
|
478
|
-
*/
|
|
479
|
-
function oldButtonsEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
480
|
-
const { children } = renderOpts
|
|
481
|
-
return children ? children.map((childRenderOpts: any) => oldButtonEditRender(childRenderOpts, params)[0]) : []
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
function renderNativeOptgroups (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any, renderOptionsMethods: any) {
|
|
485
|
-
const { optionGroups, optionGroupProps = {} } = renderOpts
|
|
486
|
-
const groupOptions = optionGroupProps.options || 'options'
|
|
487
|
-
const groupLabel = optionGroupProps.label || 'label'
|
|
488
|
-
if (optionGroups) {
|
|
489
|
-
return optionGroups.map((group: any, gIndex: any) => {
|
|
490
|
-
return h('optgroup', {
|
|
491
|
-
key: gIndex,
|
|
492
|
-
label: group[groupLabel]
|
|
493
|
-
}, renderOptionsMethods(group[groupOptions], renderOpts, params))
|
|
494
|
-
})
|
|
495
|
-
}
|
|
496
|
-
return []
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* 渲染原生的 option 标签
|
|
501
|
-
*/
|
|
502
|
-
function renderNativeOptions (options: any, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
503
|
-
const { optionProps = {} } = renderOpts
|
|
504
|
-
const { row, column } = params
|
|
505
|
-
const labelProp = optionProps.label || 'label'
|
|
506
|
-
const valueProp = optionProps.value || 'value'
|
|
507
|
-
const disabledProp = optionProps.disabled || 'disabled'
|
|
508
|
-
const cellValue = isImmediateCell(renderOpts, params) ? getCellValue(row, column) : column.model.value
|
|
509
|
-
if (options) {
|
|
510
|
-
return options.map((option: any, oIndex: any) => {
|
|
511
|
-
return h('option', {
|
|
512
|
-
key: oIndex,
|
|
513
|
-
value: option[valueProp],
|
|
514
|
-
disabled: option[disabledProp],
|
|
515
|
-
/* eslint-disable eqeqeq */
|
|
516
|
-
selected: option[valueProp] == cellValue
|
|
517
|
-
}, option[labelProp])
|
|
518
|
-
})
|
|
519
|
-
}
|
|
520
|
-
return []
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function nativeFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFilterParams) {
|
|
524
|
-
const { column } = params
|
|
525
|
-
const { name } = renderOpts
|
|
526
|
-
const attrs = getNativeAttrs(renderOpts)
|
|
527
|
-
return column.filters.map((option, oIndex) => {
|
|
528
|
-
return h(`${name}`, {
|
|
529
|
-
key: oIndex,
|
|
530
|
-
class: `vxe-default-${name}`,
|
|
531
|
-
...attrs,
|
|
532
|
-
value: option.data,
|
|
533
|
-
...getNativeFilterOns(renderOpts, params, option)
|
|
534
|
-
})
|
|
535
|
-
})
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
function defaultFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFilterParams) {
|
|
539
|
-
const { column } = params
|
|
540
|
-
return column.filters.map((option, oIndex) => {
|
|
541
|
-
const optionValue = option.data
|
|
542
|
-
return h(getDefaultComponent(renderOpts), {
|
|
543
|
-
key: oIndex,
|
|
544
|
-
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
|
|
545
|
-
...getFilterOns(renderOpts, params, option)
|
|
546
|
-
})
|
|
547
|
-
})
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
function defaultFloatingFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFloatingFilterOptions, params: VxeGlobalRendererHandles.RenderTableFloatingFilterParams) {
|
|
551
|
-
const { option } = params
|
|
552
|
-
const optionValue = option.data
|
|
553
|
-
return [
|
|
554
|
-
h(getDefaultComponent(renderOpts), {
|
|
555
|
-
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
|
|
556
|
-
...getFloatingFilterOns(renderOpts, params, option)
|
|
557
|
-
})
|
|
558
|
-
]
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
function defaultFilterOptions () {
|
|
562
|
-
return [
|
|
563
|
-
{ data: null }
|
|
564
|
-
]
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* 已废弃
|
|
569
|
-
* @deprecated
|
|
570
|
-
*/
|
|
571
|
-
function oldFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: any) {
|
|
572
|
-
const { column } = params
|
|
573
|
-
return column.filters.map((option: any, oIndex: any) => {
|
|
574
|
-
const optionValue = option.data
|
|
575
|
-
return h(getOldComponent(renderOpts), {
|
|
576
|
-
key: oIndex,
|
|
577
|
-
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
|
|
578
|
-
...getFilterOns(renderOpts, params, option)
|
|
579
|
-
})
|
|
580
|
-
})
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
function handleFilterMethod ({ option, row, column }: any) {
|
|
584
|
-
const { data } = option
|
|
585
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
586
|
-
/* eslint-disable eqeqeq */
|
|
587
|
-
return cellValue == data
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
function handleInputFilterMethod ({ option, row, column }: any) {
|
|
591
|
-
const { data } = option
|
|
592
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
593
|
-
/* eslint-disable eqeqeq */
|
|
594
|
-
return XEUtils.toValueString(cellValue).indexOf(data) > -1
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function nativeSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
598
|
-
return [
|
|
599
|
-
h('select', {
|
|
600
|
-
class: 'vxe-default-select',
|
|
601
|
-
...getNativeAttrs(renderOpts),
|
|
602
|
-
...getNativeEditOns(renderOpts, params)
|
|
603
|
-
},
|
|
604
|
-
renderOpts.optionGroups ? renderNativeOptgroups(renderOpts, params, renderNativeOptions) : renderNativeOptions(renderOpts.options, renderOpts, params))
|
|
605
|
-
]
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function defaultSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
609
|
-
const { row, column } = params
|
|
610
|
-
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
611
|
-
const cellValue = getCellValue(row, column)
|
|
612
|
-
return [
|
|
613
|
-
h(getDefaultComponent(renderOpts), {
|
|
614
|
-
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
615
|
-
...getEditOns(renderOpts, params)
|
|
616
|
-
})
|
|
617
|
-
]
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
function defaultTableOrTreeSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
621
|
-
const { row, column } = params
|
|
622
|
-
const { options, optionProps } = renderOpts
|
|
623
|
-
const cellValue = getCellValue(row, column)
|
|
624
|
-
return [
|
|
625
|
-
h(getDefaultComponent(renderOpts), {
|
|
626
|
-
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps }),
|
|
627
|
-
...getEditOns(renderOpts, params)
|
|
628
|
-
})
|
|
629
|
-
]
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* 已废弃
|
|
634
|
-
* @deprecated
|
|
635
|
-
*/
|
|
636
|
-
function oldSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
637
|
-
const { row, column } = params
|
|
638
|
-
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
639
|
-
const cellValue = getCellValue(row, column)
|
|
640
|
-
return [
|
|
641
|
-
h(getOldComponent(renderOpts), {
|
|
642
|
-
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
643
|
-
...getEditOns(renderOpts, params)
|
|
644
|
-
})
|
|
645
|
-
]
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
function handleSelectCellValue (cellValue: any, renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions) {
|
|
649
|
-
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props = {} } = renderOpts
|
|
650
|
-
let selectItem: any
|
|
651
|
-
const labelProp = optionProps.label || 'label'
|
|
652
|
-
const valueProp = optionProps.value || 'value'
|
|
653
|
-
if (!(cellValue === null || cellValue === undefined)) {
|
|
654
|
-
let vals = []
|
|
655
|
-
if (XEUtils.isArray(cellValue)) {
|
|
656
|
-
vals = cellValue
|
|
657
|
-
} else {
|
|
658
|
-
if (props.multiple && `${cellValue}`.indexOf(',') > -1) {
|
|
659
|
-
vals = `${cellValue}`.split(',')
|
|
660
|
-
} else {
|
|
661
|
-
vals = [cellValue]
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
return XEUtils.map(vals, optionGroups
|
|
665
|
-
? (value) => {
|
|
666
|
-
const groupOptions = optionGroupProps.options || 'options'
|
|
667
|
-
for (let index = 0; index < optionGroups.length; index++) {
|
|
668
|
-
/* eslint-disable eqeqeq */
|
|
669
|
-
selectItem = XEUtils.find(optionGroups[index][groupOptions], item => item[valueProp] == value)
|
|
670
|
-
if (selectItem) {
|
|
671
|
-
break
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
return selectItem ? selectItem[labelProp] : value
|
|
675
|
-
}
|
|
676
|
-
: (value) => {
|
|
677
|
-
/* eslint-disable eqeqeq */
|
|
678
|
-
selectItem = XEUtils.find(options, item => item[valueProp] == value)
|
|
679
|
-
return selectItem ? selectItem[labelProp] : value
|
|
680
|
-
}
|
|
681
|
-
).join(', ')
|
|
682
|
-
}
|
|
683
|
-
return ''
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
function getSelectCellValue (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions, { row, column }: any) {
|
|
687
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
688
|
-
return handleSelectCellValue(cellValue, renderOpts)
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function handleExportSelectMethod (params: any) {
|
|
692
|
-
const { row, column, options } = params
|
|
693
|
-
return options.original ? getCellValue(row, column) : getSelectCellValue(column.editRender || column.cellRender, params)
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
function handleTreeSelectCellValue (cellValue: any, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions) {
|
|
697
|
-
const { options, optionProps = {} } = renderOpts
|
|
698
|
-
const labelProp = optionProps.label || 'label'
|
|
699
|
-
const valueProp = optionProps.value || 'value'
|
|
700
|
-
const childrenProp = optionProps.children || 'children'
|
|
701
|
-
if (!(cellValue === null || cellValue === undefined)) {
|
|
702
|
-
const keyMaps: Record<string, any> = {}
|
|
703
|
-
XEUtils.eachTree(options, item => {
|
|
704
|
-
keyMaps[XEUtils.get(item, valueProp)] = item
|
|
705
|
-
}, { children: childrenProp })
|
|
706
|
-
return XEUtils.map(XEUtils.isArray(cellValue) ? cellValue : [cellValue], (value) => {
|
|
707
|
-
const item = keyMaps[value]
|
|
708
|
-
return item ? XEUtils.get(item, labelProp) : item
|
|
709
|
-
}
|
|
710
|
-
).join(', ')
|
|
711
|
-
}
|
|
712
|
-
return ''
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
function getTreeSelectCellValue (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, { row, column }: any) {
|
|
716
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
717
|
-
return handleTreeSelectCellValue(cellValue, renderOpts)
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
function handleExportTreeSelectMethod (params: any) {
|
|
721
|
-
const { row, column, options } = params
|
|
722
|
-
return options.original ? getCellValue(row, column) : getTreeSelectCellValue(column.editRender || column.cellRender, params)
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
function handleNumberCell (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.RenderTableDefaultParams) {
|
|
726
|
-
const { props = {}, showNegativeStatus } = renderOpts
|
|
727
|
-
const { row, column } = params
|
|
728
|
-
const { type } = props
|
|
729
|
-
let cellValue = XEUtils.get(row, column.field)
|
|
730
|
-
let isNegative = false
|
|
731
|
-
if (!isEmptyValue(cellValue)) {
|
|
732
|
-
const numberInputConfig = getConfig().numberInput || {}
|
|
733
|
-
if (type === 'float') {
|
|
734
|
-
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
735
|
-
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
|
|
736
|
-
cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
737
|
-
if (!autoFill) {
|
|
738
|
-
cellValue = XEUtils.toNumber(cellValue)
|
|
739
|
-
}
|
|
740
|
-
if (showNegativeStatus) {
|
|
741
|
-
if (cellValue < 0) {
|
|
742
|
-
isNegative = true
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
} else if (type === 'amount') {
|
|
746
|
-
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
747
|
-
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
|
|
748
|
-
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
|
|
749
|
-
cellValue = XEUtils.toNumber(cellValue)
|
|
750
|
-
if (showNegativeStatus) {
|
|
751
|
-
if (cellValue < 0) {
|
|
752
|
-
isNegative = true
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
cellValue = XEUtils.commafy(cellValue, { digits })
|
|
756
|
-
if (!autoFill) {
|
|
757
|
-
const [iStr, dStr] = cellValue.split('.')
|
|
758
|
-
if (dStr) {
|
|
759
|
-
const dRest = dStr.replace(/0+$/, '')
|
|
760
|
-
cellValue = dRest ? [iStr, '.', dRest].join('') : iStr
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
if (showCurrency) {
|
|
764
|
-
cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`
|
|
765
|
-
}
|
|
766
|
-
} else {
|
|
767
|
-
if (type === 'integer') {
|
|
768
|
-
cellValue = XEUtils.toInteger(cellValue)
|
|
769
|
-
}
|
|
770
|
-
if (showNegativeStatus) {
|
|
771
|
-
if (XEUtils.toNumber(cellValue) < 0) {
|
|
772
|
-
isNegative = true
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
return getCellLabelVNs(renderOpts, params, cellValue, isNegative
|
|
778
|
-
? {
|
|
779
|
-
class: 'is--negative'
|
|
780
|
-
}
|
|
781
|
-
: {})
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
function handleFormatDatePicker (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams) {
|
|
785
|
-
const { props = {} } = renderOpts
|
|
786
|
-
const { cellValue } = params
|
|
787
|
-
if (cellValue) {
|
|
788
|
-
if (props.type !== 'time') {
|
|
789
|
-
return getLabelFormatDate(cellValue, props)
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
return cellValue
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
function handleFormatSelect (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
796
|
-
const { cellValue } = params
|
|
797
|
-
return handleSelectCellValue(cellValue, renderOpts)
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
function handleSetSelectValue (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
801
|
-
const { row, column, cellValue } = params
|
|
802
|
-
const { field } = column
|
|
803
|
-
if (field) {
|
|
804
|
-
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props } = renderOpts
|
|
805
|
-
if (isEmptyValue(cellValue)) {
|
|
806
|
-
XEUtils.set(row, field, props && props.multiple ? [] : null)
|
|
807
|
-
return
|
|
808
|
-
}
|
|
809
|
-
const isMultiVal = XEUtils.indexOf(`${cellValue}`, ',') > -1
|
|
810
|
-
const labelProp = optionProps.label || 'label'
|
|
811
|
-
const valueProp = optionProps.value || 'value'
|
|
812
|
-
const labelMpas: Record<string, any> = {}
|
|
813
|
-
if (optionGroups && optionGroups.length) {
|
|
814
|
-
const groupOptions = optionGroupProps.options || 'options'
|
|
815
|
-
for (let i = 0; i < optionGroups.length; i++) {
|
|
816
|
-
const opts = optionGroups[i][groupOptions] || {}
|
|
817
|
-
for (let j = 0; j < opts.length; j++) {
|
|
818
|
-
const item = opts[j]
|
|
819
|
-
if (isMultiVal) {
|
|
820
|
-
labelMpas[item[labelProp]] = item
|
|
821
|
-
/* eslint-disable eqeqeq */
|
|
822
|
-
} else if (item[labelProp] == cellValue) {
|
|
823
|
-
XEUtils.set(row, field, item[valueProp])
|
|
824
|
-
return
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
} else {
|
|
829
|
-
if (options) {
|
|
830
|
-
for (let i = 0; i < options.length; i++) {
|
|
831
|
-
const item = options[i]
|
|
832
|
-
if (isMultiVal) {
|
|
833
|
-
labelMpas[item[labelProp]] = item
|
|
834
|
-
/* eslint-disable eqeqeq */
|
|
835
|
-
} else if (item[labelProp] == cellValue) {
|
|
836
|
-
XEUtils.set(row, field, item[valueProp])
|
|
837
|
-
return
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
if (isMultiVal) {
|
|
843
|
-
XEUtils.set(row, field, (isMultiVal
|
|
844
|
-
? cellValue.split(',')
|
|
845
|
-
: [cellValue]).map((label: any) => {
|
|
846
|
-
const item = labelMpas[label]
|
|
847
|
-
return item ? item[valueProp] : label
|
|
848
|
-
}))
|
|
849
|
-
} else {
|
|
850
|
-
XEUtils.set(row, field, cellValue)
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
function handleFormatTreeSelect (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
856
|
-
const { cellValue } = params
|
|
857
|
-
return handleTreeSelectCellValue(cellValue, renderOpts)
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
function handleSetTreeSelectValue (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
861
|
-
const { row, column, cellValue } = params
|
|
862
|
-
const { field } = column
|
|
863
|
-
if (field) {
|
|
864
|
-
const { options, optionProps = {} } = renderOpts
|
|
865
|
-
const labelProp = optionProps.label || 'label'
|
|
866
|
-
const valueProp = optionProps.value || 'value'
|
|
867
|
-
const childrenProp = optionProps.children || 'children'
|
|
868
|
-
const matchRest = XEUtils.findTree(options || [], item => XEUtils.get(item, labelProp) === cellValue, { children: childrenProp })
|
|
869
|
-
if (matchRest) {
|
|
870
|
-
const selectItem = matchRest.item
|
|
871
|
-
if (selectItem) {
|
|
872
|
-
XEUtils.set(row, field, selectItem[valueProp])
|
|
873
|
-
return
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
XEUtils.set(row, field, cellValue)
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
/**
|
|
881
|
-
* 表格 - 渲染器
|
|
882
|
-
*/
|
|
883
|
-
renderer.mixin({
|
|
884
|
-
input: {
|
|
885
|
-
tableAutoFocus: 'input',
|
|
886
|
-
renderTableEdit: nativeEditRender,
|
|
887
|
-
renderTableDefault: nativeEditRender,
|
|
888
|
-
createTableFilterOptions: defaultFilterOptions,
|
|
889
|
-
renderTableFilter: nativeFilterRender,
|
|
890
|
-
tableFilterDefaultMethod: handleInputFilterMethod
|
|
891
|
-
},
|
|
892
|
-
textarea: {
|
|
893
|
-
tableAutoFocus: 'textarea',
|
|
894
|
-
renderTableEdit: nativeEditRender
|
|
895
|
-
},
|
|
896
|
-
select: {
|
|
897
|
-
renderTableEdit: nativeSelectEditRender,
|
|
898
|
-
renderTableDefault: nativeSelectEditRender,
|
|
899
|
-
renderTableCell (renderOpts, params) {
|
|
900
|
-
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
901
|
-
},
|
|
902
|
-
createTableFilterOptions: defaultFilterOptions,
|
|
903
|
-
renderTableFilter (renderOpts, params) {
|
|
904
|
-
const { column } = params
|
|
905
|
-
return column.filters.map((option, oIndex) => {
|
|
906
|
-
return h('select', {
|
|
907
|
-
key: oIndex,
|
|
908
|
-
class: 'vxe-default-select',
|
|
909
|
-
...getNativeAttrs(renderOpts),
|
|
910
|
-
...getNativeFilterOns(renderOpts, params, option)
|
|
911
|
-
},
|
|
912
|
-
renderOpts.optionGroups ? renderNativeOptgroups(renderOpts, params, renderNativeOptions) : renderNativeOptions(renderOpts.options, renderOpts, params))
|
|
913
|
-
})
|
|
914
|
-
},
|
|
915
|
-
tableCellFormatter: handleFormatSelect,
|
|
916
|
-
tableCellCopyMethod: handleFormatSelect,
|
|
917
|
-
tableCellPasteMethod: handleSetSelectValue,
|
|
918
|
-
tableFilterDefaultMethod: handleFilterMethod,
|
|
919
|
-
tableExportMethod: handleExportSelectMethod
|
|
920
|
-
},
|
|
921
|
-
VxeInput: {
|
|
922
|
-
tableAutoFocus: 'input',
|
|
923
|
-
renderTableEdit: defaultEditRender,
|
|
924
|
-
renderTableCell (renderOpts, params) {
|
|
925
|
-
const { props = {} } = renderOpts
|
|
926
|
-
const { row, column } = params
|
|
927
|
-
const inputConfig = getConfig().input || {}
|
|
928
|
-
const digits = props.digits || inputConfig.digits || 2
|
|
929
|
-
let cellValue = XEUtils.get(row, column.field)
|
|
930
|
-
if (cellValue) {
|
|
931
|
-
switch (props.type) {
|
|
932
|
-
case 'date':
|
|
933
|
-
case 'week':
|
|
934
|
-
case 'month':
|
|
935
|
-
case 'quarter':
|
|
936
|
-
case 'year':
|
|
937
|
-
cellValue = getLabelFormatDate(cellValue, props)
|
|
938
|
-
break
|
|
939
|
-
case 'float':
|
|
940
|
-
cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
941
|
-
break
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
945
|
-
},
|
|
946
|
-
renderTableDefault: defaultEditRender,
|
|
947
|
-
createTableFilterOptions: defaultFilterOptions,
|
|
948
|
-
renderTableFilter: defaultFilterRender,
|
|
949
|
-
renderTableFloatingFilter: defaultFloatingFilterRender,
|
|
950
|
-
tableFilterDefaultMethod: handleInputFilterMethod
|
|
951
|
-
},
|
|
952
|
-
FormatNumberInput: {
|
|
953
|
-
renderTableDefault: handleNumberCell,
|
|
954
|
-
tableFilterDefaultMethod: handleInputFilterMethod,
|
|
955
|
-
tableExportMethod (params) {
|
|
956
|
-
const { row, column } = params
|
|
957
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
958
|
-
return cellValue
|
|
959
|
-
}
|
|
960
|
-
},
|
|
961
|
-
VxeNumberInput: {
|
|
962
|
-
tableAutoFocus: 'input',
|
|
963
|
-
renderTableEdit: defaultEditRender,
|
|
964
|
-
renderTableCell: handleNumberCell,
|
|
965
|
-
renderTableFooter (renderOpts, params) {
|
|
966
|
-
const { props = {} } = renderOpts
|
|
967
|
-
const { row, column, _columnIndex } = params
|
|
968
|
-
const { type } = props
|
|
969
|
-
// 兼容老模式
|
|
970
|
-
const itemValue = XEUtils.isArray(row) ? row[_columnIndex] : XEUtils.get(row, column.field)
|
|
971
|
-
if (XEUtils.isNumber(itemValue)) {
|
|
972
|
-
const numberInputConfig = getConfig().numberInput || {}
|
|
973
|
-
if (type === 'float') {
|
|
974
|
-
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
975
|
-
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
|
|
976
|
-
let amountLabel = XEUtils.toFixed(XEUtils.floor(itemValue, digits), digits)
|
|
977
|
-
if (!autoFill) {
|
|
978
|
-
amountLabel = XEUtils.toNumber(amountLabel)
|
|
979
|
-
}
|
|
980
|
-
return amountLabel
|
|
981
|
-
} else if (type === 'amount') {
|
|
982
|
-
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
983
|
-
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
|
|
984
|
-
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
|
|
985
|
-
let amountLabel = XEUtils.commafy(XEUtils.toNumber(itemValue), { digits })
|
|
986
|
-
if (!autoFill) {
|
|
987
|
-
const [iStr, dStr] = amountLabel.split('.')
|
|
988
|
-
if (dStr) {
|
|
989
|
-
const dRest = dStr.replace(/0+$/, '')
|
|
990
|
-
amountLabel = dRest ? [iStr, '.', dRest].join('') : iStr
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
if (showCurrency) {
|
|
994
|
-
amountLabel = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${amountLabel}`
|
|
995
|
-
}
|
|
996
|
-
return amountLabel
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
return getFuncText(itemValue, 1)
|
|
1000
|
-
},
|
|
1001
|
-
renderTableDefault: defaultEditRender,
|
|
1002
|
-
createTableFilterOptions: defaultFilterOptions,
|
|
1003
|
-
renderTableFilter: defaultFilterRender,
|
|
1004
|
-
renderTableFloatingFilter: defaultFloatingFilterRender,
|
|
1005
|
-
tableFilterDefaultMethod: handleInputFilterMethod,
|
|
1006
|
-
tableExportMethod (params) {
|
|
1007
|
-
const { row, column } = params
|
|
1008
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
1009
|
-
return cellValue
|
|
1010
|
-
}
|
|
1011
|
-
},
|
|
1012
|
-
VxeDatePicker: {
|
|
1013
|
-
tableAutoFocus: 'input',
|
|
1014
|
-
renderTableEdit: defaultEditRender,
|
|
1015
|
-
renderTableCell (renderOpts, params) {
|
|
1016
|
-
const { props = {} } = renderOpts
|
|
1017
|
-
const { row, column } = params
|
|
1018
|
-
let cellValue = XEUtils.get(row, column.field)
|
|
1019
|
-
if (cellValue) {
|
|
1020
|
-
if (props.type !== 'time') {
|
|
1021
|
-
cellValue = getLabelFormatDate(cellValue, props)
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
1026
|
-
},
|
|
1027
|
-
tableCellFormatter: handleFormatDatePicker,
|
|
1028
|
-
renderTableDefault: defaultEditRender,
|
|
1029
|
-
createTableFilterOptions: defaultFilterOptions,
|
|
1030
|
-
renderTableFilter: defaultFilterRender,
|
|
1031
|
-
renderTableFloatingFilter: defaultFloatingFilterRender,
|
|
1032
|
-
tableFilterDefaultMethod: handleFilterMethod
|
|
1033
|
-
},
|
|
1034
|
-
VxeDateRangePicker: {
|
|
1035
|
-
tableAutoFocus: 'input',
|
|
1036
|
-
renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1037
|
-
const { startField, endField } = renderOpts
|
|
1038
|
-
const { $table, row, column } = params
|
|
1039
|
-
const { model } = column
|
|
1040
|
-
const cellValue = getCellValue(row, column)
|
|
1041
|
-
const seProps: Record<string, any> = {}
|
|
1042
|
-
const seOs: Record<string, any> = {}
|
|
1043
|
-
if (startField && endField) {
|
|
1044
|
-
seProps.startValue = XEUtils.get(row, startField)
|
|
1045
|
-
seProps.endValue = XEUtils.get(row, endField)
|
|
1046
|
-
seOs['onUpdate:startValue'] = (value: any) => {
|
|
1047
|
-
if (startField) {
|
|
1048
|
-
XEUtils.set(row, startField, value)
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
seOs['onUpdate:endValue'] = (value: any) => {
|
|
1052
|
-
if (endField) {
|
|
1053
|
-
XEUtils.set(row, endField, value)
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
return [
|
|
1058
|
-
h(getDefaultComponent(renderOpts), {
|
|
1059
|
-
...getCellEditProps(renderOpts, params, cellValue, seProps),
|
|
1060
|
-
...getComponentOns(renderOpts, params, {
|
|
1061
|
-
model (cellValue) {
|
|
1062
|
-
model.update = true
|
|
1063
|
-
model.value = cellValue
|
|
1064
|
-
setCellValue(row, column, cellValue)
|
|
1065
|
-
},
|
|
1066
|
-
change () {
|
|
1067
|
-
$table.updateStatus(params)
|
|
1068
|
-
},
|
|
1069
|
-
blur () {
|
|
1070
|
-
$table.handleCellRuleUpdateStatus('blur', params)
|
|
1071
|
-
}
|
|
1072
|
-
}, seOs)
|
|
1073
|
-
})
|
|
1074
|
-
]
|
|
1075
|
-
},
|
|
1076
|
-
renderTableCell (renderOpts, params) {
|
|
1077
|
-
const { startField, endField } = renderOpts
|
|
1078
|
-
const { row, column } = params
|
|
1079
|
-
let startValue = ''
|
|
1080
|
-
let endValue = ''
|
|
1081
|
-
if (startField && endField) {
|
|
1082
|
-
startValue = XEUtils.get(row, startField)
|
|
1083
|
-
endValue = XEUtils.get(row, endField)
|
|
1084
|
-
} else {
|
|
1085
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
1086
|
-
if (cellValue) {
|
|
1087
|
-
if (XEUtils.isArray(cellValue)) {
|
|
1088
|
-
startValue = cellValue[0]
|
|
1089
|
-
endValue = cellValue[1]
|
|
1090
|
-
} else {
|
|
1091
|
-
const strs = `${cellValue}`.split(',')
|
|
1092
|
-
startValue = strs[0]
|
|
1093
|
-
endValue = strs[1]
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
let cellLabel = ''
|
|
1098
|
-
if (startValue && endValue) {
|
|
1099
|
-
cellLabel = `${startValue} ~ ${endValue}`
|
|
1100
|
-
}
|
|
1101
|
-
return getCellLabelVNs(renderOpts, params, cellLabel)
|
|
1102
|
-
}
|
|
1103
|
-
},
|
|
1104
|
-
VxeTextarea: {
|
|
1105
|
-
tableAutoFocus: 'textarea',
|
|
1106
|
-
renderTableEdit: defaultEditRender,
|
|
1107
|
-
renderTableCell (renderOpts, params) {
|
|
1108
|
-
const { row, column } = params
|
|
1109
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
1110
|
-
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
1111
|
-
}
|
|
1112
|
-
},
|
|
1113
|
-
VxeButton: {
|
|
1114
|
-
renderTableDefault: buttonCellRender
|
|
1115
|
-
},
|
|
1116
|
-
VxeButtonGroup: {
|
|
1117
|
-
renderTableDefault (renderOpts, params) {
|
|
1118
|
-
const { options } = renderOpts
|
|
1119
|
-
return [
|
|
1120
|
-
h(getDefaultComponent(renderOpts), {
|
|
1121
|
-
options,
|
|
1122
|
-
...getCellEditProps(renderOpts, params, null),
|
|
1123
|
-
...getComponentOns(renderOpts, params)
|
|
1124
|
-
})
|
|
1125
|
-
]
|
|
1126
|
-
}
|
|
1127
|
-
},
|
|
1128
|
-
VxeSelect: {
|
|
1129
|
-
tableAutoFocus: 'input',
|
|
1130
|
-
renderTableEdit: defaultSelectEditRender,
|
|
1131
|
-
renderTableDefault: defaultSelectEditRender,
|
|
1132
|
-
renderTableCell (renderOpts, params) {
|
|
1133
|
-
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1134
|
-
},
|
|
1135
|
-
createTableFilterOptions: defaultFilterOptions,
|
|
1136
|
-
renderTableFilter (renderOpts, params) {
|
|
1137
|
-
const { column } = params
|
|
1138
|
-
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
1139
|
-
return column.filters.map((option, oIndex) => {
|
|
1140
|
-
const optionValue = option.data
|
|
1141
|
-
return h(getDefaultComponent(renderOpts), {
|
|
1142
|
-
key: oIndex,
|
|
1143
|
-
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
1144
|
-
...getFilterOns(renderOpts, params, option)
|
|
1145
|
-
})
|
|
1146
|
-
})
|
|
1147
|
-
},
|
|
1148
|
-
renderTableFloatingFilter (renderOpts, params) {
|
|
1149
|
-
const { option } = params
|
|
1150
|
-
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
1151
|
-
const optionValue = option.data
|
|
1152
|
-
return h(getDefaultComponent(renderOpts), {
|
|
1153
|
-
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
1154
|
-
...getFloatingFilterOns(renderOpts, params, option)
|
|
1155
|
-
})
|
|
1156
|
-
},
|
|
1157
|
-
tableCellFormatter: handleFormatSelect,
|
|
1158
|
-
tableCellCopyMethod: handleFormatSelect,
|
|
1159
|
-
tableCellPasteMethod: handleSetSelectValue,
|
|
1160
|
-
tableFilterDefaultMethod: handleFilterMethod,
|
|
1161
|
-
tableExportMethod: handleExportSelectMethod
|
|
1162
|
-
},
|
|
1163
|
-
VxeText: {
|
|
1164
|
-
renderTableDefault (renderOpts, params) {
|
|
1165
|
-
const { $table, row, column } = params
|
|
1166
|
-
const { props } = renderOpts
|
|
1167
|
-
const cellLabel = $table.getCellLabel(row, column)
|
|
1168
|
-
return [
|
|
1169
|
-
h(getDefaultComponent(renderOpts), {
|
|
1170
|
-
...(props || {}),
|
|
1171
|
-
content: cellLabel,
|
|
1172
|
-
...getComponentOns(renderOpts, params)
|
|
1173
|
-
})
|
|
1174
|
-
]
|
|
1175
|
-
}
|
|
1176
|
-
},
|
|
1177
|
-
VxeLink: {
|
|
1178
|
-
renderTableDefault (renderOpts, params) {
|
|
1179
|
-
const { $table, row, column } = params
|
|
1180
|
-
const { props } = renderOpts
|
|
1181
|
-
const { href } = props || {}
|
|
1182
|
-
const cellLabel = $table.getCellLabel(row, column)
|
|
1183
|
-
return [
|
|
1184
|
-
h(getDefaultComponent(renderOpts), {
|
|
1185
|
-
...(props || {}),
|
|
1186
|
-
content: cellLabel,
|
|
1187
|
-
href: XEUtils.toFormatString(href, params),
|
|
1188
|
-
...getComponentOns(renderOpts, params)
|
|
1189
|
-
})
|
|
1190
|
-
]
|
|
1191
|
-
}
|
|
1192
|
-
},
|
|
1193
|
-
/**
|
|
1194
|
-
* 已废弃,被 FormatSelect 替换
|
|
1195
|
-
* @deprecated
|
|
1196
|
-
*/
|
|
1197
|
-
formatOption: {
|
|
1198
|
-
renderTableDefault (renderOpts, params) {
|
|
1199
|
-
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1200
|
-
}
|
|
1201
|
-
},
|
|
1202
|
-
FormatSelect: {
|
|
1203
|
-
renderTableDefault (renderOpts, params) {
|
|
1204
|
-
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1205
|
-
},
|
|
1206
|
-
tableCellFormatter: handleFormatSelect,
|
|
1207
|
-
tableCellCopyMethod: handleFormatSelect,
|
|
1208
|
-
tableCellPasteMethod: handleSetSelectValue,
|
|
1209
|
-
tableFilterDefaultMethod: handleFilterMethod,
|
|
1210
|
-
tableExportMethod: handleExportSelectMethod
|
|
1211
|
-
},
|
|
1212
|
-
VxeTreeSelect: {
|
|
1213
|
-
tableAutoFocus: 'input',
|
|
1214
|
-
renderTableEdit: defaultTableOrTreeSelectEditRender,
|
|
1215
|
-
renderTableCell (renderOpts, params) {
|
|
1216
|
-
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1217
|
-
},
|
|
1218
|
-
tableCellFormatter: handleFormatTreeSelect,
|
|
1219
|
-
tableCellCopyMethod: handleFormatTreeSelect,
|
|
1220
|
-
tableCellPasteMethod: handleSetTreeSelectValue,
|
|
1221
|
-
tableExportMethod: handleExportTreeSelectMethod
|
|
1222
|
-
},
|
|
1223
|
-
/**
|
|
1224
|
-
* 已废弃,被 FormatTreeSelect 替换
|
|
1225
|
-
* @deprecated
|
|
1226
|
-
*/
|
|
1227
|
-
formatTree: {
|
|
1228
|
-
renderTableDefault (renderOpts, params) {
|
|
1229
|
-
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1230
|
-
}
|
|
1231
|
-
},
|
|
1232
|
-
FormatTreeSelect: {
|
|
1233
|
-
renderTableDefault (renderOpts, params) {
|
|
1234
|
-
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1235
|
-
},
|
|
1236
|
-
tableCellFormatter: handleFormatTreeSelect,
|
|
1237
|
-
tableCellCopyMethod: handleFormatTreeSelect,
|
|
1238
|
-
tableCellPasteMethod: handleSetTreeSelectValue,
|
|
1239
|
-
tableExportMethod: handleExportTreeSelectMethod
|
|
1240
|
-
},
|
|
1241
|
-
VxeTableSelect: {
|
|
1242
|
-
tableAutoFocus: 'input',
|
|
1243
|
-
renderTableEdit: defaultTableOrTreeSelectEditRender,
|
|
1244
|
-
renderTableCell (renderOpts, params) {
|
|
1245
|
-
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1246
|
-
},
|
|
1247
|
-
tableCellFormatter: handleFormatTreeSelect,
|
|
1248
|
-
tableCellCopyMethod: handleFormatTreeSelect,
|
|
1249
|
-
tableCellPasteMethod: handleSetTreeSelectValue,
|
|
1250
|
-
tableExportMethod: handleExportTreeSelectMethod
|
|
1251
|
-
},
|
|
1252
|
-
VxeColorPicker: {
|
|
1253
|
-
tableAutoFocus: 'input',
|
|
1254
|
-
renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1255
|
-
const { row, column } = params
|
|
1256
|
-
const { options } = renderOpts
|
|
1257
|
-
const cellValue = getCellValue(row, column)
|
|
1258
|
-
return [
|
|
1259
|
-
h(getDefaultComponent(renderOpts), {
|
|
1260
|
-
...getCellEditProps(renderOpts, params, cellValue, { colors: options }),
|
|
1261
|
-
...getEditOns(renderOpts, params)
|
|
1262
|
-
})
|
|
1263
|
-
]
|
|
1264
|
-
},
|
|
1265
|
-
renderTableCell (renderOpts, params) {
|
|
1266
|
-
const { row, column } = params
|
|
1267
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
1268
|
-
return h('span', {
|
|
1269
|
-
class: 'vxe-color-picker--readonly'
|
|
1270
|
-
}, [
|
|
1271
|
-
h('div', {
|
|
1272
|
-
class: 'vxe-color-picker--readonly-color',
|
|
1273
|
-
style: {
|
|
1274
|
-
backgroundColor: cellValue
|
|
1275
|
-
}
|
|
1276
|
-
})
|
|
1277
|
-
])
|
|
1278
|
-
}
|
|
1279
|
-
},
|
|
1280
|
-
VxeIconPicker: {
|
|
1281
|
-
tableAutoFocus: 'input',
|
|
1282
|
-
renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1283
|
-
const { row, column } = params
|
|
1284
|
-
const { options } = renderOpts
|
|
1285
|
-
const cellValue = getCellValue(row, column)
|
|
1286
|
-
return [
|
|
1287
|
-
h(getDefaultComponent(renderOpts), {
|
|
1288
|
-
...getCellEditProps(renderOpts, params, cellValue, { icons: options }),
|
|
1289
|
-
...getEditOns(renderOpts, params)
|
|
1290
|
-
})
|
|
1291
|
-
]
|
|
1292
|
-
},
|
|
1293
|
-
renderTableCell (renderOpts, params) {
|
|
1294
|
-
const { row, column } = params
|
|
1295
|
-
const cellValue = XEUtils.get(row, column.field)
|
|
1296
|
-
return h('i', {
|
|
1297
|
-
class: cellValue
|
|
1298
|
-
})
|
|
1299
|
-
}
|
|
1300
|
-
},
|
|
1301
|
-
VxeRadioGroup: {
|
|
1302
|
-
renderTableDefault: radioAndCheckboxGroupEditRender
|
|
1303
|
-
},
|
|
1304
|
-
VxeCheckbox: {
|
|
1305
|
-
renderTableDefault: checkboxEditRender
|
|
1306
|
-
},
|
|
1307
|
-
VxeCheckboxGroup: {
|
|
1308
|
-
renderTableDefault: radioAndCheckboxGroupEditRender
|
|
1309
|
-
},
|
|
1310
|
-
VxeSwitch: {
|
|
1311
|
-
tableAutoFocus: 'button',
|
|
1312
|
-
renderTableEdit: defaultEditRender,
|
|
1313
|
-
renderTableDefault: defaultEditRender
|
|
1314
|
-
},
|
|
1315
|
-
VxeUpload: {
|
|
1316
|
-
renderTableEdit: defaultEditRender,
|
|
1317
|
-
renderTableCell: defaultEditRender,
|
|
1318
|
-
renderTableDefault: defaultEditRender
|
|
1319
|
-
},
|
|
1320
|
-
VxeImage: {
|
|
1321
|
-
renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1322
|
-
const { row, column } = params
|
|
1323
|
-
const { props } = renderOpts
|
|
1324
|
-
const cellValue = getCellValue(row, column)
|
|
1325
|
-
return [
|
|
1326
|
-
h(getDefaultComponent(renderOpts), {
|
|
1327
|
-
...props,
|
|
1328
|
-
src: cellValue,
|
|
1329
|
-
...getEditOns(renderOpts, params)
|
|
1330
|
-
})
|
|
1331
|
-
]
|
|
1332
|
-
}
|
|
1333
|
-
},
|
|
1334
|
-
VxeImageGroup: {
|
|
1335
|
-
renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1336
|
-
const { row, column } = params
|
|
1337
|
-
const { props } = renderOpts
|
|
1338
|
-
const cellValue = getCellValue(row, column)
|
|
1339
|
-
return [
|
|
1340
|
-
h(getDefaultComponent(renderOpts), {
|
|
1341
|
-
...props,
|
|
1342
|
-
urlList: cellValue,
|
|
1343
|
-
...getEditOns(renderOpts, params)
|
|
1344
|
-
})
|
|
1345
|
-
]
|
|
1346
|
-
}
|
|
1347
|
-
},
|
|
1348
|
-
VxeTextEllipsis: {
|
|
1349
|
-
renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1350
|
-
const { row, column } = params
|
|
1351
|
-
const { props } = renderOpts
|
|
1352
|
-
const cellValue = getCellValue(row, column)
|
|
1353
|
-
return [
|
|
1354
|
-
h(getDefaultComponent(renderOpts), {
|
|
1355
|
-
...props,
|
|
1356
|
-
content: cellValue,
|
|
1357
|
-
...getEditOns(renderOpts, params)
|
|
1358
|
-
})
|
|
1359
|
-
]
|
|
1360
|
-
}
|
|
1361
|
-
},
|
|
1362
|
-
VxeRate: {
|
|
1363
|
-
renderTableDefault: defaultEditRender
|
|
1364
|
-
},
|
|
1365
|
-
VxeSlider: {
|
|
1366
|
-
renderTableDefault: defaultEditRender
|
|
1367
|
-
},
|
|
1368
|
-
|
|
1369
|
-
// 以下已废弃
|
|
1370
|
-
$input: {
|
|
1371
|
-
tableAutoFocus: '.vxe-input--inner',
|
|
1372
|
-
renderTableEdit: oldEditRender,
|
|
1373
|
-
renderTableCell (renderOpts, params) {
|
|
1374
|
-
const { props = {} } = renderOpts
|
|
1375
|
-
const { row, column } = params
|
|
1376
|
-
const digits = props.digits || getConfig().input?.digits || 2
|
|
1377
|
-
let cellValue = XEUtils.get(row, column.field)
|
|
1378
|
-
if (cellValue) {
|
|
1379
|
-
switch (props.type) {
|
|
1380
|
-
case 'date':
|
|
1381
|
-
case 'week':
|
|
1382
|
-
case 'month':
|
|
1383
|
-
case 'year':
|
|
1384
|
-
cellValue = getLabelFormatDate(cellValue, props)
|
|
1385
|
-
break
|
|
1386
|
-
case 'float':
|
|
1387
|
-
cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
1388
|
-
break
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
1392
|
-
},
|
|
1393
|
-
renderTableDefault: oldEditRender,
|
|
1394
|
-
renderTableFilter: oldFilterRender,
|
|
1395
|
-
tableFilterDefaultMethod: handleInputFilterMethod
|
|
1396
|
-
},
|
|
1397
|
-
$textarea: {
|
|
1398
|
-
tableAutoFocus: '.vxe-textarea--inner'
|
|
1399
|
-
},
|
|
1400
|
-
$button: {
|
|
1401
|
-
renderTableDefault: oldButtonEditRender
|
|
1402
|
-
},
|
|
1403
|
-
$buttons: {
|
|
1404
|
-
renderTableDefault: oldButtonsEditRender
|
|
1405
|
-
},
|
|
1406
|
-
$select: {
|
|
1407
|
-
tableAutoFocus: '.vxe-input--inner',
|
|
1408
|
-
renderTableEdit: oldSelectEditRender,
|
|
1409
|
-
renderTableDefault: oldSelectEditRender,
|
|
1410
|
-
renderTableCell (renderOpts, params) {
|
|
1411
|
-
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1412
|
-
},
|
|
1413
|
-
renderTableFilter (renderOpts, params) {
|
|
1414
|
-
const { column } = params
|
|
1415
|
-
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
1416
|
-
return column.filters.map((option, oIndex) => {
|
|
1417
|
-
const optionValue = option.data
|
|
1418
|
-
return h(getOldComponent(renderOpts), {
|
|
1419
|
-
key: oIndex,
|
|
1420
|
-
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
1421
|
-
...getFilterOns(renderOpts, params, option)
|
|
1422
|
-
})
|
|
1423
|
-
})
|
|
1424
|
-
},
|
|
1425
|
-
tableFilterDefaultMethod: handleFilterMethod,
|
|
1426
|
-
tableExportMethod: handleExportSelectMethod
|
|
1427
|
-
},
|
|
1428
|
-
$radio: {
|
|
1429
|
-
tableAutoFocus: '.vxe-radio--input'
|
|
1430
|
-
},
|
|
1431
|
-
$checkbox: {
|
|
1432
|
-
tableAutoFocus: '.vxe-checkbox--input'
|
|
1433
|
-
},
|
|
1434
|
-
$switch: {
|
|
1435
|
-
tableAutoFocus: '.vxe-switch--button',
|
|
1436
|
-
renderTableEdit: oldEditRender,
|
|
1437
|
-
renderTableDefault: oldEditRender
|
|
1438
|
-
}
|
|
1439
|
-
// 以上已废弃
|
|
1440
|
-
})
|
|
1
|
+
import { h, resolveComponent, ComponentOptions } from 'vue'
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
import { VxeUI } from '../../ui'
|
|
4
|
+
import { getCellValue, setCellValue } from '../../table/src/util'
|
|
5
|
+
import { getFuncText, formatText, isEmptyValue } from '../../ui/src/utils'
|
|
6
|
+
import { getOnName, getModelEvent, getChangeEvent, hasInputType } from '../../ui/src/vn'
|
|
7
|
+
import { errLog } from '../../ui/src/log'
|
|
8
|
+
|
|
9
|
+
import type { VxeGlobalRendererHandles, VxeColumnPropTypes, VxeTableConstructor, VxeTablePrivateMethods, VxeTableDefines } from '../../../types'
|
|
10
|
+
|
|
11
|
+
const { getConfig, renderer, getI18n, getComponent } = VxeUI
|
|
12
|
+
|
|
13
|
+
const componentDefaultModelProp = 'modelValue'
|
|
14
|
+
|
|
15
|
+
const defaultCompProps = {}
|
|
16
|
+
|
|
17
|
+
function handleDefaultValue (value: any, defaultVal: any, initVal: any) {
|
|
18
|
+
return XEUtils.eqNull(value) ? (XEUtils.eqNull(defaultVal) ? initVal : defaultVal) : value
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function parseDate (value: any, props: any) {
|
|
22
|
+
return value && props.valueFormat ? XEUtils.toStringDate(value, props.valueFormat) : value
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getFormatDate (value: any, props: any, defaultFormat: string) {
|
|
26
|
+
const { dateConfig = {} } = props
|
|
27
|
+
return XEUtils.toDateString(parseDate(value, props), dateConfig.labelFormat || defaultFormat)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getLabelFormatDate (value: any, props: any) {
|
|
31
|
+
return getFormatDate(value, props, getI18n(`vxe.input.date.labelFormat.${props.type || 'date'}`))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 已废弃
|
|
36
|
+
* @deprecated
|
|
37
|
+
*/
|
|
38
|
+
function getOldComponentName (name: string) {
|
|
39
|
+
return `vxe-${name.replace('$', '')}`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getDefaultComponent ({ name }: any) {
|
|
43
|
+
return getComponent(name)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 已废弃
|
|
48
|
+
* @deprecated
|
|
49
|
+
*/
|
|
50
|
+
function getOldComponent ({ name }: any) {
|
|
51
|
+
return resolveComponent(getOldComponentName(name)) as ComponentOptions
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function updateFilterChangeOption (params: VxeGlobalRendererHandles.RenderTableFilterParams | VxeGlobalRendererHandles.RenderTableFloatingFilterParams, checked: boolean, option: VxeTableDefines.FilterOption) {
|
|
55
|
+
const { $table } = params
|
|
56
|
+
$table.updateFilterOptionStatus(option, checked)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function saveFilterEvent (params: VxeGlobalRendererHandles.RenderTableFilterParams | VxeGlobalRendererHandles.RenderTableFloatingFilterParams) {
|
|
60
|
+
const { $table, column } = params
|
|
61
|
+
$table.saveFilterByEvent(new Event('change'), column)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getNativeAttrs (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions) {
|
|
65
|
+
let { name, attrs } = renderOpts
|
|
66
|
+
if (name === 'input') {
|
|
67
|
+
attrs = Object.assign({ type: 'text' }, attrs)
|
|
68
|
+
}
|
|
69
|
+
return attrs
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getInputImmediateModel (renderOpts: VxeColumnPropTypes.EditRender) {
|
|
73
|
+
const { name, immediate, props } = renderOpts
|
|
74
|
+
if (!immediate) {
|
|
75
|
+
if (name === 'VxeInput' || name === '$input') {
|
|
76
|
+
const { type } = props || {}
|
|
77
|
+
return !(!type || type === 'text' || type === 'number' || type === 'integer' || type === 'float')
|
|
78
|
+
}
|
|
79
|
+
if (name === 'input' || name === 'textarea' || name === '$textarea') {
|
|
80
|
+
return false
|
|
81
|
+
}
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
return immediate
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getCellEditProps (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderEditParams, value: any, defaultProps?: any) {
|
|
88
|
+
return XEUtils.assign({ immediate: getInputImmediateModel(renderOpts) }, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value })
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getCellEditFilterProps (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any, value: any, defaultProps?: any) {
|
|
92
|
+
return XEUtils.assign({}, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value })
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isImmediateCell (renderOpts: VxeColumnPropTypes.EditRender, params: any) {
|
|
96
|
+
return params.$type === 'cell' || getInputImmediateModel(renderOpts)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getCellLabelVNs (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any, cellLabel: any, opts?: {
|
|
100
|
+
class?: string
|
|
101
|
+
}) {
|
|
102
|
+
const { placeholder } = renderOpts
|
|
103
|
+
return [
|
|
104
|
+
h('span', {
|
|
105
|
+
class: ['vxe-cell--label', opts ? opts.class : '']
|
|
106
|
+
}, placeholder && isEmptyValue(cellLabel)
|
|
107
|
+
? [
|
|
108
|
+
h('span', {
|
|
109
|
+
class: 'vxe-cell--placeholder'
|
|
110
|
+
}, formatText(getFuncText(placeholder), 1))
|
|
111
|
+
]
|
|
112
|
+
: formatText(cellLabel, 1))
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 原生事件处理
|
|
118
|
+
* @param renderOpts
|
|
119
|
+
* @param params
|
|
120
|
+
* @param modelFunc
|
|
121
|
+
* @param changeFunc
|
|
122
|
+
*/
|
|
123
|
+
function getNativeElementOns (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions | VxeGlobalRendererHandles.RenderTableFilterOptions, params: any, eFns?: {
|
|
124
|
+
model: (evnt: Event) => void
|
|
125
|
+
change?: (evnt: Event) => void
|
|
126
|
+
blur?: (evnt: Event) => void
|
|
127
|
+
}) {
|
|
128
|
+
const { events } = renderOpts
|
|
129
|
+
const modelEvent = getModelEvent(renderOpts)
|
|
130
|
+
const changeEvent = getChangeEvent(renderOpts)
|
|
131
|
+
const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {}
|
|
132
|
+
const isSameEvent = changeEvent === modelEvent
|
|
133
|
+
const ons: any = {}
|
|
134
|
+
if (events) {
|
|
135
|
+
XEUtils.objectEach(events, (func, key: any) => {
|
|
136
|
+
ons[getOnName(key)] = function (...args: any[]) {
|
|
137
|
+
func(params, ...args)
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
if (modelFunc) {
|
|
142
|
+
ons[getOnName(modelEvent)] = function (targetEvnt: any) {
|
|
143
|
+
modelFunc(targetEvnt)
|
|
144
|
+
if (isSameEvent && changeFunc) {
|
|
145
|
+
changeFunc(targetEvnt)
|
|
146
|
+
}
|
|
147
|
+
if (events && events[modelEvent]) {
|
|
148
|
+
events[modelEvent](params, targetEvnt)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!isSameEvent && changeFunc) {
|
|
153
|
+
ons[getOnName(changeEvent)] = function (evnt: Event) {
|
|
154
|
+
changeFunc(evnt)
|
|
155
|
+
if (events && events[changeEvent]) {
|
|
156
|
+
events[changeEvent](params, evnt)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (blurFunc) {
|
|
161
|
+
ons[getOnName(blurEvent)] = function (evnt: Event) {
|
|
162
|
+
blurFunc(evnt)
|
|
163
|
+
if (events && events[blurEvent]) {
|
|
164
|
+
events[blurEvent](params, evnt)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return ons
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const blurEvent = 'blur'
|
|
172
|
+
const clearEvent = 'clear'
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 组件事件处理
|
|
176
|
+
* @param renderOpts
|
|
177
|
+
* @param params
|
|
178
|
+
* @param modelFunc
|
|
179
|
+
* @param changeFunc
|
|
180
|
+
*/
|
|
181
|
+
function getComponentOns (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions | VxeGlobalRendererHandles.RenderTableFilterOptions, params: any, eFns?: {
|
|
182
|
+
model: (cellValue: any) => void
|
|
183
|
+
change?: (...args: any[]) => void
|
|
184
|
+
blur?: (...args: any[]) => void
|
|
185
|
+
clear?: (...args: any[]) => void
|
|
186
|
+
}, eventOns?: Record<string, any>) {
|
|
187
|
+
const { events } = renderOpts
|
|
188
|
+
const modelEvent = getModelEvent(renderOpts)
|
|
189
|
+
const changeEvent = getChangeEvent(renderOpts)
|
|
190
|
+
const { model: modelFunc, change: changeFunc, blur: blurFunc, clear: clearFunc } = eFns || {}
|
|
191
|
+
const ons: any = {}
|
|
192
|
+
XEUtils.objectEach(events, (func, key: any) => {
|
|
193
|
+
ons[getOnName(key)] = function (...args: any[]) {
|
|
194
|
+
if (!XEUtils.isFunction(func)) {
|
|
195
|
+
errLog('vxe.error.errFunc', [func])
|
|
196
|
+
}
|
|
197
|
+
func(params, ...args)
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
if (modelFunc) {
|
|
201
|
+
ons[getOnName(modelEvent)] = function (targetEvnt: any) {
|
|
202
|
+
modelFunc(targetEvnt)
|
|
203
|
+
if (events && events[modelEvent]) {
|
|
204
|
+
events[modelEvent](params, targetEvnt)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (changeFunc) {
|
|
209
|
+
ons[getOnName(changeEvent)] = function (...args: any[]) {
|
|
210
|
+
changeFunc(...args)
|
|
211
|
+
if (events && events[changeEvent]) {
|
|
212
|
+
events[changeEvent](params, ...args)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (blurFunc) {
|
|
217
|
+
ons[getOnName(blurEvent)] = function (...args: any[]) {
|
|
218
|
+
blurFunc(...args)
|
|
219
|
+
if (events && events[blurEvent]) {
|
|
220
|
+
events[blurEvent](params, ...args)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (clearFunc) {
|
|
225
|
+
ons[getOnName(clearEvent)] = function (...args: any[]) {
|
|
226
|
+
clearFunc(...args)
|
|
227
|
+
if (events && events[clearEvent]) {
|
|
228
|
+
events[clearEvent](params, ...args)
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return eventOns ? Object.assign(ons, eventOns) : ons
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function getEditOns (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
236
|
+
const { $table, row, column } = params
|
|
237
|
+
const { name } = renderOpts
|
|
238
|
+
const { model } = column
|
|
239
|
+
const isImmediate = isImmediateCell(renderOpts, params)
|
|
240
|
+
return getComponentOns(renderOpts, params, {
|
|
241
|
+
model (cellValue) {
|
|
242
|
+
// 处理 model 值双向绑定
|
|
243
|
+
model.update = true
|
|
244
|
+
model.value = cellValue
|
|
245
|
+
if (isImmediate) {
|
|
246
|
+
setCellValue(row, column, cellValue)
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
change (eventParams) {
|
|
250
|
+
// 处理 change 事件相关逻辑
|
|
251
|
+
if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
|
|
252
|
+
const cellValue = eventParams.value
|
|
253
|
+
model.update = true
|
|
254
|
+
model.value = cellValue
|
|
255
|
+
$table.updateStatus(params, cellValue)
|
|
256
|
+
} else {
|
|
257
|
+
$table.updateStatus(params)
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
blur () {
|
|
261
|
+
if (isImmediate) {
|
|
262
|
+
$table.handleCellRuleUpdateStatus('blur', params)
|
|
263
|
+
} else {
|
|
264
|
+
$table.handleCellRuleUpdateStatus('blur', params, model.value)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function getFilterOns (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFilterParams, option: VxeTableDefines.FilterOption) {
|
|
271
|
+
return getComponentOns(renderOpts, params, {
|
|
272
|
+
model (value: any) {
|
|
273
|
+
// 处理 model 值双向绑定
|
|
274
|
+
option.data = value
|
|
275
|
+
},
|
|
276
|
+
change () {
|
|
277
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
278
|
+
},
|
|
279
|
+
blur () {
|
|
280
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function getFloatingFilterOns (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFloatingFilterParams, option: VxeTableDefines.FilterOption) {
|
|
286
|
+
const { $table, column } = params
|
|
287
|
+
if (hasInputType(renderOpts)) {
|
|
288
|
+
return getComponentOns(renderOpts, params, {
|
|
289
|
+
model (value: any) {
|
|
290
|
+
// 处理 model 值双向绑定
|
|
291
|
+
option.data = value
|
|
292
|
+
},
|
|
293
|
+
change () {
|
|
294
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
295
|
+
},
|
|
296
|
+
clear () {
|
|
297
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
298
|
+
saveFilterEvent(params)
|
|
299
|
+
},
|
|
300
|
+
blur () {
|
|
301
|
+
$table.saveFilterByEvent(new Event('change'), column)
|
|
302
|
+
}
|
|
303
|
+
}, renderOpts.name === 'VxeNumberInput'
|
|
304
|
+
? {
|
|
305
|
+
[getOnName('plus-number')] () {
|
|
306
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
307
|
+
saveFilterEvent(params)
|
|
308
|
+
},
|
|
309
|
+
[getOnName('minus-number')] () {
|
|
310
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
311
|
+
saveFilterEvent(params)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
: {})
|
|
315
|
+
}
|
|
316
|
+
return getComponentOns(renderOpts, params, {
|
|
317
|
+
model (value: any) {
|
|
318
|
+
// 处理 model 值双向绑定
|
|
319
|
+
option.data = value
|
|
320
|
+
},
|
|
321
|
+
clear () {
|
|
322
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
323
|
+
$table.saveFilterByEvent(new Event('change'), column)
|
|
324
|
+
},
|
|
325
|
+
change () {
|
|
326
|
+
updateFilterChangeOption(params, !isEmptyValue(option.data), option)
|
|
327
|
+
$table.saveFilterByEvent(new Event('change'), column)
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function getNativeEditOns (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
333
|
+
const { $table, row, column } = params
|
|
334
|
+
const { model } = column
|
|
335
|
+
return getNativeElementOns(renderOpts, params, {
|
|
336
|
+
model (evnt) {
|
|
337
|
+
// 处理 model 值双向绑定
|
|
338
|
+
const targetEl = evnt.target as HTMLInputElement
|
|
339
|
+
if (targetEl) {
|
|
340
|
+
const cellValue = targetEl.value
|
|
341
|
+
if (isImmediateCell(renderOpts, params)) {
|
|
342
|
+
setCellValue(row, column, cellValue)
|
|
343
|
+
} else {
|
|
344
|
+
model.update = true
|
|
345
|
+
model.value = cellValue
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
change (evnt) {
|
|
350
|
+
// 处理 change 事件相关逻辑
|
|
351
|
+
const targetEl = evnt.target as HTMLInputElement
|
|
352
|
+
if (targetEl) {
|
|
353
|
+
const cellValue = targetEl.value
|
|
354
|
+
$table.updateStatus(params, cellValue)
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
blur (evnt) {
|
|
358
|
+
const targetEl = evnt.target as HTMLInputElement
|
|
359
|
+
if (targetEl) {
|
|
360
|
+
const cellValue = targetEl.value
|
|
361
|
+
$table.updateStatus(params, cellValue)
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
})
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function getNativeFilterOns (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: any, option: any) {
|
|
368
|
+
return getNativeElementOns(renderOpts, params, {
|
|
369
|
+
model (evnt) {
|
|
370
|
+
// 处理 model 值双向绑定
|
|
371
|
+
const targetEl = evnt.target as HTMLInputElement
|
|
372
|
+
if (targetEl) {
|
|
373
|
+
option.data = targetEl.value
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
change () {
|
|
377
|
+
updateFilterChangeOption(params, !XEUtils.eqNull(option.data), option)
|
|
378
|
+
},
|
|
379
|
+
blur () {
|
|
380
|
+
updateFilterChangeOption(params, !XEUtils.eqNull(option.data), option)
|
|
381
|
+
}
|
|
382
|
+
})
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* 单元格可编辑渲染-原生的标签
|
|
387
|
+
* input、textarea、select
|
|
388
|
+
*/
|
|
389
|
+
function nativeEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
390
|
+
const { row, column } = params
|
|
391
|
+
const { name } = renderOpts
|
|
392
|
+
const cellValue = isImmediateCell(renderOpts, params) ? getCellValue(row, column) : column.model.value
|
|
393
|
+
return [
|
|
394
|
+
h(`${name}`, {
|
|
395
|
+
class: `vxe-default-${name}`,
|
|
396
|
+
...getNativeAttrs(renderOpts),
|
|
397
|
+
value: cellValue,
|
|
398
|
+
...getNativeEditOns(renderOpts, params)
|
|
399
|
+
})
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function buttonCellRender (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions, params: any) {
|
|
404
|
+
return [
|
|
405
|
+
h(getDefaultComponent(renderOpts), {
|
|
406
|
+
...getCellEditProps(renderOpts, params, null),
|
|
407
|
+
...getComponentOns(renderOpts, params)
|
|
408
|
+
})
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function defaultEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
413
|
+
const { row, column } = params
|
|
414
|
+
const cellValue = getCellValue(row, column)
|
|
415
|
+
return [
|
|
416
|
+
h(getDefaultComponent(renderOpts), {
|
|
417
|
+
...getCellEditProps(renderOpts, params, cellValue),
|
|
418
|
+
...getEditOns(renderOpts, params)
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function checkboxEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
424
|
+
const { row, column } = params
|
|
425
|
+
const cellValue = getCellValue(row, column)
|
|
426
|
+
return [
|
|
427
|
+
h(getDefaultComponent(renderOpts), {
|
|
428
|
+
...getCellEditProps(renderOpts, params, cellValue),
|
|
429
|
+
...getEditOns(renderOpts, params)
|
|
430
|
+
})
|
|
431
|
+
]
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function radioAndCheckboxGroupEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
435
|
+
const { options } = renderOpts
|
|
436
|
+
const { row, column } = params
|
|
437
|
+
const cellValue = getCellValue(row, column)
|
|
438
|
+
return [
|
|
439
|
+
h(getDefaultComponent(renderOpts), {
|
|
440
|
+
options,
|
|
441
|
+
...getCellEditProps(renderOpts, params, cellValue),
|
|
442
|
+
...getEditOns(renderOpts, params)
|
|
443
|
+
})
|
|
444
|
+
]
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* 已废弃
|
|
449
|
+
* @deprecated
|
|
450
|
+
*/
|
|
451
|
+
function oldEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
452
|
+
const { row, column } = params
|
|
453
|
+
const cellValue = getCellValue(row, column)
|
|
454
|
+
return [
|
|
455
|
+
h(getOldComponent(renderOpts), {
|
|
456
|
+
...getCellEditProps(renderOpts, params, cellValue),
|
|
457
|
+
...getEditOns(renderOpts, params)
|
|
458
|
+
})
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* 已废弃
|
|
464
|
+
* @deprecated
|
|
465
|
+
*/
|
|
466
|
+
function oldButtonEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
467
|
+
return [
|
|
468
|
+
h(getComponent('vxe-button'), {
|
|
469
|
+
...getCellEditProps(renderOpts, params, null),
|
|
470
|
+
...getComponentOns(renderOpts, params)
|
|
471
|
+
})
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* 已废弃
|
|
477
|
+
* @deprecated
|
|
478
|
+
*/
|
|
479
|
+
function oldButtonsEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
480
|
+
const { children } = renderOpts
|
|
481
|
+
return children ? children.map((childRenderOpts: any) => oldButtonEditRender(childRenderOpts, params)[0]) : []
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function renderNativeOptgroups (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any, renderOptionsMethods: any) {
|
|
485
|
+
const { optionGroups, optionGroupProps = {} } = renderOpts
|
|
486
|
+
const groupOptions = optionGroupProps.options || 'options'
|
|
487
|
+
const groupLabel = optionGroupProps.label || 'label'
|
|
488
|
+
if (optionGroups) {
|
|
489
|
+
return optionGroups.map((group: any, gIndex: any) => {
|
|
490
|
+
return h('optgroup', {
|
|
491
|
+
key: gIndex,
|
|
492
|
+
label: group[groupLabel]
|
|
493
|
+
}, renderOptionsMethods(group[groupOptions], renderOpts, params))
|
|
494
|
+
})
|
|
495
|
+
}
|
|
496
|
+
return []
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* 渲染原生的 option 标签
|
|
501
|
+
*/
|
|
502
|
+
function renderNativeOptions (options: any, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
503
|
+
const { optionProps = {} } = renderOpts
|
|
504
|
+
const { row, column } = params
|
|
505
|
+
const labelProp = optionProps.label || 'label'
|
|
506
|
+
const valueProp = optionProps.value || 'value'
|
|
507
|
+
const disabledProp = optionProps.disabled || 'disabled'
|
|
508
|
+
const cellValue = isImmediateCell(renderOpts, params) ? getCellValue(row, column) : column.model.value
|
|
509
|
+
if (options) {
|
|
510
|
+
return options.map((option: any, oIndex: any) => {
|
|
511
|
+
return h('option', {
|
|
512
|
+
key: oIndex,
|
|
513
|
+
value: option[valueProp],
|
|
514
|
+
disabled: option[disabledProp],
|
|
515
|
+
/* eslint-disable eqeqeq */
|
|
516
|
+
selected: option[valueProp] == cellValue
|
|
517
|
+
}, option[labelProp])
|
|
518
|
+
})
|
|
519
|
+
}
|
|
520
|
+
return []
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function nativeFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFilterParams) {
|
|
524
|
+
const { column } = params
|
|
525
|
+
const { name } = renderOpts
|
|
526
|
+
const attrs = getNativeAttrs(renderOpts)
|
|
527
|
+
return column.filters.map((option, oIndex) => {
|
|
528
|
+
return h(`${name}`, {
|
|
529
|
+
key: oIndex,
|
|
530
|
+
class: `vxe-default-${name}`,
|
|
531
|
+
...attrs,
|
|
532
|
+
value: option.data,
|
|
533
|
+
...getNativeFilterOns(renderOpts, params, option)
|
|
534
|
+
})
|
|
535
|
+
})
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function defaultFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: VxeGlobalRendererHandles.RenderTableFilterParams) {
|
|
539
|
+
const { column } = params
|
|
540
|
+
return column.filters.map((option, oIndex) => {
|
|
541
|
+
const optionValue = option.data
|
|
542
|
+
return h(getDefaultComponent(renderOpts), {
|
|
543
|
+
key: oIndex,
|
|
544
|
+
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
|
|
545
|
+
...getFilterOns(renderOpts, params, option)
|
|
546
|
+
})
|
|
547
|
+
})
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function defaultFloatingFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFloatingFilterOptions, params: VxeGlobalRendererHandles.RenderTableFloatingFilterParams) {
|
|
551
|
+
const { option } = params
|
|
552
|
+
const optionValue = option.data
|
|
553
|
+
return [
|
|
554
|
+
h(getDefaultComponent(renderOpts), {
|
|
555
|
+
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
|
|
556
|
+
...getFloatingFilterOns(renderOpts, params, option)
|
|
557
|
+
})
|
|
558
|
+
]
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function defaultFilterOptions () {
|
|
562
|
+
return [
|
|
563
|
+
{ data: null }
|
|
564
|
+
]
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* 已废弃
|
|
569
|
+
* @deprecated
|
|
570
|
+
*/
|
|
571
|
+
function oldFilterRender (renderOpts: VxeGlobalRendererHandles.RenderTableFilterOptions, params: any) {
|
|
572
|
+
const { column } = params
|
|
573
|
+
return column.filters.map((option: any, oIndex: any) => {
|
|
574
|
+
const optionValue = option.data
|
|
575
|
+
return h(getOldComponent(renderOpts), {
|
|
576
|
+
key: oIndex,
|
|
577
|
+
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
|
|
578
|
+
...getFilterOns(renderOpts, params, option)
|
|
579
|
+
})
|
|
580
|
+
})
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function handleFilterMethod ({ option, row, column }: any) {
|
|
584
|
+
const { data } = option
|
|
585
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
586
|
+
/* eslint-disable eqeqeq */
|
|
587
|
+
return cellValue == data
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function handleInputFilterMethod ({ option, row, column }: any) {
|
|
591
|
+
const { data } = option
|
|
592
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
593
|
+
/* eslint-disable eqeqeq */
|
|
594
|
+
return XEUtils.toValueString(cellValue).indexOf(data) > -1
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function nativeSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
598
|
+
return [
|
|
599
|
+
h('select', {
|
|
600
|
+
class: 'vxe-default-select',
|
|
601
|
+
...getNativeAttrs(renderOpts),
|
|
602
|
+
...getNativeEditOns(renderOpts, params)
|
|
603
|
+
},
|
|
604
|
+
renderOpts.optionGroups ? renderNativeOptgroups(renderOpts, params, renderNativeOptions) : renderNativeOptions(renderOpts.options, renderOpts, params))
|
|
605
|
+
]
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function defaultSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
609
|
+
const { row, column } = params
|
|
610
|
+
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
611
|
+
const cellValue = getCellValue(row, column)
|
|
612
|
+
return [
|
|
613
|
+
h(getDefaultComponent(renderOpts), {
|
|
614
|
+
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
615
|
+
...getEditOns(renderOpts, params)
|
|
616
|
+
})
|
|
617
|
+
]
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function defaultTableOrTreeSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
621
|
+
const { row, column } = params
|
|
622
|
+
const { options, optionProps } = renderOpts
|
|
623
|
+
const cellValue = getCellValue(row, column)
|
|
624
|
+
return [
|
|
625
|
+
h(getDefaultComponent(renderOpts), {
|
|
626
|
+
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps }),
|
|
627
|
+
...getEditOns(renderOpts, params)
|
|
628
|
+
})
|
|
629
|
+
]
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* 已废弃
|
|
634
|
+
* @deprecated
|
|
635
|
+
*/
|
|
636
|
+
function oldSelectEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: any) {
|
|
637
|
+
const { row, column } = params
|
|
638
|
+
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
639
|
+
const cellValue = getCellValue(row, column)
|
|
640
|
+
return [
|
|
641
|
+
h(getOldComponent(renderOpts), {
|
|
642
|
+
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
643
|
+
...getEditOns(renderOpts, params)
|
|
644
|
+
})
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function handleSelectCellValue (cellValue: any, renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions) {
|
|
649
|
+
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props = {} } = renderOpts
|
|
650
|
+
let selectItem: any
|
|
651
|
+
const labelProp = optionProps.label || 'label'
|
|
652
|
+
const valueProp = optionProps.value || 'value'
|
|
653
|
+
if (!(cellValue === null || cellValue === undefined)) {
|
|
654
|
+
let vals = []
|
|
655
|
+
if (XEUtils.isArray(cellValue)) {
|
|
656
|
+
vals = cellValue
|
|
657
|
+
} else {
|
|
658
|
+
if (props.multiple && `${cellValue}`.indexOf(',') > -1) {
|
|
659
|
+
vals = `${cellValue}`.split(',')
|
|
660
|
+
} else {
|
|
661
|
+
vals = [cellValue]
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return XEUtils.map(vals, optionGroups
|
|
665
|
+
? (value) => {
|
|
666
|
+
const groupOptions = optionGroupProps.options || 'options'
|
|
667
|
+
for (let index = 0; index < optionGroups.length; index++) {
|
|
668
|
+
/* eslint-disable eqeqeq */
|
|
669
|
+
selectItem = XEUtils.find(optionGroups[index][groupOptions], item => item[valueProp] == value)
|
|
670
|
+
if (selectItem) {
|
|
671
|
+
break
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return selectItem ? selectItem[labelProp] : value
|
|
675
|
+
}
|
|
676
|
+
: (value) => {
|
|
677
|
+
/* eslint-disable eqeqeq */
|
|
678
|
+
selectItem = XEUtils.find(options, item => item[valueProp] == value)
|
|
679
|
+
return selectItem ? selectItem[labelProp] : value
|
|
680
|
+
}
|
|
681
|
+
).join(', ')
|
|
682
|
+
}
|
|
683
|
+
return ''
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function getSelectCellValue (renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions, { row, column }: any) {
|
|
687
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
688
|
+
return handleSelectCellValue(cellValue, renderOpts)
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
function handleExportSelectMethod (params: any) {
|
|
692
|
+
const { row, column, options } = params
|
|
693
|
+
return options.original ? getCellValue(row, column) : getSelectCellValue(column.editRender || column.cellRender, params)
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function handleTreeSelectCellValue (cellValue: any, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions) {
|
|
697
|
+
const { options, optionProps = {} } = renderOpts
|
|
698
|
+
const labelProp = optionProps.label || 'label'
|
|
699
|
+
const valueProp = optionProps.value || 'value'
|
|
700
|
+
const childrenProp = optionProps.children || 'children'
|
|
701
|
+
if (!(cellValue === null || cellValue === undefined)) {
|
|
702
|
+
const keyMaps: Record<string, any> = {}
|
|
703
|
+
XEUtils.eachTree(options, item => {
|
|
704
|
+
keyMaps[XEUtils.get(item, valueProp)] = item
|
|
705
|
+
}, { children: childrenProp })
|
|
706
|
+
return XEUtils.map(XEUtils.isArray(cellValue) ? cellValue : [cellValue], (value) => {
|
|
707
|
+
const item = keyMaps[value]
|
|
708
|
+
return item ? XEUtils.get(item, labelProp) : item
|
|
709
|
+
}
|
|
710
|
+
).join(', ')
|
|
711
|
+
}
|
|
712
|
+
return ''
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function getTreeSelectCellValue (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, { row, column }: any) {
|
|
716
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
717
|
+
return handleTreeSelectCellValue(cellValue, renderOpts)
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function handleExportTreeSelectMethod (params: any) {
|
|
721
|
+
const { row, column, options } = params
|
|
722
|
+
return options.original ? getCellValue(row, column) : getTreeSelectCellValue(column.editRender || column.cellRender, params)
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function handleNumberCell (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.RenderTableDefaultParams) {
|
|
726
|
+
const { props = {}, showNegativeStatus } = renderOpts
|
|
727
|
+
const { row, column } = params
|
|
728
|
+
const { type } = props
|
|
729
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
730
|
+
let isNegative = false
|
|
731
|
+
if (!isEmptyValue(cellValue)) {
|
|
732
|
+
const numberInputConfig = getConfig().numberInput || {}
|
|
733
|
+
if (type === 'float') {
|
|
734
|
+
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
735
|
+
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
|
|
736
|
+
cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
737
|
+
if (!autoFill) {
|
|
738
|
+
cellValue = XEUtils.toNumber(cellValue)
|
|
739
|
+
}
|
|
740
|
+
if (showNegativeStatus) {
|
|
741
|
+
if (cellValue < 0) {
|
|
742
|
+
isNegative = true
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
} else if (type === 'amount') {
|
|
746
|
+
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
747
|
+
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
|
|
748
|
+
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
|
|
749
|
+
cellValue = XEUtils.toNumber(cellValue)
|
|
750
|
+
if (showNegativeStatus) {
|
|
751
|
+
if (cellValue < 0) {
|
|
752
|
+
isNegative = true
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
cellValue = XEUtils.commafy(cellValue, { digits })
|
|
756
|
+
if (!autoFill) {
|
|
757
|
+
const [iStr, dStr] = cellValue.split('.')
|
|
758
|
+
if (dStr) {
|
|
759
|
+
const dRest = dStr.replace(/0+$/, '')
|
|
760
|
+
cellValue = dRest ? [iStr, '.', dRest].join('') : iStr
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (showCurrency) {
|
|
764
|
+
cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`
|
|
765
|
+
}
|
|
766
|
+
} else {
|
|
767
|
+
if (type === 'integer') {
|
|
768
|
+
cellValue = XEUtils.toInteger(cellValue)
|
|
769
|
+
}
|
|
770
|
+
if (showNegativeStatus) {
|
|
771
|
+
if (XEUtils.toNumber(cellValue) < 0) {
|
|
772
|
+
isNegative = true
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return getCellLabelVNs(renderOpts, params, cellValue, isNegative
|
|
778
|
+
? {
|
|
779
|
+
class: 'is--negative'
|
|
780
|
+
}
|
|
781
|
+
: {})
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function handleFormatDatePicker (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams) {
|
|
785
|
+
const { props = {} } = renderOpts
|
|
786
|
+
const { cellValue } = params
|
|
787
|
+
if (cellValue) {
|
|
788
|
+
if (props.type !== 'time') {
|
|
789
|
+
return getLabelFormatDate(cellValue, props)
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return cellValue
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function handleFormatSelect (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
796
|
+
const { cellValue } = params
|
|
797
|
+
return handleSelectCellValue(cellValue, renderOpts)
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function handleSetSelectValue (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
801
|
+
const { row, column, cellValue } = params
|
|
802
|
+
const { field } = column
|
|
803
|
+
if (field) {
|
|
804
|
+
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props } = renderOpts
|
|
805
|
+
if (isEmptyValue(cellValue)) {
|
|
806
|
+
XEUtils.set(row, field, props && props.multiple ? [] : null)
|
|
807
|
+
return
|
|
808
|
+
}
|
|
809
|
+
const isMultiVal = XEUtils.indexOf(`${cellValue}`, ',') > -1
|
|
810
|
+
const labelProp = optionProps.label || 'label'
|
|
811
|
+
const valueProp = optionProps.value || 'value'
|
|
812
|
+
const labelMpas: Record<string, any> = {}
|
|
813
|
+
if (optionGroups && optionGroups.length) {
|
|
814
|
+
const groupOptions = optionGroupProps.options || 'options'
|
|
815
|
+
for (let i = 0; i < optionGroups.length; i++) {
|
|
816
|
+
const opts = optionGroups[i][groupOptions] || {}
|
|
817
|
+
for (let j = 0; j < opts.length; j++) {
|
|
818
|
+
const item = opts[j]
|
|
819
|
+
if (isMultiVal) {
|
|
820
|
+
labelMpas[item[labelProp]] = item
|
|
821
|
+
/* eslint-disable eqeqeq */
|
|
822
|
+
} else if (item[labelProp] == cellValue) {
|
|
823
|
+
XEUtils.set(row, field, item[valueProp])
|
|
824
|
+
return
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
} else {
|
|
829
|
+
if (options) {
|
|
830
|
+
for (let i = 0; i < options.length; i++) {
|
|
831
|
+
const item = options[i]
|
|
832
|
+
if (isMultiVal) {
|
|
833
|
+
labelMpas[item[labelProp]] = item
|
|
834
|
+
/* eslint-disable eqeqeq */
|
|
835
|
+
} else if (item[labelProp] == cellValue) {
|
|
836
|
+
XEUtils.set(row, field, item[valueProp])
|
|
837
|
+
return
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (isMultiVal) {
|
|
843
|
+
XEUtils.set(row, field, (isMultiVal
|
|
844
|
+
? cellValue.split(',')
|
|
845
|
+
: [cellValue]).map((label: any) => {
|
|
846
|
+
const item = labelMpas[label]
|
|
847
|
+
return item ? item[valueProp] : label
|
|
848
|
+
}))
|
|
849
|
+
} else {
|
|
850
|
+
XEUtils.set(row, field, cellValue)
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
function handleFormatTreeSelect (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
856
|
+
const { cellValue } = params
|
|
857
|
+
return handleTreeSelectCellValue(cellValue, renderOpts)
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function handleSetTreeSelectValue (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
861
|
+
const { row, column, cellValue } = params
|
|
862
|
+
const { field } = column
|
|
863
|
+
if (field) {
|
|
864
|
+
const { options, optionProps = {} } = renderOpts
|
|
865
|
+
const labelProp = optionProps.label || 'label'
|
|
866
|
+
const valueProp = optionProps.value || 'value'
|
|
867
|
+
const childrenProp = optionProps.children || 'children'
|
|
868
|
+
const matchRest = XEUtils.findTree(options || [], item => XEUtils.get(item, labelProp) === cellValue, { children: childrenProp })
|
|
869
|
+
if (matchRest) {
|
|
870
|
+
const selectItem = matchRest.item
|
|
871
|
+
if (selectItem) {
|
|
872
|
+
XEUtils.set(row, field, selectItem[valueProp])
|
|
873
|
+
return
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
XEUtils.set(row, field, cellValue)
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* 表格 - 渲染器
|
|
882
|
+
*/
|
|
883
|
+
renderer.mixin({
|
|
884
|
+
input: {
|
|
885
|
+
tableAutoFocus: 'input',
|
|
886
|
+
renderTableEdit: nativeEditRender,
|
|
887
|
+
renderTableDefault: nativeEditRender,
|
|
888
|
+
createTableFilterOptions: defaultFilterOptions,
|
|
889
|
+
renderTableFilter: nativeFilterRender,
|
|
890
|
+
tableFilterDefaultMethod: handleInputFilterMethod
|
|
891
|
+
},
|
|
892
|
+
textarea: {
|
|
893
|
+
tableAutoFocus: 'textarea',
|
|
894
|
+
renderTableEdit: nativeEditRender
|
|
895
|
+
},
|
|
896
|
+
select: {
|
|
897
|
+
renderTableEdit: nativeSelectEditRender,
|
|
898
|
+
renderTableDefault: nativeSelectEditRender,
|
|
899
|
+
renderTableCell (renderOpts, params) {
|
|
900
|
+
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
901
|
+
},
|
|
902
|
+
createTableFilterOptions: defaultFilterOptions,
|
|
903
|
+
renderTableFilter (renderOpts, params) {
|
|
904
|
+
const { column } = params
|
|
905
|
+
return column.filters.map((option, oIndex) => {
|
|
906
|
+
return h('select', {
|
|
907
|
+
key: oIndex,
|
|
908
|
+
class: 'vxe-default-select',
|
|
909
|
+
...getNativeAttrs(renderOpts),
|
|
910
|
+
...getNativeFilterOns(renderOpts, params, option)
|
|
911
|
+
},
|
|
912
|
+
renderOpts.optionGroups ? renderNativeOptgroups(renderOpts, params, renderNativeOptions) : renderNativeOptions(renderOpts.options, renderOpts, params))
|
|
913
|
+
})
|
|
914
|
+
},
|
|
915
|
+
tableCellFormatter: handleFormatSelect,
|
|
916
|
+
tableCellCopyMethod: handleFormatSelect,
|
|
917
|
+
tableCellPasteMethod: handleSetSelectValue,
|
|
918
|
+
tableFilterDefaultMethod: handleFilterMethod,
|
|
919
|
+
tableExportMethod: handleExportSelectMethod
|
|
920
|
+
},
|
|
921
|
+
VxeInput: {
|
|
922
|
+
tableAutoFocus: 'input',
|
|
923
|
+
renderTableEdit: defaultEditRender,
|
|
924
|
+
renderTableCell (renderOpts, params) {
|
|
925
|
+
const { props = {} } = renderOpts
|
|
926
|
+
const { row, column } = params
|
|
927
|
+
const inputConfig = getConfig().input || {}
|
|
928
|
+
const digits = props.digits || inputConfig.digits || 2
|
|
929
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
930
|
+
if (cellValue) {
|
|
931
|
+
switch (props.type) {
|
|
932
|
+
case 'date':
|
|
933
|
+
case 'week':
|
|
934
|
+
case 'month':
|
|
935
|
+
case 'quarter':
|
|
936
|
+
case 'year':
|
|
937
|
+
cellValue = getLabelFormatDate(cellValue, props)
|
|
938
|
+
break
|
|
939
|
+
case 'float':
|
|
940
|
+
cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
941
|
+
break
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
945
|
+
},
|
|
946
|
+
renderTableDefault: defaultEditRender,
|
|
947
|
+
createTableFilterOptions: defaultFilterOptions,
|
|
948
|
+
renderTableFilter: defaultFilterRender,
|
|
949
|
+
renderTableFloatingFilter: defaultFloatingFilterRender,
|
|
950
|
+
tableFilterDefaultMethod: handleInputFilterMethod
|
|
951
|
+
},
|
|
952
|
+
FormatNumberInput: {
|
|
953
|
+
renderTableDefault: handleNumberCell,
|
|
954
|
+
tableFilterDefaultMethod: handleInputFilterMethod,
|
|
955
|
+
tableExportMethod (params) {
|
|
956
|
+
const { row, column } = params
|
|
957
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
958
|
+
return cellValue
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
VxeNumberInput: {
|
|
962
|
+
tableAutoFocus: 'input',
|
|
963
|
+
renderTableEdit: defaultEditRender,
|
|
964
|
+
renderTableCell: handleNumberCell,
|
|
965
|
+
renderTableFooter (renderOpts, params) {
|
|
966
|
+
const { props = {} } = renderOpts
|
|
967
|
+
const { row, column, _columnIndex } = params
|
|
968
|
+
const { type } = props
|
|
969
|
+
// 兼容老模式
|
|
970
|
+
const itemValue = XEUtils.isArray(row) ? row[_columnIndex] : XEUtils.get(row, column.field)
|
|
971
|
+
if (XEUtils.isNumber(itemValue)) {
|
|
972
|
+
const numberInputConfig = getConfig().numberInput || {}
|
|
973
|
+
if (type === 'float') {
|
|
974
|
+
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
975
|
+
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
|
|
976
|
+
let amountLabel = XEUtils.toFixed(XEUtils.floor(itemValue, digits), digits)
|
|
977
|
+
if (!autoFill) {
|
|
978
|
+
amountLabel = XEUtils.toNumber(amountLabel)
|
|
979
|
+
}
|
|
980
|
+
return amountLabel
|
|
981
|
+
} else if (type === 'amount') {
|
|
982
|
+
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
|
|
983
|
+
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
|
|
984
|
+
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
|
|
985
|
+
let amountLabel = XEUtils.commafy(XEUtils.toNumber(itemValue), { digits })
|
|
986
|
+
if (!autoFill) {
|
|
987
|
+
const [iStr, dStr] = amountLabel.split('.')
|
|
988
|
+
if (dStr) {
|
|
989
|
+
const dRest = dStr.replace(/0+$/, '')
|
|
990
|
+
amountLabel = dRest ? [iStr, '.', dRest].join('') : iStr
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
if (showCurrency) {
|
|
994
|
+
amountLabel = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${amountLabel}`
|
|
995
|
+
}
|
|
996
|
+
return amountLabel
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return getFuncText(itemValue, 1)
|
|
1000
|
+
},
|
|
1001
|
+
renderTableDefault: defaultEditRender,
|
|
1002
|
+
createTableFilterOptions: defaultFilterOptions,
|
|
1003
|
+
renderTableFilter: defaultFilterRender,
|
|
1004
|
+
renderTableFloatingFilter: defaultFloatingFilterRender,
|
|
1005
|
+
tableFilterDefaultMethod: handleInputFilterMethod,
|
|
1006
|
+
tableExportMethod (params) {
|
|
1007
|
+
const { row, column } = params
|
|
1008
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
1009
|
+
return cellValue
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
VxeDatePicker: {
|
|
1013
|
+
tableAutoFocus: 'input',
|
|
1014
|
+
renderTableEdit: defaultEditRender,
|
|
1015
|
+
renderTableCell (renderOpts, params) {
|
|
1016
|
+
const { props = {} } = renderOpts
|
|
1017
|
+
const { row, column } = params
|
|
1018
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
1019
|
+
if (cellValue) {
|
|
1020
|
+
if (props.type !== 'time') {
|
|
1021
|
+
cellValue = getLabelFormatDate(cellValue, props)
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
1026
|
+
},
|
|
1027
|
+
tableCellFormatter: handleFormatDatePicker,
|
|
1028
|
+
renderTableDefault: defaultEditRender,
|
|
1029
|
+
createTableFilterOptions: defaultFilterOptions,
|
|
1030
|
+
renderTableFilter: defaultFilterRender,
|
|
1031
|
+
renderTableFloatingFilter: defaultFloatingFilterRender,
|
|
1032
|
+
tableFilterDefaultMethod: handleFilterMethod
|
|
1033
|
+
},
|
|
1034
|
+
VxeDateRangePicker: {
|
|
1035
|
+
tableAutoFocus: 'input',
|
|
1036
|
+
renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1037
|
+
const { startField, endField } = renderOpts
|
|
1038
|
+
const { $table, row, column } = params
|
|
1039
|
+
const { model } = column
|
|
1040
|
+
const cellValue = getCellValue(row, column)
|
|
1041
|
+
const seProps: Record<string, any> = {}
|
|
1042
|
+
const seOs: Record<string, any> = {}
|
|
1043
|
+
if (startField && endField) {
|
|
1044
|
+
seProps.startValue = XEUtils.get(row, startField)
|
|
1045
|
+
seProps.endValue = XEUtils.get(row, endField)
|
|
1046
|
+
seOs['onUpdate:startValue'] = (value: any) => {
|
|
1047
|
+
if (startField) {
|
|
1048
|
+
XEUtils.set(row, startField, value)
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
seOs['onUpdate:endValue'] = (value: any) => {
|
|
1052
|
+
if (endField) {
|
|
1053
|
+
XEUtils.set(row, endField, value)
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
return [
|
|
1058
|
+
h(getDefaultComponent(renderOpts), {
|
|
1059
|
+
...getCellEditProps(renderOpts, params, cellValue, seProps),
|
|
1060
|
+
...getComponentOns(renderOpts, params, {
|
|
1061
|
+
model (cellValue) {
|
|
1062
|
+
model.update = true
|
|
1063
|
+
model.value = cellValue
|
|
1064
|
+
setCellValue(row, column, cellValue)
|
|
1065
|
+
},
|
|
1066
|
+
change () {
|
|
1067
|
+
$table.updateStatus(params)
|
|
1068
|
+
},
|
|
1069
|
+
blur () {
|
|
1070
|
+
$table.handleCellRuleUpdateStatus('blur', params)
|
|
1071
|
+
}
|
|
1072
|
+
}, seOs)
|
|
1073
|
+
})
|
|
1074
|
+
]
|
|
1075
|
+
},
|
|
1076
|
+
renderTableCell (renderOpts, params) {
|
|
1077
|
+
const { startField, endField } = renderOpts
|
|
1078
|
+
const { row, column } = params
|
|
1079
|
+
let startValue = ''
|
|
1080
|
+
let endValue = ''
|
|
1081
|
+
if (startField && endField) {
|
|
1082
|
+
startValue = XEUtils.get(row, startField)
|
|
1083
|
+
endValue = XEUtils.get(row, endField)
|
|
1084
|
+
} else {
|
|
1085
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
1086
|
+
if (cellValue) {
|
|
1087
|
+
if (XEUtils.isArray(cellValue)) {
|
|
1088
|
+
startValue = cellValue[0]
|
|
1089
|
+
endValue = cellValue[1]
|
|
1090
|
+
} else {
|
|
1091
|
+
const strs = `${cellValue}`.split(',')
|
|
1092
|
+
startValue = strs[0]
|
|
1093
|
+
endValue = strs[1]
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
let cellLabel = ''
|
|
1098
|
+
if (startValue && endValue) {
|
|
1099
|
+
cellLabel = `${startValue} ~ ${endValue}`
|
|
1100
|
+
}
|
|
1101
|
+
return getCellLabelVNs(renderOpts, params, cellLabel)
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
VxeTextarea: {
|
|
1105
|
+
tableAutoFocus: 'textarea',
|
|
1106
|
+
renderTableEdit: defaultEditRender,
|
|
1107
|
+
renderTableCell (renderOpts, params) {
|
|
1108
|
+
const { row, column } = params
|
|
1109
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
1110
|
+
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
VxeButton: {
|
|
1114
|
+
renderTableDefault: buttonCellRender
|
|
1115
|
+
},
|
|
1116
|
+
VxeButtonGroup: {
|
|
1117
|
+
renderTableDefault (renderOpts, params) {
|
|
1118
|
+
const { options } = renderOpts
|
|
1119
|
+
return [
|
|
1120
|
+
h(getDefaultComponent(renderOpts), {
|
|
1121
|
+
options,
|
|
1122
|
+
...getCellEditProps(renderOpts, params, null),
|
|
1123
|
+
...getComponentOns(renderOpts, params)
|
|
1124
|
+
})
|
|
1125
|
+
]
|
|
1126
|
+
}
|
|
1127
|
+
},
|
|
1128
|
+
VxeSelect: {
|
|
1129
|
+
tableAutoFocus: 'input',
|
|
1130
|
+
renderTableEdit: defaultSelectEditRender,
|
|
1131
|
+
renderTableDefault: defaultSelectEditRender,
|
|
1132
|
+
renderTableCell (renderOpts, params) {
|
|
1133
|
+
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1134
|
+
},
|
|
1135
|
+
createTableFilterOptions: defaultFilterOptions,
|
|
1136
|
+
renderTableFilter (renderOpts, params) {
|
|
1137
|
+
const { column } = params
|
|
1138
|
+
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
1139
|
+
return column.filters.map((option, oIndex) => {
|
|
1140
|
+
const optionValue = option.data
|
|
1141
|
+
return h(getDefaultComponent(renderOpts), {
|
|
1142
|
+
key: oIndex,
|
|
1143
|
+
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
1144
|
+
...getFilterOns(renderOpts, params, option)
|
|
1145
|
+
})
|
|
1146
|
+
})
|
|
1147
|
+
},
|
|
1148
|
+
renderTableFloatingFilter (renderOpts, params) {
|
|
1149
|
+
const { option } = params
|
|
1150
|
+
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
1151
|
+
const optionValue = option.data
|
|
1152
|
+
return h(getDefaultComponent(renderOpts), {
|
|
1153
|
+
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
1154
|
+
...getFloatingFilterOns(renderOpts, params, option)
|
|
1155
|
+
})
|
|
1156
|
+
},
|
|
1157
|
+
tableCellFormatter: handleFormatSelect,
|
|
1158
|
+
tableCellCopyMethod: handleFormatSelect,
|
|
1159
|
+
tableCellPasteMethod: handleSetSelectValue,
|
|
1160
|
+
tableFilterDefaultMethod: handleFilterMethod,
|
|
1161
|
+
tableExportMethod: handleExportSelectMethod
|
|
1162
|
+
},
|
|
1163
|
+
VxeText: {
|
|
1164
|
+
renderTableDefault (renderOpts, params) {
|
|
1165
|
+
const { $table, row, column } = params
|
|
1166
|
+
const { props } = renderOpts
|
|
1167
|
+
const cellLabel = $table.getCellLabel(row, column)
|
|
1168
|
+
return [
|
|
1169
|
+
h(getDefaultComponent(renderOpts), {
|
|
1170
|
+
...(props || {}),
|
|
1171
|
+
content: cellLabel,
|
|
1172
|
+
...getComponentOns(renderOpts, params)
|
|
1173
|
+
})
|
|
1174
|
+
]
|
|
1175
|
+
}
|
|
1176
|
+
},
|
|
1177
|
+
VxeLink: {
|
|
1178
|
+
renderTableDefault (renderOpts, params) {
|
|
1179
|
+
const { $table, row, column } = params
|
|
1180
|
+
const { props } = renderOpts
|
|
1181
|
+
const { href } = props || {}
|
|
1182
|
+
const cellLabel = $table.getCellLabel(row, column)
|
|
1183
|
+
return [
|
|
1184
|
+
h(getDefaultComponent(renderOpts), {
|
|
1185
|
+
...(props || {}),
|
|
1186
|
+
content: cellLabel,
|
|
1187
|
+
href: XEUtils.toFormatString(href, params),
|
|
1188
|
+
...getComponentOns(renderOpts, params)
|
|
1189
|
+
})
|
|
1190
|
+
]
|
|
1191
|
+
}
|
|
1192
|
+
},
|
|
1193
|
+
/**
|
|
1194
|
+
* 已废弃,被 FormatSelect 替换
|
|
1195
|
+
* @deprecated
|
|
1196
|
+
*/
|
|
1197
|
+
formatOption: {
|
|
1198
|
+
renderTableDefault (renderOpts, params) {
|
|
1199
|
+
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
FormatSelect: {
|
|
1203
|
+
renderTableDefault (renderOpts, params) {
|
|
1204
|
+
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1205
|
+
},
|
|
1206
|
+
tableCellFormatter: handleFormatSelect,
|
|
1207
|
+
tableCellCopyMethod: handleFormatSelect,
|
|
1208
|
+
tableCellPasteMethod: handleSetSelectValue,
|
|
1209
|
+
tableFilterDefaultMethod: handleFilterMethod,
|
|
1210
|
+
tableExportMethod: handleExportSelectMethod
|
|
1211
|
+
},
|
|
1212
|
+
VxeTreeSelect: {
|
|
1213
|
+
tableAutoFocus: 'input',
|
|
1214
|
+
renderTableEdit: defaultTableOrTreeSelectEditRender,
|
|
1215
|
+
renderTableCell (renderOpts, params) {
|
|
1216
|
+
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1217
|
+
},
|
|
1218
|
+
tableCellFormatter: handleFormatTreeSelect,
|
|
1219
|
+
tableCellCopyMethod: handleFormatTreeSelect,
|
|
1220
|
+
tableCellPasteMethod: handleSetTreeSelectValue,
|
|
1221
|
+
tableExportMethod: handleExportTreeSelectMethod
|
|
1222
|
+
},
|
|
1223
|
+
/**
|
|
1224
|
+
* 已废弃,被 FormatTreeSelect 替换
|
|
1225
|
+
* @deprecated
|
|
1226
|
+
*/
|
|
1227
|
+
formatTree: {
|
|
1228
|
+
renderTableDefault (renderOpts, params) {
|
|
1229
|
+
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
FormatTreeSelect: {
|
|
1233
|
+
renderTableDefault (renderOpts, params) {
|
|
1234
|
+
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1235
|
+
},
|
|
1236
|
+
tableCellFormatter: handleFormatTreeSelect,
|
|
1237
|
+
tableCellCopyMethod: handleFormatTreeSelect,
|
|
1238
|
+
tableCellPasteMethod: handleSetTreeSelectValue,
|
|
1239
|
+
tableExportMethod: handleExportTreeSelectMethod
|
|
1240
|
+
},
|
|
1241
|
+
VxeTableSelect: {
|
|
1242
|
+
tableAutoFocus: 'input',
|
|
1243
|
+
renderTableEdit: defaultTableOrTreeSelectEditRender,
|
|
1244
|
+
renderTableCell (renderOpts, params) {
|
|
1245
|
+
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
1246
|
+
},
|
|
1247
|
+
tableCellFormatter: handleFormatTreeSelect,
|
|
1248
|
+
tableCellCopyMethod: handleFormatTreeSelect,
|
|
1249
|
+
tableCellPasteMethod: handleSetTreeSelectValue,
|
|
1250
|
+
tableExportMethod: handleExportTreeSelectMethod
|
|
1251
|
+
},
|
|
1252
|
+
VxeColorPicker: {
|
|
1253
|
+
tableAutoFocus: 'input',
|
|
1254
|
+
renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1255
|
+
const { row, column } = params
|
|
1256
|
+
const { options } = renderOpts
|
|
1257
|
+
const cellValue = getCellValue(row, column)
|
|
1258
|
+
return [
|
|
1259
|
+
h(getDefaultComponent(renderOpts), {
|
|
1260
|
+
...getCellEditProps(renderOpts, params, cellValue, { colors: options }),
|
|
1261
|
+
...getEditOns(renderOpts, params)
|
|
1262
|
+
})
|
|
1263
|
+
]
|
|
1264
|
+
},
|
|
1265
|
+
renderTableCell (renderOpts, params) {
|
|
1266
|
+
const { row, column } = params
|
|
1267
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
1268
|
+
return h('span', {
|
|
1269
|
+
class: 'vxe-color-picker--readonly'
|
|
1270
|
+
}, [
|
|
1271
|
+
h('div', {
|
|
1272
|
+
class: 'vxe-color-picker--readonly-color',
|
|
1273
|
+
style: {
|
|
1274
|
+
backgroundColor: cellValue
|
|
1275
|
+
}
|
|
1276
|
+
})
|
|
1277
|
+
])
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
VxeIconPicker: {
|
|
1281
|
+
tableAutoFocus: 'input',
|
|
1282
|
+
renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1283
|
+
const { row, column } = params
|
|
1284
|
+
const { options } = renderOpts
|
|
1285
|
+
const cellValue = getCellValue(row, column)
|
|
1286
|
+
return [
|
|
1287
|
+
h(getDefaultComponent(renderOpts), {
|
|
1288
|
+
...getCellEditProps(renderOpts, params, cellValue, { icons: options }),
|
|
1289
|
+
...getEditOns(renderOpts, params)
|
|
1290
|
+
})
|
|
1291
|
+
]
|
|
1292
|
+
},
|
|
1293
|
+
renderTableCell (renderOpts, params) {
|
|
1294
|
+
const { row, column } = params
|
|
1295
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
1296
|
+
return h('i', {
|
|
1297
|
+
class: cellValue
|
|
1298
|
+
})
|
|
1299
|
+
}
|
|
1300
|
+
},
|
|
1301
|
+
VxeRadioGroup: {
|
|
1302
|
+
renderTableDefault: radioAndCheckboxGroupEditRender
|
|
1303
|
+
},
|
|
1304
|
+
VxeCheckbox: {
|
|
1305
|
+
renderTableDefault: checkboxEditRender
|
|
1306
|
+
},
|
|
1307
|
+
VxeCheckboxGroup: {
|
|
1308
|
+
renderTableDefault: radioAndCheckboxGroupEditRender
|
|
1309
|
+
},
|
|
1310
|
+
VxeSwitch: {
|
|
1311
|
+
tableAutoFocus: 'button',
|
|
1312
|
+
renderTableEdit: defaultEditRender,
|
|
1313
|
+
renderTableDefault: defaultEditRender
|
|
1314
|
+
},
|
|
1315
|
+
VxeUpload: {
|
|
1316
|
+
renderTableEdit: defaultEditRender,
|
|
1317
|
+
renderTableCell: defaultEditRender,
|
|
1318
|
+
renderTableDefault: defaultEditRender
|
|
1319
|
+
},
|
|
1320
|
+
VxeImage: {
|
|
1321
|
+
renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1322
|
+
const { row, column } = params
|
|
1323
|
+
const { props } = renderOpts
|
|
1324
|
+
const cellValue = getCellValue(row, column)
|
|
1325
|
+
return [
|
|
1326
|
+
h(getDefaultComponent(renderOpts), {
|
|
1327
|
+
...props,
|
|
1328
|
+
src: cellValue,
|
|
1329
|
+
...getEditOns(renderOpts, params)
|
|
1330
|
+
})
|
|
1331
|
+
]
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1334
|
+
VxeImageGroup: {
|
|
1335
|
+
renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1336
|
+
const { row, column } = params
|
|
1337
|
+
const { props } = renderOpts
|
|
1338
|
+
const cellValue = getCellValue(row, column)
|
|
1339
|
+
return [
|
|
1340
|
+
h(getDefaultComponent(renderOpts), {
|
|
1341
|
+
...props,
|
|
1342
|
+
urlList: cellValue,
|
|
1343
|
+
...getEditOns(renderOpts, params)
|
|
1344
|
+
})
|
|
1345
|
+
]
|
|
1346
|
+
}
|
|
1347
|
+
},
|
|
1348
|
+
VxeTextEllipsis: {
|
|
1349
|
+
renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
1350
|
+
const { row, column } = params
|
|
1351
|
+
const { props } = renderOpts
|
|
1352
|
+
const cellValue = getCellValue(row, column)
|
|
1353
|
+
return [
|
|
1354
|
+
h(getDefaultComponent(renderOpts), {
|
|
1355
|
+
...props,
|
|
1356
|
+
content: cellValue,
|
|
1357
|
+
...getEditOns(renderOpts, params)
|
|
1358
|
+
})
|
|
1359
|
+
]
|
|
1360
|
+
}
|
|
1361
|
+
},
|
|
1362
|
+
VxeRate: {
|
|
1363
|
+
renderTableDefault: defaultEditRender
|
|
1364
|
+
},
|
|
1365
|
+
VxeSlider: {
|
|
1366
|
+
renderTableDefault: defaultEditRender
|
|
1367
|
+
},
|
|
1368
|
+
|
|
1369
|
+
// 以下已废弃
|
|
1370
|
+
$input: {
|
|
1371
|
+
tableAutoFocus: '.vxe-input--inner',
|
|
1372
|
+
renderTableEdit: oldEditRender,
|
|
1373
|
+
renderTableCell (renderOpts, params) {
|
|
1374
|
+
const { props = {} } = renderOpts
|
|
1375
|
+
const { row, column } = params
|
|
1376
|
+
const digits = props.digits || getConfig().input?.digits || 2
|
|
1377
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
1378
|
+
if (cellValue) {
|
|
1379
|
+
switch (props.type) {
|
|
1380
|
+
case 'date':
|
|
1381
|
+
case 'week':
|
|
1382
|
+
case 'month':
|
|
1383
|
+
case 'year':
|
|
1384
|
+
cellValue = getLabelFormatDate(cellValue, props)
|
|
1385
|
+
break
|
|
1386
|
+
case 'float':
|
|
1387
|
+
cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
1388
|
+
break
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
1392
|
+
},
|
|
1393
|
+
renderTableDefault: oldEditRender,
|
|
1394
|
+
renderTableFilter: oldFilterRender,
|
|
1395
|
+
tableFilterDefaultMethod: handleInputFilterMethod
|
|
1396
|
+
},
|
|
1397
|
+
$textarea: {
|
|
1398
|
+
tableAutoFocus: '.vxe-textarea--inner'
|
|
1399
|
+
},
|
|
1400
|
+
$button: {
|
|
1401
|
+
renderTableDefault: oldButtonEditRender
|
|
1402
|
+
},
|
|
1403
|
+
$buttons: {
|
|
1404
|
+
renderTableDefault: oldButtonsEditRender
|
|
1405
|
+
},
|
|
1406
|
+
$select: {
|
|
1407
|
+
tableAutoFocus: '.vxe-input--inner',
|
|
1408
|
+
renderTableEdit: oldSelectEditRender,
|
|
1409
|
+
renderTableDefault: oldSelectEditRender,
|
|
1410
|
+
renderTableCell (renderOpts, params) {
|
|
1411
|
+
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
|
|
1412
|
+
},
|
|
1413
|
+
renderTableFilter (renderOpts, params) {
|
|
1414
|
+
const { column } = params
|
|
1415
|
+
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts
|
|
1416
|
+
return column.filters.map((option, oIndex) => {
|
|
1417
|
+
const optionValue = option.data
|
|
1418
|
+
return h(getOldComponent(renderOpts), {
|
|
1419
|
+
key: oIndex,
|
|
1420
|
+
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
|
|
1421
|
+
...getFilterOns(renderOpts, params, option)
|
|
1422
|
+
})
|
|
1423
|
+
})
|
|
1424
|
+
},
|
|
1425
|
+
tableFilterDefaultMethod: handleFilterMethod,
|
|
1426
|
+
tableExportMethod: handleExportSelectMethod
|
|
1427
|
+
},
|
|
1428
|
+
$radio: {
|
|
1429
|
+
tableAutoFocus: '.vxe-radio--input'
|
|
1430
|
+
},
|
|
1431
|
+
$checkbox: {
|
|
1432
|
+
tableAutoFocus: '.vxe-checkbox--input'
|
|
1433
|
+
},
|
|
1434
|
+
$switch: {
|
|
1435
|
+
tableAutoFocus: '.vxe-switch--button',
|
|
1436
|
+
renderTableEdit: oldEditRender,
|
|
1437
|
+
renderTableDefault: oldEditRender
|
|
1438
|
+
}
|
|
1439
|
+
// 以上已废弃
|
|
1440
|
+
})
|