Explorar o código

添加蓝湖静态页面展示相关功能

code4eat %!s(int64=2) %!d(string=hai) anos
pai
achega
d4e6f33b0f
Modificáronse 3 ficheiros con 141 adicións e 52 borrados
  1. 52 35
      src/app.tsx
  2. 25 17
      src/pages/platform/_layout.tsx
  3. 64 0
      src/pages/platform/setting/static/index.tsx

+ 52 - 35
src/app.tsx

@@ -10,6 +10,9 @@ import { logoutHandle } from './global';
 import { Platforms } from './constant';
 import { SpacicalPageParamsType } from './typings';
 
+import Report from '@/pages/platform/setting/reports';
+import Static from '@/pages/platform/setting/static';
+
 
 const loginPath = '/login';
 
@@ -34,7 +37,7 @@ type InitialStateType = {
   openedSysLists?: TopBar.Tab[]; //当前已打开的系统列表
   currentSelectedSys?: TopBar.Tab; //当前选中的tab
   logout?: () => Promise<boolean>;
-  childAppIsShowMenu?:boolean; 
+  childAppIsShowMenu?: boolean;
   spacicalPageParamsType?: SpacicalPageParamsType[];
   getHospSubSystemListFunc?: () => Promise<any[]>;
 };
@@ -105,11 +108,11 @@ const requestInterceptorsHandle = (url: string, options: RequestOptionsInit) =>
     authHeader.token = token;
   }
 
- 
+
 
   return {
     url: `/gateway${url}`,
-    options: { ...options, interceptors: true, headers: authHeader,timeout:100000000, },
+    options: { ...options, interceptors: true, headers: authHeader, timeout: 100000000, },
   };
 };
 
@@ -123,7 +126,7 @@ const responseInterceptorsHandle = async (response: Response, options: RequestOp
     msg?: string;
   } = await response.clone().json();
 
