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

[Bug]combo控件数据同步父级域数据时界面与实际数据不一致 #8773

Closed
belongwqz opened this issue Nov 16, 2023 · 1 comment · Fixed by #8831
Closed

[Bug]combo控件数据同步父级域数据时界面与实际数据不一致 #8773

belongwqz opened this issue Nov 16, 2023 · 1 comment · Fixed by #8831
Assignees

Comments

@belongwqz
Copy link
Contributor

描述问题:

combo控件开启canAccessSuperData并指定"strictMode": false"syncFields": ["xx"]时,修改父级控件数据时,combo的界面刷新了,但是对应表单的数据没有更新

截图或视频:

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的?
    sdk

  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在

3.5.2

  1. 粘贴有问题的完整 amis schema 代码:
{
  "type": "page",
  "body": {
    "type": "form",
    "debug": true,
    "mode": "horizontal",
    "api": "/amis/api/mock2/form/saveForm",
    "body": [
      {
        "type": "input-text",
        "label": "父级文本框",
        "name": "super_text",
        "value": "123"
      },
      {
        "type": "combo",
        "name": "combo2",
        "label": "可获取父级数据",
        "multiple": true,
        "canAccessSuperData": true,
        "strictMode": false,
        "syncFields": [
          "super_text"
        ],
        "items": [
          {
            "name": "super_text",
            "type": "input-text"
          }
        ]
      }
    ]
  }
}
  1. 操作步骤

combo组件添加一条数据,修改“父级文本框”的值从123为1234,combo里select的界面值已经变为1234,观察debug框的结果,combo2的值为"combo2": [{"super_text": 123}],预期应该为"combo2": [{"super_text": 1234}]

@belongwqz
Copy link
Contributor Author

变通的实现如下

{
    "type": "page", 
    "body": {
        "type": "form", 
        "debug": true, 
        "mode": "horizontal", 
        "api": "/amis/api/mock2/form/saveForm", 
        "body": [
            {
                "type": "input-text", 
                "label": "父级文本框", 
                "name": "super_text", 
                "value": "123", 
                "onEvent": {
                    "change": {
                        "actions": [
                            {
                                "componentId": "combo2", 
                                "actionType": "setValue", 
                                "args": {
                                    "value": {
                                        "super_text": "${value}"
                                    }, 
                                    "condition": "${super_text!== 456497899}"        //如果不加这句,又会是一番奇怪的景象
                                }
                            }
                        ]
                    }
                }
            }, 
            {
                "type": "combo", 
                "id": "combo2"
                "name": "combo2", 
                "label": "可获取父级数据", 
                "multiple": true, 
                "items": [
                    {
                        "name": "super_text", 
                        "type": "input-text"
                    }
                ]
            }
        ]
    }
}

@2betop 2betop self-assigned this Nov 16, 2023
lengqingfeng pushed a commit to lengqingfeng/amis that referenced this issue Dec 28, 2023
…amis

* 'gjamis' of https://github.com/lengqingfeng/amis: (57 commits)
  feat: 树组件优化 (baidu#7946)
  fix(amis-editor): 渲染错误拦截不展示schema
  docs(amis): 补充custom组件使用vue语法的说明 (baidu#8887)
  fix:兼容schema为空的情况 (baidu#8888)
  fix: 修复页面设计器重复执行onChange的问题
  feat: Switch组件的onText和offText支持Schema配置 (baidu#8816)
  fix: 修复下拉弹窗在某些情况点击外层不关闭的问题
  feat: 子编辑器公式输入框变量中加入宿主组件上下文变量的声明
  style: 「设计器」配置面板居中必填项*样式调整
  feat: 主题编辑器渲染器开源 (baidu#8820)
  styles: 调整InputRating组件图标尺寸 (baidu#8869)
  feat:scoped支持调用amis动作 (baidu#8875)
  style: 调整 table 固顶模式的样式兼容 safari Close: baidu#8708 (baidu#8863)
  fix: 修复 combo 同步父级数据可能存在展示值和实际值不一致的问题 Close: baidu#8773 (baidu#8831)
  feat: input-date & input-date-range 事件动作 setValue 支持相对时间 Close: baidu#8845 (baidu#8848)
  chore: attachement 兼容文件名空格转义成 + 号的情况 Closes baidu#8488 (baidu#8846)
  docs: 补充 crud column 的 seachable 说明结合 defaultParams 可配置默认排序 (baidu#8870)
  fix: 修复 jssdk 模式通过 embed 返回的 scoped 获取组件失败的问题 Close: baidu#8864
  chore: 弹窗中校验表单错误 3s 后自动消失以免误会 Close: baidu#1636 (baidu#8849)
  feat: CRUD组件matchFunc支持使用matchSorter函数; docs: 前端分页的使用提示
  ...
2betop added a commit that referenced this issue Mar 26, 2024
* fix: 修复 table2 树形数据展示对应错误问题

* fix: 修复 combo 同步父级数据可能存在展示值和实际值不一致的问题 Close: #8773 (#8831)

* fix: 修复 combo 中有 pipeIn & pipeOut 场景时报错 Close: #8970

* fix: 修复 combo tabs 模式新成员中有必填字段未填写也能通过校验的问题

* fix: 修复 combo 可能无限触发 onChange 的问题

* fix: 修复 combo 同步父级数据可能存在展示值和实际值不一致的问题 Close: #8773

* fix: 修复 combo 中有 pipeIn & pipeOut 场景时报错 Close: #8970 (#8980)

* fix: 修复页面设计器重复执行onChange的问题

* fix: 修复数据下发同步问题 (#9625)

* fix: 修复 crud 重置失效的问题 Close: #9686 (#9693)

* fix: crud2条件查询表单重置失效 (#9706)

* chore: combo 中减少表单项重绘

* fix typecheck error

---------

Co-authored-by: wutong25 <wutong25@baidu.com>
Co-authored-by: walkin <wyc19966@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment