Przeglądaj źródła

Merge branch 'master' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager

张延森 5 lat temu
rodzic
commit
156db15eae

+ 24
- 5
src/components/SelectButton/NewTypeSelect.jsx Wyświetl plik

1
-import React, { useState, useEffect } from 'react';
1
+import React, { useState, useEffect, useRef } from 'react';
2
 import { Select } from 'antd';
2
 import { Select } from 'antd';
3
 
3
 
4
 import request from '../../utils/request'
4
 import request from '../../utils/request'
5
 
5
 
6
 const { Option } = Select;
6
 const { Option } = Select;
7
 
7
 
8
+function usePrevious(props) {
9
+  const ref = useRef();
10
+  useEffect(() => {
11
+    ref.current = props;
12
+  });
13
+  return ref.current;
14
+}
15
+
8
 /**
16
 /**
9
  *
17
  *
10
  *
18
  *
13
  */
21
  */
14
 const NewsTypeSelect = (props) => {
22
 const NewsTypeSelect = (props) => {
15
   const [ data, setData ] = useState([])
23
   const [ data, setData ] = useState([])
24
+  const [ value, setValue ] = useState('')
25
+  const preProps = usePrevious(props)
26
+
27
+  if ((!preProps || !preProps.value) && props.value && !value) {
28
+    setValue(props.value)
29
+  }
16
 
30
 
17
   useEffect(() => {
31
   useEffect(() => {
18
-    getCityList();
32
+    getNewsTypeList();
19
   },[])
33
   },[])
20
 
34
 
21
-  const getCityList = (e) => {
35
+  const getNewsTypeList = (e) => {
22
     request({
36
     request({
23
         url: '/api/admin/taNewsType',
37
         url: '/api/admin/taNewsType',
24
         method: 'GET',
38
         method: 'GET',
29
     })
43
     })
30
   }
44
   }
31
 
45
 
46
+  const handleChange = (e) => {
47
+    setValue(e)
48
+    props.onChange(e)
49
+  }
50
+
32
   return (
51
   return (
33
-      <Select value={props.value} style={{ width: '180px' }} placeholder="请选择资讯类型" onChange={props.onChange}>
52
+      <Select value={'' === value ? undefined : value} style={{ width: '180px' }} placeholder="请选择资讯类型" onChange={handleChange}>
34
           {data.map(type => (
53
           {data.map(type => (
35
-            <Option key={type.newsTypeId}>{type.newsTypeName}</Option>
54
+            <Option key={type.newsTypeId} value={type.newsTypeId}>{type.newsTypeName}</Option>
36
           ))}
55
           ))}
37
       </Select>
56
       </Select>
38
   )
57
   )

+ 8
- 4
src/components/XForm/ImageListUpload.jsx Wyświetl plik

29
       return;
29
       return;
30
     }
30
     }
31
 
31
 
32
-    if (e.file.state === 'removed') {
33
-      const fileList = (this.props.value || []).filter(x => x != e.file.url);
34
-      this.props.onChange(fileList);
35
-    }
32
+    const fileList = (this.props.value || []).filter(x => x != e.file.url);
33
+    this.props.onChange(fileList);
34
+
35
+    // console.log('删除图片触发了', e.file)
36
+    // if (e.file.state === 'removed') {
37
+    //   const fileList = (this.props.value || []).filter(x => x != e.file.url);
38
+    //   this.props.onChange(fileList);
39
+    // }
36
 
40
 
37
     // if (e.file.status === "done") {
41
     // if (e.file.status === "done") {
38
     //   this.setState({
42
     //   this.setState({

+ 2
- 2
src/pages/carouselFigure/advertisingList.jsx Wyświetl plik

190
             </Select>,
190
             </Select>,
191
           )}
191
           )}
192
         </Form.Item>
192
         </Form.Item>
193
-        <Form.Item>
193
+        {/* <Form.Item>
194
           {getFieldDecorator('showPosition')(
194
           {getFieldDecorator('showPosition')(
195
             <Select style={{ width: '180px' }} placeholder="发布位置">
195
             <Select style={{ width: '180px' }} placeholder="发布位置">
196
               <Option value="mall">商城</Option>
196
               <Option value="mall">商城</Option>
197
               <Option value="index">首页</Option>
197
               <Option value="index">首页</Option>
198
             </Select>,
198
             </Select>,
199
           )}
199
           )}
200
-        </Form.Item>
200
+        </Form.Item> */}
201
         <Form.Item>
201
         <Form.Item>
202
           {getFieldDecorator('status')(
202
           {getFieldDecorator('status')(
203
             <Select style={{ width: '180px' }} placeholder="状态">
203
             <Select style={{ width: '180px' }} placeholder="状态">