瀏覽代碼

修复bug

魏熙美 5 年之前
父節點
當前提交
5bb68f35d4

+ 9
- 6
src/components/SelectButton/BuildSelect.jsx 查看文件

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

+ 1
- 1
src/pages/indexEcharts/components/UserBehavior.jsx 查看文件

272
           {!props.BuildSelectHide && <span style={{ fontSize: '0.09rem', color: '#888', marginLeft: '0.06rem' }}>最近七天</span>}
272
           {!props.BuildSelectHide && <span style={{ fontSize: '0.09rem', color: '#888', marginLeft: '0.06rem' }}>最近七天</span>}
273
         </p>
273
         </p>
274
         <div style={{ float: 'right', marginTop: '-40px', marginBottom: '20px' }}>
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
         </div>
276
         </div>
277
         <EChart options={options} style={style} />
277
         <EChart options={options} style={style} />
278
         {props.tableShow &&
278
         {props.tableShow &&

+ 1
- 1
src/pages/system/intention.jsx 查看文件

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