Skip to content

Commit 3287c45

Browse files
committed
fix: The form must be filled out to trigger verification, and the verification prompt is not eliminated after assignment
1 parent ce5bbc1 commit 3287c45

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

ui/src/components/dynamics-form/FormItem.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const to_rule = (rule: any) => {
119119
}
120120
return rule
121121
}
122+
122123
/**
123124
* 校验
124125
*/
@@ -127,7 +128,7 @@ const rules = computed(() => {
127128
? props_info.value.rules.map(to_rule)
128129
: {
129130
message: errMsg.value,
130-
trigger: 'blur',
131+
trigger: ['blur', 'change'],
131132
required: props.formfield.required === false ? false : true
132133
}
133134
})

ui/src/components/dynamics-form/items/radio/RadioCard.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="radio_content" :style="radioContentStyle">
33
<el-row :gutter="12" class="w-full">
4-
<template v-for="(item,index) in option_list" :key="index">
4+
<template v-for="(item, index) in option_list" :key="index">
55
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
66
<el-card
77
:key="item.value"
@@ -21,9 +21,10 @@
2121
</div>
2222
</template>
2323
<script lang="ts" setup>
24-
import { computed, ref } from 'vue'
24+
import { computed, ref, inject } from 'vue'
2525
import type { FormField } from '@/components/dynamics-form/type'
26-
import { useFormDisabled } from 'element-plus'
26+
import { useFormDisabled, formItemContextKey } from 'element-plus'
27+
2728
const inputDisabled = useFormDisabled()
2829
2930
const props = defineProps<{
@@ -37,11 +38,14 @@ const props = defineProps<{
3738
modelValue?: any
3839
disabled?: boolean
3940
}>()
40-
41+
const elFormItem = inject(formItemContextKey, void 0)
4142
const selected = (activeValue: string | number) => {
4243
emit('update:modelValue', activeValue)
44+
if (elFormItem?.validate) {
45+
elFormItem.validate('change')
46+
}
4347
}
44-
const emit = defineEmits(['update:modelValue'])
48+
const emit = defineEmits(['update:modelValue', 'change'])
4549
const width = ref<number>()
4650
const radioContentStyle = computed(() => {
4751
if (width.value) {
@@ -55,11 +59,7 @@ const radioContentStyle = computed(() => {
5559
}
5660
return {}
5761
})
58-
const resize = (wh: any) => {
59-
if (wh.height) {
60-
width.value = wh.width
61-
}
62-
}
62+
6363
const textField = computed(() => {
6464
return props.formField.text_field ? props.formField.text_field : 'key'
6565
})

ui/src/components/dynamics-form/items/radio/RadioRow.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
</div>
1313
</template>
1414
<script lang="ts" setup>
15-
import { computed } from 'vue'
15+
import { computed, inject } from 'vue'
1616
import type { FormField } from '@/components/dynamics-form/type'
17-
import { useFormDisabled } from 'element-plus'
17+
import { useFormDisabled, formItemContextKey } from 'element-plus'
1818
const inputDisabled = useFormDisabled()
1919
const props = defineProps<{
2020
formValue?: any
@@ -26,9 +26,12 @@ const props = defineProps<{
2626
// 选中的值
2727
modelValue?: any
2828
}>()
29-
29+
const elFormItem = inject(formItemContextKey, void 0)
3030
const selected = (activeValue: string | number) => {
3131
emit('update:modelValue', activeValue)
32+
if (elFormItem?.validate) {
33+
elFormItem.validate('change')
34+
}
3235
}
3336
const emit = defineEmits(['update:modelValue'])
3437

0 commit comments

Comments
 (0)