@@ -258,6 +258,7 @@ function mergeObjects(obj1, obj2) {
258
258
// Recursively merge deeply nested objects.
259
259
var preAcc = Object . assign ( { } , obj1 ) ; // Prevent mutation of source object.
260
260
261
+ if ( ! isObject ( obj2 ) ) return preAcc ;
261
262
return Object . keys ( obj2 ) . reduce ( function ( acc , key ) {
262
263
var left = obj1 ? obj1 [ key ] : { } ;
263
264
var right = obj2 [ key ] ;
@@ -415,6 +416,8 @@ var genId = function genIdFn() {
415
416
} ( ) ; // 空对象
416
417
417
418
function isEmptyObject ( obj ) {
419
+ if ( ! obj ) return true ;
420
+
418
421
for ( var key in obj ) {
419
422
if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) {
420
423
return false ;
@@ -9250,27 +9253,27 @@ function computeDefaults(_schema, parentDefaults, rootSchema) {
9250
9253
} ) ;
9251
9254
} else if ( 'oneOf' in schema ) {
9252
9255
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
+ // }
9262
9265
} else if ( 'anyOf' in schema ) {
9263
9266
var _matchSchema = retrieveSchema ( schema . anyOf [ getMatchingOption ( formData , schema . anyOf , rootSchema ) ] , rootSchema , formData ) ;
9264
9267
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
+ // }
9274
9277
} // Not defaults defined for this node, fallback to generic typed ones.
9275
9278
9276
9279
@@ -11435,42 +11438,41 @@ var SelectLinkageField = {
11435
11438
_class4 ;
11436
11439
11437
11440
var curNodePath = this . $props . curNodePath ;
11438
- var pathClassName = nodePath2ClassName ( curNodePath ) ; // object 需要保持原有属性,如果存在原有属性这里单独渲染
11441
+ var pathClassName = nodePath2ClassName ( curNodePath ) ; // is object
11439
11442
11440
- var originVNode = null ;
11441
- var isTypeObject = this . schema . type === 'object' || this . schema . properties ;
11443
+ var isTypeObject = this . schema . type === 'object' || this . schema . properties ; // 选择附加的节点
11442
11444
11443
- if ( isTypeObject && ! isEmptyObject ( this . schema . properties ) ) {
11444
- var _class2 ;
11445
+ var childrenVNodeList = [ this . getSelectBoxVNode ( ) ] ; // 当前option内容
11445
11446
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
11462
11448
11463
11449
if ( curSelectSchema ) {
11464
- // 覆盖父级的属性
11465
11450
var _this$schema = this . schema ,
11466
11451
_this$combiningType = this . combiningType ,
11467
11452
_ref3 = "" . concat ( this . combiningType , "Select" ) ;
11468
11453
_this$schema . properties ;
11469
11454
_this$schema [ _this$combiningType ] ;
11470
11455
_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
11472
11457
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配置,用来支持所有选项的统一配置
11474
11476
// 取出 oneOf anyOf 同级配置,然后再合并到 当前选中的schema中
11475
11477
11476
11478
var userUiOptions = filterObject ( getUiOptions ( {
@@ -11503,6 +11505,31 @@ var SelectLinkageField = {
11503
11505
11504
11506
} )
11505
11507
} ) ) ;
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
+ } ) ;
11506
11533
} // oneOf 校验 VNode
11507
11534
11508
11535
0 commit comments