Commit 221cbac2 authored by 武广's avatar 武广

fix: 修改拉取JD图片页面奔溃问题

parent 3cc33d48
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
import React, { useState, useEffect, useContext, forwardRef, useImperativeHandle } from 'react'; import React, { useState, useEffect, useContext, forwardRef, useImperativeHandle } from 'react';
import { Form, Button } from 'antd'; import { Form, Button } from 'antd';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
...@@ -69,6 +71,11 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -69,6 +71,11 @@ const FormRuleVPictures = forwardRef((props, ref) => {
onCheck, onCheck,
setFieldsValue: obj => { setFieldsValue: obj => {
setDetailImageList(obj.detailImageList || []); setDetailImageList(obj.detailImageList || []);
for (const key in obj.imageList) {
if (!obj.imageList[key]) {
obj.imageList[key] = [];
}
}
setImageList(obj.imageList || {}); setImageList(obj.imageList || {});
form.setFieldsValue(obj); form.setFieldsValue(obj);
}, },
......
...@@ -163,9 +163,8 @@ const ServiceGoods = options => { ...@@ -163,9 +163,8 @@ const ServiceGoods = options => {
const detailList = result.detailList || []; const detailList = result.detailList || [];
const newImageList = imageList[result.firstSpecValue]; const newImageList = imageList[result.firstSpecValue];
const carouseList = result.carouseList || []; const carouseList = result.carouseList || [];
imageList[result.firstSpecValue] = newImageList imageList[result.firstSpecValue] =
? [...newImageList, ...carouseList] (newImageList ? [...newImageList, ...carouseList] : carouseList) || [];
: carouseList;
picturesRef.current.setFieldsValue({ picturesRef.current.setFieldsValue({
imageList, imageList,
detailImageList: [...detailImageList, ...detailList], detailImageList: [...detailImageList, ...detailList],
......
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