Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Mar 21, 2021
1 parent 1caa913 commit 1c8142b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
33 changes: 25 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ function getItemProps (renderOpts: VxeGlobalRendererHandles.RenderOptions, param
return XEUtils.assign({}, defaultProps, renderOpts.props, { [getModelProp(renderOpts)]: value })
}

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

function getCellLabelVNs (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams, cellLabel: any) {
const { placeholder } = renderOpts
return [
h('span', {
class: 'vxe-cell--label'
}, isEmptyValue(cellLabel) ? [
h('span', {
class: 'vxe-cell--placeholder'
}, formatText(placeholder))
] : formatText(cellLabel))
]
}

function getOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderParams, inputFunc?: Function, changeFunc?: Function) {
const { events } = renderOpts
const modelEvent = getModelEvent(renderOpts)
Expand Down Expand Up @@ -117,8 +134,8 @@ function matchCascaderData (index: number, list: any[], values: any[], labels: a
}

function formatDatePicker (defaultFormat: string) {
return function (renderOpts: VxeColumnPropTypes.CellRender, params: VxeGlobalRendererHandles.RenderCellParams) {
return cellText(getDatePickerCellValue(renderOpts, params, defaultFormat))
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
return getCellLabelVNs(renderOpts, params, getDatePickerCellValue(renderOpts, params, defaultFormat))
}
}

Expand All @@ -144,7 +161,7 @@ function getSelectCellValue (renderOpts: VxeColumnPropTypes.EditRender, params:
return selectItem ? selectItem[labelProp] : value
}).join(', ')
}
return null
return ''
}

function getCascaderCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.ExportMethodParams) {
Expand Down Expand Up @@ -277,7 +294,7 @@ function defaultExactFilterMethod (params: VxeGlobalRendererHandles.FilterMethod
}

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

function renderOptions (options: any[], optionProps: VxeGlobalRendererHandles.RenderOptionProps) {
Expand Down Expand Up @@ -488,7 +505,7 @@ export const VXETablePluginAntd = {
]
},
renderCell (renderOpts, params) {
return cellText(getSelectCellValue(renderOpts, params))
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
},
renderFilter (renderOpts, params) {
const { options = [], optionGroups, optionProps = {}, optionGroupProps = {} } = renderOpts
Expand Down Expand Up @@ -604,7 +621,7 @@ export const VXETablePluginAntd = {
ACascader: {
renderEdit: createEditRender(),
renderCell (renderOpts, params) {
return cellText(getCascaderCellValue(renderOpts, params))
return getCellLabelVNs(renderOpts, params, getCascaderCellValue(renderOpts, params))
},
renderItemContent: createFormItemRender(),
exportMethod: createExportMethod(getCascaderCellValue)
Expand All @@ -624,7 +641,7 @@ export const VXETablePluginAntd = {
ARangePicker: {
renderEdit: createEditRender(),
renderCell (renderOpts, params) {
return cellText(getRangePickerCellValue(renderOpts, params))
return getCellLabelVNs(renderOpts, params, getRangePickerCellValue(renderOpts, params))
},
renderItemContent: createFormItemRender(),
exportMethod: createExportMethod(getRangePickerCellValue)
Expand All @@ -644,7 +661,7 @@ export const VXETablePluginAntd = {
ATreeSelect: {
renderEdit: createEditRender(),
renderCell (renderOpts, params) {
return cellText(getTreeSelectCellValue(renderOpts, params))
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
},
renderItemContent: createFormItemRender(),
exportMethod: createExportMethod(getTreeSelectCellValue)
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-antd",
"version": "3.0.1",
"version": "3.0.2",
"description": "基于 vxe-table 表格的适配插件,用于兼容 ant-design-vue 组件库",
"scripts": {
"lib": "gulp build"
Expand Down Expand Up @@ -49,7 +49,7 @@
"prettier": "^2.1.2",
"typescript": "^4.0.5",
"vue": "^3.0.6",
"vxe-table": "^4.0.3",
"vxe-table": "^4.0.5",
"xe-utils": "^3.1.11"
},
"peerDependencies": {
Expand Down

0 comments on commit 1c8142b

Please sign in to comment.