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

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

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