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

fix: 修改初始化属性

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