From d8312d57c558770d2172a03489f354bfae1e46ac Mon Sep 17 00:00:00 2001 From: xingyu Date: Wed, 24 May 2023 15:14:40 +0800 Subject: [PATCH] feat: Select defaultValue --- src/views/infra/codegen/codegen.data.ts | 18 ++++++++---------- src/views/mp/freePublish/index.vue | 14 ++++++++++---- src/views/mp/message/message.data.ts | 14 ++++++++++---- src/views/mp/tag/tag.data.ts | 14 ++++++++++---- src/views/mp/user/mpuser.data.ts | 14 ++++++++++---- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/src/views/infra/codegen/codegen.data.ts b/src/views/infra/codegen/codegen.data.ts index b37e57a0..023db72d 100644 --- a/src/views/infra/codegen/codegen.data.ts +++ b/src/views/infra/codegen/codegen.data.ts @@ -130,16 +130,14 @@ export const importTableSearchFormSchema: FormSchema[] = [ { label: '数据源', field: 'dataSourceConfigId', - component: 'ApiSelect', - componentProps: ({ formModel }) => { - return { - api: async () => { - const res = await getDataSourceConfigList() - formModel.dataSourceConfigId = res[0].id - return res - }, - labelField: 'name', - valueField: 'id' + component: 'Select', + required: true, + defaultValue: dataSourceConfigs[0].id, + componentProps: { + options: dataSourceConfigs, + fieldNames: { + label: 'name', + value: 'id' } }, colProps: { span: 8 } diff --git a/src/views/mp/freePublish/index.vue b/src/views/mp/freePublish/index.vue index f292b79a..b352608d 100644 --- a/src/views/mp/freePublish/index.vue +++ b/src/views/mp/freePublish/index.vue @@ -11,15 +11,21 @@ import { getSimpleAccounts } from '@/api/mp/account' import { deleteFreePublish, getFreePublishPage } from '@/api/mp/freePublish' import { FormSchema } from '@/components/Form' +const simpleAccountsOptinos = await getSimpleAccounts() + const searchSchema: FormSchema[] = [ { label: '公众号', field: 'accountId', - component: 'ApiSelect', + component: 'Select', + required: true, + defaultValue: simpleAccountsOptinos[0].id, componentProps: { - api: () => getSimpleAccounts(), - labelField: 'name', - valueField: 'id' + options: simpleAccountsOptinos, + fieldNames: { + label: 'name', + value: 'id' + } }, colProps: { span: 8 } } diff --git a/src/views/mp/message/message.data.ts b/src/views/mp/message/message.data.ts index 81038db9..eebf34a0 100644 --- a/src/views/mp/message/message.data.ts +++ b/src/views/mp/message/message.data.ts @@ -103,15 +103,21 @@ export const columns: BasicColumn[] = [ } ] +const simpleAccountsOptinos = await getSimpleAccounts() + export const searchFormSchema: FormSchema[] = [ { label: '公众号', field: 'accountId', - component: 'ApiSelect', + component: 'Select', + required: true, + defaultValue: simpleAccountsOptinos[0].id, componentProps: { - api: () => getSimpleAccounts(), - labelField: 'name', - valueField: 'id' + options: simpleAccountsOptinos, + fieldNames: { + label: 'name', + value: 'id' + } }, colProps: { span: 8 } }, diff --git a/src/views/mp/tag/tag.data.ts b/src/views/mp/tag/tag.data.ts index 74bcad83..f4a3ac56 100644 --- a/src/views/mp/tag/tag.data.ts +++ b/src/views/mp/tag/tag.data.ts @@ -27,15 +27,21 @@ export const columns: BasicColumn[] = [ } ] +const simpleAccountsOptinos = await getSimpleAccounts() + export const searchFormSchema: FormSchema[] = [ { label: '公众号', field: 'accountId', - component: 'ApiSelect', + component: 'Select', + required: true, + defaultValue: simpleAccountsOptinos[0].id, componentProps: { - api: () => getSimpleAccounts(), - labelField: 'name', - valueField: 'id' + options: simpleAccountsOptinos, + fieldNames: { + label: 'name', + value: 'id' + } }, colProps: { span: 8 } }, diff --git a/src/views/mp/user/mpuser.data.ts b/src/views/mp/user/mpuser.data.ts index 8a5872ee..2b659f92 100644 --- a/src/views/mp/user/mpuser.data.ts +++ b/src/views/mp/user/mpuser.data.ts @@ -49,15 +49,21 @@ export const columns: BasicColumn[] = [ } ] +const simpleAccountsOptinos = await getSimpleAccounts() + export const searchFormSchema: FormSchema[] = [ { label: '公众号', field: 'accountId', - component: 'ApiSelect', + component: 'Select', + required: true, + defaultValue: simpleAccountsOptinos[0].id, componentProps: { - api: () => getSimpleAccounts(), - labelField: 'name', - valueField: 'id' + options: simpleAccountsOptinos, + fieldNames: { + label: 'name', + value: 'id' + } }, colProps: { span: 8 } },