Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复proTable不支持formatter属性的问题 #371

Closed
wants to merge 1 commit into from

Conversation

prianyu
Copy link

@prianyu prianyu commented Dec 21, 2023

proTable应该支持el-table以及el-table-column的所有属性
目前对el-table-column传入fomatter属性则不会对列内容进行格式化处理

// 渲染表格数据
const renderCellData = (item: ColumnProps, scope: RenderScope<any>) => {
  return enumMap.value.get(item.prop) && item.isFilterEnum
    ? filterEnum(handleRowAccordingToProp(scope.row, item.prop!), enumMap.value.get(item.prop)!, item.fieldNames)
    : formatValue(handleRowAccordingToProp(scope.row, item.prop!));
};

修复后如下:

// 渲染表格数据
const renderCellData = (item: ColumnProps, scope: RenderScope<any>) => {
  if (isFunction(item.formatter)) {
    return item.formatter(scope.row, scope.column, handleRowAccordingToProp(scope.row, item.prop!), scope.$index);
  }
  return enumMap.value.get(item.prop) && item.isFilterEnum
    ? filterEnum(handleRowAccordingToProp(scope.row, item.prop!), enumMap.value.get(item.prop)!, item.fieldNames)
    : formatValue(handleRowAccordingToProp(scope.row, item.prop!));
};
`

Copy link

vercel bot commented Dec 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
geeker-admin ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2023 11:00am

@HalseySpicy
Copy link
Owner

使用 render 即可,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants