baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.33k stars 2.51k forks source link

Picker组件弹出列表为嵌套懒加载模式时,弹出列表后展开节点时没有自动勾选上字段值中包含的选项 #9375

Open yinlianghui opened 10 months ago

yinlianghui commented 10 months ago

描述问题:

使用Picker组件,配置为curd嵌套懒加载模式,见:https://aisuda.bce.baidu.com/amis/zh-CN/components/crud#%E5%B5%8C%E5%A5%97%E6%87%92%E5%8A%A0%E8%BD%BD 基本功能都正常,但是如果这个picker字段本身有值的话,点击弹出列表后,只会默认勾选第一层节点(即source api请求到的节点)中存在的选项值,当点击某个节点展开第二层节点触发懒加载时(即deferApi请求到的节点),展开后的节点不会自动选中字段值中已存在的选项。

截图或视频:

先在弹出picker列表展开某个节点,并选中子节点展开后的某个选项 企业微信截图_655cfc82-d87b-4d5f-8a37-5bcf03f6f46c

点击确认关闭窗口 image

再次点开picker列表并点开子节点展开,可以看到展开后的节点不会自动选中字段值中已存在的选项。 企业微信截图_52d9f76b-4b21-4fe0-a484-3f41b9bed9c3

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

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

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

3.6和6.0都有此问题。

  1. 粘贴有问题的完整 amis schema 代码:

    {
    "type": "page",
    "body": {
    "type": "form",
    "api": "/amis/api/mock2/form/saveForm",
    "debug": true,
    "body": [
      {
        "type": "picker",
        "name": "type4",
        "joinValues": true,
        "valueField": "id",
        "labelField": "browser",
        "label": "多选",
        "size": "lg",
        "value": "4,5",
        "multiple": true,
        "source": "/amis/api/mock2/crud/table6",
        "pickerSchema": {
          "mode": "table",
          "name": "thelist",
          "quickSaveApi": "/amis/api/mock2/sample/bulkUpdate",
          "quickSaveItemApi": "/amis/api/mock2/sample/$id",
          "draggable": true,
          "deferApi": "/amis/api/mock2/crud/table6?parentId=${id}",
          "headerToolbar": {
            "wrapWithPanel": false,
            "type": "form",
            "className": "text-right",
            "target": "thelist",
            "mode": "inline",
            "body": [
              {
                "type": "input-text",
                "name": "keywords",
                "addOn": {
                  "type": "submit",
                  "label": "搜索",
                  "level": "primary",
                  "icon": "fa fa-search pull-left"
                }
              }
            ]
          },
          "footerToolbar": [
            "statistics",
            {
              "type": "pagination",
              "showPageInput": true,
              "layout": "perPage,pager,go"
            }
          ],
          "columns": [
            {
              "name": "id",
              "label": "ID"
            },
            {
              "name": "engine",
              "label": "Rendering engine"
            },
            {
              "name": "browser",
              "label": "Browser"
            }
          ]
        }
      }
    ]
    }
    }
  2. 操作步骤 把上面的schema copy到官网demo https://aisuda.bce.baidu.com/amis/zh-CN/components/form/picker#%E9%85%8D%E7%BD%AE-pickerschema 中,按上述截图步骤操作即可重现。

yinlianghui commented 5 months ago

amis 6.3和6.4还是有此问题

yinlianghui commented 5 months ago

amis 6.3和6.4还是有此问题

基于amis 6.3源码,按以下提交修改可以修正此issue提及的问题: https://github.com/steedos/steedos-amis/commit/eae701b18ac5f2fbe1f87e025f24f3ff70018bf1