From b138e57752d6f14b1d93764e5b7dac634d8d94bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8C=E6=B5=B7?= <14166000+zhangtonghai@user.noreply.gitee.com> Date: Wed, 15 May 2024 16:39:49 +0800 Subject: [PATCH] =?UTF-8?q?ConfigForm=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ConfigForm/index.vue | 56 ++++++++++++------- .../seaexport/detail/modules/basicInfo.vue | 27 +++++++++ 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/src/components/ConfigForm/index.vue b/src/components/ConfigForm/index.vue index 373f5737..7daf0e03 100644 --- a/src/components/ConfigForm/index.vue +++ b/src/components/ConfigForm/index.vue @@ -38,31 +38,46 @@ type: Array, default: () => { return [] - } + }, }, // 表单id id: { type: String, - default: '' + default: '', }, // 表单名称 name: { type: String, - default: '' - } + default: '', + }, + isTransfer: { + type: Boolean, + default: false, + }, }, - setup(props) { + emits: ['TransferData'], + setup(props, context) { const { t } = useI18n() // 添加表单到表单设置 const addFormToSet = () => { - const columns = props.formSchema.map((item: FormSchema) => { + if (props.isTransfer) { + context.emit('TransferData') + } else { + FnaddFormToSet(null) + } + } + const FnaddFormToSet = (e) => { + let data: any = e ? e : props.formSchema + console.log(data) + + const columns = data.map((item: FormSchema) => { const res = { defaultValue: item.defaultValue || '', field: item.field || '', label: item.label || '', required: item.required || false, colProps: item.colProps || { span: 24 }, - component: item.component + component: item.component, } // 定义默认显示字段 if (item.show !== false) { @@ -80,22 +95,25 @@ templateName: props.name, permissionName: permissionsInfo().permissionName, content: JSON.stringify({ - columns: columns - }) + columns: columns, + }), } - editCodeGoodsType(Apidata).then(res => { - if (res.succeeded) { - createMessage.success('添加成功!') - } - }).catch(() => { - createMessage.error('添加失败!') - }) + editCodeGoodsType(Apidata) + .then((res) => { + if (res.succeeded) { + createMessage.success('添加成功!') + } + }) + .catch(() => { + createMessage.error('添加失败!') + }) } return { t, - addFormToSet + addFormToSet, + FnaddFormToSet, } - } + }, }) @@ -103,4 +121,4 @@ .config-form { cursor: pointer; } - \ No newline at end of file + diff --git a/src/views/operation/seaexport/detail/modules/basicInfo.vue b/src/views/operation/seaexport/detail/modules/basicInfo.vue index 315c3165..25ec1235 100644 --- a/src/views/operation/seaexport/detail/modules/basicInfo.vue +++ b/src/views/operation/seaexport/detail/modules/basicInfo.vue @@ -2,6 +2,15 @@