amis icon indicating copy to clipboard operation
amis copied to clipboard

向导组件(wizard)如何把第一步表单提交的接口返回值传给下一步的表单使用

Open ChenSen5 opened this issue 7 years ago • 7 comments

wizard有两步 第一步是一个form表单的,保存并一下会发起接口请求, 现在期望在第二步的时候可以从第一步的接口返回值中取值出来显示。我需要怎么获取?

ChenSen5 avatar Oct 16 '19 13:10 ChenSen5

这是默认行为,本来就是这样,如果你发现不对,那应该是字段没配置上。

2betop avatar Oct 16 '19 13:10 2betop

如果上个接口返回的data不是个对象,就是个字符串的话就取不到了。

ChenSen5 avatar Oct 16 '19 13:10 ChenSen5

对,必须是对象

2betop avatar Oct 16 '19 13:10 2betop

好的,看来我要明天再试试

ChenSen5 avatar Oct 16 '19 13:10 ChenSen5

@2betop 如果表单A的target 指向 Wizard 的 name , 可以用表单A的字段作为 Wizard 的 initApi 的参数吗?或者Wizard 的 steps[x].initApi 的参数?

icodingx avatar Jan 05 '20 04:01 icodingx

貌似还没加这个逻辑,我今天晚些时候添加。

2betop avatar Jan 06 '20 02:01 2betop

如果表单A的target 指向 Wizard 的 name , 可以用表单A的字段作为 Wizard 的 initApi 的参数吗?或者Wizard 的 steps[x].initApi 的参数?

@icodingx Wizard 的 initApi 的参数貌似已经实现了。 Wizard 的 steps[x].initApi参数用__super.xxx也可以实现

{
  $schema: 'https://houtai.baidu.com/v2/schemas/page.json#',
  title: '表单向导',
  body: [
    {
      type: 'wizard',
      name: 'test',
      initApi: '/api/mock2/form/initData?waitSeconds=1&name=${test1}',
      steps: [
        {
          title: '第一步',
          controls: [
            {
              name: 'author',
              label: '作者',
              type: 'text',
            },
            {
              name: 'email',
              label: '邮箱',
              type: 'email',
            }
          ],
          api: {
              url: '/api/mock2/form/saveForm?waitSeconds=2',
              method: 'post'
          },
          target: 'test'
        },
        {
          title: '第二步',
          controls: [
            {
              name: 'test1',
              type: 'email',
              label: 'Email',
              value: '[email protected]'
            },
            {
              type: 'divider'
            },
            {
              type: 'text',
              name: 'id',
              label: '必填示例1133',
              required: true
            },
            {
              type: 'divider'
            },
            {
              type: 'text',
              name: 'test3',
              placeholder: '可选'
            }
          ],
          initApi: '/api/mock2/form/initForm?id=${__super.email}',
          api: '/api/mock2/form/saveForm?waitSeconds=2'
        },
        {
          title: '确定',
          controls: ['最后一步了,确认要提交吗?'],
          api: '/api/mock2/form/saveForm?waitSeconds=2'
        }
      ]
    }
  ]
};

rudyxu1102 avatar Feb 02 '20 09:02 rudyxu1102