魏熙美 5 jaren geleden
bovenliggende
commit
ebd37162f3
2 gewijzigde bestanden met toevoegingen van 92 en 51 verwijderingen
  1. 41
    25
      src/pages/Welcome.jsx
  2. 51
    26
      src/pages/indexEcharts/index.jsx

+ 41
- 25
src/pages/Welcome.jsx Bestand weergeven

@@ -11,8 +11,11 @@ const welcome = (props) => {
11 11
 
12 12
   const [data, setData] = useState([])
13 13
 
14
+  const [checkData, setCheckData] = useState([])
15
+
14 16
   useEffect(() => {
15 17
     getIndexEcharts()
18
+    getBuildingReports()
16 19
   }, [])
17 20
 
18 21
   function getIndexEcharts(params) {
@@ -24,35 +27,48 @@ const welcome = (props) => {
24 27
       console.log(data, '11111')
25 28
     })
26 29
   }
30
+
31
+  function getBuildingReports() {
32
+    request({ ...apis.system.taBuildingReports, }).then((data) => {
33
+      setCheckData((data.records || []).map((x) => x.reportCode))
34
+    })
35
+  }
36
+
27 37
   return (
28 38
     <>
29 39
       <div style={{ display: 'flex', marginBottom: '33px' }}>
30
-        <div style={{
31
-          textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(241,43,62,1) 0%,rgba(254,144,155,1) 100%)', height: '100px',
32
-          boxShadow: '0px  0.106rem 14px -15px rgba(241,43,62,1)',
33
-          borderRadius: '12px', width: '32%', marginRight: '2%'
34
-        }}>
35
-          <span style={{ fontSize: '24px', color: '#fff' }}>总用户 </span>
36
-          <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{data.selectUserCount || '0'}</span>
37
-        </div>
38
-        <div style={{
39
-          textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(255,126,74,1) 0%,rgba(255,196,168,1) 100%)', height: '100px',
40
-          boxShadow: '0px  0.106rem 14px -15px rgba(255,126,74,1)',
41
-          borderRadius: '12px', width: '32%', marginRight: '2%'
42
-        }}>
43
-          <span style={{ fontSize: '24px', color: '#fff' }}>总注册用户 </span>
44
-          <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{(data.selectRegisteredCount && data.selectRegisteredCount + 95) || '0'}</span>
45
-        </div>
46
-        <div onClick={() => router.push('/indexEcharts/newUsers')} style={{
47
-          textAlign: 'center', display: 'flex', justifyContent: 'center', background: 'linear-gradient(137deg,rgba(107,130,230,1) 0%,rgba(152,175,251,1) 100%)', height: '100px',
48
-          boxShadow: '0px  0.106rem 14px -15px rgba(107,130,230,1)',
49
-          borderRadius: '12px', width: '32%',
50
-        }}>
51
-          <span style={{ fontSize: '24px', color: '#fff', borderBottom: '1px solid #fff', margin: '30px 0',cursor: 'pointer' }}>最近7天新增 </span>
52
-          <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy', lineHeight: '100px' }}>{data.selectRecentlyCount || '0'}</span>
53
-        </div>
40
+        {checkData.includes('total_number_of_users') &&
41
+          <div style={{
42
+            textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(241,43,62,1) 0%,rgba(254,144,155,1) 100%)', height: '100px',
43
+            boxShadow: '0px  0.106rem 14px -15px rgba(241,43,62,1)',
44
+            borderRadius: '12px', width: '32%', marginRight: '2%'
45
+          }}>
46
+            <span style={{ fontSize: '24px', color: '#fff' }}>总用户 </span>
47
+            <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{data.selectUserCount || '0'}</span>
48
+          </div>
49
+        }
50
+        {checkData.includes('total_number_of_registered_users') &&
51
+          <div style={{
52
+            textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(255,126,74,1) 0%,rgba(255,196,168,1) 100%)', height: '100px',
53
+            boxShadow: '0px  0.106rem 14px -15px rgba(255,126,74,1)',
54
+            borderRadius: '12px', width: '32%', marginRight: '2%'
55
+          }}>
56
+            <span style={{ fontSize: '24px', color: '#fff' }}>总注册用户 </span>
57
+            <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{(data.selectRegisteredCount && data.selectRegisteredCount + 95) || '0'}</span>
58
+          </div>
59
+        }
60
+        {checkData.includes('number_of_new_users') &&
61
+          <div onClick={() => router.push('/indexEcharts/newUsers')} style={{
62
+            textAlign: 'center', display: 'flex', justifyContent: 'center', background: 'linear-gradient(137deg,rgba(107,130,230,1) 0%,rgba(152,175,251,1) 100%)', height: '100px',
63
+            boxShadow: '0px  0.106rem 14px -15px rgba(107,130,230,1)',
64
+            borderRadius: '12px', width: '32%',
65
+          }}>
66
+            <span style={{ fontSize: '24px', color: '#fff', borderBottom: '1px solid #fff', margin: '30px 0',cursor: 'pointer' }}>最近7天新增 </span>
67
+            <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy', lineHeight: '100px' }}>{data.selectRecentlyCount || '0'}</span>
68
+          </div>
69
+        }
54 70
       </div>
