Commit 8ee7a7c4cb6b898a9ab62dd4586596e5f24893d5
1 parent
fdde9737
perf: auto switch basic configuration form when not validate pass
Showing
1 changed file
with
13 additions
and
8 deletions
@@ -23,6 +23,7 @@ | @@ -23,6 +23,7 @@ | ||
23 | }>(); | 23 | }>(); |
24 | 24 | ||
25 | const emit = defineEmits(['update', 'create', 'register']); | 25 | const emit = defineEmits(['update', 'create', 'register']); |
26 | + const activeKey = ref('basicConfig'); | ||
26 | 27 | ||
27 | const ROUTE = useRoute(); | 28 | const ROUTE = useRoute(); |
28 | 29 | ||
@@ -62,11 +63,15 @@ | @@ -62,11 +63,15 @@ | ||
62 | }; | 63 | }; |
63 | 64 | ||
64 | const handleSubmit = async () => { | 65 | const handleSubmit = async () => { |
65 | - const { getAllDataSourceFieldValue, validate } = unref(basicConfigurationEl)!; | ||
66 | - await validate(); | ||
67 | - const value = getAllDataSourceFieldValue(); | ||
68 | - unref(isEdit) ? handleUpdateComponent(value) : handleAddComponent(value); | ||
69 | - resetForm(); | 66 | + try { |
67 | + const { getAllDataSourceFieldValue, validate } = unref(basicConfigurationEl)!; | ||
68 | + await validate(); | ||
69 | + const value = getAllDataSourceFieldValue(); | ||
70 | + unref(isEdit) ? handleUpdateComponent(value) : handleAddComponent(value); | ||
71 | + resetForm(); | ||
72 | + } catch (error: unknown) { | ||
73 | + if (unref(activeKey) !== 'basicConfig') activeKey.value = 'basicConfig'; | ||
74 | + } | ||
70 | }; | 75 | }; |
71 | 76 | ||
72 | const { calcLayoutInfo } = useCalcGridLayout(); | 77 | const { calcLayoutInfo } = useCalcGridLayout(); |
@@ -132,8 +137,8 @@ | @@ -132,8 +137,8 @@ | ||
132 | @cancel="resetForm" | 137 | @cancel="resetForm" |
133 | > | 138 | > |
134 | <section> | 139 | <section> |
135 | - <Tabs type="card"> | ||
136 | - <Tabs.TabPane key="1" tab="基础配置"> | 140 | + <Tabs v-model:activeKey="activeKey" type="card"> |
141 | + <Tabs.TabPane key="basicConfig" tab="基础配置"> | ||
137 | <BasicConfiguration | 142 | <BasicConfiguration |
138 | ref="basicConfigurationEl" | 143 | ref="basicConfigurationEl" |
139 | :front-id="frontId" | 144 | :front-id="frontId" |
@@ -141,7 +146,7 @@ | @@ -141,7 +146,7 @@ | ||
141 | :defaultConfig="componentDefaultConfig" | 146 | :defaultConfig="componentDefaultConfig" |
142 | /> | 147 | /> |
143 | </Tabs.TabPane> | 148 | </Tabs.TabPane> |
144 | - <Tabs.TabPane key="2" tab="可视化配置"> | 149 | + <Tabs.TabPane key="visualConfig" tab="可视化配置"> |
145 | <VisualConfiguration v-model:value="frontId" @change="handleComponentCheckedChange" /> | 150 | <VisualConfiguration v-model:value="frontId" @change="handleComponentCheckedChange" /> |
146 | </Tabs.TabPane> | 151 | </Tabs.TabPane> |
147 | </Tabs> | 152 | </Tabs> |