李志伟 пре 3 година
родитељ
комит
16b1560ae3

+ 13
- 0
config/routes.js Прегледај датотеку

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

+ 18
- 15
src/access.js Прегледај датотеку

@@ -2,23 +2,26 @@
2 2
  * @see https://umijs.org/zh-CN/plugins/plugin-access
3 3
  * */
4 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 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 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 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,13 +28,9 @@ export async function getInitialState() {
28 28
 
29 29
   if (history.location.pathname !== loginPath) {
30 30
     const res = await fetchUserInfo();
31
-    localStorage.setItem('roleAlias', res.roleAlias);
32 31
     return {
33 32
       fetchUserInfo,
34 33
       currentUser: res.user,
35
-      menuAccess: res.menu,
36
-      report_url: res.report_url,
37
-      roleAlias: res.roleAlias,
38 34
       settings: {},
39 35
     };
40 36
   }

+ 0
- 34
src/components/RightContent/QrCode/QrCode.jsx Прегледај датотеку

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

+ 1
- 5
src/pages/user/Login/index.jsx Прегледај датотеку

@@ -17,15 +17,11 @@ const Login = () => {
17 17
     setSubmitting(true);
18 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 21
       await setInitialState((s) =>
23 22
       ({
24 23
         ...s,
25 24
         currentUser: user,
26
-        menuAccess: menu,
27
-        report_url: report_url,
28
-        roleAlias: roleAlias
29 25
       }));
30 26
       message.success('登录成功!');
31 27
       /** 此方法会跳转到 redirect 参数所在的位置 */