-  
+
   if (_response.status == 200) {
     if (_response.data) {
       return _response.data;
@@ -138,7 +141,7 @@ const responseInterceptorsHandle = async (response: Response, options: RequestOp
     };
   } else {
     notification.error({
-      message:`${_response.msg}`,
+      message: `${_response.msg}`,
     });
     return false
   }
@@ -164,8 +167,8 @@ const errorHandlerFunc = (error: ResponseErr) => {
 
   try {
     const { info } = error;
-    const { errorCode , errorMessage } = info;
-    
+    const { errorCode, errorMessage } = info;
+
     if (errorCode == 499) {
       //token过期
       Modal.confirm({
@@ -248,8 +251,8 @@ export const qiankun = fetch('/config').then(() => ({
     // },
     {
       name: 'budgetManaSystem', // 唯一 id
-      entry: '//localhost:8001',
-      //entry: '//120.27.235.181:5000/perform/',  //开发
+      //entry: '//localhost:8001',
+      entry: '//120.27.235.181:5000/perform/',  //开发
       //entry: '//47.96.149.190:5000/perform/', //演示
     },
     {
@@ -260,7 +263,7 @@ export const qiankun = fetch('/config').then(() => ({
   ],
   // 完整生命周期钩子请看 https://qiankun.umijs.org/zh/api/#registermicroapps-apps-lifecycles
   lifeCycles: {
-    afterMount: (props: any) => {},
+    afterMount: (props: any) => { },
   },
   // 支持更多的其他配置,详细看这里 https://qiankun.umijs.org/zh/api/#start-opts
 }));
@@ -278,36 +281,50 @@ export function useQiankunStateForSlave() {
 
 
 
-//@/pages/platform/setting/reports/index
-export function patchRoutes({ routes }:{routes:any}) {
-  
-  const paths = [...new Array(100).keys()].map((a,index)=>({
-    path: `/platform/setting/reports/${15+(index+1)}`,
-    exact: true,
-    component: require('@/pages/platform/setting/reports/index.tsx').default,
-  }));
-
-
-  const treeLoop = (treeData:any)=>{
-        //console.log({treeData})
-        if(treeData.path == '/platform'){
-          paths.forEach((a:any)=>{
-            treeData.routes.push(a); 
-          })
-          return;  
-        }else{
-            if(treeData.routes&&treeData.routes.length>0){
-              treeData.routes.forEach((a:any)=>{
-                  treeLoop(a);
-              })
-            }
-        }
+// //@/pages/platform/setting/reports/index
+export function patchRoutes({ routes }: { routes: any }) {
+
+  const treeLoop = (treeData: any) => {
+
+    if (treeData.path == '/platform') {
+      if (treeData.routes) {
+        const paths = [...new Array(10).keys()].map((a, index) => ({
+          path: `${treeData.path == '/' ? '' : treeData.path}/reports/${index}`,
+          exact: true,
+          component: require('@/pages/platform/setting/reports/index.tsx').default,
+        }));
+
+        const lanhuPagePaths = [...new Array(10).keys()].map((a, index) => ({
+          path: `${treeData.path == '/' ? '' : treeData.path}/static/${index}`,
+          exact: true,
+          component:require('@/pages/platform/setting/static/index.tsx').default,
+        }));
+
+        //console.log({paths});
+
+        paths.forEach((a: any) => {
+          treeData.routes.push(a);
+        });
+
+        lanhuPagePaths.forEach((a: any) => {
+          treeData.routes.push(a);
+        });
+      }
+    }
+
+    if (treeData.routes && treeData.routes.length > 0) {
+      treeData.routes.forEach((a: any) => {
+        treeLoop(a);
+      })
+    }
   }
-  
+
   treeLoop(routes[0]);
 }
 
 
+
+
 export const layout = ({ initialState: { userData } }: { initialState: InitialStateType }): BasicLayoutProps => {
   return {
     headerRender: false,

+ 25 - 17
src/pages/platform/_layout.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 15:25:39
- * @LastEditTime: 2023-04-17 15:54:58
+ * @LastEditTime: 2023-05-10 17:01:34
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/_layout.tsx
@@ -28,7 +28,7 @@ export default function Layout({ children, location, route, history, match, ...r
   const [isShowPageMenu, set_isShowPageMenu] = useState(true);
   const [isEmpty, set_isEmpty] = useState(false);
 
-  const [pageUrl,set_pageUrl] = useState<string|undefined>(undefined);
+  const [pageUrl, set_pageUrl] = useState<string | undefined>(undefined);
 
 
 
@@ -71,25 +71,24 @@ export default function Layout({ children, location, route, history, match, ...r
   if (location.pathname == '/platform/costMana') {
 
     //临时解决未嵌入成本核算,而实现访问的效果
-  
-    const getToken =async () => {
+
+    const getToken = async () => {
       const resp = await getAllParams();
 
-    if (resp) {
-      const needItem = resp.filter((a: any) => a.code == '1647777324889935872');
-    
-      if (needItem.length > 0) {
+      if (resp) {
+        const needItem = resp.filter((a: any) => a.code == '1647777324889935872');
+
+        if (needItem.length > 0) {
           set_pageUrl(`http://47.96.149.190:8000/platformMana/roleManage?hospSign=dOBHdoPmJgPGnMSH&token=${needItem[0].value}`)
+        }
       }
     }
-    }
-    
-    getToken();
 
+    getToken();
 
     return (
       <>
-         {pageUrl&&<iframe id={'bi_iframe'} style={{ width: '100%', height: '100%', border: 'none' }} src={pageUrl} onLoad={() => adjustIframe()} ></iframe>};
+        {pageUrl && <iframe id={'bi_iframe'} style={{ width: '100%', height: '100%', border: 'none' }} src={pageUrl} onLoad={() => adjustIframe()} ></iframe>};
       </>
     )
   }
@@ -159,8 +158,8 @@ export default function Layout({ children, location, route, history, match, ...r
                     if (t.isHomepage) {
                       homePage = t;
                     }
-                    if (t[key] && t[key] == 1) {
-                      //非一般页面
+                    if (t[key] == 1 || t[key] == 2 || t[key] == 3) {
+                      //网易有数页面
                       result.push({
                         contentType: t[key],
                         path: t['path'],
@@ -168,6 +167,15 @@ export default function Layout({ children, location, route, history, match, ...r
                         url: t['youshuUrl'],
                       });
                     }
+                    if (t[key] == 5) {
+                      //蓝湖静态展示页面
+                      result.push({
+                        contentType: t[key],
+                        path: t['path'],
+                        reportId: t['reportId'],
+                        url: t['softUrl'],
+                      });
+                    }
                     if (t.children && t.children.length > 0) {
                       looper(t.children, key);
                     }
@@ -194,7 +202,7 @@ export default function Layout({ children, location, route, history, match, ...r
                   const selectedKeys = localStorage.getItem('selectedKeys');
                   const openKeys = localStorage.getItem('openKeys');
 
-                  if (selectedKeys&&openKeys) {
+                  if (selectedKeys && openKeys) {
                     const _selectedKeys = JSON.parse(selectedKeys);
                     const _openKeys = JSON.parse(openKeys);
                     set_openKeys(_openKeys);
@@ -205,8 +213,8 @@ export default function Layout({ children, location, route, history, match, ...r
                       const childs = menuData[0].children;
                       set_openKeys([menuData[0].key]);
                       set_selectedKeys([childs[0].key]);
-                      localStorage.setItem('openKeys',JSON.stringify([menuData[0].key]));
-                      localStorage.setItem('selectedKeys',JSON.stringify([childs[0].key]));
+                      localStorage.setItem('openKeys', JSON.stringify([menuData[0].key]));
+                      localStorage.setItem('selectedKeys', JSON.stringify([childs[0].key]));
                       history.push(`${childs[0].path}`);
 
                     }

+ 64 - 0
src/pages/platform/setting/static/index.tsx

@@ -0,0 +1,64 @@
+/*
+ * @Author: your name
+ * @Date: 2022-03-03 18:04:40
+ * @LastEditTime: 2023-05-10 16:58:38
+ * @LastEditors: code4eat awesomedema@gmail.com
+ * @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 { Skeleton } from 'antd';
+import { useModel } from 'umi';
+
+
+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.userData) {
+      const {
+        spacicalPageParamsType,
+        userData: { youshuToken },
+      } = initialState;
+
+      console.log({ spacicalPageParamsType });
+
+      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}`);
+
+        const url = `${spacialPage[0].url}`;
+        setspecialPageUrl(url);
+      }
+    }
+
+  }, [initialState]);
+
+  return (
+    <>
+      <Skeleton loading={loading} paragraph={{ rows: 50 }} active />
+      <iframe
+        onLoad={() => onLoadhandle()}
+        style={{ width: '100%', height: '90vh', border: 'none' }}
+        src={specialPageUrl}
+      ></iframe>
+    </>
+  );
+};