Commit b75e03e8 authored by 邓晓峰's avatar 邓晓峰

feat: 集成报表菜单

parents 507cedfc 3910aab1
Pipeline #42979 passed with stages
in 9 minutes 22 seconds
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
// }, // },
{ {
name: 'civ_pandawork', name: 'civ_pandawork',
entry: `//${window.location.hostname}:8081/civ_pandawork`, entry: `//${window.location.hostname}:8080/civ_pandawork`,
container: '#micro-container', container: '#micro-container',
activeRule: '/civbase/civ_pandawork', activeRule: '/civbase/civ_pandawork',
}, },
......
/* eslint-disable */ /* eslint-disable */
// const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin; // const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin;
const proxyURL = 'http://192.168.10.156:8666'; const proxyURL = 'https://panda-water.com';
module.exports = { module.exports = {
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './', assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './',
......
...@@ -3,10 +3,10 @@ import { message } from 'antd'; ...@@ -3,10 +3,10 @@ import { message } from 'antd';
import _, { words } from 'lodash'; import _, { words } from 'lodash';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { loadMicroApp } from 'qiankun';
import { useIntl } from '@/locales/localeExports'; import { useIntl } from '@/locales/localeExports';
import Icon from '@ant-design/icons'; import Icon from '@ant-design/icons';
import { setDefaultMountApp } from 'qiankun'
import { actionCreators } from '../../containers/App/store'; import { actionCreators } from '../../containers/App/store';
import HeaderSearch from '../HeaderSearch'; import HeaderSearch from '../HeaderSearch';
import Avatar from './AvatarDropdown'; import Avatar from './AvatarDropdown';
...@@ -125,7 +125,10 @@ const GlobalHeaderRight = props => { ...@@ -125,7 +125,10 @@ const GlobalHeaderRight = props => {
const url = _.isString(props.global.get('homepage')) const url = _.isString(props.global.get('homepage'))
? props.global.get('homepage') ? props.global.get('homepage')
: props.global.get('homepage.url'); : props.global.get('homepage.url');
window.share.event.emit('goHome', `/civbase/civweb4/${url}`); window.share.event.emit('goHome', `/${url}`);
// setDefaultMountApp()
// 1、window.globalConfig product
// 2. 拿到当前product
url ? ( url ? (
window.share.event.emit('listenerMointer', { window.share.event.emit('listenerMointer', {
label: '首页', label: '首页',
......
...@@ -7,6 +7,7 @@ import { Storage } from '@wisdom-utils/utils'; ...@@ -7,6 +7,7 @@ import { Storage } from '@wisdom-utils/utils';
import pkg from '../../../../package.json'; import pkg from '../../../../package.json';
import defaultSetting from '../../../../config/defaultSetting'; import defaultSetting from '../../../../config/defaultSetting';
import generRoutes, { generFlatRoutes } from '../../../utils/routes'; import generRoutes, { generFlatRoutes } from '../../../utils/routes';
import { transformWidgets } from '../../../utils/routes';
import { import {
CLEAR_RCENT_KEYWORD, CLEAR_RCENT_KEYWORD,
COMPLEX_CONFIG, COMPLEX_CONFIG,
...@@ -105,6 +106,7 @@ const appReducer = (state = initialState, action) => { ...@@ -105,6 +106,7 @@ const appReducer = (state = initialState, action) => {
window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => { window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => {
modulePkg[item.PackageName] = item; modulePkg[item.PackageName] = item;
}); });
config.widgets = transformWidgets(config.widgets);
const generMenu = generRoutes(config.widgets || [], null, 0, modulePkg); const generMenu = generRoutes(config.widgets || [], null, 0, modulePkg);
let flatMenu = []; let flatMenu = [];
if(generMenu) { if(generMenu) {
......
...@@ -839,7 +839,7 @@ const BasicLayout = props => { ...@@ -839,7 +839,7 @@ const BasicLayout = props => {
if (lastIndex >= 0) { if (lastIndex >= 0) {
history.push(newTabList[lastIndex].path); history.push(newTabList[lastIndex].path);
} else { } else {
history.replace(`/civweb4/${props.global.homepage}`); history.replace(`/${props.global.homepage}`);
} }
props.updateSelectedKeys(newActiveKey); props.updateSelectedKeys(newActiveKey);
props.updatePathname(newActiveKey); props.updatePathname(newActiveKey);
......
...@@ -271,6 +271,7 @@ const BasicLayout = props => { ...@@ -271,6 +271,7 @@ const BasicLayout = props => {
// 处理隐藏菜单 // 处理隐藏菜单
let currentRoutes = props.route.routes.filter(item => !item.hideInMenu)[props.currentMenuIndex]; let currentRoutes = props.route.routes.filter(item => !item.hideInMenu)[props.currentMenuIndex];
console.log(props.route)
//props.currentMenuIndex //props.currentMenuIndex
useEffect(() => { useEffect(() => {
const initSelectRoute = findPathByLeafId( const initSelectRoute = findPathByLeafId(
...@@ -330,9 +331,11 @@ const BasicLayout = props => { ...@@ -330,9 +331,11 @@ const BasicLayout = props => {
useEffect(() => { useEffect(() => {
siteAction.setGlobalConfig(props.global); siteAction.setGlobalConfig(props.global);
if (!Cookies.get('token')) { if (!Cookies.get('token')) {
let client = props.global.get('client'); let client = props.global && props.global.client;
client = client !== 'undefined' || !_.isNull(client) || !_.isUndefined(client) ? client: 'city'; client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client: 'city';
history.replace(`/user/login?client=${client}`); let generateType = props.global.get('generateType');
generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : '';
history.replace(`/user/login?client=${client}${generateType}`);
props.logout(); props.logout();
return; return;
} }
...@@ -351,13 +354,19 @@ const BasicLayout = props => { ...@@ -351,13 +354,19 @@ const BasicLayout = props => {
// setChildrenRoutes(currentChildrenRoute) // setChildrenRoutes(currentChildrenRoute)
window.share.event.on('goHome', url => { window.share.event.on('goHome', url => {
setChildrenRoutes([ setChildrenRoutes([
{ {
icon: <HomeIcon/>, icon: <HomeIcon/>,
path: url, path: url,
name: '首页' name: '首页'
} }
]) ]);
setTabActiveKey(url);
window.history.pushState(null, '', `/civbase${url}`);
}); });
/** /**
* web4全屏退出,切换三级菜单高亮 * web4全屏退出,切换三级菜单高亮
...@@ -443,7 +452,7 @@ const BasicLayout = props => { ...@@ -443,7 +452,7 @@ const BasicLayout = props => {
} }
const handleSelectMenuItem = (item) => { const handleSelectMenuItem = (item) => {
debugger
setTabActiveKey(item); setTabActiveKey(item);
if(item.indexOf('web_console') === -1) { if(item.indexOf('web_console') === -1) {
window.history.pushState(null, '', `/civbase${item}`); window.history.pushState(null, '', `/civbase${item}`);
...@@ -546,7 +555,7 @@ const BasicLayout = props => { ...@@ -546,7 +555,7 @@ const BasicLayout = props => {
<div className={layoutStyles.splitLine}></div> <div className={layoutStyles.splitLine}></div>
<ul className={classNames(layoutStyles.menu, 'menu-vertical')}> <ul className={classNames(layoutStyles.menu, 'menu-vertical')}>
{ {
currentRoutes && (currentRoutes.routes || []).map((item, index) => { currentRoutes && (currentRoutes.routes || []).filter(item => !item.hideInMenu).map((item, index) => {
return ( return (
<React.Fragment key={index}> <React.Fragment key={index}>
<li key={index} className={classNames(layoutStyles['menu-item'], { [layoutStyles['active']]: index === selectIndex })} onClick={() => handlerSecond(item, index)}> <li key={index} className={classNames(layoutStyles['menu-item'], { [layoutStyles['active']]: index === selectIndex })} onClick={() => handlerSecond(item, index)}>
......
...@@ -21,21 +21,21 @@ class SecurityLayout extends React.Component { ...@@ -21,21 +21,21 @@ class SecurityLayout extends React.Component {
} }
render() { render() {
const { isReady } = this.state; const { isReady } = this.state;
const { children, global, loading } = this.props; const { children, global, loading } = this.props;
const isLogin = Cookies.get('token') !== null && global.token !== null; const isLogin = Cookies.get('token') !== null && global.token !== null;
// const queryString = stringify({ // const queryString = stringify({
// redirect: window.location.href, // redirect: window.location.href,
// }); // });
if(_.isNull(global.token) || (global.hasGateWay && _.isNull(global.access_token))) { if(_.isNull(global.token) || (global.hasGateWay && _.isNull(global.access_token))) {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0); this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || Cookies.get('city'); let client = global.client || Cookies.get('city');
client = client !== 'undefined' || !_.isNull(client) || !_.isUndefined(client) ? client: 'city'; client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client: 'city';
// event.emit(?'event:initConfig'); // event.emit(?'event:initConfig');
let generateType = global.generateType;
generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : '';
return ( return (
<Redirect to={`/user/login?client=${client}`} /> <Redirect to={`/user/login?client=${client}${generateType}`} render={() => window.location.reload()}/>
); );
} }
......
...@@ -345,7 +345,7 @@ class Site { ...@@ -345,7 +345,7 @@ class Site {
window.history.replaceState( window.history.replaceState(
'', '',
'', '',
`/civbase/civweb4/${self.globalConfig.homepage}`, `/${self.globalConfig.homepage}`,
); );
self.getCityStationsForUser().then(res => { self.getCityStationsForUser().then(res => {
window.share.event.emit('updateSite', res); window.share.event.emit('updateSite', res);
......
...@@ -17,6 +17,7 @@ import { actionCreators } from './containers/App/store'; ...@@ -17,6 +17,7 @@ import { actionCreators } from './containers/App/store';
import { FILTER_FOLER_REG } from './utils/constants'; import { FILTER_FOLER_REG } from './utils/constants';
import loader from './render'; import loader from './render';
import store from './stores'; import store from './stores';
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const Logger = logger('micro'); const Logger = logger('micro');
const MICRO_STATUS = { const MICRO_STATUS = {
...@@ -81,7 +82,9 @@ export const initMicroApps = () => { ...@@ -81,7 +82,9 @@ export const initMicroApps = () => {
baseRoot: item.name, baseRoot: item.name,
// eslint- // eslint-
// disable-next-line no-undef // disable-next-line no-undef
globalConfig: config, globalConfig: /civweb4/.test(item.name) ? Object.assign({}, config, {
homepage: config.homepage ? config.homepage.replace(/civweb\//, ''): config.homepage
}): config,
//createStoreage.get('globalConfig'), //createStoreage.get('globalConfig'),
XMLHttpRequest: window.XMLHttpRequest, XMLHttpRequest: window.XMLHttpRequest,
}; };
...@@ -122,14 +125,17 @@ export const initMicroApps = () => { ...@@ -122,14 +125,17 @@ export const initMicroApps = () => {
//createStoreage.get('globalConfig'), //createStoreage.get('globalConfig'),
global: globalStore.global global: globalStore.global
}); });
const globalConfig = window.globalConfig;
globalConfig.homepage = globalConfig.homepage && /civweb4/.test(globalConfig.homepage) ? config.homepage.replace(/civweb4\//, ''): globalConfig.homepage;
console.log(globalConfig);
setGlobalState({ setGlobalState({
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
globalConfig: window.globalConfig, globalConfig: globalConfig,
//createStoreage.get('globalConfig'), //createStoreage.get('globalConfig'),
}); });
microStore.set("props:globalConfig", { microStore.set("props:globalConfig", {
globalConfig: window.globalConfig, globalConfig: globalConfig,
global: globalStore.global global: globalStore.global
}); });
start({ start({
...@@ -208,26 +214,23 @@ export const initMicroApps = () => { ...@@ -208,26 +214,23 @@ export const initMicroApps = () => {
export const defaultApp = () => { export const defaultApp = () => {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const config = createStoreage.get('globalConfig'); const config = window.globalConfig;
if (config && config.token) {
const basePath =config.homepage !== '' && FILTER_FOLER_REG.test(config.homepage) ?'civweb4' :'civweb4'; if (config && config.token) {
if(config && config.home) {
setDefaultMountApp(`/civbase/${config.home.path.replace(/^\//, '')}`);
} else {
const homepage = _.isNull(config.homepage) ? '/index': '/' + config.homepage; // const basePath =config.homepage !== '' && FILTER_FOLER_REG.test(config.homepage) ?'civweb4' :'civweb4';
setDefaultMountApp(`/${pkg.name.toLocaleLowerCase()}/${basePath}${homepage}`); // if(config && config.home) {
createStoreage.set('init_web4', true) // setDefaultMountApp(`/civbase/${config.home.path.replace(/^\//, '')}`);
}
// if(config.productType && config.productType !== 'civweb4') {
// setDefaultMountApp(`/civbase/${config.productType}/${config.homepage.replace(/^\//, '')}`);
// } else { // } else {
// const homepage = _.isNull(config.homepage) ? '/index': '/' + config.homepage; // const homepage = _.isNull(config.homepage) ? '/index': '/' + config.homepage;
// setDefaultMountApp(`/${pkg.name.toLocaleLowerCase()}/civweb4${homepage}`); // setDefaultMountApp(`/${pkg.name.toLocaleLowerCase()}/${basePath}${homepage}`);
// createStoreage.set('init_web4', true) // createStoreage.set('init_web4', true)
// } // }
// let homepage = config.homepage.replace('civweb4/', '');
const url = !config.home ? `/civbase/civweb4/${config.homepage.replace(/^\//, '')}`: `/civbase/${config.homepage.replace(/^\//, '')}`;
setDefaultMountApp(url);
// if(config.homepage.indexOf('civweb4') > -1) createStoreage.set('init_web4', true);
} }
}; };
......
...@@ -43,9 +43,13 @@ class Login { ...@@ -43,9 +43,13 @@ class Login {
let { password } = this.globalConfig; let { password } = this.globalConfig;
loginName = params.getParams('loginName') ? params.getParams('loginName'): loginName; loginName = params.getParams('loginName') ? params.getParams('loginName'): loginName;
const redirect = params.getParams('redirect'); const redirect = params.getParams('redirect');
const generateType = params.getParams('generateType');
if(redirect) { if(redirect) {
this.globalConfig.homepage = redirect; this.globalConfig.homepage = redirect;
this.globalConfig.layout = 'blank'; // this.globalConfig.layout = 'blank';
}
if(generateType) {
this.globalConfig.generateType = generateType;
} }
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
...@@ -218,12 +222,12 @@ class Login { ...@@ -218,12 +222,12 @@ class Login {
: response; : response;
if (result && result.length > 0) { if (result && result.length > 0) {
const config = result.shift(); const config = result.shift();
const homeType = config.productType || 'civweb4';
self.globalConfig = Object.assign(self.globalConfig, config, { self.globalConfig = Object.assign(self.globalConfig, config, {
theme: self.globalConfig.theme, theme: self.globalConfig.theme,
menu: self.globalConfig.menu, menu: self.globalConfig.menu,
style: self.globalConfig.style, style: self.globalConfig.style,
homepage: params.getParams('redirect') || self.globalConfig.homepage || config.homepage, homepage: homeType + '/' + (params.getParams('redirect') || self.globalConfig.homepage || config.homepage),
// productType: config.productType || self.globalConfig.productType || 'civweb4'
}); });
if(self.globalConfig.hasOwnProperty('webConfig')) { if(self.globalConfig.hasOwnProperty('webConfig')) {
...@@ -235,8 +239,6 @@ class Login { ...@@ -235,8 +239,6 @@ class Login {
} }
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
// createStoreage.set('globalConfig', self.globalConfig);
// window.globalConfig.productType = self.globalConfig.productType;
self.getProjectItems().then(() => { self.getProjectItems().then(() => {
window.subSysCfg = {}; window.subSysCfg = {};
result.forEach(item => { result.forEach(item => {
...@@ -278,8 +280,9 @@ class Login { ...@@ -278,8 +280,9 @@ class Login {
: response; : response;
if (resultData && resultData.length > 0) { if (resultData && resultData.length > 0) {
const mainConf = resultData.shift(); const mainConf = resultData.shift();
const mainType = mainConf.productType || 'civweb4';
if (mainConf.homepage) if (mainConf.homepage)
self.globalConfig.homepage = mainConf.homepage; self.globalConfig.homepage = `${mainType}/${mainConf.homepage}`;
if (mainConf.bannerLogo) if (mainConf.bannerLogo)
self.globalConfig.bannerLogo = mainConf.bannerLogo; self.globalConfig.bannerLogo = mainConf.bannerLogo;
if (mainConf.logo) self.globalConfig.logo = mainConf.logo; if (mainConf.logo) self.globalConfig.logo = mainConf.logo;
...@@ -301,8 +304,6 @@ class Login { ...@@ -301,8 +304,6 @@ class Login {
} else { } else {
// loginSuccess // loginSuccess
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
// createStoreage.set('globalConfig', self.globalConfig);
// window.globalConfig.productType = self.globalConfig.productType;
// console.log("===loginSuccess===") // console.log("===loginSuccess===")
getIndustry getIndustry
? self.events.emit('toggleIndustry') ? self.events.emit('toggleIndustry')
...@@ -609,7 +610,7 @@ class Login { ...@@ -609,7 +610,7 @@ class Login {
.then(response => { .then(response => {
self.globalConfig.layout = 'blank'; // self.globalConfig.layout = 'blank';
if (response && response.token) { if (response && response.token) {
const tk = response.token; const tk = response.token;
self.globalConfig.token = tk; self.globalConfig.token = tk;
......
...@@ -25,7 +25,7 @@ const Login = forwardRef((props, _ref) => { ...@@ -25,7 +25,7 @@ const Login = forwardRef((props, _ref) => {
// homepage: params.getParams('redirect') // homepage: params.getParams('redirect')
// })); // }));
// props.history.push('/' + params.getParams('redirect')) // props.history.push('/' + params.getParams('redirect'))
props.history.push(`/?client=${props.global.client}`); props.history.push(`/?client=${props.global.client}&generateType=${props.global.generateType}`);
// window.share.event.emit('triggerMicro', props.global); // window.share.event.emit('triggerMicro', props.global);
initMicroApps(); initMicroApps();
}); });
......
...@@ -62,7 +62,7 @@ const Login = forwardRef((props, _ref) => { ...@@ -62,7 +62,7 @@ const Login = forwardRef((props, _ref) => {
action && action.events.on('loginSuccess', event => { action && action.events.on('loginSuccess', event => {
setSubmitting(false); setSubmitting(false);
props.updateCurrentIndex && props.updateCurrentIndex(0); props.updateCurrentIndex && props.updateCurrentIndex(0);
props.history.push(`/?client=${props.global.client}`); props.history.push(`/`);
// debugger // debugger
// window.share.event.emit('triggerMicro', props.global); // window.share.event.emit('triggerMicro', props.global);
initMicroApps(); initMicroApps();
......
...@@ -52,6 +52,7 @@ const getURL = url => { ...@@ -52,6 +52,7 @@ const getURL = url => {
}; };
const generRotes = (widgets, parent, level = 0) => { const generRotes = (widgets, parent, level = 0) => {
const ret = []; const ret = [];
if(!widgets || widgets.length === 0){ if(!widgets || widgets.length === 0){
return return
...@@ -103,6 +104,7 @@ const generRotes = (widgets, parent, level = 0) => { ...@@ -103,6 +104,7 @@ const generRotes = (widgets, parent, level = 0) => {
url = item.url url = item.url
} }
url = transformURL(url); url = transformURL(url);
//url = url.replace(/[(\\|)|(&)]widget=[0-9]*/, '')
const convertURL = item.icon && transformURL(item.icon.replace(/\s*/g, '')); const convertURL = item.icon && transformURL(item.icon.replace(/\s*/g, ''));
const icon = (item && item.icon && item.icon !== null && const icon = (item && item.icon && item.icon !== null &&
isAbsoluteURL(convertURL) ? convertURL: /(\\|\/)/.test(convertURL) ? isAbsoluteURL(convertURL) ? convertURL: /(\\|\/)/.test(convertURL) ?
...@@ -155,6 +157,29 @@ const generRotes = (widgets, parent, level = 0) => { ...@@ -155,6 +157,29 @@ const generRotes = (widgets, parent, level = 0) => {
}); });
return ret; return ret;
}; };
export const transformWidgets = (widgets) => {
if(!widgets || widgets.length === 0) {
return []
}
return widgets.map(item => {
const widgets = item.widgets;
const homepage = window.globalConfig.homepage;
const homePageConvertArray = homepage.split("/");
const findIndex = widgets && widgets.findIndex(item => item.label === '系统菜单组');
if(findIndex === -1 && homePageConvertArray[0] !== 'civweb4') {
widgets.push({
label: "系统菜单组",
icon: '',
product: homePageConvertArray[0],
shortName: "首页",
url: homePageConvertArray.slice(1, homePageConvertArray.length).join("/")
});
item.widgets = widgets;
}
return item;
});
}
export function simpleNormalizeChildren(children) { export function simpleNormalizeChildren(children) {
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
if (Array.isArray(children[i])) { if (Array.isArray(children[i])) {
......
...@@ -87,6 +87,8 @@ export function findPathByLeafId(leafId, nodes, path, key, clear) { ...@@ -87,6 +87,8 @@ export function findPathByLeafId(leafId, nodes, path, key, clear) {
} }
export function transformURL(path) { export function transformURL(path) {
//civweb4/
// path = path.replace(/[(\\|)|(&)]widget=[0-9]*/, '');
const el = document.createElement('input'); const el = document.createElement('input');
el.value = path; el.value = path;
String.fromCharCode(92); String.fromCharCode(92);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment