Преглед на файлове

Merge branch 'master' of http://git.ycjcjy.com/nanyang/machinery-admin

张延森 преди 3 години
родител
ревизия
6a7ced3a97

+ 0
- 18
config/routes.js Целия файл

@@ -24,24 +24,6 @@ export default [
24 24
     icon: 'smile',
25 25
     component: './Welcome',
26 26
   },
27
-  {
28
-    path: '/admin',
29
-    name: 'admin',
30
-    icon: 'crown',
31
-    access: 'canAdmin',
32
-    component: './Admin',
33
-    routes: [
34
-      {
35
-        path: '/admin/sub-page',
36
-        name: 'sub-page',
37
-        icon: 'smile',
38
-        component: './Welcome',
39
-      },
40
-      {
41
-        component: './404',
42
-      },
43
-    ],
44
-  },
45 27
   {
46 28
     path: '/MonitoringScreen',
47 29
     layout: false,

BIN
src/assets/welcome/cooperative.png Целия файл


BIN
src/assets/welcome/down.png Целия файл


BIN
src/assets/welcome/machinery.png Целия файл


BIN
src/assets/welcome/order.png Целия файл


BIN
src/assets/welcome/up.png Целия файл


BIN
src/assets/welcome/user.png Целия файл


+ 62
- 0
src/components/Bar/index.jsx Целия файл

@@ -0,0 +1,62 @@
1
+import React, { useMemo } from 'react';
2
+
3
+import ECharts from '@/components/ECharts';
4
+
5
+const labelOption = {
6
+  show: true,
7
+  formatter: '{c}',
8
+  position: 'insideTop',
9
+  distance: -20,
10
+  fontSize: 16,
11
+  rich: {
12
+    name: {}
13
+  }
14
+};
15
+
16
+export default (props) => {
17
+  const { opt, title, h } = props
18
+  const titleList = opt.map(item => { return { name: item.title } })
19
+  const seriesList = opt.map(item => {
20
+    return {
21
+      name: item.title,
22
+      type: 'bar',
23
+      label: labelOption,
24
+      emphasis: {
25
+        focus: 'series'
26
+      },
27
+      data: item.valueList
28
+    }
29
+  })
30
+  const defaultOpt = {
31
+    title: {
32
+      text: title,
33
+      left: 'center'
34
+    },
35
+    tooltip: {
36
+      trigger: 'axis',
37
+      axisPointer: {
38
+        type: 'shadow'
39
+      },
40
+      extraCssText: 'height:100px;'
41
+    },
42
+    legend: {
43
+      top: 'bottom',
44
+      data: titleList,
45
+    },
46
+    xAxis: [
47
+      {
48
+        type: 'category',
49
+        axisTick: { show: false },
50
+        data: opt[0].keyList
51
+      }
52
+    ],
53
+    yAxis: [
54
+      {
55
+        type: 'value'
56
+      }
57
+    ],
58
+    series: seriesList
59
+  }
60
+  const option = useMemo(() => defaultOpt, []);
61
+  return <div style={{ height: h, width: '100%' }}> <ECharts option={option} /></div>;
62
+};

+ 44
- 0
src/components/Pie/index.jsx Целия файл

@@ -0,0 +1,44 @@
1
+import ECharts from '@/components/ECharts';
2
+
3
+export default (props) => {
4
+  const { opt } = props
5
+  const option = {
6
+    title: {
7
+      text: '农机作业数统计',
8
+      left: 'center'
9
+    },
10
+    legend: {
11
+      orient: 'vertical',
12
+      left: 'left',
13
+      top: '5%'
14
+    },
15
+    series: [
16
+      {
17
+        type: 'pie',
18
+        radius: ['45%', '65%'],
19
+        avoidLabelOverlap: false,
20
+        itemStyle: {
21
+          borderRadius: 10,
22
+          borderColor: '#fff',
23
+          borderWidth: 2
24
+        },
25
+        label: {
26
+          show: false,
27
+          position: 'center',
28
+          formatter: '{b}\n{d}%'
29
+        },
30
+        emphasis: {
31
+          label: {
32
+            show: true,
33
+            fontSize: '18',
34
+          }
35
+        },
36
+        labelLine: {
37
+          show: false
38
+        },
39
+        data: opt
40
+      }
41
+    ]
42
+  }
43
+  return <div style={{ height: '300px', width: '100%' }}> <ECharts option={option} /></div>;
44
+}

+ 36
- 0
src/components/PieArea/index.jsx Целия файл

@@ -0,0 +1,36 @@
1
+import React, { useMemo } from 'react';
2
+import deepCopy from '@/utils/deepCopy';
3
+import ECharts from '@/components/ECharts';
4
+
5
+const defaultOpt = {
6
+  title: {
7
+    text: '农机作业量面积统计',
8
+    left: 'center'
9
+  },
10
+  legend: {
11
+    orient: 'vertical',
12
+    left: 'right',
13
+    bottom: '5%',
14
+  },
15
+  toolbox: {},
16
+  series: [
17
+    {
18
+      type: 'pie',
19
+      radius: ['40%', '55%'],
20
+      center: ['40%', '50%'],
21
+      selectedMode: 'single',
22
+      avoidLabelOverlap: false,
23
+      label: {
24
+        color: '#000',
25
+        formatter: '{b}\n{d}%'
26
+      },
27
+    }
28
+  ]
29
+}
30
+export default (props) => {
31
+  const { opt } = props
32
+  const option = useMemo(() => deepCopy(defaultOpt), []);
33
+  option.series[0].data = opt;
34
+  (option.series[0].data[0] || {}).selected = true;
35
+  return <div style={{ height: '300px', width: '100%' }}> <ECharts option={option} /></div>;
36
+}

+ 23
- 0
src/components/WelcomeCard/index.jsx Целия файл

@@ -0,0 +1,23 @@
1
+import { Card, Image } from "antd"
2
+import up from '@/assets/welcome/up.png'
3
+import down from '@/assets/welcome/down.png'
4
+import './style.less'
5
+
6
+const WCard = (props) => {
7
+  const { value } = props
8
+  //隔三位加一个逗号
9
+  function toThousands(num) {
10
+    return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
11
+  }
12
+  return (
13
+    <div className='wcard'>
14
+      <img src={value.icon} className='wImg' />
15
+      <div className='wright'>
16
+        <div className='title'>{value.title}</div>
17
+        <div className='value'>{toThousands(value.value)}</div>
18
+        <div className='percentage'><img className='wicon' src={value.percentage > 0 ? up : down} />同比上月&nbsp;&nbsp;{Math.abs(value.percentage)}%</div>
19
+      </div>
20
+    </div>
21
+  )
22
+}
23
+export default WCard

+ 28
- 0
src/components/WelcomeCard/style.less Целия файл

@@ -0,0 +1,28 @@
1
+.wcard{
2
+  display: flex;
3
+  align-items: center;
4
+  padding: 16px 32px;
5
+  background: #fff;
6
+  width: 320px;
7
+  .wImg{
8
+    width: 65px;
9
+    height: 65px;
10
+    margin-right: 64px;
11
+  }
12
+  .wright{
13
+    text-align: right;
14
+    .title{}
15
+    .value{
16
+      color:rgb(26, 182, 202);
17
+      font-size: 30px;
18
+      margin: 16px 0;
19
+    }
20
+    .percentage{
21
+      color: gray;
22
+      .wicon{
23
+        width: 20px;
24
+        height: 20px;
25
+      }
26
+    }    
27
+  }
28
+}

+ 0
- 1
src/global.less Целия файл

@@ -139,7 +139,6 @@ ol {
139 139
   color: #fff;
140 140
   // background: rgba(8, 40, 90, 0.4);
141 141
   background: rgba(3, 3, 3, 0.3);
142
-
143 142
   border: 2px solid rgba(61, 129, 240, 0.5);
144 143
 }
145 144
 .border_corner-carsMarker {

+ 0
- 55
src/pages/Admin.jsx Целия файл

@@ -1,55 +0,0 @@
1
-import React from 'react';
2
-import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons';
3
-import { Card, Typography, Alert } from 'antd';
4
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
5
-import { useIntl } from 'umi';
6
-
7
-const Admin = () => {
8
-  const intl = useIntl();
9
-  return (
10
-    <PageHeaderWrapper
11
-      content={intl.formatMessage({
12
-        id: 'pages.admin.subPage.title',
13
-        defaultMessage: 'This page can only be viewed by admin',
14
-      })}
15
-    >
16
-      <Card>
17
-        <Alert
18
-          message={intl.formatMessage({
19
-            id: 'pages.welcome.alertMessage',
20
-            defaultMessage: 'Faster and stronger heavy-duty components have been released.',
21
-          })}
22
-          type="success"
23
-          showIcon
24
-          banner
25
-          style={{
26
-            margin: -12,
27
-            marginBottom: 48,
28
-          }}
29
-        />
30
-        <Typography.Title
31
-          level={2}
32
-          style={{
33
-            textAlign: 'center',
34
-          }}
35
-        >
36
-          <SmileTwoTone /> Ant Design Pro <HeartTwoTone twoToneColor="#eb2f96" /> You
37
-        </Typography.Title>
38
-      </Card>
39
-      <p
40
-        style={{
41
-          textAlign: 'center',
42
-          marginTop: 24,
43
-        }}
44
-      >
45
-        Want to add more pages? Please refer to{' '}
46
-        <a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
47
-          use block
48
-        </a>
49
-        。
50
-      </p>
51
-    </PageHeaderWrapper>
52
-  );
53
-};
54
-
55
-export default Admin;

+ 0
- 5
src/pages/MonitoringScreen/components/WorkData.jsx Целия файл

@@ -24,11 +24,6 @@ const defaultOpt = {
24 24
         borderColor: '#041B38',
25 25
         borderWidth: 2,
26 26
       },
27
-      // itemStyle: {
28
-      //   borderRadius: 10,
29
-      //   borderColor: '#fff',
30
-      //   borderWidth: 1,
31
-      // },
32 27
       label: {
33 28
         show: false,
34 29
         position: 'center',

+ 103
- 55
src/pages/Welcome.jsx Целия файл

@@ -1,64 +1,112 @@
1
-import React from 'react';
1
+import React, { useState, useRef } from 'react';
2 2
 import { PageContainer } from '@ant-design/pro-layout';
3
-import { Card, Alert, Typography } from 'antd';
4
-import { useIntl, FormattedMessage } from 'umi';
5
-import styles from './Welcome.less';
6
-
7
-const CodePreview = ({ children }) => (
8
-  <pre className={styles.pre}>
9
-    <code>
10
-      66666
11
-      <Typography.Text copyable>{children}</Typography.Text>
12
-    </code>
13
-  </pre>
14
-);
3
+import { Card, Row, Col } from 'antd';
4
+import { useIntl } from 'umi';
5
+import WCard from '@/components/WelcomeCard'
6
+import userImg from '@/assets/welcome/user.png'
7
+import cooperative from '@/assets/welcome/cooperative.png'
8
+import machinery from '@/assets/welcome/machinery.png'
9
+import order from '@/assets/welcome/order.png'
10
+import Bar from '@/components/Bar/index.jsx';
11
+import Pie from '@/components/Pie';
12
+import PieArea from '@/components/PieArea';
13
+import './Welcome.less'
15 14
 
16 15
 const Welcome = () => {
17 16
   const intl = useIntl();
17
+  const topData = [
18
+    {
19
+      icon: userImg,
20
+      title: '注册用户',
21
+      value: 580239,
22
+      percentage: 32.6
23
+    },
24
+    {
25
+      icon: cooperative,
26
+      title: '合作社数',
27
+      value: 2017,
28
+      percentage: 5.6
29
+    },
30
+    {
31
+      icon: machinery,
32
+      title: '农用机数',
33
+      value: 2000,
34
+      percentage: 42.6
35
+    },
36
+    {
37
+      icon: order,
38
+      title: '订单数',
39
+      value: 2075994,
40
+      percentage: -1.6
41
+    },
42
+  ]
43
+  const centerData = [
44
+    {
45
+      title: '预约订单',
46
+      keyList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
47
+      valueList: [320, 332, 301, 334, 390, 88, 320, 332, 301, 334, 390, 88]
48
+    },
49
+    {
50
+      title: '完成订单',
51
+      keyList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
52
+      valueList: [220, 182, 191, 234, 290, 256, 220, 182, 191, 234, 290, 356]
53
+    }
54
+  ]
55
+
56
+  const [machineryStatus, setMachineryStatus] = useState([
57
+    {
58
+      keyList: ['预约', '作业', '闲置', '离线', '维修'],
59
+      valueList: [350, 900, 650, 180, 380],
60
+    }
61
+  ])
62
+
63
+  const [workData, setWorkData] = useState([
64
+    { name: '收割机', value: 35 },
65
+    { name: '播种机', value: 35 },
66
+    { name: '农药机', value: 30 },
67
+    { name: '其他', value: 180 },
68
+  ]);
69
+  const [workAreaData, setWorkAreaData] = useState([
70
+    { name: '收割机', value: 350 },
71
+    { name: '播种机', value: 900 },
72
+    { name: '农药机', value: 650 },
73
+    { name: '其他', value: 180 },
74
+  ]);
18 75
   return (
19 76
     <PageContainer>
20
-      <Card>
21
-        <Alert
22
-          message={intl.formatMessage({
23
-            id: 'pages.welcome.alertMessage',
24
-            defaultMessage: 'Faster and stronger heavy-duty components have been released.',
25
-          })}
26
-          type="success"
27
-          showIcon
28
-          banner
29
-          style={{
30
-            margin: -12,
31
-            marginBottom: 24,
32
-          }}
33
-        />
34
-        <Typography.Text strong>
35
-          <FormattedMessage id="pages.welcome.advancedComponent" defaultMessage="Advanced Form" />{' '}
36
-          <a
37
-            href="https://procomponents.ant.design/components/table"
38
-            rel="noopener noreferrer"
39
-            target="__blank"
40
-          >
41
-            <FormattedMessage id="pages.welcome.link" defaultMessage="Welcome" />
42
-          </a>
43
-        </Typography.Text>
44
-        <CodePreview>yarn add @ant-design/pro-table</CodePreview>
45
-        <Typography.Text
46
-          strong
47
-          style={{
48
-            marginBottom: 12,
49
-          }}
50
-        >
51
-          <FormattedMessage id="pages.welcome.advancedLayout" defaultMessage="Advanced layout" />{' '}
52
-          <a
53
-            href="https://procomponents.ant.design/components/layout"
54
-            rel="noopener noreferrer"
55
-            target="__blank"
56
-          >
57
-            <FormattedMessage id="pages.welcome.link" defaultMessage="Welcome" />
58
-          </a>
59
-        </Typography.Text>
60
-        <CodePreview>yarn add @ant-design/pro-layout</CodePreview>
61
-      </Card>
77
+      <div className="welcome">
78
+        <div className="head">
79
+          <Row justify='space-between'>
80
+            <Col flex='320px'>
81
+              <WCard value={topData[0]} />
82
+            </Col>
83
+            <Col flex='320px'>
84
+              <WCard value={topData[1]} />
85
+            </Col>
86
+            <Col flex='320px'>
87
+              <WCard value={topData[2]} />
88
+            </Col>
89
+            <Col flex='320px'>
90
+              <WCard value={topData[3]} />
91
+            </Col>
92
+          </Row>
93
+        </div>
94
+        <Card style={{ marginTop: '32px' }}>
95
+          <Bar h='500px' title='本年度预约订单数据概览' opt={centerData} />
96
+        </Card>
97
+
98
+        <div className='flex bottom'>
99
+          <Card className='flex-1 card'>
100
+            <Bar h='300px' title='农机状态统计' opt={machineryStatus} />
101
+          </Card>
102
+          <Card className='flex-1 card'>
103
+            <PieArea opt={workAreaData} />
104
+          </Card>
105
+          <Card className='flex-1 card'>
106
+            <Pie opt={workData} />
107
+          </Card>
108
+        </div>
109
+      </div>
62 110
     </PageContainer>
63 111
   );
64 112
 };

+ 20
- 7
src/pages/Welcome.less Целия файл

@@ -1,8 +1,21 @@
1
-@import (reference) '~antd/es/style/themes/index';
2
-
3
-.pre {
4
-  margin: 12px 0;
5
-  padding: 12px 20px;
6
-  background: @input-bg;
7
-  box-shadow: @card-shadow;
1
+.welcome{
2
+  .apache{
3
+    margin-top: 32px;
4
+  }
5
+  .screen-page {
6
+    padding-bottom: 30px;  
7
+    background-image: url('~@/assets/images/screen/bg.png');  
8
+  }
9
+  
10
+  .pd-lr-40 {
11
+    padding-right: 40px;
12
+    padding-left: 40px;
13
+  }
14
+  .bottom{
15
+    margin-top: 32px;
16
+    .card+.card{
17
+      margin-left: 32px;
18
+    }
19
+  }
20
+  
8 21
 }