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

【文档】表单字段联动赋值 #34

Open
sunhaolin opened this issue Dec 6, 2023 · 0 comments
Open

【文档】表单字段联动赋值 #34

sunhaolin opened this issue Dec 6, 2023 · 0 comments

Comments

@sunhaolin
Copy link
Contributor

sunhaolin commented Dec 6, 2023

  • 使用amis autoFill 自动给关联字段赋值,如新建银行信息时选择开户银行后自动给联行号(combinenum)赋值,在开户银行字段配置:
name: pk_bankdoc
label: 开户银行
reference_to: bank
required: true
sort_no: 130
type: lookup
amis:
  autoFill:
    "showSuggestion": false
    "fillMapping": 
      "combinenum": "${combinenum}"
    "api":
      "method": "post"
      "url": "/graphql"
      "data": 
        "query": '{rows:bank(filters: ["_id", "=", "${pk_bankdoc}"]){combinenum}}'
      "silent": false

name: pk_bankdoc
label: 开户银行
reference_to: bank
required: true
sort_no: 130
type: lookup
amis:
  autoFill:
    "showSuggestion": false
    "fillMapping": 
      "combinenum": "${combinenum}"
    "api":
      "method": "get"
      "url": "/api/v1/bank/${pk_bankdoc}?fields=[\"combinenum\"]"
      "silent": false

name: pk_bankdoc
label: 开户银行
reference_to: bank
required: true
sort_no: 130
type: lookup
amis:
  autoFill:
    "combinenum": "${combinenum}"

此种写法生效的前提条件为:1、联行号(combinenum)需要显示在相关表(bank)的lookup视图或all视图中;2、相关表(bank)必须启用弹出窗口查找模式

  • 根据选择不同的考核类型给最大分值字段自动赋值(选择绩效考核时为30,选择个人评分时为100)
name: type
label: 考核类型
type: select
options:
  - label: 绩效考核
    value: accessment
  - label: 个人评分
    value: personal
sort_no: 102
amis:
  autoFill:
    "max_score": "${type == 'accessment' ? 30 : 100}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant