baidu / amis

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

picker组件的嵌套crud模式多选时能否支持下选中节点时不要自动把子节点自动选中 #9295

Open yinlianghui opened 10 months ago

yinlianghui commented 10 months ago

描述问题:

amis 3.6之前,比如amis 3.2不会选中节点时自动把子节点选中,看了下提交代码记录,是amis这边在3.5版本的时候给多选的picker功能增加了自动把子节点自动选中的能力,但是并没有提供开关来保持amis 3.2的时候的模式。

截图或视频:

image

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

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

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

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

    {
    "type": "page",
    "data": {
    "rows": [
      {
        "engine": "Trident",
        "browser": "Internet Explorer 4.0",
        "platform": "Win 95+",
        "version": "4",
        "grade": "X",
        "id": 1,
        "children": [
          {
            "engine": "Trident",
            "browser": "Internet Explorer 4.0",
            "platform": "Win 95+",
            "version": "4",
            "grade": "X",
            "id": 1001
          },
          {
            "engine": "Trident",
            "browser": "Internet Explorer 5.0",
            "platform": "Win 95+",
            "version": "5",
            "grade": "C",
            "id": 1002
          }
        ]
      },
      {
        "engine": "Trident",
        "browser": "Internet Explorer 5.0",
        "platform": "Win 95+",
        "version": "5",
        "grade": "C",
        "id": 2,
        "children": [
          {
            "engine": "Trident",
            "browser": "Internet Explorer 4.0",
            "platform": "Win 95+",
            "version": "4",
            "grade": "X",
            "id": 2001
          },
          {
            "engine": "Trident",
            "browser": "Internet Explorer 5.0",
            "platform": "Win 95+",
            "version": "5",
            "grade": "C",
            "id": 2002
          }
        ]
      },
      {
        "engine": "Trident",
        "browser": "Internet Explorer 5.5",
        "platform": "Win 95+",
        "version": "5.5",
        "grade": "A",
        "id": 3,
        "children": [
          {
            "engine": "Trident",
            "browser": "Internet Explorer 4.0",
            "platform": "Win 95+",
            "version": "4",
            "grade": "X",
            "id": 3001
          },
          {
            "engine": "Trident",
            "browser": "Internet Explorer 5.0",
            "platform": "Win 95+",
            "version": "5",
            "grade": "C",
            "id": 3002
          }
        ]
      },
      {
        "engine": "Trident",
        "browser": "Internet Explorer 6",
        "platform": "Win 98+",
        "version": "6",
        "grade": "A",
        "id": 4,
        "children": [
          {
            "engine": "Trident",
            "browser": "Internet Explorer 4.0",
            "platform": "Win 95+",
            "version": "4",
            "grade": "X",
            "id": 4001
          },
          {
            "engine": "Trident",
            "browser": "Internet Explorer 5.0",
            "platform": "Win 95+",
            "version": "5",
            "grade": "C",
            "id": 4002
          }
        ]
      },
      {
        "engine": "Trident",
        "browser": "Internet Explorer 7",
        "platform": "Win XP SP2+",
        "version": "7",
        "grade": "A",
        "id": 5,
        "children": [
          {
            "engine": "Trident",
            "browser": "Internet Explorer 4.0",
            "platform": "Win 95+",
            "version": "4",
            "grade": "X",
            "id": 5001
          },
          {
            "engine": "Trident",
            "browser": "Internet Explorer 5.0",
            "platform": "Win 95+",
            "version": "5",
            "grade": "C",
            "id": 5002
          }
        ]
      }
    ]
    },
    "body": {
    "type": "form",
    "api": "/amis/api/mock2/form/saveForm",
    "body": [
      {
        "type": "picker",
        "name": "type4",
        "joinValues": true,
        "valueField": "id",
        "labelField": "engine",
        "label": "Picker",
        "embed": true,
        "source": "/amis/api/mock2/crud/tree?waitSeconds=1",
        "size": "lg",
        "multiple": true,
        "pickerSchema": {
          "mode": "table",
          "name": "thelist",
          "quickSaveApi": "/amis/api/mock2/sample/bulkUpdate",
          "quickSaveItemApi": "/amis/api/mock2/sample/$id",
          "draggable": true,
          "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"
                }
              }
            ]
          },
          "columns": [
            {
              "name": "engine",
              "label": "Engine"
            },
            {
              "name": "grade",
              "label": "Grade"
            },
            {
              "name": "version",
              "label": "Version"
            },
            {
              "name": "browser",
              "label": "Browser"
            },
            {
              "name": "id",
              "label": "ID"
            },
            {
              "name": "platform",
              "label": "Platform"
            }
          ]
        }
      }
    ]
    }
    }

image

  1. 操作步骤

bug效果如上图所示,选中任何一个有子节点的选项,会自动把其所有子节点值自动选中作为字段选择项。

github-actions[bot] commented 10 months ago

👍 Thanks for this! 🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

Ladtor commented 7 months ago

+1, 期望能提供配置

yinlianghui commented 5 months ago

另外嵌套懒加载模式时,在子节点已经展开和未展开两种情况下表现也不一致,前者会自动选中最后一个子节点。 image

yinlianghui commented 5 months ago
  • amis 6.3和6.4还是有此问题
  • 而且单选更严重,自动选中了最后一个子节点 image

另外嵌套懒加载模式时,在子节点已经展开和未展开两种情况下表现也不一致,前者会自动选中最后一个子节点。 image

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

hualwh commented 1 week ago

现在咋解决的,6.9也还有这个问题