import React, { memo, RefObject, useEffect } from 'react'; import { Form } from '@ant-design/compatible'; import '@ant-design/compatible/assets/index.css'; import { Select, InputNumber, Input, Switch, Radio } from 'antd'; import Upload from './FormComponents/Upload'; import DataList from './FormComponents/DataList'; import ImageSource from './FormComponents/ImageSource'; import ImageListJustOne from './FormComponents/ImageListJustOne'; import MutiText from './FormComponents/MutiText'; import Color from './FormComponents/Color'; import CardPicker from './FormComponents/CardPicker'; import Table from './FormComponents/Table'; import Pos from './FormComponents/Pos'; import { Store } from 'antd/lib/form/interface'; import RichText from './FormComponents/XEditor'; import FormItems from './FormComponents/FormItems'; import ImageList from './FormComponents/ImageList'; import ImageList1 from './FormComponents/ImageList1'; import ProductList from './FormComponents/ProductList'; import { useParams } from 'react-router'; import { getUrlParamByKey } from 'editorUtils'; import ChooseCoupon from './FormComponents/ChooseCoupon'; import CouponTemplate from 'editorComponents/BasicShop/BasicComponents/CouponTemplate'; import CouponTemplateType from './FormComponents/CouponTemplateType'; import ModuleList from './FormComponents/ModuleList'; const normFile = (e: any) => { // console.log('Upload event:', e); if (Array.isArray(e)) { //待修改 return e; } return e && e.fileList; }; const { Option } = Select; const { TextArea } = Input; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 }, }; interface FormEditorProps { uid: string; onSave: Function; onDel: Function; defaultValue: { [key: string]: any }; config: Array; rightPannelRef: RefObject; form: any; } export const ImgWithContext = React.createContext(0); const FormEditor = (props: FormEditorProps) => { const { config, defaultValue, onSave, uid, rightPannelRef, form } = props; const mode = getUrlParamByKey('mode'); const { getFieldDecorator, validateFieldsAndScroll, setFieldsValue, getFieldsValue } = form; useEffect(() => { return () => { form.resetFields(); }; }, [uid, form]); return (
{config.map((item, i) => { return ( {item.type === 'Number' && ( {getFieldDecorator(item.key, { initialValue: defaultValue[item.key], })( Math.floor(num) + ''} min={item?.range?.[0]} max={item?.range?.[1]} />, )} )} {item.type === 'Text' && ( {getFieldDecorator(item.key, { initialValue: defaultValue[item.key], })()} )} {item.type === 'TextArea' && ( {getFieldDecorator(item.key, { initialValue: defaultValue[item.key], })(