李志伟 3 years ago
parent
commit
76e24a7962

+ 3
- 1
src/components/Bar/index.jsx View File

16
 export default (props) => {
16
 export default (props) => {
17
   const { opt, title, h } = props
17
   const { opt, title, h } = props
18
   const titleList = opt.map(item => { return { name: item.title } })
18
   const titleList = opt.map(item => { return { name: item.title } })
19
+  const colorList = opt.map(item => { return item.color })
19
   const seriesList = opt.map(item => {
20
   const seriesList = opt.map(item => {
20
     return {
21
     return {
21
       name: item.title,
22
       name: item.title,
30
   const defaultOpt = {
31
   const defaultOpt = {
31
     title: {
32
     title: {
32
       text: title,
33
       text: title,
33
-      left: 'center'
34
+      left: 'center',
34
     },
35
     },
35
     tooltip: {
36
     tooltip: {
36
       trigger: 'axis',
37
       trigger: 'axis',
39
       },
40
       },
40
       extraCssText: 'height:100px;'
41
       extraCssText: 'height:100px;'
41
     },
42
     },
43
+    color: colorList,
42
     legend: {
44
     legend: {
43
       top: 'bottom',
45
       top: 'bottom',
44
       data: titleList,
46
       data: titleList,

+ 8
- 2
src/components/WelcomeCard/index.jsx View File

1
-import { Card, Image } from "antd"
2
 import up from '@/assets/welcome/up.png'
1
 import up from '@/assets/welcome/up.png'
3
 import down from '@/assets/welcome/down.png'
2
 import down from '@/assets/welcome/down.png'
4
 import './style.less'
3
 import './style.less'
5
 
4
 
5
+
6
+import { createFromIconfontCN } from '@ant-design/icons';
7
+
8
+
6
 const WCard = (props) => {
9
 const WCard = (props) => {
7
   const { value } = props
10
   const { value } = props
8
   //隔三位加一个逗号
11
   //隔三位加一个逗号
9
   function toThousands(num) {
12
   function toThousands(num) {
10
     return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
13
     return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
11
   }
14
   }
15
+  const MyIcon = createFromIconfontCN({
16
+    scriptUrl: '//at.alicdn.com/t/font_2904679_h2r1om69sid.js', // 在 iconfont.cn 上生成
17
+  });
12
   return (
18
   return (
13
     <div className='wcard'>
19
     <div className='wcard'>
14
-      <img src={value.icon} className='wImg' />
20
+      <MyIcon type={value.icon} className='wImg' style={{ color: value.color }} />
15
       <div className='wright'>
21
       <div className='wright'>
16
         <div className='title'>{value.title}</div>
22
         <div className='title'>{value.title}</div>
17
         <div className='value'>{toThousands(value.value)}</div>
23
         <div className='value'>{toThousands(value.value)}</div>

+ 4
- 0
src/components/WelcomeCard/style.less View File

8
     width: 65px;
8
     width: 65px;
9
     height: 65px;
9
     height: 65px;
10
     margin-right: 64px;
10
     margin-right: 64px;
11
+    svg{
12
+      width: 100%;
13
+      height:100%
14
+    }
11
   }
15
   }
12
   .wright{
16
   .wright{
13
     text-align: right;
17
     text-align: right;

+ 11
- 8
src/pages/Welcome.jsx View File

3
 import { Card, Row, Col } from 'antd';
3
 import { Card, Row, Col } from 'antd';
4
 import { useIntl } from 'umi';
4
 import { useIntl } from 'umi';
5
 import WCard from '@/components/WelcomeCard'
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';
6
 import Bar from '@/components/Bar/index.jsx';
11
 import Pie from '@/components/Pie';
7
 import Pie from '@/components/Pie';
12
 import PieArea from '@/components/PieArea';
8
 import PieArea from '@/components/PieArea';
16
   const intl = useIntl();
12
   const intl = useIntl();
17
   const topData = [
13
   const topData = [
18
     {
14
     {
19
-      icon: userImg,
15
+      icon: 'icon-icon',
16
+      color: '#1cbbb4',
20
       title: '注册用户',
17
       title: '注册用户',
21
       value: 580239,
18
       value: 580239,
22
       percentage: 32.6
19
       percentage: 32.6
23
     },
20
     },
24
     {
21
     {
25
-      icon: cooperative,
22
+      icon: 'icon-show_gongsiguanli_fill',
23
+      color: '#8dc63f',
26
       title: '合作社数',
24
       title: '合作社数',
27
       value: 2017,
25
       value: 2017,
28
       percentage: 5.6
26
       percentage: 5.6
29
     },
27
     },
30
     {
28
     {
31
-      icon: machinery,
29
+      icon: 'icon-tuolaji',
30
+      color: '#a5673f',
32
       title: '农用机数',
31
       title: '农用机数',
33
       value: 2000,
32
       value: 2000,
34
       percentage: 42.6
33
       percentage: 42.6
35
     },
34
     },
36
     {
35
     {
37
-      icon: order,
36
+      icon: 'icon-dingdanguanli',
37
+      color: '#8799a3',
38
       title: '订单数',
38
       title: '订单数',
39
       value: 2075994,
39
       value: 2075994,
40
       percentage: -1.6
40
       percentage: -1.6
43
   const centerData = [
43
   const centerData = [
44
     {
44
     {
45
       title: '预约订单',
45
       title: '预约订单',
46
+      color: '#70d4d4',
46
       keyList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
47
       keyList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
47
       valueList: [320, 332, 301, 334, 390, 88, 320, 332, 301, 334, 390, 88]
48
       valueList: [320, 332, 301, 334, 390, 88, 320, 332, 301, 334, 390, 88]
48
     },
49
     },
49
     {
50
     {
50
       title: '完成订单',
51
       title: '完成订单',
52
+      color: '#c3b6e6',
51
       keyList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
53
       keyList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
52
       valueList: [220, 182, 191, 234, 290, 256, 220, 182, 191, 234, 290, 356]
54
       valueList: [220, 182, 191, 234, 290, 256, 220, 182, 191, 234, 290, 356]
53
     }
55
     }
55
 
57
 
56
   const [machineryStatus, setMachineryStatus] = useState([
58
   const [machineryStatus, setMachineryStatus] = useState([
57
     {
59
     {
60
+      color: '#70d4d4',
58
       keyList: ['预约', '作业', '闲置', '离线', '维修'],
61
       keyList: ['预约', '作业', '闲置', '离线', '维修'],
59
       valueList: [350, 900, 650, 180, 380],
62
       valueList: [350, 900, 650, 180, 380],
60
     }
63
     }

+ 1
- 0
src/pages/Welcome.less View File

1
 .welcome{
1
 .welcome{
2
+  overflow: hidden;
2
   .apache{
3
   .apache{
3
     margin-top: 32px;
4
     margin-top: 32px;
4
   }
5
   }