魏超 5 anni fa
parent
commit
6e7c1ee1e3
1 ha cambiato i file con 1 aggiunte e 14 eliminazioni
  1. 1
    14
      src/components/SelectButton/BuildSelect.jsx

+ 1
- 14
src/components/SelectButton/BuildSelect.jsx Vedi File

22
 const BuildingSelect = props => {
22
 const BuildingSelect = props => {
23
   const [data, setData] = useState([])
23
   const [data, setData] = useState([])
24
   const [value, setValue] = useState('')
24
   const [value, setValue] = useState('')
25
-  const [disabled, setDisabled] = useState(false)
26
-  // const preProps = usePrevious(props)
27
-
28
-  // if ((!preProps) && props.value != value) {
29
-  //   setValue(props.value)
30
-  // }
31
 
25
 
32
   useEffect(() => {
26
   useEffect(() => {
33
     setValue(props.value)
27
     setValue(props.value)
35
 
29
 
36
   useEffect(() => {
30
   useEffect(() => {
37
     getCityList();
31
     getCityList();
38
-    setDisabledValue();
39
   }, [])
32
   }, [])
40
 
33
 
41
   const getCityList = e => {
34
   const getCityList = e => {
49
     })
42
     })
50
   }
43
   }
51
 
44
 
52
-  const setDisabledValue = () => {
53
-    if (props.disabled) {
54
-      setDisabled(props.disabled === true)
55
-    }
56
-  }
57
-
58
   const handleChange = e => {
45
   const handleChange = e => {
59
     setValue(e)
46
     setValue(e)
60
     props.onChange(e)
47
     props.onChange(e)
62
   // '' === value ? undefined : value
49
   // '' === value ? undefined : value
63
   return (
50
   return (
64
       <Select
51
       <Select
52
+      {...props} 
65
       showSearch
53
       showSearch
66
       value={value}
54
       value={value}
67
       style={{ width: '180px' }}
55
       style={{ width: '180px' }}
68
       placeholder="请选择项目"
56
       placeholder="请选择项目"
69
       onChange={handleChange}
57
       onChange={handleChange}
70
-      disabled={disabled}
71
       filterOption={(input, option) =>
58
       filterOption={(input, option) =>
72
         option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
59
         option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
73
       }>
60
       }>