fix: The form must be filled out to trigger verification, and the verification prompt is not eliminated after assignment (#1943)
This commit is contained in:
parent
dad08b9cd7
commit
694b3cd9c2
@ -119,6 +119,7 @@ const to_rule = (rule: any) => {
|
|||||||
}
|
}
|
||||||
return rule
|
return rule
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验
|
* 校验
|
||||||
*/
|
*/
|
||||||
@ -127,7 +128,7 @@ const rules = computed(() => {
|
|||||||
? props_info.value.rules.map(to_rule)
|
? props_info.value.rules.map(to_rule)
|
||||||
: {
|
: {
|
||||||
message: errMsg.value,
|
message: errMsg.value,
|
||||||
trigger: 'blur',
|
trigger: ['blur', 'change'],
|
||||||
required: props.formfield.required === false ? false : true
|
required: props.formfield.required === false ? false : true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="radio_content" :style="radioContentStyle">
|
<div class="radio_content" :style="radioContentStyle">
|
||||||
<el-row :gutter="12" class="w-full">
|
<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-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||||
<el-card
|
<el-card
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
@ -21,9 +21,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref, inject } from 'vue'
|
||||||
import type { FormField } from '@/components/dynamics-form/type'
|
import type { FormField } from '@/components/dynamics-form/type'
|
||||||
import { useFormDisabled } from 'element-plus'
|
import { useFormDisabled, formItemContextKey } from 'element-plus'
|
||||||
|
|
||||||
const inputDisabled = useFormDisabled()
|
const inputDisabled = useFormDisabled()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@ -37,11 +38,14 @@ const props = defineProps<{
|
|||||||
modelValue?: any
|
modelValue?: any
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
const elFormItem = inject(formItemContextKey, void 0)
|
||||||
const selected = (activeValue: string | number) => {
|
const selected = (activeValue: string | number) => {
|
||||||
emit('update:modelValue', activeValue)
|
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 width = ref<number>()
|
||||||
const radioContentStyle = computed(() => {
|
const radioContentStyle = computed(() => {
|
||||||
if (width.value) {
|
if (width.value) {
|
||||||
@ -55,11 +59,7 @@ const radioContentStyle = computed(() => {
|
|||||||
}
|
}
|
||||||
return {}
|
return {}
|
||||||
})
|
})
|
||||||
const resize = (wh: any) => {
|
|
||||||
if (wh.height) {
|
|
||||||
width.value = wh.width
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const textField = computed(() => {
|
const textField = computed(() => {
|
||||||
return props.formField.text_field ? props.formField.text_field : 'key'
|
return props.formField.text_field ? props.formField.text_field : 'key'
|
||||||
})
|
})
|
||||||
|
|||||||
@ -12,9 +12,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from 'vue'
|
import { computed, inject } from 'vue'
|
||||||
import type { FormField } from '@/components/dynamics-form/type'
|
import type { FormField } from '@/components/dynamics-form/type'
|
||||||
import { useFormDisabled } from 'element-plus'
|
import { useFormDisabled, formItemContextKey } from 'element-plus'
|
||||||
const inputDisabled = useFormDisabled()
|
const inputDisabled = useFormDisabled()
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
formValue?: any
|
formValue?: any
|
||||||
@ -26,9 +26,12 @@ const props = defineProps<{
|
|||||||
// 选中的值
|
// 选中的值
|
||||||
modelValue?: any
|
modelValue?: any
|
||||||
}>()
|
}>()
|
||||||
|
const elFormItem = inject(formItemContextKey, void 0)
|
||||||
const selected = (activeValue: string | number) => {
|
const selected = (activeValue: string | number) => {
|
||||||
emit('update:modelValue', activeValue)
|
emit('update:modelValue', activeValue)
|
||||||
|
if (elFormItem?.validate) {
|
||||||
|
elFormItem.validate('change')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user