Kaynağa Gözat

调整空白界面的流程控制

code4eat 3 yıl önce
ebeveyn
işleme
68af8210cb

+ 3 - 3
src/app.tsx

@@ -231,9 +231,9 @@ export const qiankun = fetch('/config').then(() => ({
   apps: [
     {
       name: 'app1', // 唯一 id
-      //entry: '//112.124.59.133:8804',  //测试
+      entry: '//112.124.59.133:8804',  //测试
       // entry: '//118.31.245.65:8804', //线上
-      entry: '//localhost:8804', // 开发
+      //entry: '//localhost:8804', // 开发
     },
   ],
   // 完整生命周期钩子请看 https://qiankun.umijs.org/zh/api/#registermicroapps-apps-lifecycles
@@ -245,7 +245,7 @@ export const qiankun = fetch('/config').then(() => ({
 
 //向子应用透传
 export function useQiankunStateForSlave() {
-  
+
   const [masterState, setMasterState] = useState({});
 
   return {

+ 7 - 6
src/components/topBar/index.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-16 09:12:37
- * @LastEditTime: 2022-07-08 11:47:42
+ * @LastEditTime: 2022-07-11 15:56:52
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/pages/index/components/topBar/index.tsx
@@ -50,7 +50,7 @@ const TopBar: React.FC<TopBarType> = (props) => {
 
   const _systemTabClickHandle = (item: TopBar.Tab) => {
     //导航栏tab点击
-
+    console.log('_systemTabClickHandle')
     onTabClick && onTabClick(item);
     localStorage.setItem('currentSelectedTab', JSON.stringify(item));
     setCurrentSelectedTab(item);
@@ -160,11 +160,11 @@ const TopBar: React.FC<TopBarType> = (props) => {
   
 
   const reSetNav = (_panelData: TopBar.PanelData[], cur: TopBar.Tab) => {
-
+    
 
     if (!(_panelData.length > 0)) return
 
-    if (cur) {
+    if (JSON.stringify(cur) != '{}') {
 
       let blockIndex = 0;
       let channelIndex = 0;
@@ -200,16 +200,17 @@ const TopBar: React.FC<TopBarType> = (props) => {
         setSystemTabs(_panelData[blockIndex].child[channelIndex].child);  //恢复体系列表
       }
 
-      _systemTabClickHandle(_currentSelectedTabFromLocal);  //恢复选中的tab
+      // _systemTabClickHandle(_currentSelectedTabFromLocal);  //恢复选中的tab
 
     }
   }
 
-  useEffect(() => {
+  useEffect(() => { 
     if (currentSelectedTabFromLocal) {
 
       reSetNav(navData, currentSelectedTabFromLocal);
     }
+      
     set_panelData(navData);
   }, [navData])
 

+ 2 - 1
src/components/topBar/typings.d.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-10 13:56:19
- * @LastEditTime: 2022-07-08 16:16:41
+ * @LastEditTime: 2022-07-08 18:47:38
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/components/topBar/typings.d.ts
@@ -16,6 +16,7 @@ declare namespace TopBar {
     url?: string;
     path: string;
     type:number;
+    contentType:string;
     isSetupMenu?:number;
   };
 

+ 5 - 2
src/global.tsx

@@ -1,8 +1,8 @@
 /*
  * @Author: your name
  * @Date: 2021-12-21 11:05:37
- * @LastEditTime: 2022-03-29 15:17:32
- * @LastEditors: Please set LastEditors
+ * @LastEditTime: 2022-07-11 09:41:40
+ * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/global.tsx
  */
@@ -20,6 +20,9 @@ export const logoutHandle = async () => {
   // await logout();
   localStorage.removeItem('userData');
   localStorage.removeItem('initialState');
+  localStorage.removeItem('currentSelectedTab');
+  localStorage.removeItem('isChildShowMenu');
+  localStorage.removeItem('visitedTabs');
 };
 
 (function () {

+ 44 - 20
src/layouts/index.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-09 13:56:33
- * @LastEditTime: 2022-07-08 16:35:31
+ * @LastEditTime: 2022-07-11 17:10:18
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/layouts/index.tsx
@@ -11,11 +11,14 @@ import { IRouteComponentProps, useModel, history } from 'umi';
 import ProLayout from '@ant-design/pro-layout';
 
 import TopBar from '@/components/topBar';
-import { useEffect, useState } from 'react';
-import { getPlatformMenu, getUserPlatformNav } from '@/service/menu';
+import { Key, useEffect, useState } from 'react';
+import { getPlatformMenu, getSpecifyMenuDetail, getUserPlatformNav } from '@/service/menu';
 import { NavSelecterData } from '@/components/NavSelecter';
 
-const TopHoc = ({ currentSelectedSys, openedSysLists, navData }: { currentSelectedSys: TopBar.Tab | undefined, openedSysLists: TopBar.Tab[], navData: TopBar.PanelData[] }) => {
+
+let emptyContent = '';
+
+const TopHoc = ({ currentSelectedSys, openedSysLists, navData,set_emptyPageContent }: {set_emptyPageContent:any; currentSelectedSys: TopBar.Tab | undefined, openedSysLists: TopBar.Tab[], navData: TopBar.PanelData[] }) => {
   const { initialState, setInitialState } = useModel('@@initialState');
 
 
@@ -25,23 +28,29 @@ const TopHoc = ({ currentSelectedSys, openedSysLists, navData }: { currentSelect
   };
 
   const onTabClickHandle = async (data: TopBar.Tab) => {
- 
-    await setInitialState((s) => ({ ...s, currentSelectedSys: data }));
-    console.log({data});
-    if(data.type == 4){
-        //空白页面
-        history.push(`${data.path}?isEmpty=true&menuId=${data.menuId}`);
-    }else{
-      if(data.isSetupMenu){
-        //体系菜单掩藏子应用的menu
-        localStorage.setItem('isChildShowMenu','false');
+    if(JSON.stringify(data) != '{}'){
+      await setInitialState((s) => ({ ...s, currentSelectedSys: data }));
+      // history.push(`${data.path}${data.contentType == '4' ? `?isEmpty=true&menuId=${data.menuId}` : ''}` || '/');
+
+      if(data.contentType == '4'){
+          //空白页面
+          if(data.isSetupMenu){
+            //体系菜单掩藏子应用的menu
+            localStorage.setItem('isChildShowMenu','false');
+          }
+          
+          history.push(`${data.path}?isEmpty=true&menuId=${data.menuId}`);
       }else{
-        localStorage.setItem('isChildShowMenu','true');
+        if(data.isSetupMenu){
+          //体系菜单掩藏子应用的menu
+          localStorage.setItem('isChildShowMenu','false');
+        }else{
+          localStorage.setItem('isChildShowMenu','true');
+        }
+  
+        history.push(data.path);
       }
-
-      history.push(data.path);
     }
-   
   };
 
   const userPannelTabClickhandle = (tag: string) => {
@@ -62,6 +71,7 @@ const TopHoc = ({ currentSelectedSys, openedSysLists, navData }: { currentSelect
             url: '',
             systemId: '-1',
             type:1,
+            contentType:'0',
             path: '/personalCenter',
           },
         }));
@@ -97,14 +107,28 @@ export default function Layout({ children, location, route, history, match }: IR
     }
   }
 
+
+  const getEmptyPageContent =async (menuId:Key) => {
+    const menuItem = await getSpecifyMenuDetail(menuId);
+    set_emptyPageContent(menuItem.description);
+  }
+
+
   useEffect(() => {
     if (location.pathname != '/login') {
       getNavData();
     }
+    if(location.query.isEmpty == 'true'&&location.query.menuId){
+      getEmptyPageContent(location.query.menuId as string)
+    }
   }, [])
 
   useEffect(()=>{
-    set_isEmpty(location.query.isEmpty == 'true');
+  
+    if(location.pathname != '/platform'){
+      //排除已有系统的空白页面
+      set_isEmpty(location.query.isEmpty == 'true');
+    }
   })
 
   if (location.pathname == '/login') {
@@ -121,7 +145,6 @@ export default function Layout({ children, location, route, history, match }: IR
         return (
           <a
             onClick={() => {
-              set_emptyPageContent(item.description);
               history.push(`${item.path}${item.contentType == 4 ? `?isEmpty=true&menuId=${item.key}` : ''}` || '/');
             }}
           >
@@ -145,6 +168,7 @@ export default function Layout({ children, location, route, history, match }: IR
         initialState && (
           <TopHoc
             navData={navData}
+            set_emptyPageContent={set_emptyPageContent}
             currentSelectedSys={initialState.currentSelectedSys}
             openedSysLists={initialState.openedSysLists ? initialState.openedSysLists : []}
           />

+ 21 - 9
src/pages/platform/_layout.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 15:25:39
- * @LastEditTime: 2022-07-08 16:29:17
+ * @LastEditTime: 2022-07-11 17:10:52
  * @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
@@ -10,21 +10,33 @@
 import { IRouteComponentProps, useModel, Helmet } from 'umi';
 // import { CrownOutlined, UserOutlined, SmileOutlined } from '@ant-design/icons';
 import ProLayout, { PageContainer } from '@ant-design/pro-layout';
-import { getPlatformMenu } from '@/service/menu';
+import { getPlatformMenu, getSpecifyMenuDetail } from '@/service/menu';
 import './index.less';
 import { TreeItemType } from '@/utils';
 import { SpacicalPageParamsType } from '@/typings';
-import { useEffect, useState } from 'react';
+import { Key, useEffect, useState } from 'react';
 
 export default function Layout({ children, location, route, history, match, ...rest }: IRouteComponentProps) {
   const { initialState, setInitialState } = useModel('@@initialState');
   const [openKeys, set_openKeys] = useState<string[]>([]);
   const [selectedKeys, set_selectedKeys] = useState<string[]>([]);
   const [emptyPageContent, set_emptyPageContent] = useState('');
-  const isShowMenu = localStorage.getItem('isChildShowMenu');
+  const [isShowPageMenu,set_isShowPageMenu] = useState(true);
+
+  //const isShowMenu = localStorage.getItem('isChildShowMenu');
   // console.log({ children, location, route, history, match});
 
 
+
+  const setEmptyPageContent =async (menuId:Key) => {
+    const menuItem = await getSpecifyMenuDetail(menuId);
+    if(menuItem.isSetupMenu){
+      set_isShowPageMenu(false);
+    }
+    set_emptyPageContent(menuItem.description);
+  }
+
+
   return (
     <ProLayout
       style={{
@@ -36,7 +48,7 @@ export default function Layout({ children, location, route, history, match, ...r
       location={{
 
       }}
-      siderWidth={isShowMenu == 'true' ? 220 : 0}
+      // siderWidth={isShowPageMenu? 220 : 0}
       pageTitleRender={false}
       disableContentMargin
       menuItemRender={(item, dom) => {
@@ -44,8 +56,8 @@ export default function Layout({ children, location, route, history, match, ...r
           <a
             onClick={() => {
               // console.log('_layout',item);
-              set_emptyPageContent(item.description);
-              history.push(`${item.path}${item.contentType == 4 ? `?isEmpty=true&menuId=${item.key}` : ''}` || '/');
+              setEmptyPageContent(item.key as string);
+              history.push(`${item.path}${item.contentType == '4' ? `?isEmpty=true&menuId=${item.key}` : ''}` || '/');
             }}
           >
             {dom}
@@ -71,7 +83,7 @@ export default function Layout({ children, location, route, history, match, ...r
           if (initialState) {
             const systemId = initialState.currentSelectedSys?.menuId;
             if (systemId) {
-              const menuData = await getPlatformMenu(Number(systemId));
+              const menuData = await getPlatformMenu(systemId);
               // console.log({menuData});
               if (menuData.length > 0) {
                 set_openKeys([menuData[0].key]);
@@ -123,7 +135,7 @@ export default function Layout({ children, location, route, history, match, ...r
     >
       {
         location.query.isEmpty == 'true' && (
-          <div style={{ textAlign: 'center', paddingTop: 100 }}>
+          <div className='emptyContainer' style={{ textAlign: 'center', paddingTop: 100 }}>
             <h1>{emptyPageContent}</h1>
           </div>
         )

+ 45 - 16
src/pages/platform/setting/menuManage/modals/modal.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-12 17:11:11
- * @LastEditTime: 2022-07-08 16:42:29
+ * @LastEditTime: 2022-07-11 15:34:44
  * @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/userManage/modal.tsx
@@ -54,7 +54,7 @@ const ActModal: React.FC<ActModalProps> = ({
   };
 
   const onFinishHandle = (data: any & AddUsersDataType) => {
-
+    console.log({currentEdit});
     if (tableAct == TableActType.ADD) {
       dispatch &&
         dispatch({
@@ -138,7 +138,9 @@ const ActModal: React.FC<ActModalProps> = ({
       initialValues={
         tableAct == TableActType.EDIT
           ? { ...currentEdit }
-          : { hospSign: randomString(16), isDataShare: 0,isHomepage:0 }
+          : { 
+            hospSign: randomString(16), isDataShare: 0, isHomepage: 0,
+          }
       }
       // title={tableAct == TableActType.EDIT ? '编辑菜单' : tableAct == TableActType.SET ? '设为首页' : '新增菜单'}
       title={setModalFormTitle(tableAct)}
@@ -212,18 +214,45 @@ const ActModal: React.FC<ActModalProps> = ({
                 },
               ]}
             />
-            <ProFormText
-              width="md"
-              name="path"
-              label="PATH"
-              placeholder="请输入"
-              rules={[
-                {
-                  required: true,
-                  message: '请输入!',
-                },
-              ]}
-            />
+
+            <ProFormDependency name={['type','contentType']}>
+              {
+                ({ type,contentType }) => {
+                  if (type == 1&&contentType != 4) {
+                    return (
+                      <ProFormText
+                        width="md"
+                        name="path"
+                        label="PATH"
+                        placeholder="请输入"
+                        rules={[
+                          {
+                            required: true,
+                            message: '请输入!',
+                          },
+                        ]}
+                      />
+                    )
+                  }else{
+                    return (
+                      <ProFormText
+                        width="md"
+                        name="path"
+                        label="PATH"
+                        initialValue={tableAct == TableActType.ADD?'/platform':''}
+                        placeholder="请输入"
+                        rules={[
+                          {
+                            required:false,
+                            message: '请输入!',
+                          },
+                        ]}
+                      />
+                    )
+                  }
+                }
+              }
+            </ProFormDependency>
             <ProFormText width="md" name="icon" label="icon" placeholder="请输入" />
             <ProFormDependency name={['type']}>
               {({ type }) => {
@@ -284,7 +313,7 @@ const ActModal: React.FC<ActModalProps> = ({
                         {({ contentType }) => {
                           return (
                             contentType &&
-                            contentType != 0 && contentType != 4 &&(
+                            contentType != 0 && contentType != 4 && (
                               //页面内容为非一般时,填写对应有数Id
                               <ProFormDigit
                                 label="报告Id"

+ 2 - 2
src/pages/platform/setting/userManage/modal.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-12 17:11:11
- * @LastEditTime: 2022-07-08 18:00:41
+ * @LastEditTime: 2022-07-08 18:53:21
  * @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/userManage/modal.tsx
@@ -123,7 +123,7 @@ const ActModal: React.FC<ActModalProps> = ({
       let defaultValue = dataArr.filter(t=>t.defaultValue == 1);
 
       dataArr.sort((prev:UserRelaSeletDataListType,next:UserRelaSeletDataListType)=>{
-        return next.sort - prev.sort;
+        return prev.sort - next.sort;
       });
 
       // console.log({dataArr,defaultValue});

+ 9 - 3
src/service/menu.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-10 10:27:15
- * @LastEditTime: 2022-07-08 14:39:55
+ * @LastEditTime: 2022-07-11 16:59:28
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/service/hospInfo.ts
@@ -12,7 +12,7 @@ import { Key } from 'react';
 import { request } from 'umi';
 
 //获取平台菜单
-export const getPlatformMenu = async (systemId?: number) => {
+export const getPlatformMenu = async (systemId?:Key) => {
   return request('/master/centerSys/user/getMenuNav', {
     method: 'GET',
     params: { systemId },
@@ -32,10 +32,12 @@ export interface MenuItemDataType {
   type: number;
   url?: string;
   key?:string;
+  contentType:string;
   systemId?:string;
   isHomepage:number;
   description:string;
   modifyTime: string;
+  isSetupMenu?:number;
   children: MenuItemDataType[];
 }
 
@@ -72,6 +74,7 @@ export type AddMenuDataType = {
   perms?: string;
   softUrl?: string;
   type: number;
+  contentType:string;
   url?: string;
 };
 
@@ -94,6 +97,7 @@ export type EditMenuDataType = {
   perms?: string;
   softUrl?: string;
   type: number;
+  contentType:string;
   url?: string;
 };
 
@@ -132,6 +136,7 @@ export type UserPlatformNav = {
   type:number;
   path:string;
   systemId:string;
+  contentType:string;
   child:UserPlatformNav[];
 }
 
@@ -199,9 +204,10 @@ export const transformMenu = async (type:'MOVE'|'COPY',menuId:Key,catalogId:Key)
 
 //通过ID获取指定菜单的详情
 
-export const getSpecifyMenuDetail = async () => {
+export const getSpecifyMenuDetail = async (menuId:Key) => {
   return request<MenuItemDataType>('/master/centerSys/menu/getMenuDetail', {
     method: 'GET',
+    params:{menuId}
   });   
 
 }