Forráskód Böngészése

菜单优化,无效声明删除,数据权限修改

zhouna 3 éve
szülő
commit
250ba0c1f4

+ 158 - 0
package-lock.json

@@ -3510,6 +3510,37 @@
       "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
       "optional": true
     },
+    "bl": {
+      "version": "4.1.0",
+      "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
+      "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
+      "requires": {
+        "buffer": "^5.5.0",
+        "inherits": "^2.0.4",
+        "readable-stream": "^3.4.0"
+      },
+      "dependencies": {
+        "buffer": {
+          "version": "5.7.1",
+          "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
+          "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
+          "requires": {
+            "base64-js": "^1.3.1",
+            "ieee754": "^1.1.13"
+          }
+        },
+        "readable-stream": {
+          "version": "3.6.0",
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+          "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+          "requires": {
+            "inherits": "^2.0.3",
+            "string_decoder": "^1.1.1",
+            "util-deprecate": "^1.0.1"
+          }
+        }
+      }
+    },
     "bluebird": {
       "version": "3.7.2",
       "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@@ -4111,6 +4142,22 @@
       "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
       "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="
     },
+    "commist": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/commist/-/commist-1.1.0.tgz",
+      "integrity": "sha512-rraC8NXWOEjhADbZe9QBNzLAN5Q3fsTPQtBV+fEVj6xKIgDgNiEVE6ZNfHpZOqfQ21YUzfVNUXLOEZquYvQPPg==",
+      "requires": {
+        "leven": "^2.1.0",
+        "minimist": "^1.1.0"
+      },
+      "dependencies": {
+        "leven": {
+          "version": "2.1.0",
+          "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
+          "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA="
+        }
+      }
+    },
     "common-tags": {
       "version": "1.8.0",
       "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
@@ -6869,6 +6916,27 @@
       "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
       "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
     },
+    "help-me": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/help-me/-/help-me-3.0.0.tgz",
+      "integrity": "sha512-hx73jClhyk910sidBB7ERlnhMlFsJJIBqSVMFDwPN8o2v9nmp5KgLq1Xz1Bf1fCMMZ6mPrX159iG0VLy/fPMtQ==",
+      "requires": {
+        "glob": "^7.1.6",
+        "readable-stream": "^3.6.0"
+      },
+      "dependencies": {
+        "readable-stream": {
+          "version": "3.6.0",
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+          "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+          "requires": {
+            "inherits": "^2.0.3",
+            "string_decoder": "^1.1.1",
+            "util-deprecate": "^1.0.1"
+          }
+        }
+      }
+    },
     "hex-color-regex": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/hex-color-regex/-/hex-color-regex-1.1.0.tgz",
@@ -9237,6 +9305,71 @@
         }
       }
     },
+    "mqtt": {
+      "version": "4.2.8",
+      "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz",
+      "integrity": "sha512-DJYjlXODVXtSDecN8jnNzi6ItX3+ufGsEs9OB3YV24HtkRrh7kpx8L5M1LuyF0KzaiGtWr2PzDcMGAY60KGOSA==",
+      "requires": {
+        "commist": "^1.0.0",
+        "concat-stream": "^2.0.0",
+        "debug": "^4.1.1",
+        "duplexify": "^4.1.1",
+        "help-me": "^3.0.0",
+        "inherits": "^2.0.3",
+        "minimist": "^1.2.5",
+        "mqtt-packet": "^6.8.0",
+        "pump": "^3.0.0",
+        "readable-stream": "^3.6.0",
+        "reinterval": "^1.1.0",
+        "split2": "^3.1.0",
+        "ws": "^7.5.0",
+        "xtend": "^4.0.2"
+      },
+      "dependencies": {
+        "concat-stream": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
+          "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
+          "requires": {
+            "buffer-from": "^1.0.0",
+            "inherits": "^2.0.3",
+            "readable-stream": "^3.0.2",
+            "typedarray": "^0.0.6"
+          }
+        },
+        "duplexify": {
+          "version": "4.1.2",
+          "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz",
+          "integrity": "sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==",
+          "requires": {
+            "end-of-stream": "^1.4.1",
+            "inherits": "^2.0.3",
+            "readable-stream": "^3.1.1",
+            "stream-shift": "^1.0.0"
+          }
+        },
+        "readable-stream": {
+          "version": "3.6.0",
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+          "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+          "requires": {
+            "inherits": "^2.0.3",
+            "string_decoder": "^1.1.1",
+            "util-deprecate": "^1.0.1"
+          }
+        }
+      }
+    },
+    "mqtt-packet": {
+      "version": "6.10.0",
+      "resolved": "https://registry.npmjs.org/mqtt-packet/-/mqtt-packet-6.10.0.tgz",
+      "integrity": "sha512-ja8+mFKIHdB1Tpl6vac+sktqy3gA8t9Mduom1BA75cI+R9AHnZOiaBQwpGiWnaVJLDGRdNhQmFaAqd7tkKSMGA==",
+      "requires": {
+        "bl": "^4.0.2",
+        "debug": "^4.1.1",
+        "process-nextick-args": "^2.0.1"
+      }
+    },
     "ms": {
       "version": "2.1.2",
       "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -12311,6 +12444,11 @@
         }
       }
     },
