updateSchema

const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
        //重置表单
        await resetFields();
        setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter});
        isUpdate.value = !!data?.isUpdate;
        // if (unref(isUpdate)) {
        //     //表单赋值
        //     await setFieldsValue({
        //         ...data.record,
        //     });
        // }

        let campaignId = unref(data?.record.campaignId);
        updateSchema([
            {
                field: 'campaignId',
                componentProps: {
                // 如果是添加子部门,就禁用该字段
                disabled: campaignId,
                },
            }
        ]);
        let record = unref(data?.record);
        // 隐藏底部时禁用整个表单
        if (typeof record !== 'object') {
            record = {};
        }
        //赋默认值
        record = Object.assign(
            record,
            {
                campaignId: data.record.campaignId
            }
        );
        model.value = record;
        await setFieldsValue({ ...record });
        setProps({ disabled: !data?.showFooter })
    //    setProps({ disabled: false })
       
    });
  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据你提供的代码,我看到在 `onChange` 函数中,已经调用了 `optionCityApi` 函数来获取城市列表,并将其赋值给了 `cityList`。然后通过 `updateSchema` 函数更新了 `cityId` 的选项,但是你说无法获取到市关联的列表,可能是因为你没有将 `cityId` 的选项正确地传递给 `Select` 组件。 你可以在 `cityId` 的 `componentProps` 中指定 `options` 为 `componentProps.options`,而不是将其设置为一个空数组。这样,当你更新了 `cityId` 的选项时,`Select` 组件将自动重新渲染,并显示新的选项。你还需要指定 `labelField` 和 `valueField` 属性,以确保正确地显示选项的标签和值。 修改后的代码如下: ``` { label: '省关联', field: 'provinceId', colProps: { span: 12 }, component: 'ApiSelect', componentProps: ({ formActionType }) => { return { api: optionSegmentApi, showSearch: true, optionFilterProp: 'label', resultField: 'items', labelField: 'name', valueField: 'id', onChange: async (e: any) => { const cityList = await optionCityApi(e); const { updateSchema } = formActionType; updateSchema({ field: 'cityId', componentProps: { options: cityList, labelField: 'name', valueField: 'id', }, }); console.log('cityList', cityList); // move the log statement here }, }; }, }, { label: '市关联', field: 'cityId', component: 'Select', componentProps: { showSearch: true, optionFilterProp: 'label', options: [], labelField: 'name', valueField: 'id', }, colProps: { span: 12 }, } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值