pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

👑 [功能] 两个嵌套的 ProFormList,内层 ProFormList 的 ProFormSelect 如何监听外层 ProFormList下 ProFormSelect 改变动态获取opitons

Open cuijiudai opened this issue 3 years ago • 2 comments
trafficstars

🔩 所属模块或组件

pro-form

🥰 需求描述

两个嵌套的 ProFormList,内层 ProFormList 的 ProFormSelect 如何监听外层 ProFormList下 ProFormSelect 改变,监听到改变或,内层ProFormSelect 重新调用request重置options。

我有两个嵌套的 ProFormList,大体如下结构

 ProFormList
     A 
     ProFormList
          B (依赖A)

B需要根据A的选择动态获取 options。 请问B 的 dependencies 如何写 ?或者不用 dependencies 如何做?

        <ProFormList
          name="swaggerApis"
          min={0}
          initialValue={[]}
          creatorRecord={{ appId: '' }}
          creatorButtonProps={{
            creatorButtonText: '添加服务',
          }}
        >
          <ProFormSelect
            options={apps}
            fieldProps={{
              fieldNames: { label: 'appName', value: 'appId' },
            }}
            name="appId"
            label={'服务'}
          />
          <ProFormList
            name="swaggerApiVOList"
            label=""
            min={1}
            creatorButtonProps={{
              creatorButtonText: '添加地址',
              icon: false,
              type: 'link',
              style: { width: 'unset', float: 'right', paddingRight: 0 },
            }}
            initialValue={[
              {
                uri: '',
              },
            ]}
          >
            <ProFormSelect
              labelCol={{ style: { width: '115px' } }}
              dependencies={['swaggerApis']}
              fieldProps={{
                fieldNames: { label: 'uri', value: 'uri' },
              }}
              name="uri"
              rules={[
                {
                  required: true,
                },
              ]}
              request={async (deps) => {
                //TODO 联动请求
                debugger;
              }}
              label={'接口地址'}
            />
          </ProFormList>
        </ProFormList>

版本信息

Pro-form "1.68.2" 浏览器环境 chrome 96.0.4664.45(正式版本) (x86_64) 开发环境 macOS 12.2.1

🚑 其他信息

WX20220531-173755

cuijiudai avatar May 31 '22 10:05 cuijiudai

@chenshuai2144 是不是不支持啊?

cuijiudai avatar Jun 01 '22 03:06 cuijiudai

同问,用dependencies该怎么写?我目前是用的params

slzll avatar Sep 26 '22 06:09 slzll

你们解决了吗?

buxinren avatar Dec 01 '22 07:12 buxinren

dependencies 估计写不出来,因为 proformlist的name过于复杂。你可以监听整个 formlist 然后里面做判断

chenshuai2144 avatar Jan 08 '23 09:01 chenshuai2144