Skip to content

Commit 22c658a

Browse files
fix(lib): 修复 anyOf index change 旧值不匹配不会移除的问题
1 parent 44dd77b commit 22c658a

File tree

2 files changed

+18
-4
lines changed
  • packages/lib
    • vue2/vue2-core/src/fields/combiningSchemas/SelectLinkageField
    • vue3/vue3-core/src/fields/combiningSchemas/SelectLinkageField

2 files changed

+18
-4
lines changed

packages/lib/vue2/vue2-core/src/fields/combiningSchemas/SelectLinkageField/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515

1616
import retrieveSchema from '@lljj/vjsf-utils/schema/retriev';
1717
import getDefaultFormState from '@lljj/vjsf-utils/schema/getDefaultFormState';
18-
import { getMatchingOption } from '@lljj/vjsf-utils/schema/validate';
18+
import { getMatchingOption, isValid } from '@lljj/vjsf-utils/schema/validate';
1919

2020
import vueProps from '../../props';
2121
import Widget from '../../../components/Widget';
@@ -165,7 +165,14 @@ export default {
165165
}
166166
});
167167
} else {
168-
setPathVal(this.rootFormData, this.curNodePath, newOptionData === undefined ? curFormData : newOptionData);
168+
setPathVal(
169+
this.rootFormData,
170+
this.curNodePath,
171+
(newOptionData === undefined && isValid(retrieveSchema(
172+
this.selectList[newVal],
173+
this.rootSchema
174+
), curFormData)) ? curFormData : newOptionData
175+
);
169176
}
170177

171178
// 可添加一个配置通知外部这里变更

packages/lib/vue3/vue3-core/src/fields/combiningSchemas/SelectLinkageField/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717

1818
import retrieveSchema from '@lljj/vjsf-utils/schema/retriev';
1919
import getDefaultFormState from '@lljj/vjsf-utils/schema/getDefaultFormState';
20-
import { getMatchingOption } from '@lljj/vjsf-utils/schema/validate';
20+
import { getMatchingOption, isValid } from '@lljj/vjsf-utils/schema/validate';
2121

2222
import vueProps from '../../props';
2323
import Widget from '../../../components/Widget';
@@ -160,7 +160,14 @@ export default {
160160
}
161161
});
162162
} else {
163-
setPathVal(props.rootFormData, props.curNodePath, newOptionData === undefined ? curFormData : newOptionData);
163+
setPathVal(
164+
props.rootFormData,
165+
props.curNodePath,
166+
(newOptionData === undefined && isValid(retrieveSchema(
167+
props.selectList[newVal],
168+
props.rootSchema
169+
), curFormData)) ? curFormData : newOptionData
170+
);
164171
}
165172
});
166173

0 commit comments

Comments
 (0)