Bladeren bron

增加报表route配置

code4eat 3 jaren geleden
bovenliggende
commit
0f5aea3f56
4 gewijzigde bestanden met toevoegingen van 106 en 9 verwijderingen
  1. 1 6
      config/proxy.ts
  2. 13 1
      config/routes.ts
  3. 36 2
      src/app.tsx
  4. 56 0
      src/pages/reports/index.tsx

+ 1 - 6
config/proxy.ts

@@ -1,11 +1,6 @@
 /*
  * @Author: your name
  * @Date: 2021-09-03 14:28:27
-<<<<<<< HEAD
- * @LastEditTime: 2022-01-14 10:07:19
-=======
- * @LastEditTime: 2022-03-04 18:32:02
->>>>>>> master
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /MedicalWisdomCheckSys/config/proxy.ts
@@ -24,7 +19,7 @@
 export default { 
   dev: {
     '/api': {
-      target: 'http://118.31.245.65:8083/',
+      target: 'http://112.124.59.133:8083/',
       changeOrigin: true,
       pathRewrite: { '^/api': '' },
     },

+ 13 - 1
config/routes.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-09-03 14:28:27
- * @LastEditTime: 2021-11-18 11:31:38
+ * @LastEditTime: 2022-03-11 18:57:13
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /MedicalWisdomCheckSys/config/routes.ts
@@ -148,6 +148,18 @@ export default [
     path: '/',
     redirect: '/GradeHospitalAccreditation/accreditationDetail',
   },
+  {
+    path: '/reports/a',
+    component: './reports',
+  },
+  {
+    path: '/reports/b',
+    component: './reports',
+  },
+  {
+    path: '/reports/c',
+    component: './reports',
+  },
   {
     component: './404',
   },

+ 36 - 2
src/app.tsx

@@ -1,7 +1,6 @@
 /*
  * @Author: your name
  * @Date: 2021-09-03 14:28:27
- * @LastEditTime: 2022-02-14 17:32:17
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /MedicalWisdomCheckSys/src/app.tsx
@@ -63,6 +62,7 @@ export async function getInitialState(): Promise<{
   currentUser?: API.CurrentUserData;
   logo?: string;
   isDev?: boolean,
+  spacicalPageParamsType?:any[];
   goSetting?: boolean,// 设置栏触发
   resetPasswordHandle?: (formData: any) => Promise<boolean>,
   fetchUserMenu?: () => Promise<menuDataItemType[]>,
@@ -321,10 +321,44 @@ export const layout: RunTimeLayoutConfig = ({ initialState,setInitialState }) =>
           }
       
           if (currentUser) {
-            const data: menuDataItemType[] = await getMenus();
+            const data: any[] = await getMenus();
             
             if(data){
               await setInitialState(t=>({...t,menu:data}));
+
+
+              /**
+               * 
+               * 菜单跳转报表临时处理,后期统一换成中台调用
+               */
+              const getVFromTree = (data:any[], key: string) => {
+                let result: any[] = [];
+                function looper(data: any[], key: string) {
+                  data.forEach((t) => {
+                    if (t[key] && t[key] != 0) {
+                      //非一般页面
+                      result.push({
+                        contentType: t[key],
+                        path: t['path'],
+                        reportId: t['reportId'],
+                        url: t['youshuUrl'],
+                      });
+                    }
+                    if (t.children && t.children.length > 0) {
+                      looper(t.children, key);
+                    }
+                  });
+                }
+                looper(data, key);
+                return result;
+              };
+
+              const _menu = getVFromTree(data, 'contentType');
+
+              setInitialState((t) => ({ ...t, spacicalPageParamsType: _menu }));
+              
+              /////////////////////////////--------临时处理----------///////////////////////////////////////////////
+              
               return mappingIcon(data);
             }
           } else {

+ 56 - 0
src/pages/reports/index.tsx

@@ -0,0 +1,56 @@
+/*
+ * @Author: your name
+ * @Date: 2022-03-03 18:04:40
+ * @LastEditTime: 2022-03-11 18:36:56
+ * @LastEditors: Please set LastEditors
+ * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/reports/index.tsx
+ */
+
+import { useEffect, useState } from 'react';
+import { useModel } from 'umi';
+import { Skeleton } from 'antd';
+
+export default () => {
+  const { initialState, setInitialState } = useModel('@@initialState');
+  const [specialPageUrl, setspecialPageUrl] = useState<string | undefined>(undefined);
+  const [loading, setloading] = useState(false);
+
+  const onLoadhandle = () => {
+    setloading(false);
+  };
+
+  useEffect(() => {
+    setloading(true);
+    console.log({initialState});
+    if (initialState && initialState.spacicalPageParamsType && initialState.currentUser) {
+      const {
+        spacicalPageParamsType,
+        currentUser: { youshuToken },
+      } = initialState;
+      const { pathname } = location;
+      const spacialPage = spacicalPageParamsType.filter((t) => `/app1${t.path}` == pathname);
+
+      console.log({pathname,spacialPage,spacicalPageParamsType,initialState});
+
+      if (spacialPage.length > 0) {
+        //当前页面属于有数数据展示页面
+        console.log(`${spacialPage[0].url}&token=${youshuToken}`);
+
+        const url = `${spacialPage[0].url}&token=${youshuToken}`;
+        setspecialPageUrl(url);
+      }
+    }
+  }, [initialState]);
+
+  return (
+    <>
+      <Skeleton loading={loading} paragraph={{ rows: 50 }} active />
+      <iframe
+        onLoad={() => onLoadhandle()}
+        style={{ width: '100%', height: '100%', border: 'none' }}
+        src={specialPageUrl}
+      ></iframe>
+    </>
+  );
+};