Commit 7f667c1b authored by 武广's avatar 武广

fix: 修改初始化属性

parent ac2541f2
...@@ -566,35 +566,46 @@ class goodsManage extends Component { ...@@ -566,35 +566,46 @@ class goodsManage extends Component {
checkInAttrList = id => checkInAttrList = id =>
this.state.categoryAttrs.some(item => item.valueList.some(v => +v.id === +id)); this.state.categoryAttrs.some(item => item.valueList.some(v => +v.id === +id));
// 获取初始化属性数据
getInitAttrValue = (id, supportCustomValue, optionType) => { getInitAttrValue = (id, supportCustomValue, optionType) => {
const skuAttr = this.props.initData.productAttributeApplyList?.productAttributeApplyList || []; const skuAttr = this.props.initData.productAttributeApplyList?.productAttributeApplyList || [];
const v = skuAttr.filter(item => id === item.productAttributeId); const v = skuAttr.filter(item => id === item.productAttributeId);
if (v.length) { if (
const values = v[0].productAttributeApplyValueList.map(attr => { v.length &&
if (+attr.attributeValueId && this.checkInAttrList(attr.attributeValueId)) { v[0].productAttributeApplyValueList &&
return JSON.stringify({ v[0].productAttributeApplyValueList.length
attributeValueId: attr.attributeValueId, ) {
attributeValueName: attr.attributeValueName, const values = [];
}); v[0].productAttributeApplyValueList.forEach(attr => {
if (+attr.attributeValueId) {
if (this.checkInAttrList(attr.attributeValueId)) {
values.push(
JSON.stringify({
attributeValueId: attr.attributeValueId,
attributeValueName: attr.attributeValueName,
}),
);
}
} else {
values.push(attr.attributeValueName);
} }
return attr.attributeValueName; return values;
}); });
if (+supportCustomValue.code === 1 || +optionType.code === 2) { if (+supportCustomValue.code === 1 || +optionType.code === 2) {
return values; return values;
} }
if (v[0].productAttributeApplyValueList.length) { if (v[0].productAttributeApplyValueList.length) {
const atvalue = v[0].productAttributeApplyValueList[0]; const atvalue = v[0].productAttributeApplyValueList[0];
return JSON.stringify({ if (this.checkInAttrList(atvalue.attributeValueId)) {
attributeValueId: atvalue.attributeValueId, return JSON.stringify({
attributeValueName: atvalue.attributeValueName, attributeValueId: atvalue.attributeValueId,
}); attributeValueName: atvalue.attributeValueName,
});
}
} }
return ''; return '';
} }
if (+supportCustomValue.code === 1) { if (+supportCustomValue.code === 1 || +optionType.code === 2) {
return [];
}
if (+optionType.code === 2) {
return []; return [];
} }
return ''; return '';
......
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