diff --git a/index.ts b/index.ts index b79dba8..bd3ec9b 100644 --- a/index.ts +++ b/index.ts @@ -404,7 +404,8 @@ const renderMap = { renderEdit: createEditRender(), renderFilter: createFilterRender(), filterMethod: defaultFilterMethod, - renderItem: createFormItemRender() + renderItem: createFormItemRender(), + renderItemContent: createFormItemRender() }, AutoComplete: { autofocus: 'input.ivu-input', @@ -412,7 +413,8 @@ const renderMap = { renderEdit: createEditRender(), renderFilter: createFilterRender(), filterMethod: defaultFilterMethod, - renderItem: createFormItemRender() + renderItem: createFormItemRender(), + renderItemContent: createFormItemRender() }, InputNumber: { autofocus: 'input.ivu-input-number-input', @@ -420,7 +422,8 @@ const renderMap = { renderEdit: createEditRender(), renderFilter: createFilterRender(), filterMethod: defaultFilterMethod, - renderItem: createFormItemRender() + renderItem: createFormItemRender(), + renderItemContent: createFormItemRender() }, Select: { renderEdit (h: CreateElement, renderOpts: ColumnEditRenderOptions, params: ColumnEditRenderParams) { @@ -562,6 +565,42 @@ const renderMap = { }, renderOptions(h, options, optionProps)) ] }, + renderItemContent (h: CreateElement, renderOpts: FormItemRenderOptions, params: FormItemRenderParams) { + const { options = [], optionGroups, optionProps = {}, optionGroupProps = {} } = renderOpts + const { data, property } = params + const { attrs } = renderOpts + const itemValue = XEUtils.get(data, property) + const props = getItemProps(renderOpts, params, itemValue) + const on = getItemOns(renderOpts, params) + const nativeOn = getNativeOns(renderOpts, params) + if (optionGroups) { + const groupOptions = optionGroupProps.options || 'options' + const groupLabel = optionGroupProps.label || 'label' + return [ + h('Select', { + props, + attrs, + on, + nativeOn + }, XEUtils.map(optionGroups, (group, gIndex) => { + return h('OptionGroup', { + key: gIndex, + props: { + label: group[groupLabel] + } + }, renderOptions(h, group[groupOptions], optionProps)) + })) + ] + } + return [ + h('Select', { + props, + attrs, + on, + nativeOn + }, renderOptions(h, options, optionProps)) + ] + }, cellExportMethod: createExportMethod(getSelectCellValue) }, Cascader: { @@ -570,6 +609,7 @@ const renderMap = { return cellText(h, getCascaderCellValue(renderOpts, params)) }, renderItem: createFormItemRender(), + renderItemContent: createFormItemRender(), cellExportMethod: createExportMethod(getCascaderCellValue) }, DatePicker: { @@ -618,18 +658,21 @@ const renderMap = { return false }, renderItem: createFormItemRender(), + renderItemContent: createFormItemRender(), cellExportMethod: createExportMethod(getDatePickerCellValue) }, TimePicker: { renderEdit: createEditRender({ transfer: true }), - renderItem: createFormItemRender() + renderItem: createFormItemRender(), + renderItemContent: createFormItemRender() }, Rate: { renderDefault: createEditRender(), renderEdit: createEditRender(), renderFilter: createFilterRender(), filterMethod: defaultFilterMethod, - renderItem: createFormItemRender() + renderItem: createFormItemRender(), + renderItemContent: createFormItemRender() }, iSwitch: { renderDefault: createEditRender(), @@ -657,23 +700,28 @@ const renderMap = { ] }, filterMethod: defaultFilterMethod, - renderItem: createFormItemRender() + renderItem: createFormItemRender(), + renderItemContent: createFormItemRender() }, Radio: { - renderItem: createFormItemRadioAndCheckboxRender() + renderItem: createFormItemRadioAndCheckboxRender(), + renderItemContent: createFormItemRadioAndCheckboxRender() }, Checkbox: { - renderItem: createFormItemRadioAndCheckboxRender() + renderItem: createFormItemRadioAndCheckboxRender(), + renderItemContent: createFormItemRadioAndCheckboxRender() }, Button: { renderEdit: defaultButtonEditRender, renderDefault: defaultButtonEditRender, - renderItem: defaultButtonItemRender + renderItem: defaultButtonItemRender, + renderItemContent: defaultButtonItemRender }, Buttons: { renderEdit: defaultButtonsEditRender, renderDefault: defaultButtonsEditRender, - renderItem: defaultButtonsItemRender + renderItem: defaultButtonsItemRender, + renderItemContent: defaultButtonsItemRender } } diff --git a/package.json b/package.json index d0eda24..1792f1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table-plugin-iview", - "version": "1.9.3", + "version": "1.9.4", "description": "基于 vxe-table 表格的适配插件,用于兼容 iview、view-design 组件库", "scripts": { "lib": "gulp build"