weiximei 5 年 前
コミット
920f96931e
共有2 個のファイルを変更した21 個の追加17 個の削除を含む
  1. 12
    7
      src/components/XForm/WrapperItem.jsx
  2. 9
    10
      src/pages/carouselFigure/editCarousel.jsx

+ 12
- 7
src/components/XForm/WrapperItem.jsx ファイルの表示

12
 } from 'antd';
12
 } from 'antd';
13
 import ImageUploader from './ImageUpload';
13
 import ImageUploader from './ImageUpload';
14
 
14
 
15
-const Item = Form.Item
15
+const {Item} = Form
16
 const { Option } = Select;
16
 const { Option } = Select;
17
 const { MonthPicker, RangePicker } = DatePicker
17
 const { MonthPicker, RangePicker } = DatePicker
18
 
18
 
42
   },
42
   },
43
 };
43
 };
44
 
44
 
45
-const WrapperItem = (props) => {
45
+const WrapperItem = props => {
46
   const {
46
   const {
47
     form,
47
     form,
48
     label,
48
     label,
56
     action,
56
     action,
57
     props: fieldProps,
57
     props: fieldProps,
58
     hidden = false,
58
     hidden = false,
59
+    help,
59
     ...restProps
60
     ...restProps
60
   } = props;
61
   } = props;
61
 
62
 
63
 
64
 
64
   let config = {
65
   let config = {
65
     rules,
66
     rules,
66
-    initialValue: value
67
+    initialValue: value,
67
   }
68
   }
68
 
69
 
69
   if (type === FieldTypes.Switch) {
70
   if (type === FieldTypes.Switch) {
72
       valuePropName: 'checked',
73
       valuePropName: 'checked',
73
     };
74
     };
74
   }
75
   }
75
-  
76
+
76
   if (type === FieldTypes.ImageUploader) {
77
   if (type === FieldTypes.ImageUploader) {
77
     config = {
78
     config = {
78
       ...config,
79
       ...config,
130
 
131
 
131
   const visible = typeof hidden === 'function' ? !hidden() : !hidden;
132
   const visible = typeof hidden === 'function' ? !hidden() : !hidden;
132
 
133
 
133
-  if (!label && !name && !action) return visible ? Field : null;
134
-  
134
+  if (!label && !name && !action && !help) return visible ? Field : null;
135
+
135
   const itemProps = action ? { ...restProps, ...tailFormItemLayout } : restProps
136
   const itemProps = action ? { ...restProps, ...tailFormItemLayout } : restProps
136
   const labelNode = typeof label === 'function' ? label() : label;
137
   const labelNode = typeof label === 'function' ? label() : label;
138
+  const helpNode = typeof help === 'function' ? help() : help;
139
+
140
+  const newItemProps = { ...itemProps, help: helpNode }
141
+  console.log('newItemProps: ', newItemProps)
137
 
142
 
138
   return visible && (
143
   return visible && (
139
-    <Item label={labelNode} {...itemProps}>
144
+    <Item label={labelNode} { ...newItemProps }>
140
       {action ? Field : getFieldDecorator(name, config)(Field)}
145
       {action ? Field : getFieldDecorator(name, config)(Field)}
141
     </Item>
146
     </Item>
142
   )
147
   )

+ 9
- 10
src/pages/carouselFigure/editCarousel.jsx ファイルの表示

37
     newsVisible = data.contentType === 'news';
37
     newsVisible = data.contentType === 'news';
38
     helpVisible = data.contentType === 'help';
38
     helpVisible = data.contentType === 'help';
39
     groupVisible = data.contentType === 'group';
39
     groupVisible = data.contentType === 'group';
40
-    
40
+
41
     buildingId = data.buildingId
41
     buildingId = data.buildingId
42
     locationType = data.showPosition === 'mall';
42
     locationType = data.showPosition === 'mall';
43
     console.log(locationType, 'locationType');
43
     console.log(locationType, 'locationType');
44
   }
44
   }
45
 
45
 
46
-    
46
+
47
   const handleFormValueChange = (props, changedValues, allValues) => {
47
   const handleFormValueChange = (props, changedValues, allValues) => {
48
     setExtraData(allValues)
48
     setExtraData(allValues)
49
   }
49
   }
50
 
50
 
51
   const XForm = createForm({ onValuesChange: handleFormValueChange })
51
   const XForm = createForm({ onValuesChange: handleFormValueChange })
52
 
52
 
53
-  return (props) => {
54
-
53
+  return props => {
55
     const [tab, changeTab] = useState('basic')
54
     const [tab, changeTab] = useState('basic')
56
     const { contentId } = props.location.query
55
     const { contentId } = props.location.query
57
     const [data, setData] = useState({})
56
     const [data, setData] = useState({})
85
           value: data.buildingId,
84
           value: data.buildingId,
86
         },
85
         },
87
         {
86
         {
88
-          label: locationType ? '积分商城轮播图' : '首页轮播图',
87
+          label: () => (locationType ? '积分商城轮播图' : '首页轮播图'),
89
           name: 'image',
88
           name: 'image',
90
           type: FieldTypes.ImageUploader,
89
           type: FieldTypes.ImageUploader,
91
           value: data.image,
90
           value: data.image,
92
-          help: locationType ? '建议图片尺寸:750*420px,比例16:9,格式:jpg,用于积分商城banner轮播':'建议图片尺寸:750*600px,比例5:4,格式:jpg,用于首页顶部banner轮播',
91
+          help: () => (locationType ? '建议图片尺寸:750*420px,比例16:9,格式:jpg,用于积分商城banner轮播' : '建议图片尺寸:750*600px,比例5:4,格式:jpg,用于首页顶部banner轮播'),
93
         },
92
         },
94
         {
93
         {
95
           label: '标题',
94
           label: '标题',
187
           {
186
           {
188
             label: '停用',
187
             label: '停用',
189
             value: 0,
188
             value: 0,
190
-          } ],
189
+          }],
191
           value: data.status != null ? data.status : 1,
190
           value: data.status != null ? data.status : 1,
192
         },
191
         },
193
       ]
192
       ]
195
       const handleSubmit = val => {
194
       const handleSubmit = val => {
196
         val.showType = 'banner'
195
         val.showType = 'banner'
197
         if (contentId) {
196
         if (contentId) {
198
-          request({ ...apis.carsuseFigure.updataExtendContent, urlData: { id: contentId }, data: val  }).then(data => {
197
+          request({ ...apis.carsuseFigure.updataExtendContent, urlData: { id: contentId }, data: val }).then(data => {
199
             cancelPage()
198
             cancelPage()
200
           }).catch(err => {
199
           }).catch(err => {
201
             message.info(err.msg || err.message)
200
             message.info(err.msg || err.message)
202
           })
201
           })
203
-        } else{
204
-          request({ ...apis.carsuseFigure.addExtendContent, data: val  }).then(data => {
202
+        } else {
203
+          request({ ...apis.carsuseFigure.addExtendContent, data: val }).then(data => {
205
             cancelPage()
204
             cancelPage()
206
           }).catch(err => {
205
           }).catch(err => {
207
             message.info(err.msg || err.message)
206
             message.info(err.msg || err.message)