fix: The form must be filled out to trigger verification, and the verification prompt is not eliminated after assignment (#1943)
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

This commit is contained in:
shaohuzhang1 2024-12-30 12:08:28 +08:00 committed by GitHub
parent dad08b9cd7
commit 694b3cd9c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 14 deletions

View File

@ -119,6 +119,7 @@ const to_rule = (rule: any) => {
}
return rule
}
/**
* 校验
*/
@ -127,7 +128,7 @@ const rules = computed(() => {
? props_info.value.rules.map(to_rule)
: {
message: errMsg.value,
trigger: 'blur',
trigger: ['blur', 'change'],
required: props.formfield.required === false ? false : true
}
})

View File

@ -1,7 +1,7 @@
<template>
<div class="radio_content" :style="radioContentStyle">
<el-row :gutter="12" class="w-full">
<template v-for="(item,index) in option_list" :key="index">
<template v-for="(item, index) in option_list" :key="index">
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
<el-card
:key="item.value"
@ -21,9 +21,10 @@
</div>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { computed, ref, inject } from 'vue'
import type { FormField } from '@/components/dynamics-form/type'
import { useFormDisabled } from 'element-plus'
import { useFormDisabled, formItemContextKey } from 'element-plus'
const inputDisabled = useFormDisabled()
const props = defineProps<{
@ -37,11 +38,14 @@ const props = defineProps<{
modelValue?: any
disabled?: boolean
}>()
const elFormItem = inject(formItemContextKey, void 0)
const selected = (activeValue: string | number) => {
emit('update:modelValue', activeValue)
if (elFormItem?.validate) {
elFormItem.validate('change')
}
}
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'change'])
const width = ref<number>()
const radioContentStyle = computed(() => {
if (width.value) {
@ -55,11 +59,7 @@ const radioContentStyle = computed(() => {
}
return {}
})
const resize = (wh: any) => {
if (wh.height) {
width.value = wh.width
}
}
const textField = computed(() => {
return props.formField.text_field ? props.formField.text_field : 'key'
})

View File

@ -12,9 +12,9 @@
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { computed, inject } from 'vue'
import type { FormField } from '@/components/dynamics-form/type'
import { useFormDisabled } from 'element-plus'
import { useFormDisabled, formItemContextKey } from 'element-plus'
const inputDisabled = useFormDisabled()
const props = defineProps<{
formValue?: any
@ -26,9 +26,12 @@ const props = defineProps<{
//
modelValue?: any
}>()
const elFormItem = inject(formItemContextKey, void 0)
const selected = (activeValue: string | number) => {
emit('update:modelValue', activeValue)
if (elFormItem?.validate) {
elFormItem.validate('change')
}
}
const emit = defineEmits(['update:modelValue'])