fix(form): daterange 错误信息不会消除

This commit is contained in:
roymondchen 2022-06-09 20:15:22 +08:00 committed by jia000
parent d97e265444
commit a90777f11a
2 changed files with 21 additions and 2 deletions

View File

@ -32,7 +32,7 @@
<template v-else-if="type && display">
<el-form-item
:style="config.tip ? 'flex: 1' : ''"
:class="{ hidden: itemLabelWidth === 0 || !config.text }"
:class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
:prop="itemProp"
:label-width="itemLabelWidth"
:rules="rule"
@ -154,7 +154,18 @@ export default defineComponent({
const items = computed(() => (props.config as ContainerCommonConfig).items);
const itemProp = computed(() => (name.value ? `${props.prop}${props.prop ? '.' : ''}${name.value}` : props.prop));
const itemProp = computed(() => {
let n: string | number = '';
const { names } = props.config as any;
if (names?.[0]) {
[n] = names;
} else if (name.value) {
n = name.value;
} else {
return props.prop;
}
return `${props.prop}${props.prop ? '.' : ''}${n}`;
});
const tagName = computed(() => {
const component = resolveComponent(`m-${items.value ? 'form' : 'fields'}-${type.value}`);

View File

@ -60,6 +60,14 @@ export default defineComponent({
});
} else if (props.model && props.name && v instanceof Date) {
props.model[props.name] = datetimeFormatter(v.toString(), '');
} else if (names?.length) {
names.forEach((item) => {
if (props.model) {
props.model[item] = undefined;
}
});
} else if (props.name) {
props.model[props.name] = undefined;
}
};