Skip to content

Commit 3dce376

Browse files
committed
fix(TAP-7675): improve form handling in Drawer.vue and CreateRestApi.vue
- Updated form initialization logic to use isEmpty check for better clarity. - Simplified data handling by directly using formData in the open method. - Removed unnecessary basePath generation in CreateRestApi.vue for cleaner code.
1 parent bb19b9f commit 3dce376

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

packages/business/src/views/data-server/Drawer.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import InfiniteSelect from '@tap/form/src/components/infinite-select/InfiniteSel
2424
import { useI18n } from '@tap/i18n'
2525
import { uid } from '@tap/shared'
2626
import axios from 'axios'
27-
import { cloneDeep, isEqual, merge } from 'lodash-es'
27+
import { cloneDeep, isEmpty, isEqual, merge } from 'lodash-es'
2828
import {
2929
computed,
3030
inject,
@@ -677,8 +677,6 @@ const getAPIServerToken = async (callback?: (token: string) => void) => {
677677
678678
// Methods
679679
const open = (formData?: any) => {
680-
const originalFormData = formData ? cloneDeep(formData) : {}
681-
682680
tab.value = 'form'
683681
visible.value = true
684682
isEdit.value = false
@@ -688,25 +686,28 @@ const open = (formData?: any) => {
688686
allFields.value = []
689687
workerStatus.value = ''
690688
691-
if (!originalFormData.id) {
689+
if (isEmpty(formData)) {
692690
form.value = getInitData()
693691
form_ref.value?.resetFields()
694692
695693
edit()
696694
} else {
697-
formatData(originalFormData)
695+
formatData(Object.assign(getInitData(), cloneDeep(formData)))
698696
699-
const { connectionId, tableName } = originalFormData
697+
const { connectionId, tableName } = formData
700698
701699
if (connectionId && tableName) {
702700
getFields()
703701
}
702+
703+
if (!formData.id) {
704+
edit()
705+
}
704706
}
705707
706708
getDatabaseTypes()
707709
708710
nextTick(() => {
709-
// form_ref.value?.clearValidate()
710711
containerRef.value?.parentElement?.scrollTo({ top: 0 })
711712
})
712713
}

packages/ldp/src/components/CreateRestApi.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,12 @@ export default {
2727
},
2828
methods: {
2929
open() {
30-
const basePath =
31-
Math.floor(Math.random() * 26 + 10).toString(36) + generateId(10) // 首位要求小写字母
3230
const formData = {
3331
status: 'pending',
34-
basePath,
35-
path: `/api/${basePath}`,
3632
connectionName: this.params.from.name,
3733
connectionType: this.params.from.database_type,
3834
connectionId: this.params.from.id,
3935
tableName: this.params.tableName,
40-
pathAccessMethod: this.data?.pathAccessMethod || 'default',
4136
appValue: this.params.to?.id || '',
4237
appLabel: this.params.to?.value || '',
4338
}

0 commit comments

Comments
 (0)