Skip to content

Commit

Permalink
fix(form): daterange 错误信息不会消除
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen authored and jia000 committed Jun 9, 2022
1 parent d97e265 commit a90777f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/form/src/containers/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}`);
Expand Down
8 changes: 8 additions & 0 deletions packages/form/src/fields/Daterange.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down

0 comments on commit a90777f

Please sign in to comment.