李志伟 3 年前
父节点
当前提交
16b1560ae3

+ 13
- 0
config/routes.js 查看文件

21
   {
21
   {
22
     path: '/dashboard',
22
     path: '/dashboard',
23
     name: '工作台',
23
     name: '工作台',
24
+    access:'admin',
24
     icon: 'DashboardOutlined',
25
     icon: 'DashboardOutlined',
25
     component: './dashboard',
26
     component: './dashboard',
26
   },  
27
   },  
27
   {
28
   {
28
     path: '/',
29
     path: '/',
29
     name: '工作台',//暂定
30
     name: '工作台',//暂定
31
+    access:'admin',
30
     redirect: '/person',
32
     redirect: '/person',
31
     hideInMenu: true,
33
     hideInMenu: true,
32
   },
34
   },
33
   {
35
   {
34
     path: '/banner',
36
     path: '/banner',
35
     name: '轮播图列表',
37
     name: '轮播图列表',
38
+    access:'admin',
36
     icon: 'PictureOutlined',
39
     icon: 'PictureOutlined',
37
     component: '@/pages/banner',
40
     component: '@/pages/banner',
38
   },
41
   },
45
   {
48
   {
46
     path: '/notice',
49
     path: '/notice',
47
     name: '通知列表',
50
     name: '通知列表',
51
+    access:'admin',
48
     icon: 'BellOutlined',
52
     icon: 'BellOutlined',
49
     component: '@/pages/notice',
53
     component: '@/pages/notice',
50
   },
54
   },
57
   {
61
   {
58
     path: '/applicationList',
62
     path: '/applicationList',
59
     name: '申请列表',
63
     name: '申请列表',
64
+    access:'admin',
60
     icon: 'FieldTimeOutlined',
65
     icon: 'FieldTimeOutlined',
61
     component: '@/pages/applicationList',
66
     component: '@/pages/applicationList',
62
   },
67
   },
69
   {
74
   {
70
     path: '/examine',
75
     path: '/examine',
71
     name: '审核列表',
76
     name: '审核列表',
77
+    access:'auditor',
72
     icon: 'AuditOutlined',
78
     icon: 'AuditOutlined',
73
     component: '@/pages/examine',
79
     component: '@/pages/examine',
74
   },
80
   },
81
   {
87
   {
82
     path: '/certificateIssuance',
88
     path: '/certificateIssuance',
83
     name: '证件发放',
89
     name: '证件发放',
90
+    access:'maker',
84
     icon: 'FileDoneOutlined',
91
     icon: 'FileDoneOutlined',
85
     component: '@/pages/certificateIssuance',
92
     component: '@/pages/certificateIssuance',
86
   },
93
   },
93
   {
100
   {
94
     path: '/cardNoList',
101
     path: '/cardNoList',
95
     name: '证件制卡',
102
     name: '证件制卡',
103
+    access:'admin',
96
     icon: 'CreditCardOutlined',
104
     icon: 'CreditCardOutlined',
97
     component: '@/pages/cardNoList',
105
     component: '@/pages/cardNoList',
98
   },
106
   },
99
   {
107
   {
100
     path: '/cardList',
108
     path: '/cardList',
101
     name: '证件列表',
109
     name: '证件列表',
110
+    access:'admin',
102
     icon: 'IdcardOutlined',
111
     icon: 'IdcardOutlined',
103
     component: '@/pages/cardList',
112
     component: '@/pages/cardList',
104
   },
113
   },
105
   {
114
   {
106
     path: '/cardList/detail.jsx',
115
     path: '/cardList/detail.jsx',
107
     name: '证件详情',
116
     name: '证件详情',
117
+    access:'admin',
108
     hideInMenu: true,
118
     hideInMenu: true,
109
     component: '@/pages/cardList/detail.jsx',
119
     component: '@/pages/cardList/detail.jsx',
110
   },
120
   },
111
   {
121
   {
112
     path: '/userList',
122
     path: '/userList',
113
     name: '犬主列表',
123
     name: '犬主列表',
124
+    access:'admin',
114
     icon: 'SolutionOutlined',
125
     icon: 'SolutionOutlined',
115
     component: '@/pages/userList',
126
     component: '@/pages/userList',
116
   },
127
   },
117
   {
128
   {
118
     path: '/person',
129
     path: '/person',
119
     name: '人员列表',
130
     name: '人员列表',
131
+    access:'admin',
120
     icon: 'UserOutlined',
132
     icon: 'UserOutlined',
121
     component: '@/pages/person',
133
     component: '@/pages/person',
122
   },
134
   },
123
   {
135
   {
124
     path: '/BasicParameters',
136
     path: '/BasicParameters',
125
     name: '系统参数',
137
     name: '系统参数',
138
+    access:'admin',
126
     icon: 'SettingOutlined',
139
     icon: 'SettingOutlined',
127
     component: '@/pages/BasicParameters',
140
     component: '@/pages/BasicParameters',
128
   },
141
   },

+ 18
- 15
src/access.js 查看文件

2
  * @see https://umijs.org/zh-CN/plugins/plugin-access
2
  * @see https://umijs.org/zh-CN/plugins/plugin-access
3
  * */
3
  * */
