3.10 工程代码同步master

This commit is contained in:
jl-zhoujl2
2022-03-10 14:24:13 +08:00
parent 41ab55a4ac
commit 62f6b07ee2
914 changed files with 143121 additions and 29110 deletions

View File

@ -1,6 +0,0 @@
import request from '@/utils/request';
// 获取字典信息
export async function getDictionaries(){
return request('/api/biz-service-ebtp-project/v1/dictProject/refreshDictCache');
}

View File

@ -2,28 +2,104 @@ import ProLayout, {
MenuDataItem,
BasicLayoutProps as ProLayoutProps,
Settings,
DefaultFooter,
} from '@ant-design/pro-layout';
import React, { useEffect, useMemo, useRef } from 'react';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Link, useIntl, connect, Dispatch, history } from 'umi';
import { Result, Button } from 'antd';
import { Result, Button, message } from 'antd';
import Authorized from '@/utils/Authorized';
import RightContent from '@/components/GlobalHeader/RightContent';
import { ConnectState } from '@/models/connect';
import { getMatchMenu } from '@umijs/route-utils';
import { getMenu } from './services'
import logo from '../assets/logo.svg';
import { getDictionaries } from './BasDicData';
import { getSessionRoleData } from '@/utils/session';
import {
HomeOutlined,
DesktopOutlined,
NotificationOutlined,
BookOutlined,
ProfileOutlined,
CommentOutlined,
MacCommandOutlined,
ProjectOutlined,
PartitionOutlined,
PayCircleOutlined,
ContactsOutlined,
WalletOutlined,
AppstoreOutlined,
ShopOutlined,
} from '@ant-design/icons';
import { getAuthority } from '@/utils/authority';
import { JumpToOutside } from '@/utils/CommonUtils';
const menuImgList = [
{
key: 'HomeOutlined',
value: <HomeOutlined />
},
{
key: 'ContactsOutlined',
value: <ContactsOutlined />
},
{
key: 'DesktopOutlined',
value: <DesktopOutlined />
},
{
key: 'NotificationOutlined',
value: <NotificationOutlined />
},
{
key: 'BookOutlined',
value: <BookOutlined />
},
{
key: 'ProfileOutlined',
value: <ProfileOutlined />
},
{
key: 'CommentOutlined',
value: <CommentOutlined />
},
{
key: 'MacCommandOutlined',
value: <MacCommandOutlined />
},
{
key: 'ProjectOutlined',
value: <ProjectOutlined />
},
{
key: 'PartitionOutlined',
value: <PartitionOutlined />
},
{
key: 'PayCircleOutlined',
value: <PayCircleOutlined />
},
{
key: 'WalletOutlined',
value: <WalletOutlined />
},
{
key: 'AppstoreOutlined',
value: <AppstoreOutlined />
},
{
key: 'ShopOutlined',
value: <ShopOutlined />
},
]
const noMatch = (
<Result
status={403}
title="403"
subTitle="Sorry, you are not authorized to access this page."
subTitle="对不起,您没有访问本页面的权限。"
extra={
<Button type="primary">
<Link to="/user/login">Go Login</Link>
{/* <Link to="/user/login">Go Login</Link> */}
<Link to="/usercooper/login"></Link>
</Button>
}
/>
@ -44,10 +120,6 @@ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
[path: string]: MenuDataItem;
};
};
/**
* use Authorized check all menu item
*/
const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
menuList.map((item) => {
const localItem = {
@ -56,33 +128,6 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
};
return Authorized.check(item.authority, localItem, null) as MenuDataItem;
});
// const defaultFooterDom = (
// <DefaultFooter
// copyright={`${new Date().getFullYear()} 中国联通系统集成吉林分公司`}
// links={[
// {
// key: 'Ant Design Pro',
// title: 'Ant Design Pro',
// href: 'https://pro.ant.design',
// blankTarget: true,
// },
// {
// key: 'github',
// title: <GithubOutlined />,
// href: 'https://github.com/ant-design/ant-design-pro',
// blankTarget: true,
// },
// {
// key: 'Ant Design',
// title: 'Ant Design',
// href: 'https://ant.design',
// blankTarget: true,
// },
// ]}
// />
// );
const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const {
dispatch,
@ -92,30 +137,41 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
pathname: '/',
},
} = props;
useEffect(() => {
getDictionaries().then(res => {
if(res.code == 200) {
const DicData = res.data;
const DicDataSearch: any = sessionStorage.setItem('DicData', JSON.stringify(DicData));
return DicDataSearch;
}
})
}, []);
const [menuData, setMenuData] = React.useState<any>();
const [menuShow, setmenuShow] = React.useState<any>(false);
const menuDataRef = useRef<MenuDataItem[]>([]);
useEffect(() => {
if (dispatch) {
dispatch({
type: 'user/fetchCurrent',
});
if (getSessionRoleData()?.roleId) {
let params = {
roleIdList: [getSessionRoleData()?.roleId]
}
getMenu(params).then(res => {
if (res.code == 1) {
setMenuData(res.data || [])
setmenuShow(true)
} else {
message.error("数据错误请联系管理员")
}
})
}
}, []);
/**
* init variables
*/
function menuICon(menuData: any) {
if (menuData != undefined && menuData != null && menuData.length > 0) {
let data: any[] = [...menuData]
let arr3 = data.map((item: any) => {
menuImgList.forEach((item3: any) => {
if (item.icon == item3.key) {
item.icon = item3.value
}
})
return item
})
return arr3
} else {
return []
}
}
const handleMenuCollapse = (payload: boolean): void => {
if (dispatch) {
dispatch({
@ -124,7 +180,6 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
});
}
};
// get children authority
const authorized = useMemo(
() =>
getMatchMenu(location.pathname || '/', menuDataRef.current).pop() || {
@ -132,68 +187,60 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
},
[location.pathname],
);
const { formatMessage } = useIntl();
return (
<ProLayout
// menuHeaderRender={(logo, title) => (
// <div
// id="customize_menu_header"
// onClick={() => {
// window.open('https://remaxjs.org/');
// }}
// >
// {logo}
// {title}
// </div>
// }
// title={中国联通电子招投标系统}
logo={logo}
formatMessage={formatMessage}
onCollapse={handleMenuCollapse}
onMenuHeaderClick={() => history.push('/')}
menuItemRender={(menuItemProps, defaultDom) => {
if (menuItemProps.isUrl || !menuItemProps.path) {
return defaultDom;
}
if(menuItemProps.projectType!=undefined){
menuItemProps.path = menuItemProps.path+`?projectType=${menuItemProps.projectType}`;
}
return menuShow ? (<ProLayout
menuDataRender={() => menuICon(menuData)}
logo={logo}
// formatMessage={formatMessage}
onCollapse={handleMenuCollapse}
onMenuHeaderClick={() => history.push('/')}
menuItemRender={(menuItemProps, defaultDom) => {
if (menuItemProps.isUrl || !menuItemProps.path) {
return defaultDom;
}
if (menuItemProps.projectType != undefined) {
menuItemProps.path = menuItemProps.path + `?projectType=${menuItemProps.projectType}`;
}
if (menuItemProps.frame && menuItemProps.frame == 'N') {
return <Link to={menuItemProps.path}>{defaultDom}</Link>;
}}
breadcrumbRender={(routers = []) => [
{
path: '/',
breadcrumbName: formatMessage({ id: 'menu.home' }),
},
...routers,
]}
itemRender={(route, params, routes, paths) => {
const first = routes.indexOf(route) === 0;
return first ? (
<Link to={paths.join('/')}>{route.breadcrumbName}</Link>
) : (
<span>{route.breadcrumbName}</span>
);
}}
//footerRender={() => defaultFooterDom}
menuDataRender={menuDataRender}
rightContentRender={() => <RightContent />}
postMenuData={(menuData) => {
menuDataRef.current = menuData || [];
return menuData || [];
}}
{...props}
{...settings}
>
<Authorized authority={authorized!.authority} noMatch={noMatch}>
} else if (menuItemProps.frame && menuItemProps.frame == 'Y') {
return <Link onClick={() => window.open(menuItemProps.path)} to="#">{defaultDom}</Link>;
} else if (menuItemProps.frame && menuItemProps.frame == 'S') {
return <Link onClick={() => window.open(menuItemProps.path + '&mall3_token=' + sessionStorage.getItem('Authorization'))} to="#">{defaultDom}</Link>;
} else {
return <Link to={menuItemProps.path}>{defaultDom}</Link>;
}
}}
breadcrumbRender={(routers = []) => [
{
path: '/',
breadcrumbName: formatMessage({ id: 'menu.home' }),
},
...routers,
]}
itemRender={(route, params, routes, paths) => {
const first = routes.indexOf(route) === 0;
return first ? (
<Link to={paths.join('/')}>{route.breadcrumbName}</Link>
) : (
<span>{route.breadcrumbName}</span>
);
}}
rightContentRender={() => <RightContent />}
postMenuData={(menuData) => {
menuDataRef.current = menuData || [];
return menuData || [];
}}
{...props}
{...settings}
>
<Authorized authority={authorized!.authority} noMatch={noMatch}>
<div style={{ width: "100%" }}>
{children}
</Authorized>
</ProLayout>
);
};
</div>
</Authorized>
</ProLayout>) : null
}
export default connect(({ global, settings }: ConnectState) => ({
collapsed: global.collapsed,

View File

@ -40,13 +40,13 @@ const CosMenTabLsLayout: React.FC<BasicLayoutProps> = (props) => {
const menuDataRef = useRef<MenuDataItem[]>([]);
useEffect(() => {
if (dispatch) {
dispatch({
type: 'user/fetchCurrent',
});
}
}, []);
// useEffect(() => {
// if (dispatch) {
// dispatch({
// type: 'user/fetchCurrent',
// });
// }
// }, []);
const authorized = useMemo(
() =>
getMatchMenu(location.pathname || '/', menuDataRef.current).pop() || {
@ -57,13 +57,16 @@ const CosMenTabLsLayout: React.FC<BasicLayoutProps> = (props) => {
return (
<Authorized authority={authorized!.authority} noMatch={noMatch}>
<Authorized authority={authorized!.authority} noMatch={noMatch}>
<div style={{ backgroundColor: 'white', height: innerHeight - 106 }}>
<LayLeftMenu />
<div className="bace-layout-room">
{children}
</div>
</Authorized>
<div className="bace-layout-room">
{/* <div style={{float:'right'}}> */}
{children}
</div>
</div>
</Authorized>
);
};

View File

@ -41,13 +41,13 @@ const CosMenTabsLayout: React.FC<BasicLayoutProps> = (props) => {
const menuDataRef = useRef<MenuDataItem[]>([]);
useEffect(() => {
if (dispatch) {
dispatch({
type: 'user/fetchCurrent',
});
}
}, []);
// useEffect(() => {
// if (dispatch) {
// dispatch({
// type: 'user/fetchCurrent',
// });
// }
// }, []);
const authorized = useMemo(
() =>
getMatchMenu(location.pathname || '/', menuDataRef.current).pop() || {

View File

@ -40,13 +40,13 @@ const CosMenuLayout: React.FC<BasicLayoutProps> = (props) => {
const menuDataRef = useRef<MenuDataItem[]>([]);
useEffect(() => {
if (dispatch) {
dispatch({
type: 'user/fetchCurrent',
});
}
}, []);
// useEffect(() => {
// if (dispatch) {
// dispatch({
// type: 'user/fetchCurrent',
// });
// }
// }, []);
const authorized = useMemo(
() =>
getMatchMenu(location.pathname || '/', menuDataRef.current).pop() || {
@ -57,15 +57,12 @@ const CosMenuLayout: React.FC<BasicLayoutProps> = (props) => {
return (
<Authorized authority={authorized!.authority} noMatch={noMatch}>
<Promenu />
<div style={{marginTop:'5px'}}>
{children}
</div>
</Authorized>
<Authorized authority={authorized!.authority} noMatch={noMatch}>
<Promenu />
<div className='basicLayout-children' style={{ height: innerHeight - 240 }}>
{children}
</div>
</Authorized>
);
};

View File

@ -34,7 +34,7 @@ const RoomLayout: React.FC<UserLayoutProps> = (props) => {
const { Content } = Layout;
return (
<Layout>
<Content>{children}</Content>
<Content style={{borderRadius:"6px"}}>{children}</Content>
</Layout>
);
};

View File

@ -24,11 +24,11 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout
isReady: true,
});
const { dispatch } = this.props;
if (dispatch) {
dispatch({
type: 'user/fetchCurrent',
});
}
// if (dispatch) {
// dispatch({
// type: 'user/fetchCurrent',
// });
// }
}
render() {
@ -36,7 +36,8 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout
const { children, loading, currentUser } = this.props;
// You can replace it to your authentication rule (such as check token exists)
// 你可以把它替换成你自己的登录认证规则(比如判断 token 是否存在)
const isLogin = currentUser && currentUser.userid;
// const isLogin = currentUser && currentUser.userid;
const isLogin = true
const queryString = stringify({
redirect: window.location.href,
});

72
src/layouts/TopLayout.tsx Normal file
View File

@ -0,0 +1,72 @@
import React, { useMemo, useRef } from 'react';
import { Link } from 'umi';
import { Result, Button, Layout, Avatar } from 'antd';
import Authorized from '@/utils/Authorized';
import { getMatchMenu } from '@umijs/route-utils';
import logo from '@/assets/logo.svg'
import { CarryOutOutlined, UserSwitchOutlined } from '@ant-design/icons';
import moment from 'moment';
import { getSessionUserData } from '@/utils/session';
const noMatch = (
<Result
status={403}
title="403"
subTitle="Sorry, you are not authorized to access this page."
extra={
<Button type="primary">
<Link to="/user/login">Go Login</Link>
</Button>
}
/>
);
const TopLayout: React.FC<{}> = (props) => {
const {
children,
} = props;
const { Header, Content } = Layout;
const menuDataRef = useRef<any[]>([]);
let data = getSessionUserData();
const authorized = useMemo(
() =>
getMatchMenu(location.pathname || '/', menuDataRef.current).pop() || {
authority: undefined,
},
[location.pathname],
);
return (
<Authorized authority={authorized!.authority} noMatch={noMatch}>
<Layout>
<Header style={{ position: 'fixed', zIndex: 1, width: '100%', background: '#b30000', height: '56px' }}>
<div className="top-menu">
<div className="left-logo" style={{ color: '#fff', top: '-4px' }}>
<img src={logo} alt="" />
</div>
<ul className="right-btns">
<li><CarryOutOutlined />{moment().format("YYYY-MM-DD")}</li>
{data?.organizationName == null ? null : (<li><UserSwitchOutlined />{data?.organizationName}</li>)}
<li>
<Avatar size="small" src="https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png" style={{ width: '30px' }} />
<a className="antd-dropdown-link" style={{ color: "#fff" }}>
{data?.fullName}
</a>
</li>
</ul>
</div>
</Header>
<Content style={{ padding: '0 24px', marginTop: 64, width: '100%' }}>
{children}
</Content>
</Layout>
</Authorized>
);
};
export default TopLayout;

View File

@ -1,9 +1,8 @@
import { MenuDataItem, getMenuData, getPageTitle } from '@ant-design/pro-layout';
import { Helmet, HelmetProvider } from 'react-helmet-async';
import { Link, SelectLang, useIntl, ConnectProps, connect } from 'umi';
import { SelectLang, useIntl, ConnectProps, connect } from 'umi';
import React from 'react';
import { ConnectState } from '@/models/connect';
import logo from '../assets/logo.svg';
import styles from './UserLayout.less';
export interface UserLayoutProps extends Partial<ConnectProps> {
@ -45,14 +44,12 @@ const UserLayout: React.FC<UserLayoutProps> = (props) => {
<SelectLang />
</div>
<div className={styles.content}>
<div className={styles.top}>
{/* <div className={styles.top}>
<div className={styles.header}>
<Link to="/">
<img alt="logo" className={styles.logo} src={logo} />
<span className={styles.title}></span>
</Link>
<span className={styles.title}>中国联通电子招投标系统-开发</span>
</div>
</div>
</div> */}
{children}
</div>
</div>

9
src/layouts/services.ts Normal file
View File

@ -0,0 +1,9 @@
import request from '@/utils/request';
export async function getMenu(params: any) {
let requestUrl = '/api/core-service-usercenter-public/v1.0/menu/findMenuList';
return request(requestUrl, {
method: 'POST',
data: params,
});
}