魏熙美 5 gadus atpakaļ
vecāks
revīzija
5bb68f35d4

+ 9
- 6
src/components/SelectButton/BuildSelect.jsx Parādīt failu

@@ -22,11 +22,15 @@ function usePrevious(props) {
22 22
 const BuildingSelect = (props) => {
23 23
   const [ data, setData ] = useState([])
24 24
   const [ value, setValue ] = useState('')
25
-  const preProps = usePrevious(props)
25
+  // const preProps = usePrevious(props)
26 26
 
27
-  if ((!preProps || !preProps.value) && props.value && !value) {
27
+  // if ((!preProps) && props.value != value) {
28
+  //   setValue(props.value)
29
+  // }
30
+
31
+  useEffect(() => {
28 32
     setValue(props.value)
29
-  }
33
+  }, [props.value])
30 34
 
31 35
   useEffect(() => {
32 36
     getCityList();
@@ -36,7 +40,7 @@ const BuildingSelect = (props) => {
36 40
     request({ ...apis.building.buildingSelect, params: {pageNum: 1,pageSize: 999}, }).then((data) => {
37 41
         setData(data.records)
38 42
         // 默认选中第一个
39
-        if ((!preProps || !preProps.one) && props.one === 'true') {
43
+        if (props.checkFirst) {
40 44
           setValue(data.records[0].buildingId)
41 45
           props.onChange(data.records[0].buildingId)
42 46
         }
@@ -51,7 +55,7 @@ const BuildingSelect = (props) => {
51 55
   return (
52 56
       <Select
53 57
       showSearch
54
-      value={props.value}
58
+      value={value}
55 59
       style={{ width: '180px' }} 
56 60
       placeholder="请选择项目" 
57 61
       onChange={handleChange}
@@ -65,4 +69,3 @@ const BuildingSelect = (props) => {
65 69
   )
66 70
 }
67 71
 export default BuildingSelect
68
-

+ 1
- 1
src/pages/indexEcharts/components/UserBehavior.jsx Parādīt failu

@@ -272,7 +272,7 @@ const UserBehavior = props => {
272 272
           {!props.BuildSelectHide && <span style={{ fontSize: '0.09rem', color: '#888', marginLeft: '0.06rem' }}>最近七天</span>}
273 273
         </p>
274 274
         <div style={{ float: 'right', marginTop: '-40px', marginBottom: '20px' }}>
275
-          {!props.BuildSelectHide && <BuildSelect slot="action" onChange={(e => handleBuildingChange(e))} one="true"></BuildSelect>}
275
+          {!props.BuildSelectHide && <BuildSelect slot="action" onChange={(e => handleBuildingChange(e))} checkFirst></BuildSelect>}
276 276
         </div>
277 277
         <EChart options={options} style={style} />
278 278
         {props.tableShow &&

+ 1
- 1
src/pages/system/intention.jsx Parādīt failu

@@ -57,7 +57,7 @@ const Edit = (props) => {
57 57
     <>
58 58
       <Row>
59 59
         <Col span={6}>
60
-          <BuildSelect onChange={changBuilding} one="true" />
60
+          <BuildSelect onChange={changBuilding} checkFirst/>
61 61
         </Col>
62 62
         <Col span={5} style={{ lineHeight: '30px' }}>
63 63
           用户操作