@vxe-ui/plugin-render-antd 4.2.3 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +15 -12
- package/dist/index.umd.min.js +1 -1
- package/es/form/index.js +265 -0
- package/es/form-design/checkbox-widget.js +148 -0
- package/es/form-design/date-picker-widget.js +130 -0
- package/es/form-design/index.js +97 -0
- package/es/form-design/input-widget.js +130 -0
- package/es/form-design/number-input-widget.js +130 -0
- package/es/form-design/radio-widget.js +148 -0
- package/es/form-design/select-widget.js +140 -0
- package/es/form-design/switch-widget.js +126 -0
- package/es/form-design/textarea-widget.js +134 -0
- package/es/form-design/use.js +226 -0
- package/es/index.esm.js +105 -0
- package/es/index.js +105 -0
- package/es/store/index.js +2 -0
- package/es/style.css +63 -0
- package/es/style.min.css +1 -0
- package/es/table/index.js +472 -0
- package/es/util/comp.js +9 -0
- package/{dist → lib}/form/index.js +3 -0
- package/{dist → lib}/index.common.js +3 -3
- package/{dist → lib}/index.js +3 -3
- package/lib/index.umd.js +2731 -0
- package/lib/index.umd.min.js +1 -0
- package/lib/style.css +63 -0
- package/lib/style.min.css +1 -0
- package/package.json +14 -17
- package/src/form/index.ts +5 -2
- /package/{dist → lib}/form-design/checkbox-widget.js +0 -0
- /package/{dist → lib}/form-design/date-picker-widget.js +0 -0
- /package/{dist → lib}/form-design/index.js +0 -0
- /package/{dist → lib}/form-design/input-widget.js +0 -0
- /package/{dist → lib}/form-design/number-input-widget.js +0 -0
- /package/{dist → lib}/form-design/radio-widget.js +0 -0
- /package/{dist → lib}/form-design/select-widget.js +0 -0
- /package/{dist → lib}/form-design/switch-widget.js +0 -0
- /package/{dist → lib}/form-design/textarea-widget.js +0 -0
- /package/{dist → lib}/form-design/use.js +0 -0
- /package/{dist → lib}/store/index.js +0 -0
- /package/{dist → lib}/table/index.js +0 -0
- /package/{dist → lib}/util/comp.js +0 -0
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { h } from 'vue';
|
|
2
|
+
import { getCurrComponent } from '../util/comp';
|
|
3
|
+
import XEUtils from 'xe-utils';
|
|
4
|
+
/**
|
|
5
|
+
* 表格 - 渲染器
|
|
6
|
+
*/
|
|
7
|
+
export function defineTableRender(VxeUI) {
|
|
8
|
+
function isEmptyValue(cellValue) {
|
|
9
|
+
return cellValue === null || cellValue === undefined || cellValue === '';
|
|
10
|
+
}
|
|
11
|
+
function getOnName(type) {
|
|
12
|
+
return 'on' + type.substring(0, 1).toLocaleUpperCase() + type.substring(1);
|
|
13
|
+
}
|
|
14
|
+
function getModelProp(renderOpts) {
|
|
15
|
+
let prop = 'value';
|
|
16
|
+
switch (renderOpts.name) {
|
|
17
|
+
case 'ASwitch':
|
|
18
|
+
prop = 'checked';
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
return prop;
|
|
22
|
+
}
|
|
23
|
+
function getModelEvent(renderOpts) {
|
|
24
|
+
let type = 'update:value';
|
|
25
|
+
switch (renderOpts.name) {
|
|
26
|
+
case 'ASwitch':
|
|
27
|
+
type = 'update:checked';
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
return type;
|
|
31
|
+
}
|
|
32
|
+
function dateFormatToVxeFormat(format) {
|
|
33
|
+
if (format) {
|
|
34
|
+
return `${format}`.replace('YYYY', 'yyyy').replace('DD', 'dd');
|
|
35
|
+
}
|
|
36
|
+
return format;
|
|
37
|
+
}
|
|
38
|
+
function getChangeEvent(renderOpts) {
|
|
39
|
+
return 'change';
|
|
40
|
+
}
|
|
41
|
+
function getCellEditFilterProps(renderOpts, params, value, defaultProps) {
|
|
42
|
+
return XEUtils.assign({}, defaultProps, renderOpts.props, { [getModelProp(renderOpts)]: value });
|
|
43
|
+
}
|
|
44
|
+
function formatText(cellValue) {
|
|
45
|
+
return '' + (isEmptyValue(cellValue) ? '' : cellValue);
|
|
46
|
+
}
|
|
47
|
+
function getCellLabelVNs(renderOpts, params, cellLabel) {
|
|
48
|
+
const { placeholder } = renderOpts;
|
|
49
|
+
return [
|
|
50
|
+
h('span', {
|
|
51
|
+
class: 'vxe-cell--label'
|
|
52
|
+
}, placeholder && isEmptyValue(cellLabel)
|
|
53
|
+
? [
|
|
54
|
+
h('span', {
|
|
55
|
+
class: 'vxe-cell--placeholder'
|
|
56
|
+
}, formatText(placeholder))
|
|
57
|
+
]
|
|
58
|
+
: formatText(cellLabel))
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
function getOns(renderOpts, params, inputFunc, changeFunc) {
|
|
62
|
+
const { events } = renderOpts;
|
|
63
|
+
const modelEvent = getModelEvent(renderOpts);
|
|
64
|
+
const changeEvent = getChangeEvent(renderOpts);
|
|
65
|
+
const isSameEvent = changeEvent === modelEvent;
|
|
66
|
+
const ons = {};
|
|
67
|
+
XEUtils.objectEach(events, (func, key) => {
|
|
68
|
+
ons[getOnName(key)] = function (...args) {
|
|
69
|
+
func(params, ...args);
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
if (inputFunc) {
|
|
73
|
+
ons[getOnName(modelEvent)] = function (targetEvnt) {
|
|
74
|
+
inputFunc(targetEvnt);
|
|
75
|
+
if (events && events[modelEvent]) {
|
|
76
|
+
events[modelEvent](params, targetEvnt);
|
|
77
|
+
}
|
|
78
|
+
if (isSameEvent && changeFunc) {
|
|
79
|
+
changeFunc(targetEvnt);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (!isSameEvent && changeFunc) {
|
|
84
|
+
ons[getOnName(changeEvent)] = function (...args) {
|
|
85
|
+
changeFunc(...args);
|
|
86
|
+
if (events && events[changeEvent]) {
|
|
87
|
+
events[changeEvent](params, ...args);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return ons;
|
|
92
|
+
}
|
|
93
|
+
function getEditOns(renderOpts, params) {
|
|
94
|
+
const { $table, row, column } = params;
|
|
95
|
+
return getOns(renderOpts, params, (value) => {
|
|
96
|
+
// 处理 model 值双向绑定
|
|
97
|
+
XEUtils.set(row, column.field, value);
|
|
98
|
+
}, () => {
|
|
99
|
+
// 处理 change 事件相关逻辑
|
|
100
|
+
$table.updateStatus(params);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function getFilterOns(renderOpts, params, option, changeFunc) {
|
|
104
|
+
return getOns(renderOpts, params, (value) => {
|
|
105
|
+
// 处理 model 值双向绑定
|
|
106
|
+
option.data = value;
|
|
107
|
+
}, changeFunc);
|
|
108
|
+
}
|
|
109
|
+
function matchCascaderData(index, list, values, labels) {
|
|
110
|
+
const val = values[index];
|
|
111
|
+
if (list && values.length > index) {
|
|
112
|
+
XEUtils.each(list, (item) => {
|
|
113
|
+
if (item.value === val) {
|
|
114
|
+
labels.push(item.label);
|
|
115
|
+
matchCascaderData(++index, item.children, values, labels);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function formatDatePicker(defaultFormat) {
|
|
121
|
+
return function (renderOpts, params) {
|
|
122
|
+
return getCellLabelVNs(renderOpts, params, getDatePickerCellValue(renderOpts, params, defaultFormat));
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function formatTimePicker(defaultFormat) {
|
|
126
|
+
return function (renderOpts, params) {
|
|
127
|
+
const { props = {} } = renderOpts;
|
|
128
|
+
const { row, column } = params;
|
|
129
|
+
let cellValue = XEUtils.get(row, column.field);
|
|
130
|
+
try {
|
|
131
|
+
if (cellValue) {
|
|
132
|
+
if (!XEUtils.isString(cellValue)) {
|
|
133
|
+
cellValue = cellValue.format ? cellValue.format(props.format || props.valueFormat || defaultFormat) : XEUtils.toDateString(cellValue, dateFormatToVxeFormat(props.format || props.valueFormat || defaultFormat));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (e) { }
|
|
138
|
+
return getCellLabelVNs(renderOpts, params, cellValue);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function getSelectCellValue(renderOpts, params) {
|
|
142
|
+
const { options = [], optionGroups, props = {}, optionProps = {}, optionGroupProps = {} } = renderOpts;
|
|
143
|
+
const { row, column } = params;
|
|
144
|
+
const labelProp = optionProps.label || 'label';
|
|
145
|
+
const valueProp = optionProps.value || 'value';
|
|
146
|
+
const groupOptions = optionGroupProps.options || 'options';
|
|
147
|
+
const cellValue = XEUtils.get(row, column.field);
|
|
148
|
+
if (!isEmptyValue(cellValue)) {
|
|
149
|
+
return XEUtils.map(props.mode === 'multiple' ? cellValue : [cellValue], optionGroups
|
|
150
|
+
? (value) => {
|
|
151
|
+
let selectItem;
|
|
152
|
+
for (let index = 0; index < optionGroups.length; index++) {
|
|
153
|
+
selectItem = XEUtils.find(optionGroups[index][groupOptions], (item) => item[valueProp] === value);
|
|
154
|
+
if (selectItem) {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return selectItem ? selectItem[labelProp] : value;
|
|
159
|
+
}
|
|
160
|
+
: (value) => {
|
|
161
|
+
const selectItem = XEUtils.find(options, (item) => item[valueProp] === value);
|
|
162
|
+
return selectItem ? selectItem[labelProp] : value;
|
|
163
|
+
}).join(', ');
|
|
164
|
+
}
|
|
165
|
+
return '';
|
|
166
|
+
}
|
|
167
|
+
function getCascaderCellValue(renderOpts, params) {
|
|
168
|
+
const { props = {} } = renderOpts;
|
|
169
|
+
const { row, column } = params;
|
|
170
|
+
const cellValue = XEUtils.get(row, column.field);
|
|
171
|
+
const values = cellValue || [];
|
|
172
|
+
const labels = [];
|
|
173
|
+
matchCascaderData(0, props.options, values, labels);
|
|
174
|
+
return (props.showAllLevels === false ? labels.slice(labels.length - 1, labels.length) : labels).join(` ${props.separator || '/'} `);
|
|
175
|
+
}
|
|
176
|
+
function getRangePickerCellValue(renderOpts, params) {
|
|
177
|
+
const { props = {} } = renderOpts;
|
|
178
|
+
const { row, column } = params;
|
|
179
|
+
let cellValue = XEUtils.get(row, column.field);
|
|
180
|
+
if (cellValue) {
|
|
181
|
+
cellValue = XEUtils.map(cellValue, (date) => {
|
|
182
|
+
return date && date.format ? date.format(props.format || 'YYYY-MM-DD') : XEUtils.toDateString(date, dateFormatToVxeFormat(props.format || 'YYYY-MM-DD'));
|
|
183
|
+
}).join(' ~ ');
|
|
184
|
+
}
|
|
185
|
+
return cellValue;
|
|
186
|
+
}
|
|
187
|
+
function getTreeSelectCellValue(renderOpts, params) {
|
|
188
|
+
const { props = {} } = renderOpts;
|
|
189
|
+
const { treeData, treeCheckable } = props;
|
|
190
|
+
const { row, column } = params;
|
|
191
|
+
const cellValue = XEUtils.get(row, column.field);
|
|
192
|
+
if (!isEmptyValue(cellValue)) {
|
|
193
|
+
return XEUtils.map(treeCheckable ? cellValue : [cellValue], (value) => {
|
|
194
|
+
const matchObj = XEUtils.findTree(treeData, (item) => item.value === value, { children: 'children' });
|
|
195
|
+
return matchObj ? matchObj.item.title : value;
|
|
196
|
+
}).join(', ');
|
|
197
|
+
}
|
|
198
|
+
return cellValue;
|
|
199
|
+
}
|
|
200
|
+
function getDatePickerCellValue(renderOpts, params, defaultFormat) {
|
|
201
|
+
const { props = {} } = renderOpts;
|
|
202
|
+
const { row, column } = params;
|
|
203
|
+
let cellValue = XEUtils.get(row, column.field);
|
|
204
|
+
try {
|
|
205
|
+
if (cellValue) {
|
|
206
|
+
if (!defaultFormat) {
|
|
207
|
+
if (renderOpts.name === 'ADatePicker') {
|
|
208
|
+
switch (props.picker) {
|
|
209
|
+
case 'week':
|
|
210
|
+
defaultFormat = 'YYYY-WW周';
|
|
211
|
+
break;
|
|
212
|
+
case 'month':
|
|
213
|
+
defaultFormat = 'YYYY-MM';
|
|
214
|
+
break;
|
|
215
|
+
case 'year':
|
|
216
|
+
defaultFormat = 'YYYY';
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
defaultFormat = props.showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD';
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
cellValue = cellValue.format ? cellValue.format(props.format || defaultFormat) : XEUtils.toDateString(cellValue, dateFormatToVxeFormat(props.format || defaultFormat));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (e) { }
|
|
228
|
+
return cellValue;
|
|
229
|
+
}
|
|
230
|
+
function createEditRender(defaultProps) {
|
|
231
|
+
return function (renderOpts, params) {
|
|
232
|
+
const { row, column } = params;
|
|
233
|
+
const { name, attrs } = renderOpts;
|
|
234
|
+
const cellValue = XEUtils.get(row, column.field);
|
|
235
|
+
return [
|
|
236
|
+
h(getCurrComponent(name), Object.assign(Object.assign(Object.assign({}, attrs), getCellEditFilterProps(renderOpts, params, cellValue, defaultProps)), getEditOns(renderOpts, params)))
|
|
237
|
+
];
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function defaultButtonEditRender(renderOpts, params) {
|
|
241
|
+
const { attrs } = renderOpts;
|
|
242
|
+
return [
|
|
243
|
+
h(getCurrComponent('a-button'), Object.assign(Object.assign(Object.assign({}, attrs), getCellEditFilterProps(renderOpts, params, null)), getOns(renderOpts, params)), cellText(renderOpts.content))
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
function defaultButtonsEditRender(renderOpts, params) {
|
|
247
|
+
const { children } = renderOpts;
|
|
248
|
+
if (children) {
|
|
249
|
+
return children.map((childRenderOpts) => defaultButtonEditRender(childRenderOpts, params)[0]);
|
|
250
|
+
}
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
function createFilterRender(defaultProps) {
|
|
254
|
+
return function (renderOpts, params) {
|
|
255
|
+
const { column } = params;
|
|
256
|
+
const { name, attrs } = renderOpts;
|
|
257
|
+
return [
|
|
258
|
+
h('div', {
|
|
259
|
+
class: 'vxe-table--filter-antd-wrapper'
|
|
260
|
+
}, column.filters.map((option, oIndex) => {
|
|
261
|
+
const optionValue = option.data;
|
|
262
|
+
return h(getCurrComponent(name), Object.assign(Object.assign(Object.assign({ key: oIndex }, attrs), getCellEditFilterProps(renderOpts, params, optionValue, defaultProps)), getFilterOns(renderOpts, params, option, () => {
|
|
263
|
+
// 处理 change 事件相关逻辑
|
|
264
|
+
handleConfirmFilter(params, !!option.data, option);
|
|
265
|
+
})));
|
|
266
|
+
}))
|
|
267
|
+
];
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function handleConfirmFilter(params, checked, option) {
|
|
271
|
+
const { $panel } = params;
|
|
272
|
+
$panel.changeOption(null, checked, option);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 模糊匹配
|
|
276
|
+
* @param params
|
|
277
|
+
*/
|
|
278
|
+
function defaultFuzzyFilterMethod(params) {
|
|
279
|
+
const { option, row, column } = params;
|
|
280
|
+
const { data } = option;
|
|
281
|
+
const cellValue = XEUtils.get(row, column.field);
|
|
282
|
+
return XEUtils.toValueString(cellValue).indexOf(data) > -1;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* 精确匹配
|
|
286
|
+
* @param params
|
|
287
|
+
*/
|
|
288
|
+
function defaultExactFilterMethod(params) {
|
|
289
|
+
const { option, row, column } = params;
|
|
290
|
+
const { data } = option;
|
|
291
|
+
const cellValue = XEUtils.get(row, column.field);
|
|
292
|
+
/* eslint-disable eqeqeq */
|
|
293
|
+
return cellValue === data;
|
|
294
|
+
}
|
|
295
|
+
function cellText(cellValue) {
|
|
296
|
+
return [formatText(cellValue)];
|
|
297
|
+
}
|
|
298
|
+
function createDatePickerExportMethod(defaultFormat) {
|
|
299
|
+
return function (params) {
|
|
300
|
+
const { row, column, options } = params;
|
|
301
|
+
return options && options.original ? XEUtils.get(row, column.field) : getDatePickerCellValue(column.editRender || column.cellRender, params, defaultFormat);
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function createExportMethod(getExportCellValue) {
|
|
305
|
+
return function (params) {
|
|
306
|
+
const { row, column, options } = params;
|
|
307
|
+
return options && options.original ? XEUtils.get(row, column.field) : getExportCellValue(column.editRender || column.cellRender, params);
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
VxeUI.renderer.mixin({
|
|
311
|
+
AAutoComplete: {
|
|
312
|
+
tableAutoFocus: 'input',
|
|
313
|
+
renderTableDefault: createEditRender(),
|
|
314
|
+
renderTableEdit: createEditRender(),
|
|
315
|
+
renderTableFilter: createFilterRender(),
|
|
316
|
+
tableFilterDefaultMethod: defaultExactFilterMethod
|
|
317
|
+
},
|
|
318
|
+
AInput: {
|
|
319
|
+
tableAutoFocus: 'input',
|
|
320
|
+
renderTableDefault: createEditRender(),
|
|
321
|
+
renderTableEdit: createEditRender(),
|
|
322
|
+
renderTableFilter: createFilterRender(),
|
|
323
|
+
tableFilterDefaultMethod: defaultFuzzyFilterMethod
|
|
324
|
+
},
|
|
325
|
+
AInputNumber: {
|
|
326
|
+
tableAutoFocus: 'input',
|
|
327
|
+
renderTableDefault: createEditRender(),
|
|
328
|
+
renderTableEdit: createEditRender(),
|
|
329
|
+
renderTableFilter: createFilterRender(),
|
|
330
|
+
tableFilterDefaultMethod: defaultFuzzyFilterMethod
|
|
331
|
+
},
|
|
332
|
+
ASelect: {
|
|
333
|
+
renderTableEdit(renderOpts, params) {
|
|
334
|
+
const { options, optionGroups } = renderOpts;
|
|
335
|
+
const { row, column } = params;
|
|
336
|
+
const { attrs } = renderOpts;
|
|
337
|
+
const cellValue = XEUtils.get(row, column.field);
|
|
338
|
+
const props = getCellEditFilterProps(renderOpts, params, cellValue);
|
|
339
|
+
const ons = getEditOns(renderOpts, params);
|
|
340
|
+
if (optionGroups) {
|
|
341
|
+
return [
|
|
342
|
+
h(getCurrComponent('a-select'), Object.assign(Object.assign(Object.assign(Object.assign({}, props), attrs), { options: optionGroups }), ons))
|
|
343
|
+
];
|
|
344
|
+
}
|
|
345
|
+
return [
|
|
346
|
+
h(getCurrComponent('a-select'), Object.assign(Object.assign(Object.assign(Object.assign({}, props), attrs), { options: props.options || options }), ons))
|
|
347
|
+
];
|
|
348
|
+
},
|
|
349
|
+
renderTableCell(renderOpts, params) {
|
|
350
|
+
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params));
|
|
351
|
+
},
|
|
352
|
+
renderTableFilter(renderOpts, params) {
|
|
353
|
+
const { options = [], optionGroups, optionGroupProps = {} } = renderOpts;
|
|
354
|
+
const groupOptions = optionGroupProps.options || 'options';
|
|
355
|
+
const { column } = params;
|
|
356
|
+
const { attrs } = renderOpts;
|
|
357
|
+
return [
|
|
358
|
+
h('div', {
|
|
359
|
+
class: 'vxe-table--filter-antd-wrapper'
|
|
360
|
+
}, optionGroups
|
|
361
|
+
? column.filters.map((option, oIndex) => {
|
|
362
|
+
const optionValue = option.data;
|
|
363
|
+
const props = getCellEditFilterProps(renderOpts, params, optionValue);
|
|
364
|
+
return h(getCurrComponent('a-select'), Object.assign(Object.assign(Object.assign(Object.assign({ key: oIndex }, attrs), props), { options: groupOptions }), getFilterOns(renderOpts, params, option, () => {
|
|
365
|
+
// 处理 change 事件相关逻辑
|
|
366
|
+
handleConfirmFilter(params, props.mode === 'multiple' ? (option.data && option.data.length > 0) : !XEUtils.eqNull(option.data), option);
|
|
367
|
+
})));
|
|
368
|
+
})
|
|
369
|
+
: column.filters.map((option, oIndex) => {
|
|
370
|
+
const optionValue = option.data;
|
|
371
|
+
const props = getCellEditFilterProps(renderOpts, params, optionValue);
|
|
372
|
+
return h(getCurrComponent('a-select'), Object.assign(Object.assign(Object.assign(Object.assign({ key: oIndex }, attrs), props), { options: props.options || options }), getFilterOns(renderOpts, params, option, () => {
|
|
373
|
+
// 处理 change 事件相关逻辑
|
|
374
|
+
handleConfirmFilter(params, props.mode === 'multiple' ? (option.data && option.data.length > 0) : !XEUtils.eqNull(option.data), option);
|
|
375
|
+
})));
|
|
376
|
+
}))
|
|
377
|
+
];
|
|
378
|
+
},
|
|
379
|
+
tableFilterDefaultMethod(params) {
|
|
380
|
+
const { option, row, column } = params;
|
|
381
|
+
const { data } = option;
|
|
382
|
+
const { field, filterRender: renderOpts } = column;
|
|
383
|
+
const { props = {} } = renderOpts;
|
|
384
|
+
const cellValue = XEUtils.get(row, field);
|
|
385
|
+
if (props.mode === 'multiple') {
|
|
386
|
+
if (XEUtils.isArray(cellValue)) {
|
|
387
|
+
return XEUtils.includeArrays(cellValue, data);
|
|
388
|
+
}
|
|
389
|
+
return data.indexOf(cellValue) > -1;
|
|
390
|
+
}
|
|
391
|
+
/* eslint-disable eqeqeq */
|
|
392
|
+
return cellValue == data;
|
|
393
|
+
},
|
|
394
|
+
tableExportMethod: createExportMethod(getSelectCellValue)
|
|
395
|
+
},
|
|
396
|
+
ACascader: {
|
|
397
|
+
renderTableEdit: createEditRender(),
|
|
398
|
+
renderTableCell(renderOpts, params) {
|
|
399
|
+
return getCellLabelVNs(renderOpts, params, getCascaderCellValue(renderOpts, params));
|
|
400
|
+
},
|
|
401
|
+
tableExportMethod: createExportMethod(getCascaderCellValue)
|
|
402
|
+
},
|
|
403
|
+
ADatePicker: {
|
|
404
|
+
renderTableEdit: createEditRender(),
|
|
405
|
+
renderTableCell: formatDatePicker(),
|
|
406
|
+
tableExportMethod: createDatePickerExportMethod()
|
|
407
|
+
},
|
|
408
|
+
AMonthPicker: {
|
|
409
|
+
renderTableEdit: createEditRender(),
|
|
410
|
+
renderTableCell: formatDatePicker('YYYY-MM'),
|
|
411
|
+
tableExportMethod: createDatePickerExportMethod('YYYY-MM')
|
|
412
|
+
},
|
|
413
|
+
ARangePicker: {
|
|
414
|
+
renderTableEdit: createEditRender(),
|
|
415
|
+
renderTableCell(renderOpts, params) {
|
|
416
|
+
return getCellLabelVNs(renderOpts, params, getRangePickerCellValue(renderOpts, params));
|
|
417
|
+
},
|
|
418
|
+
tableExportMethod: createExportMethod(getRangePickerCellValue)
|
|
419
|
+
},
|
|
420
|
+
AWeekPicker: {
|
|
421
|
+
renderTableEdit: createEditRender(),
|
|
422
|
+
renderTableCell: formatDatePicker('YYYY-WW周'),
|
|
423
|
+
tableExportMethod: createDatePickerExportMethod('YYYY-WW周')
|
|
424
|
+
},
|
|
425
|
+
ATimePicker: {
|
|
426
|
+
renderTableEdit: createEditRender(),
|
|
427
|
+
renderTableCell: formatTimePicker('HH:mm:ss'),
|
|
428
|
+
tableExportMethod: createDatePickerExportMethod('HH:mm:ss')
|
|
429
|
+
},
|
|
430
|
+
ATreeSelect: {
|
|
431
|
+
renderTableEdit: createEditRender(),
|
|
432
|
+
renderTableCell(renderOpts, params) {
|
|
433
|
+
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params));
|
|
434
|
+
},
|
|
435
|
+
tableExportMethod: createExportMethod(getTreeSelectCellValue)
|
|
436
|
+
},
|
|
437
|
+
ARate: {
|
|
438
|
+
renderTableDefault: createEditRender(),
|
|
439
|
+
renderTableEdit: createEditRender(),
|
|
440
|
+
renderTableFilter: createFilterRender(),
|
|
441
|
+
tableFilterDefaultMethod: defaultExactFilterMethod
|
|
442
|
+
},
|
|
443
|
+
ASwitch: {
|
|
444
|
+
renderTableDefault: createEditRender(),
|
|
445
|
+
renderTableEdit: createEditRender(),
|
|
446
|
+
renderTableFilter(renderOpts, params) {
|
|
447
|
+
const { column } = params;
|
|
448
|
+
const { name, attrs } = renderOpts;
|
|
449
|
+
return [
|
|
450
|
+
h('div', {
|
|
451
|
+
class: 'vxe-table--filter-antd-wrapper'
|
|
452
|
+
}, column.filters.map((option, oIndex) => {
|
|
453
|
+
const optionValue = option.data;
|
|
454
|
+
return h(name, Object.assign(Object.assign(Object.assign({ key: oIndex }, attrs), getCellEditFilterProps(renderOpts, params, optionValue)), getFilterOns(renderOpts, params, option, () => {
|
|
455
|
+
// 处理 change 事件相关逻辑
|
|
456
|
+
handleConfirmFilter(params, XEUtils.isBoolean(option.data), option);
|
|
457
|
+
})));
|
|
458
|
+
}))
|
|
459
|
+
];
|
|
460
|
+
},
|
|
461
|
+
tableFilterDefaultMethod: defaultExactFilterMethod
|
|
462
|
+
},
|
|
463
|
+
AButton: {
|
|
464
|
+
renderTableEdit: defaultButtonEditRender,
|
|
465
|
+
renderTableDefault: defaultButtonEditRender
|
|
466
|
+
},
|
|
467
|
+
AButtons: {
|
|
468
|
+
renderTableEdit: defaultButtonsEditRender,
|
|
469
|
+
renderTableDefault: defaultButtonsEditRender
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
package/es/util/comp.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { resolveComponent } from 'vue';
|
|
2
|
+
import { globalConfig, componentMaps } from '../store';
|
|
3
|
+
export function getCurrComponent(name) {
|
|
4
|
+
const comp = componentMaps[name] || (globalConfig.Antd ? globalConfig.Antd[name] : null);
|
|
5
|
+
if (comp) {
|
|
6
|
+
return comp;
|
|
7
|
+
}
|
|
8
|
+
return resolveComponent(name);
|
|
9
|
+
}
|
|
@@ -54,7 +54,7 @@ var VxeUIPluginRenderAntd = exports.VxeUIPluginRenderAntd = {
|
|
|
54
54
|
_store.componentMaps[kcName] = comp;
|
|
55
55
|
_store.componentMaps[ccName] = comp;
|
|
56
56
|
} else {
|
|
57
|
-
console.error('[@vxe-ui/plugin-render-antd 4.
|
|
57
|
+
console.error('[@vxe-ui/plugin-render-antd 4.3.1] error component.', comp);
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
install: function install(VxeUI, options) {
|
|
@@ -67,11 +67,11 @@ var VxeUIPluginRenderAntd = exports.VxeUIPluginRenderAntd = {
|
|
|
67
67
|
var pVersion = 4;
|
|
68
68
|
var sVersion = 11;
|
|
69
69
|
if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
|
|
70
|
-
console.error("[@vxe-ui/plugin-render-antd 4.
|
|
70
|
+
console.error("[@vxe-ui/plugin-render-antd 4.3.1] ".concat(VxeUI.getI18n('vxe.error.errorVersion', ["vxe-table@".concat(VxeUI.tableVersion || '?'), "vxe-table v".concat(pVersion, ".").concat(sVersion, "+")]), " https://vxeui.com/other4/#/plugin-render-antd/install"));
|
|
71
71
|
}
|
|
72
72
|
} else {
|
|
73
73
|
if (!/^(4)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
|
|
74
|
-
console.error('[@vxe-ui/plugin-render-antd 4.
|
|
74
|
+
console.error('[@vxe-ui/plugin-render-antd 4.3.1] Requires vxe-table 4.7.0+ version. https://vxeui.com/other4/#/plugin-render-antd/install');
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
/**
|
package/{dist → lib}/index.js
RENAMED
|
@@ -54,7 +54,7 @@ var VxeUIPluginRenderAntd = exports.VxeUIPluginRenderAntd = {
|
|
|
54
54
|
_store.componentMaps[kcName] = comp;
|
|
55
55
|
_store.componentMaps[ccName] = comp;
|
|
56
56
|
} else {
|
|
57
|
-
console.error('[@vxe-ui/plugin-render-antd 4.
|
|
57
|
+
console.error('[@vxe-ui/plugin-render-antd 4.3.1] error component.', comp);
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
install: function install(VxeUI, options) {
|
|
@@ -67,11 +67,11 @@ var VxeUIPluginRenderAntd = exports.VxeUIPluginRenderAntd = {
|
|
|
67
67
|
var pVersion = 4;
|
|
68
68
|
var sVersion = 11;
|
|
69
69
|
if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
|
|
70
|
-
console.error("[@vxe-ui/plugin-render-antd 4.
|
|
70
|
+
console.error("[@vxe-ui/plugin-render-antd 4.3.1] ".concat(VxeUI.getI18n('vxe.error.errorVersion', ["vxe-table@".concat(VxeUI.tableVersion || '?'), "vxe-table v".concat(pVersion, ".").concat(sVersion, "+")]), " https://vxeui.com/other4/#/plugin-render-antd/install"));
|
|
71
71
|
}
|
|
72
72
|
} else {
|
|
73
73
|
if (!/^(4)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
|
|
74
|
-
console.error('[@vxe-ui/plugin-render-antd 4.
|
|
74
|
+
console.error('[@vxe-ui/plugin-render-antd 4.3.1] Requires vxe-table 4.7.0+ version. https://vxeui.com/other4/#/plugin-render-antd/install');
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
/**
|