Commit a3f2cc2d authored by GuanHua's avatar GuanHua

fix: 商品属性选择问题

parent 2b5dc9d5
......@@ -348,7 +348,6 @@ const CommodityDetail = (props) => {
setSelectCommodityUnitPriceId(null)
}
}
}, [selectAttrVal, commodityDetail])
/**
......@@ -874,15 +873,15 @@ const CommodityDetail = (props) => {
return list.some(item => item.id === attrId)
}
const judgeSelectAttrInList = (list, attrId, key) => {
return list.some(item => item[key] === attrId)
const judgeSelectAttrInList = (list, attrValId, attrId) => {
return list.some(item => item["attrId"] === attrId && item["attrValId"] === attrValId)
}
const handleSelectAttrVal = (attrId: number, attrValId: number) => {
// if (!judgeHasAttr(attrId, attrValId)) {
// return
// }
if (judgeSelectAttrInList(selectAttrVal, attrId, 'attrId')) {
if (selectAttrVal.some(item => item["attrId"] === attrId)) {
const result = []
for (const item of selectAttrVal) {
if (item.attrId === attrId && item.attrValId !== attrValId) {
......@@ -1062,7 +1061,7 @@ const CommodityDetail = (props) => {
<div
key={`product_info_line_list_item_${childItem.id}_${index}`}
className={cx(styles.product_info_line_list_item,
judgeSelectAttrInList(selectAttrVal, childItem.id, 'attrValId') ? styles.active : '',
judgeSelectAttrInList(selectAttrVal, childItem.id, item.customerAttribute.id) ? styles.active : '',
)}
onClick={() => handleSelectAttrVal(item.customerAttribute.id, childItem.id)} >
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment