Browse Source

Merge branch 'dev'

张延森 3 years ago
parent
commit
982dcad481

+ 2
- 2
config/routes.js View File

@@ -48,10 +48,10 @@ export default [
48 48
         component: '@/pages/org/org/index.jsx',
49 49
       },
50 50
       {
51
-        path: '/org/edit',
51
+        path: '/org/Edit',
52 52
         name: '企业维护',
53 53
         hideInMenu: true,
54
-        component: '@/pages/org/org/Edit.jsx',
54
+        component: '@/pages/org/org/Edit',
55 55
       },
56 56
     ],
57 57
   },

+ 2
- 1
package.json View File

@@ -59,11 +59,12 @@
59 59
     "antd": "^4.17.0",
60 60
     "classnames": "^2.3.0",
61 61
     "echarts": "^5.3.2",
62
+    "html2canvas": "^1.4.1",
62 63
     "lodash": "^4.17.0",
63 64
     "md5": "^2.3.0",
64 65
     "moment": "^2.29.1",
65 66
     "omit.js": "^2.0.2",
66
-    "qrcodejs2": "^0.0.2",
67
+    "qrcode": "^1.5.0",
67 68
     "rc-menu": "^9.1.0",
68 69
     "rc-util": "^5.16.0",
69 70
     "react": "^17.0.0",

+ 2
- 3
src/app.jsx View File

@@ -4,7 +4,7 @@ import RightContent from '@/components/RightContent';
4 4
 import Footer from '@/components/Footer';
5 5
 import { currentUser as queryCurrentUser } from './services/user';
6 6
 import { requestConfig } from '@/utils/request';
7
-import myPath from './utils/myPath';
7
+import { getLoginPath } from './utils';
8 8
 
9 9
 const isDev = process.env.NODE_ENV === 'development';
10 10
 let loginPath = '/user/orgLogin';
