Commit 1d2f86f1 authored by 武广's avatar 武广

fix: 修改添加商品没有属性报错问题

parent 36d460ca
......@@ -420,29 +420,31 @@ class goodsManage extends Component {
}
});
const attributeApplyList = [];
values.attributeApplyList.forEach(item => {
const key = Object.keys(item)[0];
let attrs = item[key];
if (Array.isArray(item[key])) {
attrs = item[key].map(attr => {
if (values.attributeApplyList && values.attributeApplyList.length) {
values.attributeApplyList.forEach(item => {
const key = Object.keys(item)[0];
let attrs = item[key];
if (Array.isArray(item[key])) {
attrs = item[key].map(attr => {
try {
return JSON.parse(attr);
} catch {
return { attributeValueName: attr };
}
});
} else {
try {
return JSON.parse(attr);
attrs = [JSON.parse(item[key])];
} catch {
return { attributeValueName: attr };
attrs = [{ attributeValueName: item[key] }];
}
});
} else {
try {
attrs = [JSON.parse(item[key])];
} catch {
attrs = [{ attributeValueName: item[key] }];
}
}
attributeApplyList.push({
attributeId: key.replace('attr', ''),
attributeApplyValueList: attrs,
attributeApplyList.push({
attributeId: key.replace('attr', ''),
attributeApplyValueList: attrs,
});
});
});
}
await this.setState(prev => ({
confirmLoading: true,
createData: {
......@@ -859,6 +861,7 @@ class goodsManage extends Component {
})(
<Select
mode={this.getMode(k.supportCustomValue, k.optionType)}
maxTagTextLength={8}
allowClear
>
{k.valueList &&
......
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