Open fengwenyi opened 1 week ago
同问
在 useModalInner
这个函数里面,使用 updateSchema
,如下示例:
const [registerForm, { updateSchema, validate }] = useForm({
name: 'attr_relation_form',
schemas: schemas,
})
const [register, { modalLoading, closeModal }] = useModalInner(async data => {
modalLoading(true)
const { attrGroupId } = data
attrGroupIdRef.value = attrGroupId
await updateSchema({
field: 'attrId',
componentProps: {
params: { attrGroupId: attrGroupId },
api: AttrGroupApi.getUnallocatedAttrs,
afterFetch: data => {
data.forEach(item => {
item.attrId = item.attrId.toString()
})
return data
},
},
})
modalLoading(false)
})
Subject of the feature
在 FormSchema 中使用 ApiSelect 组件,params赋值的问题
Problem
我在 x.data.ts 定义了 FormSchema,如下:
export const formAddSchema: FormSchema[] = [ { field: 'companyCode', label: '公司', component: 'ApiSelect', componentProps: { api: companyGetOptionListApi, labelField: 'companyName', valueField: 'companyCode', }, }, { field: 'designerId', label: '设计师', component: 'ApiSelect', componentProps: { api: teamGetOptionListApi, params: { companyCode: '', type: 'designer' }, labelField: 'name', valueField: 'id', }, } ];
查询 designerId 的选项值时,需要参数 companyCode,如何获取 companyCode 的值
export const formUpdateSchema: FormSchema[] = [ { field: 'designerId', label: '设计师', component: 'ApiSelect', componentProps: { api: teamGetOptionListApi, params: { companyCode: '', type: 'designer' }, labelField: 'name', valueField: 'id', }, } ];
这个是一个 修改弹窗,点击修改某条数据时,会弹出,我的需求是,查询 designerId 的选项值时,需要参数 companyCode,如何获取 这条数据的 companyCode 的值。
附,完整示例代码
demo.data.ts
代码:DemoModal.vue
index.vue
Expected behaviour
在新增组件时,获取填写的值; 在修改组件时,获取数据字段值。
Alternatives
What are the alternative solutions? Please describe what else you have considered?