@@ -21,7 +21,7 @@ export async function getInitialState() {
21 21
     try {
22 22
       return await queryCurrentUser();
23 23
     } catch (error) {
24
-      history.push(myPath());
24
+      history.push(getLoginPath());
25 25
     }
26 26
 
27 27
     return undefined;
@@ -30,7 +30,6 @@ export async function getInitialState() {
30 30
   if (history.location.pathname !== loginPath) {
31 31
     const res = await fetchUserInfo();
32 32
     localStorage.setItem('roleAlias', res.roleAlias);
33
-    localStorage.setItem('orgId', res.user.orgId);
34 33
     return {
35 34
       fetchUserInfo,
36 35
       currentUser: res.user,

+ 35
- 33
src/components/Footer/index.jsx View File

@@ -2,38 +2,40 @@ import { useIntl } from 'umi';
2 2
 import { GithubOutlined } from '@ant-design/icons';
3 3
 import { DefaultFooter } from '@ant-design/pro-layout';
4 4
 
5
-const Footer = () => {
6
-  const intl = useIntl();
7
-  const defaultMessage = intl.formatMessage({
8
-    id: 'app.copyright.produced',
9
-    defaultMessage: '云致科技',
10
-  });
11
-  const currentYear = new Date().getFullYear();
12
-  return (
13
-    <DefaultFooter
14
-      copyright={`${currentYear} ${defaultMessage}`}
15
-    // links={[
16
-    //   {
17
-    //     key: 'Ant Design Pro',
18
-    //     title: 'Ant Design Pro',
19
-    //     href: 'https://pro.ant.design',
20
-    //     blankTarget: true,
21
-    //   },
22
-    //   {
23
-    //     key: 'github',
24
-    //     title: <GithubOutlined />,
25
-    //     href: 'https://github.com/ant-design/ant-design-pro',
26
-    //     blankTarget: true,
27
-    //   },
28
-    //   {
29
-    //     key: 'Ant Design',
30
-    //     title: 'Ant Design',
31
-    //     href: 'https://ant.design',
32
-    //     blankTarget: true,
33
-    //   },
34
-    // ]}
35
-    />
36
-  );
37
-};
5
+const Footer = () => <></>
6
+
7
+// const Footer = () => {
8
+//   const intl = useIntl();
9
+//   const defaultMessage = intl.formatMessage({
10
+//     id: 'app.copyright.produced',
11
+//     defaultMessage: '云致科技',
12
+//   });
13
+//   const currentYear = new Date().getFullYear();
14
+//   return (
15
+//     <DefaultFooter
16
+//       copyright={`${currentYear} ${defaultMessage}`}
17
+//     // links={[
18
+//     //   {
19
+//     //     key: 'Ant Design Pro',
20
+//     //     title: 'Ant Design Pro',
21
+//     //     href: 'https://pro.ant.design',
22
+//     //     blankTarget: true,
23
+//     //   },
24
+//     //   {
25
+//     //     key: 'github',
26
+//     //     title: <GithubOutlined />,
27
+//     //     href: 'https://github.com/ant-design/ant-design-pro',
28
+//     //     blankTarget: true,
29
+//     //   },
30
+//     //   {
31
+//     //     key: 'Ant Design',
32
+//     //     title: 'Ant Design',
33
+//     //     href: 'https://ant.design',
34
+//     //     blankTarget: true,
35
+//     //   },
36
+//     // ]}
37
+//     />
38
+//   );
39
+// };
38 40
 
39 41
 export default Footer;

+ 70
- 0
src/components/QRCode/index.jsx View File

@@ -0,0 +1,70 @@
1
+import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useImperativeHandle } from 'react'
2
+import classNames from 'classnames'
3
+import QRCode from 'qrcode'
4
+import html2canvas from 'html2canvas'
5
+import styles from './style.less'
6
+
7
+export default forwardRef((props, ref) => {
8
+  const { className, width = 430, border, content, title, fileName, onError } = props
9
+
10
+  const rootRef = useRef()
11
+  const canvasRef = useRef()
12
+
13
+  const { style1, style2 } = useMemo(() => {
14
+    return {
15
+      style1: {
16
+        border: border ? '2px solid rgba(0,0,0)' : 'none',
17
+        borderRadius: border ? '8px' : 'none'
18
+      },
19
+      style2: {
20
+        width: `${width}px`,
21
+        height: `${width}px`,
22
+      }
23
+    }
24
+  }, [width, border])
25
+
26
+  const qrOption = useMemo(() => ({
27
+    margin: 0,
28
+    width: width,
29
+    errorCorrectionLevel: 'M'
30
+  }), [width])
31
+
32
+  useEffect(() => {
33
+    if (content) {
34
+      QRCode.toCanvas(canvasRef.current, content, qrOption, onError)
35
+    }
36
+  }, [content, qrOption, onError])
37
+
38
+  useImperativeHandle(ref, () => ({
39
+    download: () => {
40
+      return new Promise((resolve, reject) => {
41
+        html2canvas(rootRef.current).then((canvas) => {
42
+          const imageData = canvas.toDataURL('image/png', .8);
43
+          const link = document.createElement('a');
44
+          link.download = `${fileName || 'qrcode'}.png`
45
+          link.href = imageData
46
+          link.click()
47
+          resolve()
48
+        }).catch(reject)
49
+      })
50
+    },
51
+    getCanvas: () => {
52
+      return new Promise((resolve, reject) => {
53
+        html2canvas(rootRef.current).then((canvas) => {
54
+          resolve(canvas)
55
+        }).catch(reject)
56
+      })
57
+    }
58
+  }), [fileName])
59
+
60
+  return (
61
+    <div className={classNames(className, styles['qrcode-box'])} ref={rootRef}>
62
+      <div className={styles['qrcode-container']} style={style1}>
63
+        <canvas ref={canvasRef} style={style2}/>
64
+      </div>
65
+      {
66
+        title && <h3>{title}</h3>
67
+      }
68
+    </div>
69
+  )
70
+})

+ 18
- 0
src/components/QRCode/style.less View File

@@ -0,0 +1,18 @@
1
+
2
+.qrcode-box {
3
+  display: flex;
4
+  align-items: center;
5
+  justify-content: center;
6
+  flex-direction: column;
7
+
8
+  .qrcode-container {
9
+    padding: 16px;
10
+    flex: none;
11
+  }
12
+
13
+  h3 {
14
+    font-size: 24px;
15
+    font-weight: bold;
16
+    line-height: 3em;
17
+  }
18
+}

+ 7
- 6
src/components/RightContent/AvatarDropdown.jsx View File

@@ -6,18 +6,20 @@ import { stringify } from 'querystring';
6 6
 import HeaderDropdown from '../HeaderDropdown';
7 7
 import ChangePassword from './ChangePassword';
8 8
 import styles from './index.less';
9
-import myPath from '@/utils/myPath';
9
+import { getLoginPath } from '@/utils';
10 10
 
11 11
 /**
12 12
  * 退出登录,并且将当前的 url 保存
13 13
  */
14 14
 const loginOut = async () => {
15
+  const loginPath = getLoginPath()
16
+  
15 17
   localStorage.removeItem('token');
16 18
   const { query = {}, pathname } = history.location;
17 19
   const { redirect } = query;
18 20
   if (window.location.pathname !== '/user/login' && !redirect) {
19 21
     history.replace({
20
-      pathname: myPath(),
22
+      pathname: loginPath,
21 23
       search: stringify({
22 24
         redirect: pathname,
23 25
       }),
@@ -26,7 +28,7 @@ const loginOut = async () => {
26 28
 };
27 29
 const AvatarDropdown = ({ menu }) => {
28 30
   const [showPasswordModal, setShowPasswordModal] = useState(false);
29
-  const { initialState, setInitialState } = useModel('@@initialState');
31
+  const { initialState,setInitialState } = useModel('@@initialState');
30 32
 
31 33
   const onMenuClick = useCallback(
32 34
     (event) => {
@@ -34,7 +36,7 @@ const AvatarDropdown = ({ menu }) => {
34 36
 
35 37
       if (key === 'logout') {
36 38
         setInitialState((s) => ({ ...s, currentUser: undefined }));
37
-        loginOut('admin');
39
+        loginOut();
38 40
         return;
39 41
       }
40 42
 
@@ -43,13 +45,12 @@ const AvatarDropdown = ({ menu }) => {
43 45
         return;
44 46
       }
45 47
     },
46
-    [setInitialState],
48
+    [],
47 49
   );
48 50
 
49 51
   const handleChangeSuccessful = () => {
50 52
     message.success('密码修改成功');
51 53
     setShowPasswordModal(false);
52
-    setInitialState((s) => ({ ...s, currentUser: undefined }));
53 54
     loginOut();
54 55
     return;
55 56
   };

+ 5
- 27
src/components/RightContent/QrCode/QrCode.jsx View File

@@ -1,43 +1,21 @@
1 1
 import React, {useState, useRef, useEffect, useCallback} from 'react'
2 2
 import { useModel } from 'umi'
3 3
 import { Button, Spin } from 'antd';
4
-import QRCode from 'qrcodejs2'
4
+import QRCode from '@/components/QRCode'
5 5
 import styles from './style.less';
6 6
 
7 7
 export default (props) => {
8 8
   const { initialState } = useModel('@@initialState');
9 9
   const [isLoading, setLoading] = useState(false);
10
+
10 11
   const qrcodeRef = useRef()
11
-  const linkRef = useRef()
12 12
 
13 13
   const downloadQrcode = useCallback(() => {
14
-    if (linkRef.current) {
15
-      linkRef.current.click();
14
+    if (qrcodeRef.current) {
15
+      qrcodeRef.current.download();
16 16
     }
17 17
   }, [])
18 18
 
19
-
20
-  useEffect(() => {
21
-    // 初始化二维码
22
-    const qrcode = new QRCode(qrcodeRef.current, {
23
-      width: 200,
24
-      height: 200, // 高度
25
-      text: initialState.report_url
26
-    })
27
-
28
-    const canvas = qrcodeRef.current.querySelector('canvas')
29
-
30
-    // 创建下载链接
31
-    const aElement = document.createElement('a');
32
-    linkRef.current = aElement;
33
-    linkRef.current.download = 'qrcode.png'
34
-
35
-    // 构造链接地址
36
-    setLoading(true);
37
-    linkRef.current.href = canvas.toDataURL('image/jpg')
38
-    setLoading(false);
39
-  }, [])
40
-
41 19
   return isLoading ?
42 20
     <Spin
43 21
       size="small"
@@ -49,7 +27,7 @@ export default (props) => {
49 27
   : (
50 28
       <div className={styles.qrcodebox}>
51 29
         <p>疫情监测结果表入口</p>
52
-        <div ref={qrcodeRef} />
30
+        <QRCode ref={qrcodeRef} width={200} content={initialState.report_url} />
53 31
         <p><Button onClick={downloadQrcode}>下载</Button></p>
54 32
       </div>
55 33
     )

+ 29
- 29
src/pages/deleteLog/index.jsx View File

@@ -16,36 +16,31 @@ const formatterTime = (val) => {
16 16
 };
17 17
 
18 18
 export default (props) => {
19
-  const initDate = useRef(moment())
20
-  const deleteDateRef = useRef(moment())
21 19
   const { initialState } = useModel('@@initialState');
22
-  const [orgName,setOrgName]=useState('')
23
-
20
+  let myOrgId = initialState.currentUser.orgId;
24 21
 
25
-  const handleBeforSearch = (params) => {
26
-    const { createDate, deleteDate, ...others } = params;
22
+  const [orgName,setOrgName]=useState('')
27 23
 
28
-    let start, end;
29
-    if (!createDate || createDate.length < 1) {
30
-      // 默认时间是今天
31
-      start = moment().format('YYYY-MM-DD')
32
-      end = start
33
-    } else {
34
-      start = moment(createDate[0]).format('YYYY-MM-DD')
35
-      end = moment(createDate[1]).format('YYYY-MM-DD')
36
-    }
37
-    let deleteStart, deleteEnd;
38
-    if (!deleteDate || deleteDate.length < 1) {
39
-      // 默认时间是今天
40
-      deleteStart = moment().format('YYYY-MM-DD')
41
-      deleteEnd = deleteStart
42
-    } else {
43
-      deleteStart = moment(deleteDate[0]).format('YYYY-MM-DD')
44
-      deleteEnd = moment(deleteDate[1]).format('YYYY-MM-DD')
45
-    }
24
+  const [start, setStart] = useState()
25
+  const [end, setEnd] = useState()  
26
+  const [deleteStart, setdeleteStart] = useState()
27
+  const [deleteEnd, setdeleteEnd] = useState()
46 28
 
47
-    return { ...others, start, end, deleteStart, deleteEnd };
29
+  const handelChange = (date, dateStrings) => {
30
+    setStart(dateStrings[0])
31
+    setEnd(dateStrings[1])
48 32
   }
33
+  const handelDeleteChange = (date, dateStrings) => {
34
+    setdeleteStart(dateStrings[0])
35
+    setdeleteEnd(dateStrings[1])
36
+  }
37
+  const handleReset = () => {
38
+    setStart()
39
+    setEnd()
40
+    setdeleteStart()
41
+    setdeleteEnd()
42
+  }
43
+
49 44
   useEffect(()=>{
50 45
     if (initialState.currentUser.orgId) {
51 46
       getDetail(initialState.currentUser.orgId).then((res)=>{
@@ -83,7 +78,9 @@ export default (props) => {
83 78
       dataIndex: 'deleteDate',
84 79
       key: 'deleteDate',
85 80
       render: (t) => formatterTime(t),
86
-      renderFormItem: (_, record) => <RangePicker defaultValue={[deleteDateRef.current, deleteDateRef.current]} placeholder={['开始日期', '结束日期']} format='YYYY-MM-DD' />
81
+      renderFormItem: (_, record) => 
82
+      <RangePicker onChange={handelDeleteChange} 
83
+      placeholder={['开始日期', '结束日期']} format='YYYY-MM-DD' />
87 84
     },
88 85
     {
89 86
       title: '申请人',
@@ -95,17 +92,20 @@ export default (props) => {
95 92
       dataIndex: 'createDate',
96 93
       key: 'createDate',
97 94
       render: (t) => formatterTime(t),
98
-      renderFormItem: (_, record) => <RangePicker defaultValue={[initDate.current, initDate.current]} placeholder={['开始日期', '结束日期']} format='YYYY-MM-DD' />
95
+      renderFormItem: (_, record) => <RangePicker onChange={handelChange} placeholder={['开始日期', '结束日期']} format='YYYY-MM-DD' />
99 96
     },
100 97
   ]
101
-
102 98
   return (
103 99
     <PageHeaderWrapper>
104 100
       <PageTable
105 101
         columns={columns}
106 102
         request={getDeleteformList}
107 103
         options={false}
108
-        beforeSearchSubmit={handleBeforSearch}
104
+        search={{
105
+          defaultCollapsed:false
106
+        }}
107
+        params={{ start, end, deleteStart, deleteEnd,myOrgId }}        
108
+        onReset={handleReset}
109 109
         rowKey="formId"
110 110
       />
111 111
     </PageHeaderWrapper>

+ 0
- 194
src/pages/org/org/Edit.jsx View File

@@ -1,194 +0,0 @@
1
-import React, { useEffect, useState, useCallback, useRef } from 'react'
2
-import { useModel } from 'umi'
3
-import { Form, Input, Button, message } from 'antd';
4
-import ProCard from '@ant-design/pro-card';
5
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
-import QRCode from 'qrcodejs2'
7
-import md5 from 'md5';
8
-import { getDetail, saveOrg, updateOrg, saveOrgUser, getOrgAdminDetail } from '@/services/org';
9
-
10
-export default (props) => {
11
-  const { history } = props;
12
-  const { id } = history.location.query;
13
-  const { initialState } = useModel('@@initialState');
14
-
15
-  const [form] = Form.useForm();
16
-  const [formData, setFormData] = useState()
17
-  const [loading, setLoading] = useState(false)
18
-  const qrcodeRef = useRef()
19
-  const linkRef = useRef()
20
-
21
-  const [adminForm] = Form.useForm();
22
-  const [adminFormData, setAdminFormData] = useState()
23
-  const [adminLoading, setAdminLoading] = useState(false)
24
-
25
-  const downloadQrcode = useCallback(() => {
26
-    if (linkRef.current) {
27
-      linkRef.current.click();
28
-    }
29
-  }, [])
30
-  const onFinish = (values) => {
31
-    setLoading(true)
32
-    if (id) {
33
-      updateOrg(id, values).then(() => {
34
-        setLoading(false);
35
-        history.go(-1);
36
-      }).catch(() => {
37
-        setLoading(false);
38
-      })
39
-    } else {
40
-      saveOrg(values).then((res) => {
41
-        setLoading(false);
42
-        history.replace(`/org/edit?id=${res.orgId}`)
43
-      }).catch(() => {
44
-        setLoading(false);
45
-      })
46
-    }
47
-  };
48
-  const onFinishFailed = (errorInfo) => {
49
-    console.log('Failed:', errorInfo);
50
-  };
51
-
52
-  const onAdminFinish = (values) => {
53
-    if (!/^1[0-9]{10}$/.test(values.phone)) {
54
-      message.warning('请输入正确的十一位手机号');
55
-      setLoading(false);
56
-      return false;
57
-    }
58
-    var data = { ...adminFormData, ...values, password: md5(values.password), isAdmin: true };
59
-    setAdminLoading(true)
60
-    saveOrgUser(id, data).then(res => {
61
-      message.success('保存成功');
62
-      history.go(-1);
63
-      setAdminLoading(false)
64
-    }).catch(err => {
65
-      console.log(err);
66
-      setAdminLoading(false)
67
-    })
68
-  }
69
-
70
-  useEffect(() => {
71
-    if (id) {
72
-      getDetail(id).then(res => {
73
-        setFormData(res);
74
-        form.setFieldsValue(res);
75
-
76
-        // 初始化二维码
77
-        const qrcode = new QRCode(qrcodeRef.current, {
78
-          width: 160,
79
-          height: 160, // 高度
80
-          text: initialState.report_url + '#resume-work-form?org=' + id
81
-        })
82
-        const canvas = qrcodeRef.current.querySelector('canvas')
83
-        // 创建下载链接
84
-        const aElement = document.createElement('a');
85
-        linkRef.current = aElement;
86
-        linkRef.current.download = res.orgName + '.png'
87
-        linkRef.current.href = canvas.toDataURL('image/jpg')
88
-      })
89
-      getOrgAdminDetail(id).then((res) => {
90
-        setAdminFormData(res);
91
-        adminForm.setFieldsValue(res);
92
-      })
93
-    }
94
-  }, [id, form])
95
-
96
-  return (
97
-    <PageHeaderWrapper>
98
-      <ProCard tabs={{ type: 'card' }} style={{ minHeight: '700px' }}>
99
-        <ProCard.TabPane key={1} tab="基本信息">
100
-          <div style={{ maxWidth: '600px' }}>
101
-            <Form
102
-              name="basic"
103
-              form={form}
104
-              labelCol={{ span: 8 }}
105
-              wrapperCol={{ span: 16 }}
106
-              initialValues={formData}
107
-              onFinish={onFinish}
108
-              onFinishFailed={onFinishFailed}
109
-              autoComplete="off"
110
-            >
111
-              <Form.Item
112
-                label="企业名称"
113
-                name="orgName"
114
-                rules={[{ required: true, message: '请填写企业名称!' }]}
115
-              >
116
-                <Input />
117
-              </Form.Item>
118
-              <Form.Item
119
-                label="权重"
120
-                name="weight"
121
-                rules={[{ required: true, message: '请填写企业权重!' }]}
122
-              >
123
-                <Input type='number' min='0' />
124
-              </Form.Item>
125
-              {
126
-                id && <Form.Item label=' ' colon={false} wrapperCol={{ offset: 3 }}>
127
-                  <div ref={qrcodeRef} />
128
-                </Form.Item>
129
-              }
130
-              <Form.Item label=' ' colon={false} >
131
-                <Button type="primary" htmlType="submit" loading={loading}>
132
-                  保存
133
-                </Button>
134
-                {id &&
135
-                  <Button style={{ marginLeft: '32px' }} onClick={downloadQrcode} >
136
-                    下载二维码
137
-                  </Button>
138
-                }
139
-                <Button style={{ marginLeft: '32px' }} onClick={() => { history.go(-1); }} >返回</Button>
140
-              </Form.Item>
141
-            </Form>
142
-          </div>
143
-        </ProCard.TabPane>
144
-        <ProCard.TabPane disabled={!id} key={2} tab='管理员'>
145
-          <div style={{ maxWidth: '600px' }}>
146
-            <Form
147
-              form={adminForm}
148
-              labelCol={{ span: 8 }}
149
-              wrapperCol={{ span: 16 }}
150
-              initialValues={adminFormData}
151
-              onFinish={onAdminFinish}
152
-            >
153
-              <Form.Item
154
-                label="姓名"
155
-                name="userName"
156
-                rules={[{ required: true, message: '请填写管理员姓名!' }]}
157
-              >
158
-                <Input />
159
-              </Form.Item>
160
-              <Form.Item
161
-                label="手机号"
162
-                name="phone"
163
-                rules={[{ required: true, message: '请填写手机号!' }]}
164
-              >
165
-                <Input maxLength={11} />
166
-              </Form.Item>
167
-              <Form.Item
168
-                label="登录账号"
169
-                name="loginName"
170
-                rules={[{ required: true, message: '请填写登录账号!' }]}
171
-              >
172
-                <Input />
173
-              </Form.Item>
174
-              <Form.Item
175
-                label="密码"
176
-                name="password"
177
-                rules={[{ required: true, message: '请填写密码!' }]}
178
-              >
179
-                <Input />
180
-              </Form.Item>
181
-              <Form.Item label=' ' colon={false} >
182
-                <Button type="primary" htmlType="submit" loading={adminLoading}>
183
-                  保存
184
-                </Button>
185
-                <Button style={{ marginLeft: '32px' }} onClick={() => { history.go(-1); }}>返回</Button>
186
-              </Form.Item>
187
-            </Form>
188
-          </div>
189
-
190
-        </ProCard.TabPane>
191
-      </ProCard>
192
-    </PageHeaderWrapper>
193
-  )
194
-}

+ 84
- 0
src/pages/org/org/Edit/components/AdminPage.jsx View File

@@ -0,0 +1,84 @@
1
+import React, { useEffect, useState } from 'react'
2
+import { Form, Input, Button, message } from 'antd';
3
+import { history } from 'umi';
4
+import md5 from 'md5';
5
+import { saveOrgUser, getOrgAdminDetail } from '@/services/org';
6
+
7
+export default (props) => {
8
+  const { id } = props;
9
+  const [adminForm] = Form.useForm();
10
+  const [adminFormData, setAdminFormData] = useState()
11
+  const [adminLoading, setAdminLoading] = useState(false)
12
+
13
+  const onAdminFinish = (values) => {
14
+    if (!/^1[0-9]{10}$/.test(values.phone)) {
15
+      message.warning('请输入正确的十一位手机号');
16
+      setLoading(false);
17
+      return false;
18
+    }
19
+    var data = { ...adminFormData, ...values, password: md5(values.password), isAdmin: true };
20
+    setAdminLoading(true)
21
+    saveOrgUser(id, data).then(res => {
22
+      message.success('保存成功');
23
+      history.go(-1);
24
+      setAdminLoading(false)
25
+    }).catch(err => {
26
+      console.log(err);
27
+      setAdminLoading(false)
28
+    })
29
+  }
30
+  useEffect(() => {
31
+    if (id) {
32
+      getOrgAdminDetail(id).then((res) => {
33
+        setAdminFormData(res);
34
+        adminForm.setFieldsValue(res);
35
+      })
36
+    }
37
+  }, [id])
38
+  return (
39
+    <div style={{ maxWidth: '600px' }}>
40
+      <Form
41
+        form={adminForm}
42
+        labelCol={{ span: 8 }}
43
+        wrapperCol={{ span: 16 }}
44
+        onFinish={onAdminFinish}
45
+      >
46
+        <Form.Item
47
+          label="姓名"
48
+          name="userName"
49
+          rules={[{ required: true, message: '请填写管理员姓名!' }]}
50
+        >
51
+          <Input />
52
+        </Form.Item>
53
+        <Form.Item
54
+          label="手机号"
55
+          name="phone"
56
+          rules={[{ required: true, message: '请填写手机号!' }]}
57
+        >
58
+          <Input maxLength={11} />
59
+        </Form.Item>
60
+        <Form.Item
61
+          label="登录账号"
62
+          name="loginName"
63
+          rules={[{ required: true, message: '请填写登录账号!' }]}
64
+        >
65
+          <Input />
66
+        </Form.Item>
67
+        <Form.Item
68
+          label="密码"
69
+          name="password"
70
+          rules={[{ required: true, message: '请填写密码!' }]}
71
+        >
72
+          <Input />
73
+        </Form.Item>
74
+        <Form.Item label=' ' colon={false} >
75
+          <Button type="primary" htmlType="submit" loading={adminLoading}>
76
+            保存
77
+          </Button>
78
+          <Button style={{ marginLeft: '32px' }} onClick={() => { history.go(-1); }}>返回</Button>
79
+        </Form.Item>
80
+      </Form>
81
+    </div>
82
+
83
+  )
84
+}

+ 87
- 0
src/pages/org/org/Edit/components/BasicPage.jsx View File

@@ -0,0 +1,87 @@
1
+import { Form, Input, Button } from 'antd';
2
+import { history } from 'umi';
3
+import React, { useEffect, useState, useCallback, useRef, useMemo } from 'react'
4
+import { useModel } from 'umi'
5
+import { getDetail, saveOrg, updateOrg } from '@/services/org';
6
+import QRCode from './QRCode'
7
+
8
+export default (props) => {
9
+  const { id } = props;
10
+  const { initialState } = useModel('@@initialState');
11
+
12
+  const [form] = Form.useForm();
13
+  const [formData, setFormData] = useState()
14
+  const [loading, setLoading] = useState(false)
15
+
16
+  const qrcodeText = useMemo(() => initialState.report_url + '#resume-work-form?org=' + id, [id, initialState.report_url])
17
+
18
+  const onFinish = (values) => {
19
+    setLoading(true)
20
+    if (id) {
21
+      updateOrg(id, values).then(() => {
22
+        setLoading(false);
23
+        history.go(-1);
24
+      }).catch(() => {
25
+        setLoading(false);
26
+      })
27
+    } else {
28
+      saveOrg(values).then((res) => {
29
+        setLoading(false);
30
+        history.replace(`/org/Edit?id=${res.orgId}`)
31
+      }).catch(() => {
32
+        setLoading(false);
33
+      })
34
+    }
35
+  };
36
+  const onFinishFailed = (errorInfo) => {
37
+    console.log('Failed:', errorInfo);
38
+  };
39
+  useEffect(() => {
40
+    if (id) {
41
+      getDetail(id).then(res => {
42
+        setFormData(res);
43
+        form.setFieldsValue(res);
44
+      })
45
+    }
46
+  }, [id])
47
+  return (
48
+    <div style={{ maxWidth: '600px' }}>
49
+      <Form
50
+        name="basic"
51
+        form={form}
52
+        labelCol={{ span: 8 }}
53
+        wrapperCol={{ span: 16 }}
54
+        onFinish={onFinish}
55
+        onFinishFailed={onFinishFailed}
56
+        autoComplete="off"
57
+      >
58
+        <Form.Item
59
+          label="企业名称"
60
+          name="orgName"
61
+          rules={[{ required: true, message: '请填写企业名称!' }]}
62
+        >
63
+          <Input readOnly={formData?.canEditName} />
64
+        </Form.Item>
65
+        <Form.Item
66
+          label="权重"
67
+          name="weight"
68
+          rules={[{ required: true, message: '请填写企业权重!' }]}
69
+        >
70
+          <Input type='number' min='0' />
71
+        </Form.Item>
72
+        {
73
+          id && <Form.Item label='申报二维码' >
74
+            <QRCode text={qrcodeText} title={formData?.orgName} />
75
+          </Form.Item>
76
+        }
77
+        <Form.Item label=' ' colon={false} >
78
+          <Button type="primary" htmlType="submit" loading={loading}>
79
+            保存
80
+          </Button>
81
+          <Button style={{ marginLeft: '32px' }} onClick={() => { history.go(-1); }} >返回</Button>
82
+        </Form.Item>
83
+      </Form>
84
+    </div>
85
+
86
+  )
87
+}

+ 43
- 0
src/pages/org/org/Edit/components/QRCode.jsx View File

@@ -0,0 +1,43 @@
1
+import React, { useRef } from 'react'
2
+import { Popover, Button } from 'antd';
3
+import { QrcodeOutlined } from '@ant-design/icons';
4
+import QRCode from '@/components/QRCode'
5
+
6
+const style = {
7
+  display: 'flex',
8
+  alignItem: 'center',
9
+  justifyContent: 'center',
10
+  flexDirection: 'column',
11
+}
12
+
13
+export default (props) => {
14
+  const { text, title } = props
15
+
16
+  const qrcodeRef = useRef()
17
+  const download = () => {
18
+    if (qrcodeRef.current) {
19
+      qrcodeRef.current.getCanvas().then((canvas) => {
20
+        const imageData = canvas.toDataURL('image/png', .8);
21
+        const link = document.createElement('a');
22
+        link.download = `${title}.png`
23
+        link.href = imageData
24
+        link.click()
25
+      });
26
+    }
27
+  }
28
+
29
+  const content = (
30
+    <div style={style}>
31
+      <QRCode ref={qrcodeRef} border content={text} title={title} />
32
+      <div style={{ textAlign: 'center' }}>
33
+        <Button  onClick={download} type='primary'>下载</Button>
34
+      </div>
35
+    </div>
36
+  )
37
+
38
+  return (
39
+    <Popover content={content} placement="right">
40
+      <QrcodeOutlined style={{ fontSize: '32px' }} />
41
+    </Popover>
42
+  )
43
+}

+ 20
- 0
src/pages/org/org/Edit/index.jsx View File

@@ -0,0 +1,20 @@
1
+import ProCard from '@ant-design/pro-card';
2
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
3
+import AdminPage from './components/AdminPage';
4
+import BasicPage from './components/BasicPage';
5
+export default (props) => {
6
+  const { history } = props;
7
+  const { id } = history.location.query;
8
+  return (
9
+    <PageHeaderWrapper>
10
+      <ProCard tabs={{ type: 'card' }} style={{ minHeight: '700px' }}>
11
+        <ProCard.TabPane key={1} tab="基本信息">
12
+          <BasicPage id={id} />
13
+        </ProCard.TabPane>
14
+        <ProCard.TabPane disabled={!id} key={2} tab='管理员'>
15
+          <AdminPage id={id} />
16
+        </ProCard.TabPane>
17
+      </ProCard>
18
+    </PageHeaderWrapper>
19
+  )
20
+}

+ 2
- 3
src/pages/org/org/index.jsx View File

@@ -13,9 +13,8 @@ const formatterTime = (val) => {
13 13
 };
14 14
 
15 15
 export default (props) => {
16
-  // document.title='666'
17 16
   const handleClick = () => {
18
-    history.push('/org/edit');
17
+    history.push('/org/Edit');
19 18
   }
20 19
   const AddNew = useMemo(() => (
21 20
     <Button type="primary" icon={<PlusOutlined />} onClick={handleClick}>
@@ -43,7 +42,7 @@ export default (props) => {
43 42
       key: 'option',
44 43
       ellipsis: true,
45 44
       render: (_, record) => [
46
-        <Button type="link" key={1} onClick={() => history.push(`/org/edit?id=${record.orgId}`)}>
45
+        <Button type="link" key={1} onClick={() => history.push(`/org/Edit?id=${record.orgId}`)}>
47 46
           详情
48 47
         </Button>,
49 48
       ],

+ 6
- 3
src/pages/resumework/abnormal/index.jsx View File

@@ -1,15 +1,17 @@
1 1
 import React from 'react'
2
+import { useModel } from 'umi';
2 3
 import moment from 'moment';
3 4
 import { Badge, Image } from 'antd';
4 5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
5
-import { getAbnormalList,getOrgAbnormalList } from '@/services/work'
6
+import { getAbnormalList } from '@/services/work'
6 7
 import PageTable from '@/components/PageTable'
7 8
 
8 9
 const formatterTime = (val) => {
9 10
   return val ? moment(val).format('YYYY-MM-DD HH:mm') : '';
10 11
 };
11 12
 export default (props) => {
12
-  let role = localStorage.getItem('roleAlias');
13
+  const { initialState } = useModel('@@initialState');
14
+  let myOrgId = initialState.currentUser.orgId;
13 15
   const columns = [
14 16
     {
15 17
       title: '企业名称',
@@ -65,7 +67,8 @@ export default (props) => {
65 67
     <PageHeaderWrapper>
66 68
       <PageTable
67 69
         columns={columns}
68
-        request={role=='admin'?getAbnormalList:getOrgAbnormalList}
70
+        request={getAbnormalList}
71
+        params={{myOrgId}}
69 72
         search={false}
70 73
         options={false}
71 74
         rowKey="formId"

+ 3
- 0
src/pages/resumework/form/index.jsx View File

@@ -159,6 +159,9 @@ export default (props) => {
159 159
         request={getList}
160 160
         expfunc={exportList}
161 161
         options={false}
162
+        search={{
163
+          defaultCollapsed:false
164
+        }}
162 165
         form={{ ignoreRules: false }}
163 166
         manualRequest={true}
164 167
         revalidateOnFocus={false}

+ 0
- 1
src/pages/user/orgLogin/index.jsx View File

@@ -19,7 +19,6 @@ const Login = () => {
19 19
       // 登录
20 20
       const { user, menu, report_url, roleAlias } = await orgLogin({ ...values, password: md5(values.password) });
21 21
       localStorage.setItem('roleAlias', roleAlias);
22
-      localStorage.setItem('orgId', user.orgId);
23 22
       await setInitialState((s) => ({ ...s, currentUser: user, menuAccess: menu, report_url: report_url, roleAlias: roleAlias }));
24 23
       message.success('登录成功!');
25 24
       /** 此方法会跳转到 redirect 参数所在的位置 */

+ 11
- 19
src/services/work.js View File

@@ -1,5 +1,6 @@
1 1
 import request from '@/utils/request';
2 2
 import moment from 'moment';
3
+import { getIsAllParams } from '@/utils';
3 4
 
4 5
 // 获取列表
5 6
 export const getList = (params) => request('/resume-work-form', { params });
@@ -8,19 +9,20 @@ export const getList = (params) => request('/resume-work-form', { params });
8 9
 export const exportList = (params) => request('/resume-work-form/export', { params });
9 10
 
10 11
 // 获取异常列表
11
-export const getAbnormalList = (params) =>
12
-  request(
12
+export const getAbnormalList = (params) =>{
13
+  return request(
13 14
     `/resume-work-form?start=${moment(Date.now()).format('YYYY-MM-DD')}&end=${moment(
14 15
       Date.now(),
15
-    ).format('YYYY-MM-DD')}&isAll=true&isAbnormal=true`,
16
-    { params },
16
+    ).format('YYYY-MM-DD')}&isAbnormal=true`,
17
+    {params:getIsAllParams(params)},
17 18
   );
19
+    }
18 20
 // 获取删除列表
19
-export const getDeleteformList = (params) =>
20
-  request(
21
-    `/resume-work-form?isAll=true&isDelete=true`,
22
-    { params },
23
-  );
21
+export const getDeleteformList = (params) =>{
22
+  return request(`/resume-work-form?isDelete=true`, {
23
+    params:getIsAllParams(params),
24
+  });
25
+}
24 26
 
25 27
 /**
26 28
  * 删除提交记录
@@ -28,13 +30,3 @@ export const getDeleteformList = (params) =>
28 30
  * @returns
29 31
  */
30 32
 export const deleteworkForm = (id) => request(`/resume-work-form/${id}`, { method: 'delete' });
31
-
32
-let orgId = localStorage.getItem('orgId');
33
-// 获取企业异常列表
34
-export const getOrgAbnormalList = (params) =>
35
-  request(
36
-    `/resume-work-form?start=${moment(Date.now()).format('YYYY-MM-DD')}&end=${moment(
37
-      Date.now(),
38
-    ).format('YYYY-MM-DD')}&orgId=${orgId}&isAbnormal=true`,
39
-    { params },
40
-  );

+ 18
- 0
src/utils/index.js View File

@@ -0,0 +1,18 @@
1
+
2
+export function getLoginPath(){
3
+  let role = localStorage.getItem('roleAlias');
4
+  if (role == 'admin') {
5
+    return '/user/login'
6
+  } else {
7
+    return '/user/orgLogin'
8
+  }
9
+}
10
+
11
+export const getIsAllParams=(params)=>{
12
+  if (!params.myOrgId) {
13
+    params.isAll=true
14
+  } else {
15
+    params.orgId=params.myOrgId
16
+  }
17
+  return params
18
+}

+ 0
- 9
src/utils/myPath.js View File

@@ -1,9 +0,0 @@
1
-
2
-export default function myPath(){
3
-  let role = localStorage.getItem('roleAlias');
4
-  if (role == 'admin') {
5
-    return '/user/login'
6
-  } else {
7
-    return '/user/orgLogin'
8
-  }
9
-}