feat: Select defaultValue

pull/19/head
xingyu 2023-05-24 15:14:40 +08:00
parent f4e9d2f5e2
commit d8312d57c5
5 changed files with 48 additions and 26 deletions

View File

@ -130,16 +130,14 @@ export const importTableSearchFormSchema: FormSchema[] = [
{ {
label: '数据源', label: '数据源',
field: 'dataSourceConfigId', field: 'dataSourceConfigId',
component: 'ApiSelect', component: 'Select',
componentProps: ({ formModel }) => { required: true,
return { defaultValue: dataSourceConfigs[0].id,
api: async () => { componentProps: {
const res = await getDataSourceConfigList() options: dataSourceConfigs,
formModel.dataSourceConfigId = res[0].id fieldNames: {
return res label: 'name',
}, value: 'id'
labelField: 'name',
valueField: 'id'
} }
}, },
colProps: { span: 8 } colProps: { span: 8 }

View File

@ -11,15 +11,21 @@ import { getSimpleAccounts } from '@/api/mp/account'
import { deleteFreePublish, getFreePublishPage } from '@/api/mp/freePublish' import { deleteFreePublish, getFreePublishPage } from '@/api/mp/freePublish'
import { FormSchema } from '@/components/Form' import { FormSchema } from '@/components/Form'
const simpleAccountsOptinos = await getSimpleAccounts()
const searchSchema: FormSchema[] = [ const searchSchema: FormSchema[] = [
{ {
label: '公众号', label: '公众号',
field: 'accountId', field: 'accountId',
component: 'ApiSelect', component: 'Select',
required: true,
defaultValue: simpleAccountsOptinos[0].id,
componentProps: { componentProps: {
api: () => getSimpleAccounts(), options: simpleAccountsOptinos,
labelField: 'name', fieldNames: {
valueField: 'id' label: 'name',
value: 'id'
}
}, },
colProps: { span: 8 } colProps: { span: 8 }
} }

View File

@ -103,15 +103,21 @@ export const columns: BasicColumn[] = [
} }
] ]
const simpleAccountsOptinos = await getSimpleAccounts()
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: '公众号', label: '公众号',
field: 'accountId', field: 'accountId',
component: 'ApiSelect', component: 'Select',
required: true,
defaultValue: simpleAccountsOptinos[0].id,
componentProps: { componentProps: {
api: () => getSimpleAccounts(), options: simpleAccountsOptinos,
labelField: 'name', fieldNames: {
valueField: 'id' label: 'name',
value: 'id'
}
}, },
colProps: { span: 8 } colProps: { span: 8 }
}, },

View File

@ -27,15 +27,21 @@ export const columns: BasicColumn[] = [
} }
] ]
const simpleAccountsOptinos = await getSimpleAccounts()
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: '公众号', label: '公众号',
field: 'accountId', field: 'accountId',
component: 'ApiSelect', component: 'Select',
required: true,
defaultValue: simpleAccountsOptinos[0].id,
componentProps: { componentProps: {
api: () => getSimpleAccounts(), options: simpleAccountsOptinos,
labelField: 'name', fieldNames: {
valueField: 'id' label: 'name',
value: 'id'
}
}, },
colProps: { span: 8 } colProps: { span: 8 }
}, },

View File

@ -49,15 +49,21 @@ export const columns: BasicColumn[] = [
} }
] ]
const simpleAccountsOptinos = await getSimpleAccounts()
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: '公众号', label: '公众号',
field: 'accountId', field: 'accountId',
component: 'ApiSelect', component: 'Select',
required: true,
defaultValue: simpleAccountsOptinos[0].id,
componentProps: { componentProps: {
api: () => getSimpleAccounts(), options: simpleAccountsOptinos,
labelField: 'name', fieldNames: {
valueField: 'id' label: 'name',
value: 'id'
}
}, },
colProps: { span: 8 } colProps: { span: 8 }
}, },