Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Mar 21, 2021
1 parent 8977fbc commit f9fc823
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
31 changes: 23 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ function getItemProps (renderOpts: RenderOptions, params: FormItemRenderParams,
return XEUtils.assign(vSize ? { size: vSize } : {}, defaultProps, renderOpts.props, { [getModelProp(renderOpts)]: value })
}

function formatText (cellValue: any) {
return '' + (isEmptyValue(cellValue) ? '' : cellValue)
}

function getCellLabelVNs (h: CreateElement, renderOpts: ColumnEditRenderOptions, params: ColumnEditRenderParams, cellLabel: any) {
const { placeholder } = renderOpts
return [
h('span', {
class: 'vxe-cell--label'
}, placeholder && isEmptyValue(cellLabel) ? [
h('span', {
class: 'vxe-cell--placeholder'
}, formatText(placeholder))
] : formatText(cellLabel))
]
}

function getNativeOns (renderOpts: RenderOptions, params: RenderParams) {
const { nativeEvents } = renderOpts
const nativeOns: { [type: string]: Function } = {}
Expand Down Expand Up @@ -202,7 +219,7 @@ function getSelectCellValue (renderOpts: ColumnCellRenderOptions, params: Column
}
return selectlabel
}
return null
return ''
}

function getCascaderCellValue (renderOpts: RenderOptions, params: ColumnCellRenderParams) {
Expand Down Expand Up @@ -360,7 +377,7 @@ function renderOptions (h: CreateElement, options: any[], optionProps: OptionPro
}

function cellText (h: CreateElement, cellValue: any) {
return ['' + (isEmptyValue(cellValue) ? '' : cellValue)]
return [formatText(cellValue)]
}

function createFormItemRender (defaultProps?: { [key: string]: any }) {
Expand Down Expand Up @@ -542,7 +559,7 @@ export const VXETablePluginElement = {
]
},
renderCell (h, renderOpts, params) {
return cellText(h, getSelectCellValue(renderOpts, params))
return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params))
},
renderFilter (h, renderOpts, params) {
const { options = [], optionGroups, optionProps = {}, optionGroupProps = {} } = renderOpts
Expand Down Expand Up @@ -685,7 +702,7 @@ export const VXETablePluginElement = {
ElCascader: {
renderEdit: createEditRender(),
renderCell (h, renderOpts, params) {
return cellText(h, getCascaderCellValue(renderOpts, params))
return getCellLabelVNs(h, renderOpts, params, getCascaderCellValue(renderOpts, params))
},
renderItem: createFormItemRender(),
renderItemContent: createFormItemRender(),
Expand All @@ -695,7 +712,7 @@ export const VXETablePluginElement = {
ElDatePicker: {
renderEdit: createEditRender(),
renderCell (h, renderOpts, params) {
return cellText(h, getDatePickerCellValue(renderOpts, params))
return getCellLabelVNs(h, renderOpts, params, getDatePickerCellValue(renderOpts, params))
},
renderFilter (h, renderOpts, params) {
const { column } = params
Expand Down Expand Up @@ -747,9 +764,7 @@ export const VXETablePluginElement = {
ElTimePicker: {
renderEdit: createEditRender(),
renderCell (h, renderOpts, params) {
return [
getTimePickerCellValue(renderOpts, params)
]
return getCellLabelVNs(h, renderOpts, params, getTimePickerCellValue(renderOpts, params))
},
renderItem: createFormItemRender(),
renderItemContent: createFormItemRender(),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table-plugin-element",
"version": "1.11.0",
"version": "1.11.1",
"description": "基于 vxe-table 表格的适配插件,用于兼容 element-ui 组件库",
"scripts": {
"lib": "gulp build"
Expand Down Expand Up @@ -53,7 +53,7 @@
"xe-utils": "^3.1.11"
},
"peerDependencies": {
"vxe-table": "^2.10.0"
"vxe-table": "^2.10.0 || ^3.2.0"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f9fc823

Please sign in to comment.