amis icon indicating copy to clipboard operation
amis copied to clipboard

Picker 如何带回多列

Open dikar opened this issue 3 years ago • 3 comments

实现场景:

请简单描述你想要实现的原始场景,例如:我想要实现xxx的功能...

我想实现弹出 picker之后,选择了A 列,同时可以把BCD列带回到母页面。

存在的问题:

请简单描述你现在遇到的不符合预期的问题...

当前方案:

请粘贴你当前方案的完整 amis schema 代码...

code here...

dikar avatar Jun 14 '23 09:06 dikar

看不太懂,picker 是选择行数据的,跟列没有关系啊。是指选中的数据格式只提取了 valueField 对应的值吗?如果是这个可以配置 joinValues: false 来保留其他数据

2betop avatar Jun 14 '23 12:06 2betop

我说个场景,看看怎么实现 1:我有个inputtable 里面有 a,b,c d四列。 我对于a 配置了一个picker 。弹出的picker 里展示了 abxyz 五列。我希望选择某一行的时候,把picker里的 ab两列带下来给到 inputtable里的 ab两列

dikar avatar Jun 14 '23 14:06 dikar

可以利用 picker(所有选项类组件都有)的 autoFill 功能,即选中的时候,可以把选项里面的值填充出来的功能。

{
  "type": "page",
  "title": "表单页面",
  "body": [
    {
      "type": "form",
      "mode": "horizontal",
      "api": "/api/mock2/form/saveForm",
      "body": [
        {
          "type": "page",
          "body": {
            "type": "form",
            "debug": "true",
            "data": {
              "table": [
                {
                  "a": "a1",
                  "b": "b1",
                  "c": "c1"
                }
              ]
            },
            "api": "/api/mock2/form/saveForm",
            "body": [
              {
                "type": "input-table",
                "name": "table",
                "columns": [
                  {
                    "name": "x",
                    "type": "picker",
                    "label": "Picker",
                    "valueField": "x",
                    "labelField": "x",
                    "multiple": false,
                    "pickerSchema": {
                      "columns": [
                        {
                          "label": "X",
                          "name": "x"
                        },
                        {
                          "label": "A",
                          "name": "a"
                        },
                        {
                          "label": "B",
                          "name": "b"
                        },
                        {
                          "label": "C",
                          "name": "c"
                        },
                        {
                          "label": "D",
                          "name": "d"
                        }
                      ]
                    },
                    "autoFill": {
                      "a": "${a}",
                      "b": "${b}",
                      "c": "${c}",
                      "d": "${d}"
                    },
                    "options": [
                      {
                        "a": "a1",
                        "b": "b1",
                        "c": "c1",
                        "x": "1"
                      },
                      {
                        "a": "a2",
                        "b": "b2",
                        "c": "c2",
                        "x": "2"
                      },
                      {
                        "a": "a3",
                        "b": "b3",
                        "c": "c3",
                        "x": "3"
                      },
                      {
                        "a": "a4",
                        "b": "b4",
                        "c": "c4",
                        "x": "4"
                      }
                    ]
                  },
                  {
                    "name": "a",
                    "label": "A"
                  },
                  {
                    "name": "b",
                    "label": "B"
                  },
                  {
                    "name": "c",
                    "label": "C"
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  ]
}

有问题再开,这个 issue 先关了

2betop avatar Jun 15 '23 01:06 2betop