amis 表单提交数据给CRUD组件,如果在CRUD外包裹一个service,功能就不可用了

mnemlml8  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(59)
描述问题:

一个表单提交的数据更新CRUD组件数据刷新,如果表单与CRUD组件同级功能正常可用,如果把CRUD外面包裹一个service,功能就不可用了。

截图或视频:
如何复现(请务必完整填写下面内容):
  1. 你是如何使用 amis 的?
    npm
  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在

"amis": "1.9.1-beta.17"

  1. 粘贴有问题的完整 amis schema 代码:
{
  "type": "page",
  "title": "测试表单提交数据给CRUD",
  "body": [
    {
      "type": "form",
      "title": "表单",
      "body": [
        {
          "type": "input-text",
          "id": "u:e80db48b3773",
          "name": "username",
          "label": "用户名:"
        },
        {
          "type": "submit",
          "label": "搜索",
          "id": "u:548612920241",
          "level": "primary"
        }
      ],
      "id": "u:4fd2ce747d5d",
      "wrapWithPanel": false,
      "mode": "inline",
      "reload": "UserCRUD?username=${username}"
    },
    {
      "type": "service",
      "body": [
        {
          "type": "crud",
          "syncLocation": false,
          "api": {
            "method": "post",
            "url": "/api/userList"
          },
          "columns": [
            {
              "name": "id",
              "label": "ID",
              "type": "text",
              "id": "u:3d06f8bc97c1"
            },
            {
              "name": "username",
              "label": "用户名",
              "type": "text",
              "id": "u:7bf9d1345d89"
            },
            {
              "type": "mapping",
              "label": "会员类型",
              "name": "userType",
              "placeholder": "-",
              "width": 100,
              "source": "${userTypeList}",
              "id": "u:132547d66911"
            }
          ],
          "bulkActions": [
          ],
          "itemActions": [
          ],
          "id": "u:472ecda0a1fa",
          "perPageAvailable": [
            10
          ],
          "name": "UserCRUD"
        }
      ],
      "id": "u:0041f14d7d76",
      "api": {
        "method": "get",
        "url": "/api/userType",
        "responseData": {
          "userTypeList": "${items}"
        }
      }
    }
  ],
  "id": "u:cca29f554324",
  "messages": {
  },
  "pullRefresh": {
  },
  "regions": [
    "body"
  ]
}
  1. 操作步骤
    随便拖一个表单和一个service,service里面再拖一个CRUD,然后把表单提交的数据直接转给CRUD组件
am46iovg

am46iovg1#

我也遇到这个问题了。下面是复现schema

{
  "type": "crud",
  "id": "u:c6b1bdb0bd50",
  "api": {
    "url": "https://aisuda.bce.baidu.com/amis/api/mock2/sample",
    "method": "get"
  },
  "bulkActions": [
  ],
  "itemActions": [
  ],
  "syncLocation": false,
  "filterSettingSource": [
    "id",
    "name",
    "avatar",
    "sex",
    "department_id",
    "created_by",
    "updated_by",
    "status",
    "created_at",
    "updated_at"
  ],
  "placeholder": "-",
  "perPageAvailable": [
    10
  ],
  "messages": {
  },
  "filter": null,
  "mode": "table",
  "columns": [
    {
      "label": "id",
      "type": "text",
      "name": "id",
      "id": "u:ef6d943fc490"
    },
    {
      "label": "name",
      "type": "text",
      "name": "name",
      "id": "u:d5bf10fc76fa"
    },
    {
      "type": "operation",
      "label": "操作",
      "buttons": [
      ],
      "id": "u:70cc39bfc4ff"
    }
  ],
  "headerToolbar": [
    {
      "type": "button",
      "tpl": "内容",
      "label": "搜索侧边栏",
      "actionType": "drawer",
      "drawer": {
        "type": "drawer",
        "title": "弹框标题",
        "body": [
          {
            "type": "form",
            "title": "表单",
            "body": [
              {
                "label": "文本框",
                "type": "input-text",
                "name": "text",
                "id": "u:2187f96f6a51"
              },
              {
                "type": "input-text",
                "label": "文本",
                "name": "text",
                "id": "u:36a467bc802d"
              }
            ],
            "api": "https://aisuda.bce.baidu.com/amis/api/mock2/sample",
            "id": "u:d32ba8d1a1d0",
            "target": "tableCrud"
          }
        ],
        "id": "u:a4ac68136560"
      },
      "id": "u:c6ccbabfae0e"
    }
  ],
  "features": [
  ],
  "filterColumnCount": 3,
  "filterEnabledList": [
    {
      "label": "name",
      "value": "name"
    },
    {
      "label": "sex",
      "value": "sex"
    },
    {
      "label": "department_id",
      "value": "department_id"
    },
    {
      "label": "status",
      "value": "status"
    },
    {
      "label": "id",
      "value": "id"
    }
  ],
  "name": "tableCrud"
}

相关问题