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(form:utils): replace getEnum with getCopyEnum in getData #1890

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

xucr11
Copy link
Contributor

@xucr11 xucr11 commented Feb 21, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

  • 【受益人银行所在国家】和【受益人所在国家】都是下拉框,并且用了同样的异步数据源
  • 【受益人所在国家】设置了 readOnly: true,导致【受益人银行所在国家】下拉框的数据受到影响
  • 希望在底层用deepCopy解决

image

// html
        depositcountry: {
          type: "string",
          title: "受益人银行所在国家",
          ui: {
            widget: "select",
            allowClear: true,
            placeholder: "请选择",
            optionalHelp: "系统会根据所选国家判断是境内账户或境外账户",
            showRequired: true,
            showSearch: true,
            serverSearch: true,
            asyncData: (): Observable<SFSchemaEnum[]> => {
              return this.fetchDataMixin.getDepositCountry()
            },
            onSearch: (keyword: string): Promise<SFSchemaEnum[]> => {
              return this.fetchDataMixin.getDepositCountry(keyword).toPromise()
            },
            change: () => {
              this.schemaDynamicMixin.initDynamicSchema()
            },
          },
        },
        country: {
          type: "string",
          title: "受益人所在国家",
          readOnly: true,
          default: "CHN",
          ui: {
            widget: "select",
            allowClear: true,
            placeholder: "请选择",
            showRequired: true,
            showSearch: true,
            serverSearch: true,
            asyncData: (): Observable<SFSchemaEnum[]> => {
              return this.fetchDataMixin.getDepositCountry()
            },
            onSearch: (keyword: string): Promise<SFSchemaEnum[]> => {
              return this.fetchDataMixin.getDepositCountry(keyword).toPromise()
            },
            change: () => {
              this.schemaDynamicMixin.initDynamicSchema()
            },
          },
        },
// ts
  public getDepositCountry(keyword?: string): Observable<SFSchemaEnum[]> {
    const obs = this.countryCodeList?.length
      ? of(this.countryCodeList)
      : this.apiService.getOverseasCountryCodeListUsingGET().pipe(
        map(({ data = [] }) => {
          this.countryCodeList = data.map((item) => {
            return {
              ...item,
              label: item.desc,
              value: item.code,
            } as SFSchemaEnum
          })
          return this.countryCodeList
        }),
      )
    return obs.pipe(
      map((list) => {
        if (!keyword) { return list }
        return list.filter((item) => item?.label?.includes(keyword) || item?.value?.includes(keyword))
      }),
    )
  }

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.99%. Comparing base (f359731) to head (ce20b5b).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #1890    +/-   ##
========================================
  Coverage   94.99%   94.99%            
========================================
  Files         273      273            
  Lines        8846     8846            
  Branches     1711     1811   +100     
========================================
  Hits         8403     8403            
  Misses        365      365            
  Partials       78       78            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cipchk cipchk merged commit ace3a28 into ng-alain:master Mar 4, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants