Kaynağa Gözat

添加注销接口/html模板

code4eat 3 yıl önce
ebeveyn
işleme
d7ca8d12d9

+ 1 - 1
.prettierrc

@@ -1,7 +1,7 @@
 {
   "singleQuote": true,
   "trailingComma": "all",
-  "printWidth": 80,
+  "printWidth": 100,
   "overrides": [
     {
       "files": ".prettierrc",

+ 4 - 2
config/config.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-07 10:04:20
- * @LastEditTime: 2022-02-09 13:56:26
+ * @LastEditTime: 2022-02-14 16:28:05
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/config/config.ts
@@ -17,6 +17,7 @@ export default defineConfig({
   nodeModulesTransform: {
     type: 'none',
   },
+  publicPath: '/',
   dva: {
     immer: true,
     hmr: true,
@@ -31,7 +32,7 @@ export default defineConfig({
     modifyVars: { '@ant-prefix': 'kcmp-ant' },
   }, //
   theme: {
-    // '@primary-color': '#1d4984',
+    '@primary-color': '#3376FE',
   },
   routes: [
     {
@@ -79,6 +80,7 @@ export default defineConfig({
   fastRefresh: {},
   layout: {
     layout: 'top',
+    title: '医务中台',
   },
   // mfsu: {},
   qiankun: {

+ 2 - 2
config/proxy.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-07 10:00:52
- * @LastEditTime: 2022-02-09 15:51:48
+ * @LastEditTime: 2022-02-14 16:17:25
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/config/proxy.ts
@@ -13,7 +13,7 @@
 const proxy: { [key: string]: any } = {
   dev: {
     '/master': {
-      target: 'http://192.168.50.176:7001/',
+      target: 'http://112.124.59.133:7001/',
       changeOrigin: true,
       pathRewrite: { '^/master': '' },
     },

BIN
public/favicon.ico


BIN
public/images/pfmIcon.png


BIN
public/images/platformIcon.png


+ 22 - 35
src/app.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-09 13:57:41
- * @LastEditTime: 2022-02-09 14:09:24
+ * @LastEditTime: 2022-02-14 17:33:26
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/app.ts
@@ -14,10 +14,11 @@ import { RequestConfig, history } from 'umi';
 import type { RequestOptionsInit } from 'umi-request';
 import { getHospSubSystemList } from '@/service/login';
 
-import {
-  BasicLayoutProps,
-  Settings as LayoutSettings,
-} from '@ant-design/pro-layout';
+import { BasicLayoutProps, Settings as LayoutSettings } from '@ant-design/pro-layout';
+import { logoutHandle } from './global';
+
+import platformIcon from '../public/images/platformIcon.png';
+import { Platforms } from './constant';
 
 const loginPath = '/login';
 
@@ -63,16 +64,19 @@ export async function getInitialState(): Promise<InitialStateType> {
     return undefined;
   };
 
+  const getAppIcon = (name: string) => {
+    return Platforms.filter((i) => i.name == name).length > 0
+      ? Platforms.filter((i) => i.name == name)[0].logo
+      : '';
+  };
+
   //获取当前账号所有子应用列表
   const getHospSubSystemListFunc = async () => {
     const data = await getHospSubSystemList();
     if (data) {
       const _data = data.map((t) => ({
         ...t,
-        icon:
-          t.name == '业务中台'
-            ? 'https://i.postimg.cc/J4fsWx1V/2x.png'
-            : 'https://i.postimg.cc/yNrSZ4pN/2x.png',
+        icon: getAppIcon(t.name),
         url: t.name == '业务中台' ? '/platform/setting/userManage' : '/app1',
       }));
 
@@ -81,11 +85,7 @@ export async function getInitialState(): Promise<InitialStateType> {
     return [];
   };
 
-  const logout = () => {
-    localStorage.removeItem('userData');
-    history.replace(`${loginPath}?hospSign=${hospSign}`);
-    return Promise.resolve(true);
-  };
+  const logout = logoutHandle;
 
   const userData = await fetchUserInfo();
 
@@ -108,10 +108,7 @@ export async function getInitialState(): Promise<InitialStateType> {
   };
 }
 
-const requestInterceptorsHandle = (
-  url: string,
-  options: RequestOptionsInit,
-) => {
+const requestInterceptorsHandle = (url: string, options: RequestOptionsInit) => {
   const userData = localStorage.getItem('userData');
   let authHeader = { token: '' };
 
@@ -126,10 +123,7 @@ const requestInterceptorsHandle = (
   };
 };
 
-const responseInterceptorsHandle = async (
-  response: Response,
-  options: RequestOptionsInit,
-) => {
+const responseInterceptorsHandle = async (response: Response, options: RequestOptionsInit) => {
   const _response: {
     data?: any;
     status: number;
@@ -141,8 +135,11 @@ const responseInterceptorsHandle = async (
     if (_response.data) {
       return _response.data;
     }
+    // notification.success({
+    //   message: `${_response.msg}`,
+    // });
     notification.success({
-      message: `${_response.msg}`,
+      message: `操作成功!`,
     });
     return {
       status: _response.status,
@@ -242,9 +239,7 @@ export const qiankun = fetch('/config').then(() => ({
   ],
   // 完整生命周期钩子请看 https://qiankun.umijs.org/zh/api/#registermicroapps-apps-lifecycles
   lifeCycles: {
-    afterMount: (props: any) => {
-      console.log(props);
-    },
+    afterMount: (props: any) => {},
   },
   // 支持更多的其他配置,详细看这里 https://qiankun.umijs.org/zh/api/#start-opts
 }));
@@ -260,19 +255,11 @@ export function useQiankunStateForSlave() {
 }
 
 export const layout = ({
-  initialState: {
-    systemLists = [],
-    openedSysLists = [],
-    userData,
-    currentSelectedSys,
-  },
+  initialState: { userData },
 }: {
   initialState: InitialStateType;
 }): BasicLayoutProps => {
   return {
-    // headerRender: () => (
-    //   <TopHoc systemLists={systemLists} openedSysLists={openedSysLists} currentSelectedSys={currentSelectedSys} />
-    // ),
     headerRender: false,
     rightContentRender: () => <>right</>,
     footerRender: () => null,

+ 9 - 29
src/components/topBar/index.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-16 09:12:37
- * @LastEditTime: 2022-02-09 14:32:22
+ * @LastEditTime: 2022-02-14 11:39:52
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/pages/index/components/topBar/index.tsx
@@ -93,17 +93,11 @@ const TopBar: React.FC<TopBarType> = (props) => {
   const UserPannel = () => {
     return (
       <div className={styles.userPannel}>
-        <div
-          className={styles.userPannelTab}
-          onClick={() => _userPannelTabClick('SETTING')}
-        >
+        <div className={styles.userPannelTab} onClick={() => _userPannelTabClick('SETTING')}>
           <SettingOutlined />
           设置
         </div>
-        <div
-          className={styles.userPannelTab}
-          onClick={() => _userPannelTabClick('LOGOUT')}
-        >
+        <div className={styles.userPannelTab} onClick={() => _userPannelTabClick('LOGOUT')}>
           <LogoutOutlined />
           退出
         </div>
@@ -115,6 +109,7 @@ const TopBar: React.FC<TopBarType> = (props) => {
     if (openedTabs.length == 1) {
       //当有且仅当只有一个的时候,默认激活
       setCurrentSelectedTab(openedTabs[0]);
+      history.push(openedTabs[0].url);
     }
     if (openedTabs.length == 0) {
       //当所有tab都关闭时
@@ -135,11 +130,7 @@ const TopBar: React.FC<TopBarType> = (props) => {
         <img className={styles.logo} src={logo} />
       </div>
       <div
-        className={
-          ifOpenPannel
-            ? `${styles.platformMenu} ${styles.on}`
-            : `${styles.platformMenu}`
-        }
+        className={ifOpenPannel ? `${styles.platformMenu} ${styles.on}` : `${styles.platformMenu}`}
         onClick={() => setIfOpenPannel(!ifOpenPannel)}
       >
         <img src={platFormMenuIcon} />
@@ -164,19 +155,13 @@ const TopBar: React.FC<TopBarType> = (props) => {
           <div
             key={item.id}
             className={
-              currentSelectedTab?.id == item.id
-                ? `${styles.tab} ${styles.on}`
-                : `${styles.tab}`
+              currentSelectedTab?.id == item.id ? `${styles.tab} ${styles.on}` : `${styles.tab}`
             }
             onClick={() => _systemTabClickHandle(item)}
           >
             <div className={styles.tabText}>{item.name} </div>
             <div className={styles.closeIconWrap}>
-              <img
-                src={tabCloseIcon}
-                onClick={(e) => closeTabHandle(item, e)}
-                alt="close"
-              />
+              <img src={tabCloseIcon} onClick={(e) => closeTabHandle(item, e)} alt="close" />
             </div>
           </div>
         ))}
@@ -194,15 +179,10 @@ const TopBar: React.FC<TopBarType> = (props) => {
           onVisibleChange={(visible) => setArrowRotate(visible)}
         >
           <div className={styles.user}>
-            <img
-              className={styles.avator}
-              src={require('../../../public/images/Mask.png')}
-            />
+            <img className={styles.avator} src={require('../../../public/images/Mask.png')} />
             <span className={styles.name}>{userData?.name}</span>
             <img
-              className={
-                arrowRotate ? `${styles.arrow} ${styles.on}` : `${styles.arrow}`
-              }
+              className={arrowRotate ? `${styles.arrow} ${styles.on}` : `${styles.arrow}`}
               src={require('../../../public/images/arrow_white.png')}
             />
           </div>

+ 16 - 2
src/constant.ts

@@ -1,12 +1,15 @@
 /*
  * @Author: your name
  * @Date: 2022-01-14 16:09:09
- * @LastEditTime: 2022-01-14 16:13:10
- * @LastEditors: your name
+ * @LastEditTime: 2022-02-14 16:32:54
+ * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/constant.ts
  */
 
+import platformIcon from '../public/images/platformIcon.png';
+import pfmIcon from '../public/images/pfmIcon.png';
+
 //菜单所有类型
 export const MenuTypes = [
   {
@@ -26,3 +29,14 @@ export const MenuTypes = [
     value: 3,
   },
 ];
+
+export const Platforms = [
+  {
+    name: '业务中台',
+    logo: platformIcon,
+  },
+  {
+    name: '智慧查检',
+    logo: pfmIcon,
+  },
+];

+ 35 - 2
src/global.tsx

@@ -1,11 +1,44 @@
 /*
  * @Author: your name
  * @Date: 2021-12-21 11:05:37
- * @LastEditTime: 2022-01-06 11:24:06
+ * @LastEditTime: 2022-02-14 15:53:08
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/global.tsx
  */
 
+import { history } from 'umi';
+import { logout } from './service/login';
 
-import { history } from 'umi';
+interface EventType extends Event {
+  key?: string;
+}
+
+const loginPath = '/login';
+
+export const logoutHandle = async () => {
+  await logout();
+  localStorage.removeItem('userData');
+};
+
+(function () {
+  let originalRemoveItem = localStorage.removeItem;
+  //重写removeItem函数
+  localStorage.removeItem = function (key) {
+    let event: EventType = new Event('removeLocalItemEvent');
+    event.key = key;
+    //提交事件
+    window.dispatchEvent(event);
+    //执行原removeItem函数
+    originalRemoveItem.apply(this, [`${key}`]);
+  };
+})();
+
+//添加removeLocalItemEvent监听事件
+//用于子应用token过期触发登录
+window.addEventListener('removeLocalItemEvent', function (e: EventType) {
+  if (e.key == 'userData') {
+    const hospSign = localStorage.getItem('hospSign');
+    history.replace(`${loginPath}?hospSign=${hospSign}`);
+  }
+});

+ 6 - 12
src/layouts/index.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-09 13:56:33
- * @LastEditTime: 2022-02-10 08:53:19
+ * @LastEditTime: 2022-02-14 17:02:18
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/layouts/index.tsx
@@ -122,7 +122,7 @@ export default function Layout({
   match,
 }: IRouteComponentProps) {
   const { initialState, setInitialState } = useModel('@@initialState');
-
+  const viewportH = window.innerHeight;
   // console.log({children, location, route, history, match});
   if (location.pathname == '/index' || location.pathname == '/login') {
     return <div>{children}</div>;
@@ -138,22 +138,16 @@ export default function Layout({
       headerRender={() =>
         initialState && (
           <TopHoc
-            systemLists={
-              initialState.systemLists ? initialState.systemLists : []
-            }
-            openedSysLists={
-              initialState.openedSysLists ? initialState.openedSysLists : []
-            }
+            systemLists={initialState.systemLists ? initialState.systemLists : []}
+            openedSysLists={initialState.openedSysLists ? initialState.openedSysLists : []}
             currentSelectedSys={
-              initialState.currentSelectedSys
-                ? initialState.currentSelectedSys
-                : undefined
+              initialState.currentSelectedSys ? initialState.currentSelectedSys : undefined
             }
           />
         )
       }
     >
-      <div style={{ height: 'calc(100vh - 48px)' }}>{children}</div>
+      <div style={{ height: `calc(100vh - 48px)`, overflowY: 'scroll' }}>{children}</div>
     </ProLayout>
   );
 }

+ 26 - 0
src/pages/document.ejs

@@ -0,0 +1,26 @@
+<!--
+ * @Author: your name
+ * @Date: 2022-02-14 14:02:45
+ * @LastEditTime: 2022-02-14 16:20:23
+ * @LastEditors: Please set LastEditors
+ * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ * @FilePath: /KC-MiddlePlatform/src/pages/document.ejs
+-->
+
+
+<!doctype html>
+<html>
+<head>
+  <meta charset="utf-8" />
+  <meta  name="description" content="康程智医技术出品" />
+  <meta
+  name="viewport"
+  content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
+/>
+  <title>医务中台</title>
+  <link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon" />
+</head>
+<body>
+  <!-- <div id="root"></div> -->
+</body>
+</html>

+ 11 - 30
src/pages/login/index.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-09 14:58:08
- * @LastEditTime: 2022-02-10 16:52:48
+ * @LastEditTime: 2022-02-14 14:29:52
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/pages/login/index.tsx
@@ -31,16 +31,11 @@ const LoginPage: React.FC<LoginPageType> = ({ location, children }) => {
   const [transitionObj, setTransitionObj] = useState<string>();
   const [transformObj, setTransformObj] = useState<string>();
   const loginPageRef = useRef<HTMLDivElement>(null);
-  const [subHospList, setSubHospList] = useState<
-    { name: string; value: string | number }[]
-  >([]); //分院列表
+  const [subHospList, setSubHospList] = useState<{ name: string; value: string | number }[]>([]); //分院列表
   const [ifSelectSystem, setIfSelectSystem] = useState(false); //是否跳转到选择系统界面
   const [ifLoading, setIfLoading] = useState(false);
-  const [systemList, setSystemList] = useState<userRelationInfo.OwnAppsItem[]>(
-    [],
-  ); //可选平台列表
-  const [currentHospName, setCurrentHospName] =
-    useState('欢迎进入医务管理系统');
+  const [systemList, setSystemList] = useState<userRelationInfo.OwnAppsItem[]>([]); //可选平台列表
+  const [currentHospName, setCurrentHospName] = useState('欢迎进入医务管理系统');
   const { initialState, setInitialState } = useModel('@@initialState');
 
   const onMouseMoveHandle = (mouseEvent: any) => {
@@ -57,9 +52,7 @@ const LoginPage: React.FC<LoginPageType> = ({ location, children }) => {
         percentageY = deltaY / centerY;
       let deg = 20; //控制 偏差的 程度
       // console.log(percentageX*20,percentageY*20);
-      setTransformObj(
-        `translate(${percentageX * deg}px,${percentageY * deg}px)`,
-      );
+      setTransformObj(`translate(${percentageX * deg}px,${percentageY * deg}px)`);
       // setTransformObj('rotateX(' + percentageY * deg + 'deg)');
     }
   };
@@ -170,10 +163,7 @@ const LoginPage: React.FC<LoginPageType> = ({ location, children }) => {
       {location.pathname == '/login' ? (
         <div className="loginBlock">
           <div className="left">
-            <img
-              className="bannerImg"
-              src={require('../../../public/images/loginBannner.png')}
-            />
+            <img className="bannerImg" src={require('../../../public/images/loginBannner.png')} />
           </div>
           <div className="rightLoginArea">
             <div className="subHospSelector">
@@ -203,29 +193,20 @@ const LoginPage: React.FC<LoginPageType> = ({ location, children }) => {
             <Form onFinish={onFinish}>
               <Form.Item
                 name="account"
-                rules={[
-                  { required: true, message: 'Please input your username!' },
-                ]}
+                rules={[{ required: true, message: 'Please input your username!' }]}
               >
-                <Input className="input" />
+                <Input className="input" placeholder="请输入用户名" />
               </Form.Item>
 
               <Form.Item
                 name="password"
-                rules={[
-                  { required: true, message: 'Please input your password!' },
-                ]}
+                rules={[{ required: true, message: 'Please input your password!' }]}
               >
-                <Input.Password className="input" />
+                <Input.Password className="input" placeholder="请输入密码" />
               </Form.Item>
 
               <Form.Item>
-                <Button
-                  className="loginBtn"
-                  type="primary"
-                  htmlType="submit"
-                  loading={ifLoading}
-                >
+                <Button className="loginBtn" type="primary" htmlType="submit" loading={ifLoading}>
                   登录
                 </Button>
               </Form.Item>

+ 7 - 31
src/pages/platform/_layout.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 15:25:39
- * @LastEditTime: 2022-02-08 17:24:15
+ * @LastEditTime: 2022-02-14 16:42:22
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/_layout.tsx
@@ -51,31 +51,7 @@ export default function Layout({
             if (systemId) {
               const menuData = await getPlatformMenu(systemId);
 
-              // return menuData;
-              return [
-                {
-                  path: '/platform/setting',
-                  name: '系统设置',
-                  routes: [
-                    {
-                      path: '/platform/setting/userManage',
-                      name: '用户管理',
-                    },
-                    {
-                      path: '/platform/setting/hospManage',
-                      name: '院区管理',
-                    },
-                    {
-                      path: '/platform/setting/menuManage',
-                      name: '菜单管理',
-                    },
-                    {
-                      path: '/platform/setting/roleManage',
-                      name: '角色管理',
-                    },
-                  ],
-                },
-              ];
+              return menuData;
             }
             return [];
           }
@@ -88,15 +64,15 @@ export default function Layout({
       navTheme="light"
     >
       <PageContainer
-        header={{}}
+        className="kcmpPageContainer"
+        header={{
+          title: '',
+        }}
         style={{
           margin: 0,
         }}
       >
-        <div
-          className="page"
-          style={{ height: 'calc(100vh - 180px)', overflowY: 'scroll' }}
-        >
+        <div className="page" style={{ height: 'calc(100vh - 98px)', overflowY: 'scroll' }}>
           {children}
         </div>
       </PageContainer>

+ 13 - 1
src/pages/platform/index.less

@@ -3,6 +3,18 @@
 //     // box-shadow: 2px 0px 6px 0px rgba(54, 61, 77, 0.1);
 //     box-shadow: 12px 12px 2px 1px rgba(0, 0, 255, .2);
 // }
-.ant-pro-sider-light .ant-menu-light {
+.kcmp-ant-pro-sider-light .kcmp-ant-menu-light {
   border-right-color: rgba(54, 61, 77, 0.1);
 }
+
+.kcmp-ant-page-header {
+  background-color: #f0f2f5;
+}
+
+.kcmpPageContainer {
+  .kcmp-ant-pro-page-container-children-content {
+    margin: 0;
+    margin-left: 24px;
+    margin-right: 24px;
+  }
+}

+ 10 - 7
src/service/login.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-11 10:35:56
- * @LastEditTime: 2022-01-10 11:46:01
+ * @LastEditTime: 2022-02-14 15:46:24
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/service/login.ts
@@ -24,12 +24,9 @@ export const getHospConfigBySign = async (hospSign: string) => {
 
 //获取该账户拥有的子应用列表
 export const getHospSubSystemList = async () => {
-  return request<userRelationInfo.OwnAppsItem[]>(
-    '/master/centerSys/user/getSystemList',
-    {
-      method: 'GET',
-    },
-  );
+  return request<userRelationInfo.OwnAppsItem[]>('/master/centerSys/user/getSystemList', {
+    method: 'GET',
+  });
 };
 
 export const login = async (data: LoginApi.LoginParams) => {
@@ -42,3 +39,9 @@ export const login = async (data: LoginApi.LoginParams) => {
     data: data,
   });
 };
+
+export const logout = async () => {
+  return request('/master/centerSys/logout', {
+    method: 'POST',
+  });
+};