Skip to content

Commit 80bd7bd

Browse files
SFantasychenjiahan
andauthored
fix(sku): 修复禁用属性仍会被默认选中的问题 (#11261)
* feat(sku): 支持属性的禁用状态 * fix(sku): 修复禁用属性仍会被默认选中的问题 * chore(sku): drop console Co-authored-by: neverland <[email protected]>
1 parent 207e80c commit 80bd7bd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sku/Sku.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)