|
@@ -1,6 +1,6 @@
|
|
|
|
|
|
|
|
|
-import React, { useEffect,useRef } from 'react'
|
|
|
+import React, { useEffect,useRef,useState } from 'react'
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
import {Modal, Divider } from 'antd';
|
|
@@ -9,14 +9,35 @@ import type { ProFormInstance } from '@ant-design/pro-form';
|
|
|
import ProForm, {
|
|
|
ProFormText,
|
|
|
} from '@ant-design/pro-form';
|
|
|
-import { useModel } from 'umi';
|
|
|
+import { useModel,history } from 'umi';
|
|
|
import './index.less';
|
|
|
|
|
|
+import {menuDataItemType} from '@/app';
|
|
|
+
|
|
|
+import IframePage from '@/components/iframePage/index';
|
|
|
+
|
|
|
|
|
|
type MccsPageContainerType = {
|
|
|
[key:string]:any
|
|
|
}
|
|
|
|
|
|
+const getCurrentRoutesData = (data: menuDataItemType[], path: string) => {
|
|
|
+ let result;
|
|
|
+ function looper (arr:menuDataItemType[]){
|
|
|
+ for (const element of arr) {
|
|
|
+ if (element.path == path) {
|
|
|
+ result = element
|
|
|
+ } else {
|
|
|
+ if (element.children && element.children.length > 0) {
|
|
|
+ looper(element.children);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ looper(data);
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
const MccsPageContainer:React.FC<MccsPageContainerType> = (props)=>{
|
|
|
/**
|
|
|
* @param {*} children
|
|
@@ -25,12 +46,15 @@ const MccsPageContainer:React.FC<MccsPageContainerType> = (props)=>{
|
|
|
*/
|
|
|
const { children, config } = props;
|
|
|
const formRef = useRef<ProFormInstance>();
|
|
|
- const { goSetting, update,currentUser,resetPasswordHandle} = useModel('@@initialState', (model) => ({
|
|
|
- goSetting: model.initialState?.goSetting,
|
|
|
+ const { goSetting, update,currentUser,resetPasswordHandle,menu} = useModel('@@initialState', (model) => ({
|
|
|
+ goSetting: model.initialState?.goSetting,
|
|
|
update: model.setInitialState,
|
|
|
currentUser:model.initialState?.currentUser,
|
|
|
+ menu:model.initialState?.menu,
|
|
|
resetPasswordHandle:model.initialState?.resetPasswordHandle,
|
|
|
}));
|
|
|
+ const [ifIframePage,setIfIframePage] = useState(false);
|
|
|
+ const [iframeUrl,setIframeUrl] = useState<string>();
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
@@ -90,6 +114,19 @@ const MccsPageContainer:React.FC<MccsPageContainerType> = (props)=>{
|
|
|
}
|
|
|
}, [goSetting]);
|
|
|
|
|
|
+ useEffect(()=>{
|
|
|
+ const { location: { pathname } } = history;
|
|
|
+ if (menu) {
|
|
|
+ const currentRouteData:any = getCurrentRoutesData(menu, pathname);
|
|
|
+ if(currentRouteData){
|
|
|
+ console.log({currentRouteData});
|
|
|
+ setIframeUrl(currentRouteData.softUrl);
|
|
|
+ }else{
|
|
|
+ setIframeUrl('');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },[]);
|
|
|
+
|
|
|
return (
|
|
|
<PageContainer
|
|
|
{
|
|
@@ -98,7 +135,7 @@ const MccsPageContainer:React.FC<MccsPageContainerType> = (props)=>{
|
|
|
style={{ padding: '16px' }}
|
|
|
>
|
|
|
{
|
|
|
- children
|
|
|
+ iframeUrl?<IframePage url={`${iframeUrl}`} />:children
|
|
|
}
|
|
|
</PageContainer>
|
|
|
)
|