File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -419,14 +419,22 @@ export default createComponent({
419419 this . selectedProp [ item . k_id ] = selectedProp [ item . k_id ] ;
420420 }
421421 } ) ;
422+
422423 if ( isEmpty ( this . selectedProp ) ) {
423424 this . propList . forEach ( ( item ) => {
424425 // 没有加价的属性,默认选中第一个
425426 if ( item ?. v ?. length > 0 ) {
426427 const { v, k_id } = item ;
427428 const isHasConfigPrice = v . some ( ( i ) => + i . price !== 0 ) ;
429+ // 没有加价属性
428430 if ( ! isHasConfigPrice ) {
429- this . selectedProp [ k_id ] = [ v [ 0 ] . id ] ;
431+ // 找到第一个不被禁用的属性
432+ // 历史如果没有 text_status 字段的,就相当于沿用直接原来的逻辑取第一个属性
433+ const firstEnableProp = v . find ( ( prop ) => prop . text_status !== 0 ) ;
434+
435+ if ( firstEnableProp ) {
436+ this . selectedProp [ k_id ] = [ firstEnableProp . id ] ;
437+ }
430438 }
431439 }
432440 } ) ;
You can’t perform that action at this time.
0 commit comments