From 1af4c343e69bde50226f89990eae3c6c729cd029 Mon Sep 17 00:00:00 2001 From: Gary Fu Date: Sun, 31 Dec 2023 18:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A1=A8=E5=8D=95=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common-form-control/index.vue | 21 +++++++++- src/services/global/GlobalService.js | 2 +- .../components/global/GlobalSettings.vue | 12 ++---- src/views/tools/Forms.vue | 40 +++++++++++++++++++ 4 files changed, 64 insertions(+), 11 deletions(-) diff --git a/src/components/common-form-control/index.vue b/src/components/common-form-control/index.vue index 83f0720..49f8200 100644 --- a/src/components/common-form-control/index.vue +++ b/src/components/common-form-control/index.vue @@ -78,6 +78,23 @@ const modelValue = computed({ } }) +const childTypeMapping = { // 自动映射子元素类型,配置的时候可以不写type + 'checkbox-group': 'checkbox', + 'radio-group': 'radio', + select: 'option' +} + +const children = computed(() => { + const option = props.option + const result = option.children || [] // 初始化一些默认值 + result.forEach(childItem => { + if (!childItem.type) { + childItem.type = childTypeMapping[option.type] + } + }) + return result +}) +