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 | 23 | }>(); |
| 24 | 24 | |
| 25 | 25 | const emit = defineEmits(['update', 'create', 'register']); |
| 26 | + const activeKey = ref('basicConfig'); | |
| 26 | 27 | |
| 27 | 28 | const ROUTE = useRoute(); |
| 28 | 29 | |
| ... | ... | @@ -62,11 +63,15 @@ |
| 62 | 63 | }; |
| 63 | 64 | |
| 64 | 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 | 77 | const { calcLayoutInfo } = useCalcGridLayout(); |
| ... | ... | @@ -132,8 +137,8 @@ |
| 132 | 137 | @cancel="resetForm" |
| 133 | 138 | > |
| 134 | 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 | 142 | <BasicConfiguration |
| 138 | 143 | ref="basicConfigurationEl" |
| 139 | 144 | :front-id="frontId" |
| ... | ... | @@ -141,7 +146,7 @@ |
| 141 | 146 | :defaultConfig="componentDefaultConfig" |
| 142 | 147 | /> |
| 143 | 148 | </Tabs.TabPane> |
| 144 | - <Tabs.TabPane key="2" tab="可视化配置"> | |
| 149 | + <Tabs.TabPane key="visualConfig" tab="可视化配置"> | |
| 145 | 150 | <VisualConfiguration v-model:value="frontId" @change="handleComponentCheckedChange" /> |
| 146 | 151 | </Tabs.TabPane> |
| 147 | 152 | </Tabs> | ... | ... |