baidu / amis

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

Picker的内嵌模式,值不继承父组件而被置为空,导致表格数据没有默认被选择; #2149

Open cbz20000 opened 3 years ago

cbz20000 commented 3 years ago

描述问题:

Picker的内嵌模式,值不继承父组件而被置为空,导致表格数据没有默认被选择; 非内嵌模式值继承父组件,无此问题

截图或视频:

image image image

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

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

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

    {
                "type": "page",
                "body": {
                    "type": "form",
                    "name": "form1",
                    "debug": true,
                    "initApi": {
                        "method": "get",
                        "url": "/mock/blank.json",
                        "data": { "&": "$$" },
                        "requestAdaptor": "console.log(api);return api;",
                        "adaptor": "console.log(api);if(api.query['row']){api.query['table1']?payload['table1']=api.query['table1']:payload['table1']=[];payload['table1'].push(api.query['row']);}return payload;"
                    },
                    "controls": [
                        {
                            "type": "table",
                            "name": "table1",
                            "addable": true,
                            "editable": true,
                            "removable": true,
                            "columns": [{
                                "name": "label", "label": "Name"
                            }, {
                                "name": "position", "label": "Title"
                            }]
                        },
                        {
                            "type": "action",
                            "label": "穿梭器提交到表格",
                            "actionType": "drawer",
                            "drawer": {
                                "title": "表格2",
                                "body": {
                                    "type": "form",
                                    "name": "form2",
                                    "target": "form1",
                                    "controls": [{
                                        "label": false,
                                        "type": "transfer",
                                        "name": "table1",
                                        "source": "get:/mock/picker_ajax.json",
                                        "selectMode": "table",
                                        "joinValues": false,
                                        "columns": [
                                            {
                                                "name": "label",
                                                "label": "英雄"
                                            },
                                            {
                                                "name": "position",
                                                "label": "位置"
                                            }
                                        ]
                                    }]
                                }
                            }
                        },
                        {
                            "type": "action",
                            "label": "表单提交到表格",
                            "actionType": "drawer",
                            "drawer": {
                                "title": "表格2",
                                "body": {
                                    "type": "form",
                                    "name": "form3",
                                    "debug": true,
                                    "target": "form1",
                                    "controls": [
                                        {
                                            "type": "text",
                                            "name": "row.label",
                                            "label": "英雄"
                                        },
                                        {
                                            "type": "text",
                                            "name": "row.position",
                                            "label": "位置"
                                        },
                                        {
                                            "type": "table",
                                            "name": "row.table",
                                            "addable": true,
                                            "editable": true,
                                            "removable": true,
                                            "columns": [{
                                                "name": "id", "label": "id"
                                            }, {
                                                "name": "name", "label": "name"
                                            }]
                                        }
                                    ]
                                }
                            }
                        },
                        {
                            "type": "action",
                            "label": "Picker提交到表格",
                            "actionType": "drawer",
                            "drawer": {
                                "title": "请选择",
                                "data":{"&":"$$","tableFixBug":"${table1}"},
                                "body": {
                                    "type": "form",
                                    "name": "form4",
                                    "debug": true,
                                    "target": "form1",
                                    "controls": [
                                        {
                                            "label": false,
                                            "type": "picker",
                                            "name": "table1",
                                            "joinValues": false,
                                            "embed": false,
                                            "multiple": true,
                                            "source": "get:/mock/picker_ajax.json",
                                            "pickerSchema": {
                                                "mode": "table",
                                                "name": "thelist",
                                                "draggable": true,
                                                "primaryField": "label",
                                                "headerToolbar": {
                                                    "wrapWithPanel": false,
                                                    "type": "form",
                                                    "className": "text-right",
                                                    "target": "thelist",
                                                    "mode": "inline",
                                                    "controls": [
                                                        {
                                                            "type": "text",
                                                            "name": "keywords",
                                                            "addOn": {
                                                                "type": "submit",
                                                                "label": "搜索",
                                                                "level": "primary",
                                                                "icon": "fa fa-search pull-left"
                                                            }
                                                        }
                                                    ]
                                                },
                                                "columns": [
                                                    {
                                                        "type": "text",
                                                        "name": "label",
                                                        "label": "英雄",
                                                        "sortable": true,
                                                        "toggled": true
                                                    },
                                                    {
                                                        "type": "text",
                                                        "name": "position",
                                                        "label": "位置",
                                                        "sortable": true,
                                                        "toggled": true
                                                    }
                                                ]
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    ]
                }
            }
  3. 操作步骤 请简单描述一下复现的操作步骤...

April-Zheng commented 3 years ago

遇到了同样的问题,怎么解决呢

agileago commented 2 years ago

@2betop 遇到同样问题

agileago commented 2 years ago

@cbz20000 解决没, @nwind 这个感觉比较严重,谁看一下?

cbz20000 commented 2 years ago

@cbz20000 解决没, @nwind 这个感觉比较严重,谁看一下?

仔细看我最下面一个picker的代码,data":{"&":"$$","tableFixBug":"${table1}"},我当时在drawer层引用父页面table1的值并且改名字为tableFixBug,然后下面picker的名字也改为tableFixBug暂时绕过了这个bug,相同名字按理说值应该继承的