+    "reinterval": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/reinterval/-/reinterval-1.1.0.tgz",
+      "integrity": "sha1-M2Hs+jymwYKDOA3Qu5VG85D17Oc="
+    },
     "relateurl": {
       "version": "0.2.7",
       "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
@@ -13498,6 +13636,26 @@
         "extend-shallow": "^3.0.0"
       }
     },
+    "split2": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz",
+      "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==",
+      "requires": {
+        "readable-stream": "^3.0.0"
+      },
+      "dependencies": {
+        "readable-stream": {
+          "version": "3.6.0",
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+          "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+          "requires": {
+            "inherits": "^2.0.3",
+            "string_decoder": "^1.1.1",
+            "util-deprecate": "^1.0.1"
+          }
+        }
+      }
+    },
     "sprintf-js": {
       "version": "1.0.3",
       "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",

+ 1 - 0
package.json

@@ -12,6 +12,7 @@
     "axios": "^0.21.1",
     "craco-less": "^1.18.0",
     "html-loader": "^2.1.2",
+    "mqtt": "^4.2.8",
     "quill": "^1.3.7",
     "raw-loader": "^4.0.2",
     "react": "^17.0.2",

+ 7 - 5
src/api/index.js

@@ -1,6 +1,8 @@
 import api from './request';
+import { getCookie,setCookie } from '@utils/index'
 import {message} from 'antd'
 const axios=require('axios');
+
 //axios.defaults.baseURL = 'http://192.168.3.184:8871';//'http://192.168.2.237:8871/';
 const post=(url,data)=>{
     return axios({
@@ -44,8 +46,8 @@ function interceptors(){
 //拦截所有请求添加token
     axios.interceptors.request.use(function (req) {
         const tokenStr = localStorage.getItem('token');
-        const sysId = localStorage.getItem('systemId');
-        const hisId = localStorage.getItem('hospitalId');
+        const sysId = getCookie('systemId');
+        const hisId = getCookie('hospitalId');
         if (tokenStr) {
             (req.headers.Authorization = `Bearer ${tokenStr}`);
             sysId&&(req.headers.softwareId=sysId);
@@ -60,10 +62,10 @@ function interceptors(){
     //拦截响应
     axios.interceptors.response.use(function (res) {
         const code = res.data.code;
-        if (code===401||code===403) {   //401/403返回登录
+        if (code===401) {   //401/403返回登录
             localStorage.removeItem("token");
-            localStorage.removeItem("systemId");
-            localStorage.removeItem("hospitalId");
+            setCookie();
+            //localStorage.removeItem("hospitalId");
             message.error("登录信息失效,请重新登录");
             window.location = '/';
         }else{

+ 57 - 27
src/components/AHeader/index.js

@@ -4,7 +4,7 @@ import { useState, useEffect } from 'react';
 import { useSelector, useDispatch } from 'react-redux';
 import MyMessage from "../MyMessage";
 import { panesNow } from '@reducers/tabPanes.js';
-import utils from '@utils/index';
+import { getTimeDetail,getCookie,setCookie } from '@utils/index';
 import logo from '@images/logo.png';
 import msg from '@images/msg.png';
 import me from '@images/me.png';
@@ -12,7 +12,7 @@ import down from '@images/down.png';
 import './index.less'
 import { message } from "antd/lib/index";
 import { add, active } from '@reducers/tabPanes'
-import { setSys, setUser, setUnReadNum} from '@reducers/userInfo.js';
+import { setSys, setUser} from '@reducers/userInfo.js';
 import apiObj from '@api/index';
 
 const { post, api, xPost } = apiObj;
@@ -21,7 +21,7 @@ const propTypes = {
 }
 const defaultProps = {};
 const { Header } = Layout;
-const { getTimeDetail } = utils;
+
 function AHeader({ history, hideName }) {
     const dispatch = useDispatch();//当前选中的菜单
     const { panes } = useSelector(state => {
@@ -30,14 +30,17 @@ function AHeader({ history, hideName }) {
     const [form] = Form.useForm();
     const [dateTime, setDateTime] = useState('');
     const [visible, setVisible] = useState(false);
-    const { user, sysName,unReadNum } = useSelector((state) => {
+    //const [socket,setSocket] = useState(null);
+    const [unReadNum,setUnReadNum] = useState(0);
+    const { user, sysName } = useSelector((state) => {
         return state.userInfo;
     });
     //退出
     function loginOut() {
         localStorage.removeItem("token");
-        localStorage.removeItem("systemId");
-        localStorage.removeItem("hospitalId");
+        setCookie();
+        /*localStorage.removeItem("systemId");
+        localStorage.removeItem("hospitalId");*/
         dispatch(panesNow([]));
         history.push('/login');
     }
@@ -45,9 +48,12 @@ function AHeader({ history, hideName }) {
     function getNotNoticeCount(){
         xPost(api.getNotNoticeCount).then((res) => {
             if (res.data.code === 200) {
-                let count = res.data.count;
+                const data = res.data.data||{};
+                let count = data.count;
                 count = count>99?'99+':count;
-                dispatch(setUnReadNum(count));
+                setUnReadNum(count)
+                initWebsocket(count);
+                //dispatch(setUnReadNum(count));
             } else {
                 //message.warning(res.data.msg || '请求失败');
             }
@@ -64,23 +70,45 @@ function AHeader({ history, hideName }) {
             add({ title: '我的通知', content: <MyMessage />, key: 'ZNTZ-WDTZ&我的通知',isUnRead:true})
         )
     }
-    //获取组织列表
-    function getOrgList() {
-        xPost(api.getUserHospitals).then((res) => {
-            if (res.data.code === 200) {
-                const data = res.data.data;
-                const { userInfo, software } = data;
-                const sysId = localStorage.getItem("systemId");
-                const hisId = localStorage.getItem("hospitalId");
-                const sys = software.find((it) => {
-                    return +it.id === +sysId
-                });
-                dispatch(setUser(userInfo));
-                sys && dispatch(setSys({ sysId, sysName: sys.name, hisId }));
-            } else {
-                message.warning(res.data.msg || '获取医院列表失败');
-            }
+    async function initWebsocket(num){
+        const mqtt = require('mqtt');
+        const client  = mqtt.connect('ws://192.168.2.237:15675/ws');
+        //const userInfo = await getUserHos();
+        //const userdata = userInfo.data.data;
+        //handleUserInfo(userdata);
+        const hisId = getCookie("hospitalId");
+        //setSocket(client)
+        client.on('connect', function () {
+            client.subscribe(hisId+"-"+user.id, function (err) {
+                if (!err) {
+                    console.log(hisId+"-"+user.id+"订阅成功")
+                }
+            })
         })
+
+        client.on('message', function (topic, message) {
+            let n = num>unReadNum?num:unReadNum;
+            setUnReadNum(+n+1)
+            console.log('收到消息+1:',message.toString())
+        })
+    }
+    function handleUserInfo(data){
+        const { userInfo, software } = data;
+        const sysId = getCookie("systemId");
+        const hisId = getCookie("hospitalId");
+        const sys = software.find((it) => {
+            return +it.id === +sysId
+        });
+        dispatch(setUser(userInfo));
+        sys && dispatch(setSys({ sysId, sysName: sys.name, hisId }));
+    }
+    //获取组织列表
+    function getUserHos() {
+        return new Promise((resolve)=>{
+            xPost(api.getUserHospitals).then((res)=>{
+                resolve(res);
+            });
+        });
     }
     //修改密码
     function changePsd() {
@@ -108,9 +136,11 @@ function AHeader({ history, hideName }) {
     useEffect(() => {
         countTime();
         getNotNoticeCount();
-        if (!user.name) {
-            getOrgList();
-        }
+        //initWebsocket();
+        /*if (!user.name) {
+            //刷新操作时重新获取数据
+            //getOrgList();
+        }*/
         return function clearUp() {
             clearInterval(interVal)
         }

+ 23 - 5
src/components/AMenu/index.js

@@ -65,14 +65,32 @@ function AMenu() {
                 const data = res.data.data;
                 const menuData = data.showMenuInfo;
                 setMenuList(menuData);
-                firstMenuPage = menuData[0].children ? menuData[0].children[0] : menuData[0]
-                
+                firstMenuPage = findFirstPage(menuData);
+                const {menuName,code}=firstMenuPage;
+                dispatch(
+                    add({ title: menuName, content: pageMap[code] || <NullPage />, key: code+"&"+menuName })
+                );
             } else {
                 message.error(res.data.msg || '获取菜单失败');
             }
         })
     }
-    function getSubMenu(data) {
+    function findFirstPage(menuData){
+        //获取第一个菜单页面,默认选中
+        if(!menuData) return null;
+        let page1=null;
+        menuData.find((it)=>{
+            if(it.menuType==='1'){
+                page1=it;
+                return true;
+            }else if(it.menuType==='0'&&it.children){
+                page1=findFirstPage(it.children);
+                if(page1) return true
+            }
+        });
+        return page1;
+    }
+    function getSubMenu(data) {     //menuType=0目录,1页面,2按钮
         return data.map((it) => {
             if (it.menuType === '1') {
                 return (
@@ -91,14 +109,14 @@ function AMenu() {
     }
     useEffect(() => {
         getUserMenus();
-        const timeO = setTimeout(() => { 
+        /*const timeO = setTimeout(() => {
             dispatch(
                 add({ title: firstMenuPage.menuName, content: pageMap[firstMenuPage.menuName] || <NullPage />, key: firstMenuPage.code })
             );
         }, 500);
         return function clearOut() {
             clearTimeout(timeO);
-        }
+        }*/
 
     }, []);
     return (

+ 2 - 2
src/components/DataManager/AddData.js

@@ -6,11 +6,11 @@ import SelectedTag from '@common/SelectedTag.js';
 import MyDeptStruct from '@common/MyDeptStruct.js';
 import { useSelector } from 'react-redux'
 import apiObj from '@api/index';
-import utils from '@utils/index';
+import {filterIds } from '@utils/index';
 import backIcon from "@images/back.png";
 import DoctorList from "./doctorList"
 const { api, xPost } = apiObj;
-const {filterIds }=utils;
+
 const { SHOW_PARENT } = TreeSelect;
 const { TabPane } = Tabs;
 function AddData(props) {

+ 5 - 9
src/components/DataManager/doctorList.js

@@ -1,14 +1,10 @@
-import React, { useState, useEffect, useContext } from 'react';
-import { Form, Input, Button, Table, Select, Pagination, Space, TreeSelect, Tag } from 'antd';
-import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
+import React, { useState, useEffect } from 'react';
+import { Form, Input, Button, Table, Space, TreeSelect } from 'antd';
 import apiObj from '@api/index';
-import { useSelector } from 'react-redux'
-import utils from '@utils/index'
-import { getOverflowOptions } from 'antd/lib/tooltip/placements';
-const { post, api, xPost } = apiObj;
-const { Option } = Select;
+import { organizationData } from '@utils/index'
+const { post, api,} = apiObj;
 const { SHOW_PARENT } = TreeSelect;
-const { organizationData } = utils;
+
 function DoctorList(props) {
   useEffect(() => {
     getDoctorPage();

+ 3 - 4
src/components/DataManager/index.js

@@ -1,15 +1,14 @@
 import React, { useState, useEffect } from 'react';
 import { Form, Input, Button, Table, Select, Space, Modal, message, Row, Col } from 'antd';
-import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
-// import NormalPlayer from './testComponent/testComponent'
+import { PlusOutlined } from '@ant-design/icons';
 import '@common/common.less';
 import apiObj from '@api/index';
-import utils from '@utils/index';
+import {filterIds } from '@utils/index';
 import DataContext from './data-context';
 import AddData from './AddData';
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
-const {filterIds }=utils;
+
 function DataManager() {
   useEffect(() => {
     getDataAuthPage();

+ 2 - 11
src/components/FuncManager/AddFunc.js

@@ -1,15 +1,11 @@
 import React, {
   useState, useEffect, useContext
 } from 'react';
-import { Modal, Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
+import {  Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
 import apiObj from '@api/index';
-import utils from '@utils/index'
 import FuncContext from './func-context';
-import { useSelector } from 'react-redux'
-import Item from 'antd/lib/list/Item';
 const { post, api, xPost } = apiObj;
-const { Option, OptGroup } = Select;
-const { organizationData } = utils;
+const { Option } = Select;
 const { SHOW_PARENT } = TreeSelect;
 const { TextArea } = Input;
 function AddUser(props) {
@@ -18,12 +14,7 @@ function AddUser(props) {
   }, []);
   const [form] = Form.useForm();
   const { type,id,detail } = useContext(FuncContext);
-  const [treeData, setTreeData] = useState([]);
   const [treeFunc, setTreeFunc] = useState([]);
-  const staticInfo = useSelector(state => {
-    return state.staticInfo;
-  });
-  const { titleList } = staticInfo;
   const initialValues = detail
   //所属系统
   function getHospitalTree() {

+ 1 - 2
src/components/FuncManager/index.js

@@ -6,8 +6,7 @@ import AddFunc from './AddFunc';
 // import './index.less';
 import apiObj from '@api/index';
 import FuncContext from './func-context';
-import utils from '@utils/index'
-const { pickCheckedTreeIds } = utils;
+import { pickCheckedTreeIds } from '@utils/index'
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
 function OrgManager() {

+ 3 - 12
src/components/InpaManager/addInpa.js

@@ -1,16 +1,10 @@
 import React, {
-  useState, useEffect, useContext
+   useContext
 } from 'react';
-import { Modal, Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
+import {  Form, Input, Button, Switch, message, Space } from 'antd';
 import apiObj from '@api/index';
-import utils from '@utils/index'
 import InpaContext from './inpa-context';
-import { useSelector } from 'react-redux'
-import Item from 'antd/lib/list/Item';
-const { post, api, xPost } = apiObj;
-const { organizationData } = utils;
-const { Option, OptGroup } = Select;
-const { SHOW_PARENT } = TreeSelect;
+const { post, api } = apiObj;
 function AddUser(props) {
   const [form] = Form.useForm();
   const { id, type, formData } = useContext(InpaContext);
@@ -20,9 +14,6 @@ function AddUser(props) {
   function swichChange(val) {
     form.setFieldsValue({ status: val ? 1 : 0 })
   }
-  const onChangeRloe = value => {
-    form.setFieldsValue({ roles: value })
-  };
   const onFinish = values => {
     let params = values
     if (type == 2) {

+ 5 - 8
src/components/InpaManager/index.js

@@ -1,14 +1,13 @@
-import React, { useState, useEffect, useRef } from 'react';
-import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Modal, message, Row, Col, Tooltip } from 'antd';
-import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
+import React, { useState, useEffect } from 'react';
+import { Form, Input, Button, Table, Select, Space, Modal, message, Row, Col, Tooltip } from 'antd';
+import { PlusOutlined } from '@ant-design/icons';
 import '@common/common.less';
 import AddInpa from './addInpa'
 import apiObj from '@api/index';
 import { useSelector } from 'react-redux'
 import InpaContext from './inpa-context';
-import utils from '@utils/index'
+import { getValueFromEvent } from '@utils/index'
 const { post, api, xPost } = apiObj;
-const { organizationData, getValueFromEvent } = utils;
 const { Option } = Select;
 function InpaManager() {
   useEffect(() => {
@@ -17,7 +16,6 @@ function InpaManager() {
   }, []);
   const [form] = Form.useForm();
   const [userList, setUserList] = useState([]);
-  const [deptList, setDeptList] = useState([]);
   const [title, setTitle] = useState("");
   const [visible, setVisible] = useState(false);
   const [id, setId] = useState("");
@@ -25,7 +23,6 @@ function InpaManager() {
   const [modalType, setModalType] = useState("");
   const [type, setType] = useState("");
   const [formData, setFormData] = useState(null);
-  const [username, setUsername] = useState(null);
   const [total, setTotal] = useState(0);
   const [size, setSize] = useState(15);
   const [current, setCurrent] = useState(1);
@@ -34,7 +31,7 @@ function InpaManager() {
     current: 1,
     size: 15
   });
-  const { user, sysName } = useSelector((state) => {
+  const { user } = useSelector((state) => {
     return state.userInfo;
   });
   let data = {

+ 0 - 1
src/components/Login/index.js

@@ -2,7 +2,6 @@ import { Form, Input, Button, message } from 'antd';
 import { UserOutlined, LockOutlined } from '@ant-design/icons';
 import apiObj from '@api/index';
 import './index.less'
-import loginBg from '@images/login-bg.png'
 import loginIcon from '@images/logo1.png'
 
 const {post,api,interceptors} = apiObj;

+ 2 - 3
src/components/MsgManage/UserList.js

@@ -1,11 +1,10 @@
 import { useEffect, useState } from 'react';
 import { Table, Form, Input, Button, Row, Col, TreeSelect } from 'antd';
-import { DownOutlined, PlusOutlined } from '@ant-design/icons';
 import './index.less';
-import utils from '@utils/index'
+import { organizationData } from '@utils/index'
 import apiObj from '@api/index';
 const { post, api } = apiObj;
-const { organizationData } = utils;
+
 const { SHOW_PARENT } = TreeSelect;
 function UserList(props) {
     useEffect(() => {

+ 3 - 4
src/components/MsgManage/index.js

@@ -1,12 +1,11 @@
 import { useEffect, useState } from 'react';
 import { useSelector } from 'react-redux'
-import { Table, Modal, message, Menu, Breadcrumb, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd';
-import { DownOutlined, PlusOutlined } from '@ant-design/icons';
+import { Table, Modal, message, Space, Form, Button, Row, Col, Select } from 'antd';
+import { PlusOutlined } from '@ant-design/icons';
 import AddNewMsg from './AddNewMsg.js';
 import './index.less';
 import apiObj from '@api/index';
-import utils from '@utils/index'
-const { pickCheckedTreeIds } = utils;
+
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
 function MsgManage() {

+ 5 - 5
src/components/OrgManager/index.js

@@ -1,13 +1,13 @@
 import { useEffect, useState } from 'react';
 import { useSelector } from 'react-redux'
-import { Table, Modal, message, Menu, Breadcrumb, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd';
+import { Table, Modal, message, Menu, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd';
 import { DownOutlined, PlusOutlined } from '@ant-design/icons';
 import AddSubOrg from './AddSubOrg';
 import './index.less';
 import apiObj from '@api/index';
 import OrgContext from './org-context';
-import utils from '@utils/index'
-const { pickCheckedTreeIds, getValueFromEvent } = utils;
+import { pickCheckedTreeIds, getValueFromEvent,getCookie } from '@utils/index'
+
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
 function OrgManager() {
@@ -18,7 +18,7 @@ function OrgManager() {
         //     setTableHt(window.innerHeight - 260);
         // });
         //刷新列表
-        setOrgType(localStorage.getItem('type'))
+        setOrgType(getCookie('hosType'))
         getTableData();
         //解绑事件
         // return function clear() {
@@ -39,7 +39,7 @@ function OrgManager() {
     const [orgName, setOrgName] = useState('');      //上级组织名称,新增修改用
     const [orgDetail, setOrgDetail] = useState(null);
     const [typeId, setTypeId] = useState('');
-    const [orgType, setOrgType] = useState(localStorage.getItem('type'));
+    const [orgType, setOrgType] = useState(getCookie('hosType'));
     // const [hisTypeList, setHisTypeList] = useState([]);
     const [type, setType] = useState('');
     //从state中取出状态、类型列表

+ 4 - 4
src/components/RoleManager/index.js

@@ -1,15 +1,15 @@
 import {useEffect,useState} from 'react';
 import { useSelector } from 'react-redux'
 /*import { useDispatch,useSelector } from 'react-redux'*/
-import { Table,Modal, message, Menu, Breadcrumb, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd';
-import { DownOutlined,PlusOutlined } from '@ant-design/icons';
+import { Table,Modal, message,Space, Form, Input, Button, Row, Col, Select } from 'antd';
+import { PlusOutlined } from '@ant-design/icons';
 import AddRole from './AddRole';
 import './index.less';
 import apiObj from '@api/index';
 import RoleContext from './role-context';
-import utils from '@utils/index'
+import { pickCheckedTreeIds, getValueFromEvent } from '@utils/index'
 const {post,api,xPost} = apiObj;
-const { pickCheckedTreeIds, getValueFromEvent } = utils;
+
 const { Option } = Select;
 function RoleManager(){
     useEffect(() => {

+ 7 - 5
src/components/SysChoose/index.js

@@ -1,5 +1,5 @@
 import {useEffect,useState} from 'react';
-import { useDispatch, useSelector } from 'react-redux'
+import { useDispatch } from 'react-redux'
 import { setSys,setUser } from '@reducers/userInfo.js';
 import { Radio, Row, Col,Steps, Select, Button } from 'antd';
 import AHeader from '../AHeader'
@@ -8,6 +8,7 @@ import iconLb from '@images/lb.png';
 import iconHis from '@images/his.png';
 import rightIcon from '@images/right.png';
 import {message} from "antd/lib/index";
+import { getCookie,setCookie } from "@utils/index";
 import apiObj from '@api/index';
 
 const {api,xPost,interceptors} = apiObj;
@@ -43,13 +44,14 @@ function SysChoose({history}) {
     }
     //获取组织列表
     function getOrgList(){
-        xPost(api.getUserHospitals).then((res)=>{console.log(res)
+        xPost(api.getUserHospitals).then((res)=>{
             if(res.data.code===200){
                 const data = res.data.data;
                 const { software,userInfo } = data;
                 setOrgList(software);
                 setSysName(software[0].name)
                 setSysId(software[0].id);
+                setCookie('userId',userInfo.id);
                 dispatch(setUser(userInfo));
                 //默认显示第一个系统的组织
                 setHisList(software[0]?software[0].hospitals:[]);
@@ -69,9 +71,9 @@ function SysChoose({history}) {
         console.log(type);
         
         dispatch(setSys({sysId,sysName,hisId:id}));
-        localStorage.setItem('systemId', sysId || sysid);
-        localStorage.setItem('hospitalId',id);
-        localStorage.setItem('type', type);
+        setCookie('systemId', sysId || sysid);
+        setCookie('hospitalId',id);
+        setCookie('hosType', type);
         interceptors();
         history.push("/manage");
     }

+ 4 - 5
src/components/UserManager/addUser.js

@@ -1,15 +1,14 @@
 import React, {
   useState, useEffect, useContext
 } from 'react';
-import { Modal, Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
+import {  Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
 import apiObj from '@api/index';
-import utils from '@utils/index'
+import { organizationData } from '@utils/index'
 import UserContext from './user-context';
 import { useSelector } from 'react-redux'
-import Item from 'antd/lib/list/Item';
 const { post, api, xPost } = apiObj;
-const { Option, OptGroup } = Select;
-const { organizationData } = utils;
+const { Option } = Select;
+
 const { SHOW_PARENT } = TreeSelect;
 function AddUser(props) {
   useEffect(() => {

+ 5 - 6
src/components/UserManager/index.js

@@ -1,13 +1,13 @@
-import React, { useState, useEffect, useRef } from 'react';
-import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Dropdown, Modal, Breadcrumb, message, Row, Col } from 'antd';
-import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
+import React, { useState, useEffect} from 'react';
+import { Form, Input, Button, Table, Select, Space, Menu, Dropdown, Modal, message, Row, Col } from 'antd';
+import { DownOutlined, PlusOutlined } from '@ant-design/icons';
 import AddUser from './addUser'
 import '@common/common.less';
 import { useSelector } from 'react-redux'
 import apiObj from '@api/index';
 import UserContext from './user-context';
-import utils from '@utils/index'
-const { getValueFromEvent } = utils;
+import { getValueFromEvent } from '@utils/index'
+
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
 function UserManager() {
@@ -22,7 +22,6 @@ function UserManager() {
   const [modalType, setModalType] = useState("");
   const [type, setType] = useState("");
   const [formData, setFormData] = useState(null);
-  const [username, setUsername] = useState(null);
   const [roleList, setRoleList] = useState([]);
   const [size, setSize] = useState(15);
   const [total, setTotal] = useState(0);

+ 26 - 18
src/utils/index.js

@@ -1,7 +1,7 @@
 import { message } from 'antd';
 //统一处理请求成功、失败
 
-function handleResponse(res, callback, error) {
+export function handleResponse(res, callback, error) {
     if (res.data.code === 200) {
         callback()
     } else {
@@ -10,7 +10,7 @@ function handleResponse(res, callback, error) {
     }
 }
 
-function pickCheckedTreeIds(data, menuIds = [], resourceIds = []) {
+export function pickCheckedTreeIds(data, menuIds = [], resourceIds = []) {
     let arr = data.children;
     if (data.relation === '1') {
         data.softwareMenuId && menuIds.push(data.softwareMenuId);
@@ -29,7 +29,7 @@ function pickCheckedTreeIds(data, menuIds = [], resourceIds = []) {
     }
 }
 // 处理组织结构数据
-function organizationData(arr) {
+export function organizationData(arr) {
     arr.forEach(item => {
         item.value = item.hospitalId
         item.title = item.hospitalName
@@ -48,13 +48,13 @@ function organizationData(arr) {
 }
 
 // 去重
-function unique(arr) {
+export function unique(arr) {
     return arr.filter(function (item, index, arr) {
         return arr.indexOf(item, 0) === index;
     });
 }
 //时间获取
-function getTimeDetail() {
+export function getTimeDetail() {
     const d = new Date();
     const days = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
     let sec = d.getSeconds()
@@ -63,11 +63,29 @@ function getTimeDetail() {
     let str = `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日 / ${days[d.getDay()]} / ${hour > 9 ? hour : '0' + hour}:${min > 9 ? min : '0' + min}:${sec > 9 ? sec : '0' + sec}`
     return str;
 }
-function getValueFromEvent(e) {
+export function getValueFromEvent(e) {
     return e.target.value.replace(/(^\s*)|(\s*$)/g, '');
 }
+//存取cookie
+export function setCookie(cname,cvalue){
+    if(!cname){     //删除cookie
+        document.cookie = 'userId=;expires=Thu, 01 Jan 1970 00:00:00 GMT;';
+        return;
+    }
+    const text = cname+"="+cvalue;
+    document.cookie = text;
+}
+export function getCookie(cname){
+    var name = cname + "=";
+    var ca = document.cookie.split(';');
+    for(var i=0; i<ca.length; i++) {
+        var c = ca[i].trim();
+        if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
+    }
+    return "";
+}
 //从对象数组中遍历出id
-function filterIds(arr,str){    //arr需遍历的数组;str需拼接的字段数组
+export function filterIds(arr,str){    //arr需遍历的数组;str需拼接的字段数组
     let tempStr = '',temp='';
     return arr.map((it)=>{
         if(str){
@@ -79,14 +97,4 @@ function filterIds(arr,str){    //arr需遍历的数组;str需拼接的字段
         }
         return it.id+''
     })
-}
-const obj = {
-    handleResponse,
-    pickCheckedTreeIds,
-    organizationData,
-    getTimeDetail,
-    unique,
-    getValueFromEvent,
-    filterIds
-};
-export default obj;
+}