Yansen 2 年之前
父節點
當前提交
423101ea97

+ 8
- 2
src/pages/statis/components/Filter.jsx 查看文件

11
   { label: '本年', value: '3' },
11
   { label: '本年', value: '3' },
12
 ];
12
 ];
13
 
13
 
14
+export const last30Days = [
15
+  moment().subtract(30, 'days'),
16
+  moment(),
17
+];
18
+
14
 export const yearRange = [
19
 export const yearRange = [
15
   moment().startOf('year'),
20
   moment().startOf('year'),
16
   moment(),
21
   moment(),
29
   const [radioValue, setRadioValue] = React.useState();
34
   const [radioValue, setRadioValue] = React.useState();
30
 
35
 
31
   const onChange = (val) => {
36
   const onChange = (val) => {
37
+    console.log(val);
32
     if (typeof props.onChange === 'function') {
38
     if (typeof props.onChange === 'function') {
33
       props.onChange(getStrValue(val));
39
       props.onChange(getStrValue(val));
34
     }
40
     }
37
   const onPickerChange = val => {
43
   const onPickerChange = val => {
38
     setDateRange(val);
44
     setDateRange(val);
39
     setRadioValue();
45
     setRadioValue();
40
-    onChange(getStrValue(val));
46
+    onChange(val);
41
   }
47
   }
42
 
48
 
43
   const onRadioChange = e => {
49
   const onRadioChange = e => {
59
     }
65
     }
60
     
66
     
61
     setDateRange(dateRange);
67
     setDateRange(dateRange);
62
-    onChange(getStrValue(dateRange));
68
+    onChange(dateRange);
63
   }
69
   }
64
 
70
 
65
   return (
71
   return (

+ 19
- 7
src/pages/statis/components/Sumary.jsx 查看文件

1
 import React from 'react';
1
 import React from 'react';
2
 import { Row, Col } from 'antd';
2
 import { Row, Col } from 'antd';
3
 import classNames from 'classnames';
3
 import classNames from 'classnames';
4
+import { getSummary } from '@/services/statis';
4
 import icon1 from '@/assets/images/statistic/数字统计.png';
5
 import icon1 from '@/assets/images/statistic/数字统计.png';
5
 import icon2 from '@/assets/images/statistic/接待军人总数.png';
6
 import icon2 from '@/assets/images/statistic/接待军人总数.png';
6
 import icon3 from '@/assets/images/statistic/保障机构数.png';
7
 import icon3 from '@/assets/images/statistic/保障机构数.png';
8
 import Styles from './style.module.less';
9
 import Styles from './style.module.less';
9
 
10
 
10
 const DataCard = (props) => {
11
 const DataCard = (props) => {
11
-  const { className, icon } = props;
12
+  const { className, icon, title, value = 0, size } = props;
12
 
13
 
13
   const cls = classNames(Styles['data-card'], className);
14
   const cls = classNames(Styles['data-card'], className);
14
 
15
 
16
+  const valStyle = React.useMemo(() => {
17
+    return size ? { fontSize: size } : {}
18
+  }, [size]);
19
+
15
   return (
20
   return (
16
     <dl className={cls}>
21
     <dl className={cls}>
17
-      <dt>0</dt>
18
-      <dd>任务总数</dd>
22
+      <dt style={valStyle}>{value}</dt>
23
+      <dd>{title}</dd>
19
       <img src={icon} alt="" />
24
       <img src={icon} alt="" />
20
     </dl>
25
     </dl>
21
   )
26
   )
22
 }
27
 }
23
 
28
 
24
 export default (props) => {
29
 export default (props) => {
30
+  
31
+  const [data, setData] = React.useState({});
32
+
33
+  React.useEffect(() => {
34
+    getSummary().then(setData);
35
+  }, []);
36
+
25
   return (
37
   return (
26
     <Row gutter={props.gutter} justify="space-between">
38
     <Row gutter={props.gutter} justify="space-between">
27
       <Col span={6}>
39
       <Col span={6}>
28
-        <DataCard icon={icon1} className={Styles['bk1']} />
40
+        <DataCard title="任务总数" value={data.taskCount} icon={icon1} className={Styles['bk1']} />
29
       </Col>
41
       </Col>
30
       <Col span={6}>
42
       <Col span={6}>
31
-        <DataCard icon={icon2} className={Styles['bk2']} />
43
+        <DataCard title="接待军人总数" value={data.personNum} icon={icon2} className={Styles['bk2']} />
32
       </Col>
44
       </Col>
33
       <Col span={6}>
45
       <Col span={6}>
34
-        <DataCard icon={icon3} className={Styles['bk3']} />
46
+        <DataCard title="总体评价" value={data.evaValue} icon={icon3} className={Styles['bk3']} size="24px" />
35
       </Col>
47
       </Col>
36
       <Col span={6}>
48
       <Col span={6}>
37
-        <DataCard icon={icon4} className={Styles['bk4']} />
49
+        <DataCard title="设备数量" value={data.deviceNum} icon={icon4} className={Styles['bk4']} />
38
       </Col>
50
       </Col>
39
     </Row>
51
     </Row>
40
   )
52
   )

+ 25
- 5
src/pages/statis/components/Task.jsx 查看文件

2
 import * as echarts from 'echarts/core';
2
 import * as echarts from 'echarts/core';
3
 import icon from '@/assets/images/statistic/任务统计.png';
3
 import icon from '@/assets/images/statistic/任务统计.png';
4
 import Chart from '@/components/chart';
4
 import Chart from '@/components/chart';
5
+import { getTaskInfo } from '@/services/statis';
5
 import StatisCard from './StatisCard';
6
 import StatisCard from './StatisCard';
6
-import Filter from './Filter';
7
+import Filter, { last30Days, getStrValue } from './Filter';
7
 
8
 
9
+const defaultValue = getStrValue(last30Days);
8
 export default (props) => {
10
 export default (props) => {
9
 
11
 
10
-  const option = getOption(["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], [0, 0, 0, 0, 0, 0, 8, 9, 10, 1, 1, 6])
12
+  const [dateRange, setDateRange] = React.useState(defaultValue);
13
+  const [option, setOption] = React.useState({});
14
+  // const option = getOption(["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], [0, 0, 0, 0, 0, 0, 8, 9, 10, 1, 1, 6])
15
+
16
+  React.useEffect(() => {
17
+    getTaskInfo({ startDate: dateRange[0], endDate: dateRange[1] }).then(res => {
18
+      const keys = res.map(x => x.dt);
19
+      const vals = res.map(x => x.cnt);
20
+
21
+      const opt = getOption(keys, vals);
22
+
23
+      setOption(res.length > 30 ? { ...opt, dataZoom: {} } : opt);
24
+    });
25
+  }, [dateRange]);
11
 
26
 
12
   return (
27
   return (
13
     <StatisCard
28
     <StatisCard
14
       title="任务统计"
29
       title="任务统计"
15
       icon={icon}
30
       icon={icon}
16
-      extra={<Filter />}
31
+      extra={<Filter onChange={setDateRange} />}
17
     >
32
     >
18
       <Chart option={option} style={{ height: '300px' }} />
33
       <Chart option={option} style={{ height: '300px' }} />
19
     </StatisCard>
34
     </StatisCard>
39
     },
54
     },
40
     xAxis: {
55
     xAxis: {
41
       type: 'category',
56
       type: 'category',
42
-      axisLabel: axisLabel,
57
+      axisLabel: { ...axisLabel, rotate: 45 },
43
       axisLine: {
58
       axisLine: {
44
         show: true,
59
         show: true,
45
         lineStyle: lineStyle
60
         lineStyle: lineStyle
57
       },
72
       },
58
       type: 'value'
73
       type: 'value'
59
     },
74
     },
75
+    // dataZoom: [
76
+    //   {
77
+    //     show: true,
78
+    //   }
79
+    // ],
60
     grid: {
80
     grid: {
61
       top: 20,
81
       top: 20,
62
       left: 50,
82
       left: 50,
63
       right: 20,
83
       right: 20,
64
-      bottom: 50,
84
+      bottom: 100,
65
     },
85
     },
66
     series: [
86
     series: [
67
       {
87
       {

+ 2
- 1
src/pages/statis/components/style.module.less 查看文件

14
 
14
 
15
   dt {
15
   dt {
16
     font-size: 36px;
16
     font-size: 36px;
17
+    line-height: 55px;
17
   }
18
   }
18
 
19
 
19
   dd {
20
   dd {
20
     font-size: 16px;
21
     font-size: 16px;
22
+    line-height: 1.53846;
21
   }
23
   }
22
 
24
 
23
   dt, dd {
25
   dt, dd {
24
     padding: 0;
26
     padding: 0;
25
     font-weight: 400;
27
     font-weight: 400;
26
     color: rgb(255, 255, 255);
28
     color: rgb(255, 255, 255);
27
-    line-height: 1.53846;
28
   }
29
   }
29
 
30
 
30
   img {
31
   img {

+ 1
- 1
src/routes/routes.jsx 查看文件

75
         path: "guaranteeTask",
75
         path: "guaranteeTask",
76
         element: <GuaranteeTaskList />,
76
         element: <GuaranteeTaskList />,
77
         meta: {
77
         meta: {
78
-          title: "军供通报",
78
+          title: "任务通报",
79
         },
79
         },
80
       },
80
       },
81
       {
81
       {

+ 5
- 0
src/services/statis.js 查看文件

1
+import request from '@/utils/request';
2
+
3
+export const getSummary = () => request('/statis/summary', { successTip: false });
4
+
5
+export const getTaskInfo = (params) => request('/statis/taskInfo', { params, successTip: false });