perf: 优化Form事件传递

This commit is contained in:
kailong321200875
2023-06-27 09:49:07 +08:00
parent 24c8af9183
commit 69cafb3b7b
6 changed files with 53 additions and 228 deletions

View File

@@ -8,6 +8,7 @@ import { cloneDeep, set } from 'lodash-es'
import { initModel } from '@/components/Form/src/helper'
import ActionButton from './components/ActionButton.vue'
import { SearchProps } from './types'
import { FormItemProp } from 'element-plus'
const props = defineProps({
// 生成Form的布局结构数组
@@ -42,7 +43,7 @@ const props = defineProps({
resetLoading: propTypes.bool.def(false)
})
const emit = defineEmits(['search', 'reset', 'register'])
const emit = defineEmits(['search', 'reset', 'register', 'validate'])
const visible = ref(true)
@@ -214,6 +215,10 @@ onMounted(() => {
})
defineExpose(defaultExpose)
const onFormValidate = (prop: FormItemProp, isValid: boolean, message: string) => {
emit('validate', prop, isValid, message)
}
</script>
<template>
@@ -226,6 +231,7 @@ defineExpose(defaultExpose)
:is-col="getProps.isCol"
:schema="newSchema"
@register="formRegister"
@validate="onFormValidate"
/>
<template v-if="layout === 'bottom'">