amis icon indicating copy to clipboard operation
amis copied to clipboard

input-table如果某列配置了select,确认模式下,点了保存或者编辑后,显示的是select的value值而不是lable

Open africa1207 opened this issue 1 year ago • 2 comments

描述问题:

input-table如果某列配置了select,确认模式下,点了保存或者编辑后,显示的是select的value值而不是lable

截图或视频:

test

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

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

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

    "amis": "^3.4.1",
    "amis-formula": "^3.4.1",
  1. 粘贴有问题的完整 amis schema 代码:
{
  "type": "input-table",
  "name": "table",
  "label": "表格表单",
  "columns": [
    {
      "label": "名称",
      "name": "name",
      "quickEdit": {
        "type": "input-text",
        "name": "name",
        "id": "u:7b4b5e6b46a0"
      },
      "id": "u:1b83b5350ccf"
    },
    {
      "label": "等级",
      "name": "level",
      "quickEdit": {
        "type": "select",
        "name": "level",
        "id": "u:38718c443e28",
        "multiple": false,
        "options": [
          {
            "label": "选项1",
            "value": "1"
          },
          {
            "label": "选项2",
            "value": "2"
          },
          {
            "label": "选项3",
            "value": "3"
          }
        ],
        "value": "",
        "mode": "popOver"
      },
      "id": "u:015f84a09ba3",
      "placeholder": "-"
    }
  ],
  "addable": true,
  "footerAddBtn": {
    "label": "新增",
    "icon": "fa fa-plus",
    "id": "u:01236239ade0"
  },
  "strictMode": true,
  "id": "u:0cefd2266f58",
  "editable": true,
  "removable": true
}

africa1207 avatar Dec 07 '23 06:12 africa1207

求助,升级amis3.6.3问题依旧,给"label": "等级",增加type:"select",可以显示,但是下拉框会一直存在。另外还有个问题,如果下拉框的选项是来源接口,form表单是static,input-table初始化的时候是不会调用获取下拉框接口的,导致给表单默认值的时候下拉框只显示id,代码如下

// form表单值
{
    table:[{name:'testName',level:'1'}]
}
// 下拉框接口返回值
[
          {
            "label": "选项1",
            "value": "1"
          },
          {
            "label": "选项2",
            "value": "2"
          },
          {
            "label": "选项3",
            "value": "3"
          }
        ]
// schema
{
  "type": "input-table",
  "name": "table",
  "label": "表格表单",
  "columns": [
    {
      "label": "名称",
      "name": "name",
      "quickEdit": {
        "type": "input-text",
        "name": "name",
      },
    },
    {
      "label": "等级",
      "name": "level",
        "type": "select",
      "quickEdit": {
        "type": "select",
        "name": "level",
        "multiple": false,
        "source":{
"api":"/api/getOptList"
},
        "mode": "popOver"
      },
      "placeholder": "-"
    }
  ],
  "addable": true,
  "footerAddBtn": {
    "label": "新增",
    "icon": "fa fa-plus",
  },
  "strictMode": true,
  "editable": true,
  "removable": true
}

africa1207 avatar Dec 12 '23 04:12 africa1207

@2betop 呼叫大佬,官网也都有这问题

africa1207 avatar Jan 26 '24 07:01 africa1207

外层用 mapping,因为不设置默认是 text 文本,直接展示对应的 value 值

{
  "type": "page",
  "title": "表单页面",
  "body": [
    {
      "type": "input-table",
      "name": "table",
      "label": "表格表单",
      "columns": [
        {
          "label": "名称",
          "name": "name",
          "quickEdit": {
            "type": "input-text",
            "name": "name",
            "id": "u:7b4b5e6b46a0"
          },
          "id": "u:1b83b5350ccf"
        },
        {
          "label": "等级",
          "name": "level",
          "type": "mapping",
          "map": [
            {
              "label": "选项1",
              "value": "1"
            },
            {
              "label": "选项2",
              "value": "2"
            },
            {
              "label": "选项3",
              "value": "3"
            }
          ],
          "quickEdit": {
            "type": "select",
            "name": "level",
            "id": "u:38718c443e28",
            "multiple": false,
            "options": [
              {
                "label": "选项1",
                "value": "1"
              },
              {
                "label": "选项2",
                "value": "2"
              },
              {
                "label": "选项3",
                "value": "3"
              }
            ],
            "value": "",
            "mode": "popOver"
          },
          "id": "u:015f84a09ba3",
          "placeholder": "-"
        }
      ],
      "addable": true,
      "footerAddBtn": {
        "label": "新增",
        "icon": "fa fa-plus",
        "id": "u:01236239ade0"
      },
      "strictMode": true,
      "id": "u:0cefd2266f58",
      "editable": true,
      "removable": true
    }
  ]
}

2betop avatar Mar 26 '24 12:03 2betop

外层用 mapping,因为不设置默认是 text 文本,直接展示对应的 value 值

{
  "type": "page",
  "title": "表单页面",
  "body": [
    {
      "type": "input-table",
      "name": "table",
      "label": "表格表单",
      "columns": [
        {
          "label": "名称",
          "name": "name",
          "quickEdit": {
            "type": "input-text",
            "name": "name",
            "id": "u:7b4b5e6b46a0"
          },
          "id": "u:1b83b5350ccf"
        },
        {
          "label": "等级",
          "name": "level",
          "type": "mapping",
          "map": [
            {
              "label": "选项1",
              "value": "1"
            },
            {
              "label": "选项2",
              "value": "2"
            },
            {
              "label": "选项3",
              "value": "3"
            }
          ],
          "quickEdit": {
            "type": "select",
            "name": "level",
            "id": "u:38718c443e28",
            "multiple": false,
            "options": [
              {
                "label": "选项1",
                "value": "1"
              },
              {
                "label": "选项2",
                "value": "2"
              },
              {
                "label": "选项3",
                "value": "3"
              }
            ],
            "value": "",
            "mode": "popOver"
          },
          "id": "u:015f84a09ba3",
          "placeholder": "-"
        }
      ],
      "addable": true,
      "footerAddBtn": {
        "label": "新增",
        "icon": "fa fa-plus",
        "id": "u:01236239ade0"
      },
      "strictMode": true,
      "id": "u:0cefd2266f58",
      "editable": true,
      "removable": true
    }
  ]
}

但是下拉选项是接口来的,如何用map进行映射?我目前只能将quickEdit中的options、api这些选项全部复制到外层来,但是会有个问题就是非编辑状态也展示的下拉框,再继续添加static:true,quickEdit中添加static:false也一样

africa1207 avatar Mar 27 '24 07:03 africa1207