4
 export default function access(initialState) {
4
 export default function access(initialState) {
5
-  const { menuAccess,roleAlias } = initialState || {};
6
-  if(roleAlias=='org'){
5
+  const { currentUser } = initialState || {};
6
+  const { roleName } = currentUser || {};
7
+  if (roleName == 'maker') {
7
     return {
8
     return {
8
-      admin:false,
9
-      org:true
10
-    }
11
-  }else if(roleAlias=='admin'){
9
+      admin: false,
10
+      maker: true,
11
+      auditor: false,
12
+    };
13
+  } else if (roleName == 'auditor') {
12
     return {
14
     return {
13
-      admin:true,
14
-      org:false
15
-    }
16
-  }
17
-  return (menuAccess || []).reduce((acc, item) => {
18
-    const { permission, canAccess } = item;
15
+      admin: false,
16
+      maker: false,
17
+      auditor: true,
18
+    };
19
+  } else if (roleName == 'admin') {
19
     return {
20
     return {
20
-      ...acc,
21
-      [permission]: canAccess,
21
+      admin: true,
22
+      maker: true,
23
+      auditor: true,
22
     };
24
     };
23
-  }, {});
25
+  }
26
+  return {};
24
 }
27
 }

+ 0
- 4
src/app.jsx 查看文件

28
 
28
 
29
   if (history.location.pathname !== loginPath) {
29
   if (history.location.pathname !== loginPath) {
30
     const res = await fetchUserInfo();
30
     const res = await fetchUserInfo();
31
-    localStorage.setItem('roleAlias', res.roleAlias);
32
     return {
31
     return {
33
       fetchUserInfo,
32
       fetchUserInfo,
34
       currentUser: res.user,
33
       currentUser: res.user,
35
-      menuAccess: res.menu,
36
-      report_url: res.report_url,
37
-      roleAlias: res.roleAlias,
38
       settings: {},
34
       settings: {},
39
     };
35
     };
40
   }
36
   }

+ 0
- 34
src/components/RightContent/QrCode/QrCode.jsx 查看文件

1
-import React, {useState, useRef, useEffect, useCallback} from 'react'
2
-import { useModel } from 'umi'
3
-import { Button, Spin } from 'antd';
4
-import QRCode from '@/components/QRCode'
5
-import styles from './style.less';
6
-
7
-export default (props) => {
8
-  const { initialState } = useModel('@@initialState');
9
-  const [isLoading, setLoading] = useState(false);
10
-
11
-  const qrcodeRef = useRef()
12
-
13
-  const downloadQrcode = useCallback(() => {
14
-    if (qrcodeRef.current) {
15
-      qrcodeRef.current.download();
16
-    }
17
-  }, [])
18
-
19
-  return isLoading ?
20
-    <Spin
21
-      size="small"
22
-      style={{
23
-        marginLeft: 8,
24
-        marginRight: 8,
25
-      }}
26
-    />
27
-  : (
28
-      <div className={styles.qrcodebox}>
29
-        <p>疫情监测结果表入口</p>
30
-        <QRCode ref={qrcodeRef} width={200} content={initialState.report_url} />
31
-        <p><Button onClick={downloadQrcode}>下载</Button></p>
32
-      </div>
33
-    )
34
-}

+ 0
- 16
src/components/RightContent/QrCode/index.jsx 查看文件

1
-import React from 'react';
2
-import { QrcodeOutlined } from '@ant-design/icons';
3
-import HeaderDropdown from '@/components/HeaderDropdown';
4
-import QrCode from './QrCode';
5
-import styles from '../index.less';
6
-
7
-export default (props) => {
8
-
9
-  return (
10
-    <HeaderDropdown overlay={<QrCode />}>
11
-      <span className={`${styles.action} ${styles.account}`} style={{ padding: 0 }}>
12
-        <span className={`${styles.name} anticon`}><QrcodeOutlined style={{ fontSize: '24px' }} /></span>
13
-      </span>
14
-    </HeaderDropdown>
15
-  );
16
-};

+ 0
- 7
src/components/RightContent/QrCode/style.less 查看文件

1
-.qrcodebox{
2
-  padding: 16px;
3
-  text-align: center;
4
-  img{
5
-    margin: 16px 0;
6
-  }
7
-}

+ 0
- 3
src/components/RightContent/index.jsx 查看文件

1
 import { Space } from 'antd';
1
 import { Space } from 'antd';
2
 import Avatar from './AvatarDropdown';
2
 import Avatar from './AvatarDropdown';
3
-import QRCode from './QrCode';
4
 import styles from './index.less';
3
 import styles from './index.less';
5
 
4
 
6
 const GlobalHeaderRight = () => {
5
 const GlobalHeaderRight = () => {
7
   let className = styles.right;
6
   let className = styles.right;
8
   className = `${styles.right}  ${styles.dark}`;
7
   className = `${styles.right}  ${styles.dark}`;
9
- 
10
   
8
   
11
   return (
9
   return (
12
     <Space className={className}>
10
     <Space className={className}>
13
-      <QRCode />
14
       <Avatar />      
11
       <Avatar />      
15
     </Space>
12
     </Space>
16
   );
13
   );

+ 1
- 5
src/pages/user/Login/index.jsx 查看文件

17
     setSubmitting(true);
17
     setSubmitting(true);
18
     try {
18
     try {
19
       // 登录
19
       // 登录
20
-      const { user, menu, report_url, roleAlias } = await login({ ...values, password: md5(values.password) });
21
-      localStorage.setItem('roleAlias', roleAlias);
20
+      const { user } = await login({ ...values, password: md5(values.password) });
22
       await setInitialState((s) =>
21
       await setInitialState((s) =>
23
       ({
22
       ({
24
         ...s,
23
         ...s,
25
         currentUser: user,
24
         currentUser: user,
26
-        menuAccess: menu,
27
-        report_url: report_url,
28
-        roleAlias: roleAlias
29
       }));
25
       }));
30
       message.success('登录成功!');
26
       message.success('登录成功!');
31
       /** 此方法会跳转到 redirect 参数所在的位置 */
27
       /** 此方法会跳转到 redirect 参数所在的位置 */