private formItem()

in src/ui/editor/complex/AForm.tsx [114:146]


  private formItem(hideField: boolean, hideMap:HideMap, f: MFieldSchema, objectFields: MFieldSchema[], uispec, morph: MORPH,
    labelWidth: number, invalidLayoutMsg: string, column: number): JSX.Element {

    const path = MUtil.jsonPath(this.props.path, f.name)
    const wrapperProp = {
      style: {
        display: undefined,
        marginBottom: 15,
        content: f.name // debug用
      },
      open: !hideField,
      //ms: this.state.shouldAnimation?.[f.name] ? 500 : null,
      ms: 500,
      key: f.name,
      id: path,
      name: f.name
    };
    if (column > 1) {
      // 计算每项的宽度(保留2位有效数字)
      Object.assign(wrapperProp.style, {
        width: Math.floor(100 / column * 100) / 100 + '%'
      })
    }

    const fieldViewer = <MFieldViewer morph={morph ?? "readable"} key={path} schema={f} database={this.props.database} path={path} afterChange={(p, v: any, blur) => {
      this.props.afterChange?.(path, v, blur);

      const newHideMap = MUtil.hideMap(MUtil.get(this.props.database, this.props.path), objectFields, uispec);
      if (!_.isEqual(newHideMap, hideMap)) { // 如果有字段依赖导致表单项展示与否变化
        //this.setState({shouldAnimation: shouldAnimation(hideMap, newHideMap, objectFields)});
        this.setState({});
      }
    }} parent={this.props.schema} forceValid={this.props.forceValid} style={{ width: "100%" }} />