ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.3k stars 1.36k forks source link

🐛[BUG]自定义valuetype时候 request fieldProps 等关键词无法通过fieldProps传递到组件里面来 #8621

Open Caisin opened 3 months ago

Caisin commented 3 months ago

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

自定义valuetype时候 request fieldProps 等关键词无法通过fieldProps传递到组件里面来 image image image

📷 复现步骤

  1. 将ProFromTreeSelect定义为自定义valuetype image

  2. 在column schema image

  3. 打印valuetype里面的props无法拿到request方法,换成其他名字比如api就能拿到 image

🏞 期望结果

💻 复现代码

// 自定义valuetype代码

/**
 * 自定义 valueMap
 */
export const valueTypeMap: Record<string, ProRenderFieldPropsType> = {
  proTreeSelect: {
    renderFormItem(text, props) {
      console.log(text);
      console.log(props);
      // request fieldProps 等参数无法传过来
      return (
        <ProFormTreeSelect
          value={text}
          {...props?.fieldProps}
          request={props?.fieldProps?.api}
          fieldProps={props.fieldProps.tree}
        />
      );
    },
  },
};
// column schema
{
      title: '上级ID',
      dataIndex: 'pid',
      width: 300,
      valueType: 'proTreeSelect',
      fieldProps: () => {
        return {
          // hell: () => {},
          request: (v: any) => {
            return new Promise((resolve, reject) => {
              all_permission(v)
                .then((ret) => {
                  resolve(to_tree(ret.data, ''));
                })
                .catch((e) => reject(e));
            });
          },
          tree: {
            fieldNames: {
              label: 'name',
              value: 'id',
            },
          },
        };
      },
    }

© 版本信息

🚑 其他信息