@vxe-ui/plugin-render-element 4.4.0 → 4.4.3
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 +92 -17
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +3 -3
- package/es/index.js +3 -3
- package/es/table/index.js +73 -2
- package/lib/index.common.js +3 -3
- package/lib/index.js +3 -3
- package/lib/index.umd.js +92 -17
- package/lib/index.umd.min.js +1 -1
- package/lib/table/index.js +89 -14
- package/package.json +6 -7
- package/src/table/index.ts +72 -3
package/src/table/index.ts
CHANGED
|
@@ -234,9 +234,69 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
function
|
|
237
|
+
function handleFormatSelect (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, renderParams: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
238
|
+
const { cellValue } = renderParams
|
|
239
|
+
return handleSelectCellValue(cellValue, renderOpts, renderParams)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function handleSetSelectValue (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, renderParams: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
243
|
+
const { row, column, cellValue } = renderParams
|
|
244
|
+
const { field } = column
|
|
245
|
+
if (field) {
|
|
246
|
+
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props } = renderOpts
|
|
247
|
+
if (isEmptyValue(cellValue)) {
|
|
248
|
+
XEUtils.set(row, field, props && props.multiple ? [] : null)
|
|
249
|
+
return
|
|
250
|
+
}
|
|
251
|
+
const isMultiVal = XEUtils.indexOf(`${cellValue}`, ',') > -1
|
|
252
|
+
const labelProp = optionProps.label || 'label'
|
|
253
|
+
const valueProp = optionProps.value || 'value'
|
|
254
|
+
const labelMpas: Record<string, any> = {}
|
|
255
|
+
if (optionGroups && optionGroups.length) {
|
|
256
|
+
const groupOptions = optionGroupProps.options || 'options'
|
|
257
|
+
for (let i = 0; i < optionGroups.length; i++) {
|
|
258
|
+
const opts = optionGroups[i][groupOptions] || {}
|
|
259
|
+
for (let j = 0; j < opts.length; j++) {
|
|
260
|
+
const item = opts[j]
|
|
261
|
+
if (isMultiVal) {
|
|
262
|
+
labelMpas[item[labelProp]] = item
|
|
263
|
+
/* eslint-disable eqeqeq */
|
|
264
|
+
} else if (item[labelProp] == cellValue) {
|
|
265
|
+
XEUtils.set(row, field, item[valueProp])
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
if (options) {
|
|
272
|
+
for (let i = 0; i < options.length; i++) {
|
|
273
|
+
const item = options[i]
|
|
274
|
+
if (isMultiVal) {
|
|
275
|
+
labelMpas[item[labelProp]] = item
|
|
276
|
+
/* eslint-disable eqeqeq */
|
|
277
|
+
} else if (item[labelProp] == cellValue) {
|
|
278
|
+
XEUtils.set(row, field, item[valueProp])
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (isMultiVal) {
|
|
285
|
+
XEUtils.set(row, field, (isMultiVal
|
|
286
|
+
? cellValue.split(',')
|
|
287
|
+
: [cellValue]).map((label: any) => {
|
|
288
|
+
const item = labelMpas[label]
|
|
289
|
+
return item ? item[valueProp] : label
|
|
290
|
+
}))
|
|
291
|
+
} else {
|
|
292
|
+
XEUtils.set(row, field, cellValue)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function handleSelectCellValue (cellValue: any, renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions, renderParams: VxeGlobalRendererHandles.RenderTableCellParams | VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
238
298
|
const { options = [], optionGroups, props = {}, optionProps = {}, optionGroupProps = {} } = renderOpts
|
|
239
|
-
const { $table,
|
|
299
|
+
const { $table, row, column } = renderParams
|
|
240
300
|
const { filterable, multiple } = props
|
|
241
301
|
const labelProp = optionProps.label || 'label'
|
|
242
302
|
const valueProp = optionProps.value || 'value'
|
|
@@ -246,6 +306,7 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
246
306
|
if (filterable) {
|
|
247
307
|
const { internalData } = $table
|
|
248
308
|
const { fullAllDataRowIdData } = internalData
|
|
309
|
+
const rowid = (renderParams as any).rowid || $table.getRowid(row)
|
|
249
310
|
const rest: any = fullAllDataRowIdData[rowid]
|
|
250
311
|
if (rest) {
|
|
251
312
|
cellData = rest.cellData
|
|
@@ -500,7 +561,12 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
500
561
|
createTableFilterOptions: defaultFilterOptions,
|
|
501
562
|
renderTableFilter: createFilterRender(),
|
|
502
563
|
renderTableFloatingFilter: createFloatingFilterRender(),
|
|
503
|
-
tableFilterDefaultMethod
|
|
564
|
+
tableFilterDefaultMethod (params) {
|
|
565
|
+
const { option, row, column } = params
|
|
566
|
+
const { data } = option
|
|
567
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
568
|
+
return cellValue == data
|
|
569
|
+
}
|
|
504
570
|
},
|
|
505
571
|
ElSelect: {
|
|
506
572
|
tableAutoFocus: 'input',
|
|
@@ -618,6 +684,9 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
618
684
|
}))
|
|
619
685
|
]
|
|
620
686
|
},
|
|
687
|
+
tableCellFormatter: handleFormatSelect,
|
|
688
|
+
tableCellCopyMethod: handleFormatSelect,
|
|
689
|
+
tableCellPasteMethod: handleSetSelectValue,
|
|
621
690
|
tableFilterDefaultMethod (params) {
|
|
622
691
|
const { option, row, column } = params
|
|
623
692
|
const { data } = option
|