55
-      <IndexEcharts style={{ width: '100%' }} onReData={(e) => redata(e)} ></IndexEcharts>
71
+      <IndexEcharts style={{ width: '100%' }} onReData={(e) => redata(e)} checkData={checkData}></IndexEcharts>
56 72
     </>
57 73
   )
58 74
 

+ 51
- 26
src/pages/indexEcharts/index.jsx Bestand weergeven

@@ -15,11 +15,19 @@ import IntentionalCustomers from './components/IntentionalCustomers'
15 15
 import styles from './styles.less'
16 16
 import moment from 'moment';
17 17
 import CityNums from '../charts/CityNums';
18
-const indexEcharts = (props) => {
18
+const indexEcharts = props => {
19
+
20
+  // eslint-disable-next-line react-hooks/rules-of-hooks
21
+  const [checkData, setCheckData] = useState([])
22
+
23
+  // eslint-disable-next-line react-hooks/rules-of-hooks
24
+  useEffect(() => {
25
+    setCheckData(props.checkData)
26
+  }, [props.checkData]);
19 27
 
20 28
   const endDate = new Date()
21 29
 
22
-  //为了观察数据先设30天
30
+  // 为了观察数据先设30天
23 31
   const startDate = moment().subtract(7, 'day').toDate()
24 32
 
25 33
   function onTabledatas (e) {
@@ -29,37 +37,54 @@ const indexEcharts = (props) => {
29 37
   return (
30 38
 
31 39
     <>
32
-      <div style={{ display: 'flex',width:'100%' }}>
33
-        <div className={styles.bar}>
34
-          <UserSource endDate={endDate}  startDate={startDate} onSuccess={(e) => onTabledatas(e)}></UserSource>
40
+      <div style={{ display: 'flex', width: '100%' }}>
41
+        {checkData.includes('user_source') &&
42
+          <div className={styles.bar}>
43
+            <UserSource endDate={endDate} startDate={startDate} onSuccess={e => onTabledatas(e)}></UserSource>
44
+          </div>
45
+        }
46
+        {checkData.includes('user_source') &&
47
+          <div className={styles.pie}>
48
+            <UserSourcepie endDate={endDate} startDate={startDate}></UserSourcepie>
49
+          </div>
50
+        }
51
+      </div>
52
+      {checkData.includes('urban_distribution') &&
53
+        <div>
54
+          <CityNums></CityNums>
35 55
         </div>
36
-        <div className={styles.pie}>
37
-          <UserSourcepie endDate={endDate} startDate={startDate}></UserSourcepie>
56
+      }
57
+      {checkData.includes('user_behavior') &&
58
+        <div className={styles.behavior}>
59
+          <UserBehavior tableShow={false} endDate={endDate} startDate={startDate} dataZoom={false}></UserBehavior>
38 60
         </div>
39
-      </div>
40
-      <div>
41
-      <CityNums></CityNums>
42
-      </div>
43
-      <div className={styles.behavior}>
44
-        <UserBehavior tableShow={false} endDate={endDate} startDate={startDate} dataZoom={false}></UserBehavior>
45
-      </div>
61
+      }
46 62
       <div style={{ display: 'flex' }}>
47
-        <div className={styles.bar}>
48
-
49
-          <UserActive ></UserActive>
50
-        </div>
51
-        <div className={styles.pie}><UserSex></UserSex> </div>
63
+        {checkData.includes('active_users') &&
64
+          <div className={styles.bar}>
65
+            <UserActive ></UserActive>
66
+          </div>
67
+        }
68
+        {checkData.includes('sex_ratio') &&
69
+          <div className={styles.pie}><UserSex></UserSex> </div>
70
+        }
52 71
       </div>
53 72
       <div style={{ display: 'flex' }}>
54
-        <div className={styles.bar}>
55
-          <NewUsers endDate={endDate} startDate={startDate} dataZoom={false}></NewUsers>
56
-        </div>
57
-        <div className={styles.pie}><UserConversion></UserConversion> </div>
73
+        {checkData.includes('number_of_new_users') &&
74
+          <div className={styles.bar}>
75
+            <NewUsers endDate={endDate} startDate={startDate} dataZoom={false}></NewUsers>
76
+          </div>
77
+        }
78
+        {checkData.includes('conversion_rate') &&
79
+          <div className={styles.pie}><UserConversion></UserConversion> </div>
80
+        }
58 81
       </div >
59 82
 
60
-      <div className={styles.customers}>
61
-        <IntentionalCustomers></IntentionalCustomers>
62
-      </div>
83
+      {checkData.includes('intentional_user') &&
84
+        <div className={styles.customers}>
85
+          <IntentionalCustomers></IntentionalCustomers>
86
+        </div>
87
+      }
63 88
     </>
64 89
   )
65 90
 }