Commit a3f2cc2d authored by GuanHua's avatar GuanHua

fix: 商品属性选择问题

parent 2b5dc9d5
...@@ -348,7 +348,6 @@ const CommodityDetail = (props) => { ...@@ -348,7 +348,6 @@ const CommodityDetail = (props) => {
setSelectCommodityUnitPriceId(null) setSelectCommodityUnitPriceId(null)
} }
} }
}, [selectAttrVal, commodityDetail]) }, [selectAttrVal, commodityDetail])
/** /**
...@@ -874,15 +873,15 @@ const CommodityDetail = (props) => { ...@@ -874,15 +873,15 @@ const CommodityDetail = (props) => {
return list.some(item => item.id === attrId) return list.some(item => item.id === attrId)
} }
const judgeSelectAttrInList = (list, attrId, key) => { const judgeSelectAttrInList = (list, attrValId, attrId) => {
return list.some(item => item[key] === attrId) return list.some(item => item["attrId"] === attrId && item["attrValId"] === attrValId)
} }
const handleSelectAttrVal = (attrId: number, attrValId: number) => { const handleSelectAttrVal = (attrId: number, attrValId: number) => {
// if (!judgeHasAttr(attrId, attrValId)) { // if (!judgeHasAttr(attrId, attrValId)) {
// return // return
// } // }
if (judgeSelectAttrInList(selectAttrVal, attrId, 'attrId')) { if (selectAttrVal.some(item => item["attrId"] === attrId)) {
const result = [] const result = []
for (const item of selectAttrVal) { for (const item of selectAttrVal) {
if (item.attrId === attrId && item.attrValId !== attrValId) { if (item.attrId === attrId && item.attrValId !== attrValId) {
...@@ -1062,7 +1061,7 @@ const CommodityDetail = (props) => { ...@@ -1062,7 +1061,7 @@ const CommodityDetail = (props) => {
<div <div
key={`product_info_line_list_item_${childItem.id}_${index}`} key={`product_info_line_list_item_${childItem.id}_${index}`}
className={cx(styles.product_info_line_list_item, 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)} > 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