code4eat 3 лет назад
Родитель
Сommit
ee9d21390d
2 измененных файлов с 92 добавлено и 2 удалено
  1. 37 2
      src/app.tsx
  2. 55 0
      src/pages/reports/index.tsx

+ 37 - 2
src/app.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-09-03 14:28:27
- * @LastEditTime: 2022-01-05 09:22:09
+ * @LastEditTime: 2022-03-11 18:01:43
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /MedicalWisdomCheckSys/src/app.tsx
@@ -64,6 +64,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[]>,
@@ -327,10 +328,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 {

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

@@ -0,0 +1,55 @@
+/*
+ * @Author: your name
+ * @Date: 2022-03-03 18:04:40
+ * @LastEditTime: 2022-03-11 18:03:26
+ * @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);
+    if (initialState && initialState.spacicalPageParamsType && initialState.currentUser) {
+      const {
+        spacicalPageParamsType,
+        currentUser: { youshuToken },
+      } = initialState;
+      const { pathname } = location;
+      const spacialPage = spacicalPageParamsType.filter((t) => 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>
+    </>
+  );
+};