constructor()

in src/setter/object-setter/index.tsx [207:234]


  constructor(props: RowSetterProps) {
    super(props);
    const { config, field } = props;
    const { extraProps } = field;

    if (Array.isArray(field.items) && field.items.length > 0) {
      field.items.forEach((item: IPublicModelSettingField | IPublicTypeCustomView) => {
        if (isSettingField(item)) {
          const originalSetValue = item.extraProps.setValue;
          item.extraProps.setValue = (...args) => {
            // 调用子字段本身的 setValue
            originalSetValue?.apply(null, args);
            // 调用父字段本身的 setValue
            extraProps.setValue?.apply(null, args);
          };
        }
      });
      this.items = field.items;
    } else {
      this.items = (config?.items || []).map((conf) =>
        field.createField({
          ...conf,
          setValue: extraProps?.setValue,
        }),
      );
    }
    // TODO: extraConfig for custom fields
  }