refactor: Logic optimization
This commit is contained in:
parent
13390b59c4
commit
849738f0d0
@ -28,24 +28,21 @@ export default class Registry {
|
|||||||
if (this.registry.has(field)) {
|
if (this.registry.has(field)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.registry.set(field, component)
|
this.registry.set(field, component)
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const value = getNested(this.ctx.initialValues, field)
|
||||||
const hasModel = has(component.$options.propsData || {}, 'value')
|
const hasModel = has(component.$options.propsData || {}, 'value')
|
||||||
if (
|
|
||||||
!hasModel &&
|
// @ts-ignore
|
||||||
// @ts-ignore
|
if (!hasModel && this.ctx.hasInitialValue && value !== undefined) {
|
||||||
this.ctx.hasInitialValue &&
|
|
||||||
// @ts-ignore
|
|
||||||
getNested(this.ctx.initialValues, field) !== undefined
|
|
||||||
) {
|
|
||||||
// In the case that the form is carrying an initial value and the
|
// In the case that the form is carrying an initial value and the
|
||||||
// element is not, set it directly.
|
// element is not, set it directly.
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
component.context.model = getNested(this.ctx.initialValues, field)
|
component.context.model = value
|
||||||
} else if (
|
|
||||||
hasModel &&
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
!shallowEqualObjects(component.proxy, getNested(this.ctx.initialValues, field))
|
} else if (hasModel && !shallowEqualObjects(component.proxy, value)) {
|
||||||
) {
|
|
||||||
// In this case, the field is v-modeled or has an initial value and the
|
// In this case, the field is v-modeled or has an initial value and the
|
||||||
// form has no value or a different value, so use the field value
|
// form has no value or a different value, so use the field value
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
Loading…
Reference in New Issue
Block a user