Commit a9e8af17 authored by 张子雨's avatar 张子雨

feat: 修改数据结构

parent b51bead2
...@@ -333,6 +333,7 @@ class goodsManage extends Component { ...@@ -333,6 +333,7 @@ class goodsManage extends Component {
const { const {
form: { validateFields }, form: { validateFields },
initData, initData,
specListData,
} = this.props; } = this.props;
const { editData, productType } = this.state; const { editData, productType } = this.state;
...@@ -357,6 +358,15 @@ class goodsManage extends Component { ...@@ -357,6 +358,15 @@ class goodsManage extends Component {
notification.error({ message: '滑动图不全,请检查!' }); notification.error({ message: '滑动图不全,请检查!' });
return; return;
} }
const specs = [];
specListData.forEach(item => {
if (values.hasOwnProperty(item.specId)) {
specs.push({
specId: item.specId,
specValues: values[item.specId] || [],
});
}
});
await this.setState(prev => ({ await this.setState(prev => ({
confirmLoading: true, confirmLoading: true,
createData: { createData: {
...@@ -370,6 +380,7 @@ class goodsManage extends Component { ...@@ -370,6 +380,7 @@ class goodsManage extends Component {
categoryId: prev.categoryId ? prev.categoryId : initData?.thirdCategoryId, categoryId: prev.categoryId ? prev.categoryId : initData?.thirdCategoryId,
// productType: values.productType, // productType: values.productType,
type: values.productType, type: values.productType,
specs,
}, },
})); }));
const data = initData.id const data = initData.id
...@@ -448,23 +459,7 @@ class goodsManage extends Component { ...@@ -448,23 +459,7 @@ class goodsManage extends Component {
}; };
render() { render() {
// specListData
const { visible, form, initData = {}, treeData, virtualTreeData, specListData } = this.props; const { visible, form, initData = {}, treeData, virtualTreeData, specListData } = this.props;
// const specListData = [{
// "specName": "服务",
// "specId":"services",
// "specValues": [
// {
// "value": 1,
// "label": "七天无理由退货"
// },
// {
// "value": 2,
// "label": "2222"
// }
// ]
// }
// ]
const isEdit = Object.keys(initData).length !== 0; const isEdit = Object.keys(initData).length !== 0;
// 是否仅编辑卖点和服务 // 是否仅编辑卖点和服务
const isService = initData.state !== 4; const isService = initData.state !== 4;
...@@ -642,7 +637,7 @@ class goodsManage extends Component { ...@@ -642,7 +637,7 @@ class goodsManage extends Component {
</Col> </Col>
<Col span={24}> <Col span={24}>
<FormItem label="商品卖点" labelCol={{ span: 2 }}> <FormItem label="商品卖点" labelCol={{ span: 2 }}>
{getFieldDecorator('name', { {getFieldDecorator('character', {
initialValue: initData.character, initialValue: initData.character,
})( })(
<Input <Input
......
...@@ -131,6 +131,9 @@ class goodsManage extends Component { ...@@ -131,6 +131,9 @@ class goodsManage extends Component {
} }
}); });
data.specs.forEach(item => {
data[item.specId] = item.specValues;
});
data.imageList = []; data.imageList = [];
data.carouseList.forEach(i => { data.carouseList.forEach(i => {
data.imageList[`${i.specValue}`] = i.skuSpecImageList || []; data.imageList[`${i.specValue}`] = i.skuSpecImageList || [];
...@@ -244,6 +247,23 @@ class goodsManage extends Component { ...@@ -244,6 +247,23 @@ class goodsManage extends Component {
if (data.code === '0000' && data.data.length) { if (data.code === '0000' && data.data.length) {
this.setState({ specListData: data.data }); this.setState({ specListData: data.data });
} }
const specListData = [
{
specName: '服务',
specId: 'services',
specValues: [
{
value: 1,
label: '七天无理由退货',
},
{
value: 2,
label: '2222',
},
],
},
];
this.setState({ specListData });
}; };
render() { render() {
......
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