@@ -258,6 +258,7 @@ function mergeObjects(obj1, obj2) {
258258 // Recursively merge deeply nested objects.
259259 var preAcc = Object . assign ( { } , obj1 ) ; // Prevent mutation of source object.
260260
261+ if ( ! isObject ( obj2 ) ) return preAcc ;
261262 return Object . keys ( obj2 ) . reduce ( function ( acc , key ) {
262263 var left = obj1 ? obj1 [ key ] : { } ;
263264 var right = obj2 [ key ] ;
@@ -415,6 +416,8 @@ var genId = function genIdFn() {
415416} ( ) ; // 空对象
416417
417418function isEmptyObject ( obj ) {
419+ if ( ! obj ) return true ;
420+
418421 for ( var key in obj ) {
419422 if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) {
420423 return false ;
@@ -9250,27 +9253,27 @@ function computeDefaults(_schema, parentDefaults, rootSchema) {
92509253 } ) ;
92519254 } else if ( 'oneOf' in schema ) {
92529255 var matchSchema = retrieveSchema ( schema . oneOf [ getMatchingOption ( formData , schema . oneOf , rootSchema ) ] , rootSchema , formData ) ;
9253-
9254- if ( schema . properties && matchSchema . properties ) {
9255- // 对象 oneOf 需要合并原属性和 oneOf 属性
9256- var mergeSchema = mergeObjects ( schema , matchSchema ) ;
9257- delete mergeSchema . oneOf ;
9258- schema = mergeSchema ;
9259- } else {
9260- schema = matchSchema ;
9261- }
9256+ schema = mergeObjects ( schema , matchSchema ) ;
9257+ delete schema . oneOf ; // if (schema.properties && matchSchema.properties) {
9258+ // // 对象 oneOf 需要合并原属性和 oneOf 属性
9259+ // const mergeSchema = mergeObjects(schema, matchSchema);
9260+ // delete mergeSchema.oneOf;
9261+ // schema = mergeSchema;
9262+ // } else {
9263+ // schema = matchSchema;
9264+ // }
92629265 } else if ( 'anyOf' in schema ) {
92639266 var _matchSchema = retrieveSchema ( schema . anyOf [ getMatchingOption ( formData , schema . anyOf , rootSchema ) ] , rootSchema , formData ) ;
92649267
9265- if ( schema . properties && _matchSchema . properties ) {
9266- // 对象 anyOf 需要合并原属性和 anyOf 属性
9267- var _mergeSchema = mergeObjects ( schema , _matchSchema ) ;
9268-
9269- delete _mergeSchema . anyOf ;
9270- schema = _mergeSchema ;
9271- } else {
9272- schema = _matchSchema ;
9273- }
9268+ schema = mergeObjects ( schema , _matchSchema ) ;
9269+ delete schema . anyOf ; // if (schema.properties && matchSchema.properties) {
9270+ // // 对象 anyOf 需要合并原属性和 anyOf 属性
9271+ // const mergeSchema = mergeObjects(schema, matchSchema);
9272+ // delete mergeSchema .anyOf;
9273+ // schema = mergeSchema ;
9274+ // } else {
9275+ // schema = matchSchema ;
9276+ // }
92749277 } // Not defaults defined for this node, fallback to generic typed ones.
92759278
92769279
@@ -11435,42 +11438,41 @@ var SelectLinkageField = {
1143511438 _class4 ;
1143611439
1143711440 var curNodePath = this . $props . curNodePath ;
11438- var pathClassName = nodePath2ClassName ( curNodePath ) ; // object 需要保持原有属性,如果存在原有属性这里单独渲染
11441+ var pathClassName = nodePath2ClassName ( curNodePath ) ; // is object
1143911442
11440- var originVNode = null ;
11441- var isTypeObject = this . schema . type === 'object' || this . schema . properties ;
11443+ var isTypeObject = this . schema . type === 'object' || this . schema . properties ; // 选择附加的节点
1144211444
11443- if ( isTypeObject && ! isEmptyObject ( this . schema . properties ) ) {
11444- var _class2 ;
11445+ var childrenVNodeList = [ this . getSelectBoxVNode ( ) ] ; // 当前option内容
1144511446
11446- var origSchema = Object . assign ( { } , this . schema ) ;
11447- delete origSchema [ this . combiningType ] ;
11448- originVNode = h ( SchemaField , {
11449- key : "origin_" . concat ( this . combiningType ) ,
11450- class : ( _class2 = { } , _defineProperty ( _class2 , "" . concat ( this . combiningType , "_originBox" ) , true ) , _defineProperty ( _class2 , "" . concat ( pathClassName , "-originBox" ) , true ) , _class2 ) ,
11451- props : _objectSpread2 ( _objectSpread2 ( { } , this . $props ) , { } , {
11452- schema : origSchema // needValidFieldGroup: false // 单独校验,这里无需处理
11453-
11454- } )
11455- } ) ;
11456- } // 选择附加的节点
11457-
11458-
11459- var childrenVNodeList = [ this . getSelectBoxVNode ( ) ] ; // 当前选中的 oneOf 附加的节点
11460-
11461- var curSelectSchema = this . selectList [ this . curSelectIndex ] ;
11447+ var curSelectSchema = this . selectList [ this . curSelectIndex ] ; // 当前选中节点合并schema
1146211448
1146311449 if ( curSelectSchema ) {
11464- // 覆盖父级的属性
1146511450 var _this$schema = this . schema ,
1146611451 _this$combiningType = this . combiningType ,
1146711452 _ref3 = "" . concat ( this . combiningType , "Select" ) ;
1146811453 _this$schema . properties ;
1146911454 _this$schema [ _this$combiningType ] ;
1147011455 _this$schema [ _ref3 ] ;
11471- var parentSchema = _objectWithoutProperties ( _this$schema , [ "properties" , _this$combiningType , _ref3 ] . map ( _toPropertyKey ) ) ;
11456+ var parentSchema = _objectWithoutProperties ( _this$schema , [ "properties" , _this$combiningType , _ref3 ] . map ( _toPropertyKey ) ) ; // 合并父级schema
1147211457
11473- curSelectSchema = Object . assign ( { } , parentSchema , curSelectSchema ) ; // 当前节点的ui err配置,用来支持所有选项的统一配置
11458+
11459+ curSelectSchema = Object . assign ( { } , parentSchema , curSelectSchema ) ;
11460+ } // object类型但没有附加属性
11461+
11462+
11463+ var isObjectEmptyAttachProperties = isTypeObject && isEmptyObject ( curSelectSchema && curSelectSchema . properties ) ; // 当前选中的 oneOf 附加节点 VNode
11464+
11465+ if ( curSelectSchema && ! isObjectEmptyAttachProperties ) {
11466+ // 覆盖父级的属性
11467+ var _this$schema2 = this . schema ,
11468+ _this$combiningType2 = this . combiningType ,
11469+ _ref4 = "" . concat ( this . combiningType , "Select" ) ;
11470+ _this$schema2 . properties ;
11471+ _this$schema2 [ _this$combiningType2 ] ;
11472+ _this$schema2 [ _ref4 ] ;
11473+ var _parentSchema = _objectWithoutProperties ( _this$schema2 , [ "properties" , _this$combiningType2 , _ref4 ] . map ( _toPropertyKey ) ) ;
11474+
11475+ curSelectSchema = Object . assign ( { } , _parentSchema , curSelectSchema ) ; // 当前节点的ui err配置,用来支持所有选项的统一配置
1147411476 // 取出 oneOf anyOf 同级配置,然后再合并到 当前选中的schema中
1147511477
1147611478 var userUiOptions = filterObject ( getUiOptions ( {
@@ -11503,6 +11505,31 @@ var SelectLinkageField = {
1150311505
1150411506 } )
1150511507 } ) ) ;
11508+ } // object 需要保持原有属性,如果存在原有属性这里单独渲染
11509+
11510+
11511+ var originVNode = null ;
11512+
11513+ if ( isTypeObject && ! isEmptyObject ( this . schema . properties ) ) {
11514+ var _class2 ;
11515+
11516+ var _curSelectSchema = curSelectSchema ;
11517+ _curSelectSchema . title ;
11518+ _curSelectSchema . description ;
11519+ _curSelectSchema . properties ;
11520+ var optionSchema = _objectWithoutProperties ( _curSelectSchema , [ "title" , "description" , "properties" ] ) ; // object 原始项渲染也需要合并anyOf的内容
11521+
11522+
11523+ var origSchema = Object . assign ( { } , this . schema , optionSchema ) ;
11524+ delete origSchema [ this . combiningType ] ;
11525+ originVNode = h ( SchemaField , {
11526+ key : "origin_" . concat ( this . combiningType ) ,
11527+ class : ( _class2 = { } , _defineProperty ( _class2 , "" . concat ( this . combiningType , "_originBox" ) , true ) , _defineProperty ( _class2 , "" . concat ( pathClassName , "-originBox" ) , true ) , _class2 ) ,
11528+ props : _objectSpread2 ( _objectSpread2 ( { } , this . $props ) , { } , {
11529+ schema : origSchema // needValidFieldGroup: false // 单独校验,这里无需处理
11530+
11531+ } )
11532+ } ) ;
1150611533 } // oneOf 校验 VNode
1150711534
1150811535
0 commit comments