Skip to content

Commit deb71ce

Browse files
Update BasePage.vue
1 parent 2f75b1a commit deb71ce

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

packages/builtinComponent/src/components/BasePage.vue

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
</div>
158158
</template>
159159
<script setup>
160-
import { ref, defineProps, defineEmits, defineExpose, computed, reactive, watch, useAttrs, onMounted } from 'vue'
160+
import { ref, computed, reactive, watch, useAttrs, onMounted } from 'vue'
161161
import {
162162
Form as TinyForm,
163163
FormItem as TinyFormItem,
@@ -220,19 +220,19 @@ const props = defineProps({
220220
type: Object
221221
}
222222
})
223-
224223
const emit = defineEmits(['update:searchFormData', 'update:tableData', 'update:editFormData'])
225224
226225
const formRef = ref(null)
227226
228227
const colNumber = computed(() => 12 / props.layout)
228+
229229
const insideColNumber = computed(() => (props.layout === 1 ? 6 : 12))
230230
231231
const pageModel = computed(() => props.serviceModel)
232232
233-
const formData = ref({})
233+
const formData = ref()
234234
235-
const addFormData = ref({})
235+
const addFormData = ref()
236236
237237
const boxVisibility = ref(false)
238238
@@ -431,7 +431,7 @@ const initEditFormData = () => {
431431
]
432432
})
433433
)
434-
emit('update:editFormData', formData.value)
434+
emit('update:editFormData', addFormData.value)
435435
}
436436
437437
const resetSearchForm = () => {
@@ -478,8 +478,6 @@ watch(
478478
(value) => {
479479
if (value) {
480480
formData.value = props.searchFormData
481-
} else {
482-
initSearchFormData()
483481
}
484482
},
485483
{ deep: true, immediate: true }
@@ -490,13 +488,24 @@ watch(
490488
(value) => {
491489
if (value) {
492490
addFormData.value = props.editFormData
493-
} else {
494-
initEditFormData()
495491
}
496492
},
497493
{ deep: true, immediate: true }
498494
)
499495
496+
watch(
497+
() => props.serviceModel,
498+
() => {
499+
if (!formData.value) {
500+
initSearchFormData()
501+
}
502+
if (!addFormData.value) {
503+
initEditFormData()
504+
}
505+
},
506+
{ immediate: true }
507+
)
508+
500509
onMounted(() => {
501510
queryApi()
502511
})

0 commit comments

Comments
 (0)