ant-design / ant-design/pro-components
🐛[BUG]BetaSchemaForm的valueEnum传入一个函数(row)=>xxx时,row一直是undefined,无法获取到值
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
### 🐛 bug 描述
BetaSchemaForm的valueEnum传入一个函数(row)=>xxx时,row一直是undefined,无法获取到值
文档里说可以传函数的:https://github.com/ant-design/pro-components/blob/817898fabd2f199113ebb8a063d1ffbf0ab22829/docs/components/schema.md#%E8%87%AA%E5%AE%9A%E4%B9%89-valuetype
### 📷 复现步骤
codesandbox.io:
https://codesandbox.io/p/sandbox/shi-yong-proformdependency-forked-llfyp9?file=%2FApp.tsx%3A32%2C25&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522cls17y0sd0007356ma48cgpwz%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522cls17y0sd0003356mlcnn7udc%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522cls17y0sd0004356mah1rcuny%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522cls17y0sd0006356my2csi576%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522cls17y0sd0003356mlcnn7udc%2522%253A%257B%2522id%2522%253A%2522cls17y0sd0003356mlcnn7udc%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cls18o4ic0002356kut78t8fy%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A32%252C%2522startColumn%2522%253A25%252C%2522endLineNumber%2522%253A32%252C%2522endColumn%2522%253A25%257D%255D%252C%2522filepath%2522%253A%2522%252FApp.tsx%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522activeTabId%2522%253A%2522cls18o4ic0002356kut78t8fy%2522%257D%252C%2522cls17y0sd0006356my2csi576%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cls17y0sd0005356m5khsz4lo%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522cls17y0sd0006356my2csi576%2522%252C%2522activeTabId%2522%253A%2522cls17y0sd0005356m5khsz4lo%2522%257D%252C%2522cls17y0sd0004356mah1rcuny%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522cls17y0sd0004356mah1rcuny%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D
### 🏞 期望结果
(row)=>{
// 希望这里能获取到row表单内容
}
### 💻 复现代码
见上方sandbox
或者:
```js
import type { ProFormColumnsType } from "@ant-design/pro-components";
import { BetaSchemaForm, ProForm } from "@ant-design/pro-components";
const valueEnum = {
money: { text: "按金额" },
discount: { text: "按折扣" },
};
type DataItem = {
type: string;
testEnum: number;
};
const columns: ProFormColumnsType[] = [
{
title: "优惠方式",
dataIndex: "type",
formItemProps: {
rules: [
{
required: true,
message: "此项为必填项",
},
],
},
valueType: "select",
valueEnum,
width: "m",
},
{
title: "test enum",
dataIndex: "testEnum",
valueType: "select",
valueEnum: (row) => {
console.log("row=", row);
return new Map([
[1, "一"],
[2, "二"],
[3, `row是${JSON.stringify(row)}`],
]);
},
},
];
export default () => {
return (
<>
普通json表单
onFinish={async (values) => {
console.log(values);
}}
columns={columns}
/>
);
};
```
### © 版本信息
- ProComponents 版本: 2.6.48
- umi 版本
- 浏览器环境
- 开发环境 [e.g. mac OS]
### 🚑 其他信息

Contributor guide
Research direction
Start by running the linked CodeSandbox and inspecting the BetaSchemaForm entry point and its valueEnum handling. Verify how the callback is invoked and whether form values are available there; done means the reproduced callback receives the expected row data instead of undefined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100