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

fix: 修复mapsetting

parent cd7ae4fb
...@@ -82,6 +82,7 @@ const appReducer = (state = initialState, action) => { ...@@ -82,6 +82,7 @@ const appReducer = (state = initialState, action) => {
case GET_CONFIG: case GET_CONFIG:
// eslint-disable-next-line no-debugger // eslint-disable-next-line no-debugger
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
window.__INITIAL_STATE__ = Object.assign( window.__INITIAL_STATE__ = Object.assign(
{}, {},
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
...@@ -99,6 +100,7 @@ const appReducer = (state = initialState, action) => { ...@@ -99,6 +100,7 @@ const appReducer = (state = initialState, action) => {
window.__INITIAL_STATE__.mdi = 'SDI'; window.__INITIAL_STATE__.mdi = 'SDI';
window.__INITIAL_STATE__.menu = 'banner-left'; window.__INITIAL_STATE__.menu = 'banner-left';
window.globalConfig = AppConfig(window.__INITIAL_STATE__); window.globalConfig = AppConfig(window.__INITIAL_STATE__);
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
createStoreage.set('globalConfig', window.globalConfig); createStoreage.set('globalConfig', window.globalConfig);
// eslint-disable-next-line no-undef,no-case-declarations // eslint-disable-next-line no-undef,no-case-declarations
......
import React from 'react'; import React from 'react';
import { Spin } from 'antd'; import _ from 'lodash'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import MapComponent from '@/components/mapView'; import MapComponent from '@/components/mapView';
...@@ -11,26 +10,55 @@ class CreateMap extends React.Component { ...@@ -11,26 +10,55 @@ class CreateMap extends React.Component {
this.mapManganerRef = React.createRef(); this.mapManganerRef = React.createRef();
} }
state = { // state = {
loading: true, // loading: true,
config: window.globalConfig.mapsettings, // config: this.props.global.mapsettings,
widgets: window.globalConfig.uiwidgets, // widgets: this.props.global.uiwidgets,
}; // };
// componentWillReceiveProps(nextProps) {
// if(nextProps.global.mapsettings !== this.props.global.mapsettings) {
// this.setState(Object.assign({}, this.state, {
// config: nextProps.global.mapsettings
// }))
// }
// if(nextProps.global.uiwidgets !== this.props.global.uiwidgets) {
// this.setState(Object.assign({}, this.state, {
// widgets: nextProps.global.uiwidgets
// }))
// }
// }
getView = view => { getView = view => {
console.log(view)
this.props.updageMapView(view); this.props.updageMapView(view);
}; };
render() { render() {
if(_.isNull(this.props.global.mapsettings.areasettings)) {
return null;
}
const props = {
loading: true,
config: this.props.global.mapsettings,
widgets: this.props.global.uiwidgets,
}
return ( return (
<> <>
<MapComponent {...this.state} getMapInfo={this.getView} /> <MapComponent {...props} getMapInfo={this.getView} />
</> </>
); );
} }
} }
const mapStateToProps = state => ({}); const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig'])
});
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
updageMapView(mapView) { updageMapView(mapView) {
......
...@@ -214,27 +214,18 @@ class Login { ...@@ -214,27 +214,18 @@ class Login {
}) })
.then(response => { .then(response => {
const result = const result = response && response.code === SERVICE_INTERFACE_SUCCESS_CODE ? Array.isArray(response.data)? response.data: [] : response;
response && response.code === SERVICE_INTERFACE_SUCCESS_CODE
? Array.isArray(response.data)
? response.data
: []
: response;
if (result && result.length > 0) { if (result && result.length > 0) {
const config = result.shift(); const config = result.shift();
const homeType = config.productType || 'civweb4'; const homeType = config.productType || 'civweb4';
// 产品类型和首页路径同时有才行 // 产品类型和首页路径同时有才行
const homepage = const homepage = homeType && (params.getParams('redirect') || config.homepage) ? homeType + '/' + (params.getParams('redirect') || config.homepage) : '';
homeType && (params.getParams('redirect') || config.homepage)
? homeType +
'/' +
(params.getParams('redirect') || config.homepage)
: '';
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: homepage, homepage: homepage
// mapsettings: config.mapsettings
}); });
if(self.globalConfig.hasOwnProperty('webConfig')) { if(self.globalConfig.hasOwnProperty('webConfig')) {
...@@ -246,8 +237,11 @@ class Login { ...@@ -246,8 +237,11 @@ class Login {
} }
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
self.getProjectItems().then(() => { self.getProjectItems().then((res) => {
window.subSysCfg = {}; window.subSysCfg = {};
self.globalConfig = Object.assign(self.globalConfig, {
mapsettings: res
})
result.forEach(item => { result.forEach(item => {
window.subSysCfg[item.client] = item; window.subSysCfg[item.client] = item;
}); });
...@@ -261,11 +255,7 @@ class Login { ...@@ -261,11 +255,7 @@ class Login {
// this.events.removeAllListeners('loginSuccess') // this.events.removeAllListeners('loginSuccess')
// this.events.removeAllListeners('toggleIndustry') // this.events.removeAllListeners('toggleIndustry')
// window.share.event = this.events; // window.share.event = this.events;
if ( if (self.globalConfig.userInfo && self.globalConfig.userInfo.site &&self.globalConfig.userInfo.site.length > 0) {
self.globalConfig.userInfo &&
self.globalConfig.userInfo.site &&
self.globalConfig.userInfo.site.length > 0
) {
// eslint-disable-next-line no-undef,no-underscore-dangle // eslint-disable-next-line no-undef,no-underscore-dangle
getWebSiteConfig( getWebSiteConfig(
...@@ -311,6 +301,8 @@ class Login { ...@@ -311,6 +301,8 @@ class Login {
}); });
} else { } else {
// loginSuccess // loginSuccess
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
// console.log("===loginSuccess===") // console.log("===loginSuccess===")
getIndustry getIndustry
...@@ -380,16 +372,24 @@ class Login { ...@@ -380,16 +372,24 @@ class Login {
url: 'product/webgisPanda/ToggleProject/ToggleProject', url: 'product/webgisPanda/ToggleProject/ToggleProject',
}); });
} }
debugger
if (layer.areaName) if (layer.areaName) {
this.globalConfig.mapsettings.areasettings.areaName = layer.areaName; this.globalConfig.mapsettings.areasettings.areaName = layer.areaName;
if (layer.backgroundColor) }
if (layer.backgroundColor) {
this.globalConfig.mapsettings.areasettings.backgroundColor = this.globalConfig.mapsettings.areasettings.backgroundColor =
layer.backgroundColor; layer.backgroundColor;
if (layer.boundColor) }
if (layer.boundColor) {
this.globalConfig.mapsettings.areasettings.boundColor = layer.boundColor; this.globalConfig.mapsettings.areasettings.boundColor = layer.boundColor;
if (layer.boundWidth) }
if (layer.boundWidth) {
this.globalConfig.mapsettings.areasettings.boundWidth = layer.boundWidth; this.globalConfig.mapsettings.areasettings.boundWidth = layer.boundWidth;
}
// eslint-disable-next-line radix // eslint-disable-next-line radix
if (Number.isInteger(parseInt(layer.backgroundOpacity))) { if (Number.isInteger(parseInt(layer.backgroundOpacity))) {
this.globalConfig.mapsettings.areasettings.backgroundOpacity = this.globalConfig.mapsettings.areasettings.backgroundOpacity =
...@@ -397,10 +397,15 @@ class Login { ...@@ -397,10 +397,15 @@ class Login {
} }
if (layer.extent) if (layer.extent)
this.globalConfig.mapsettings.areasettings.extent = layer.extent; this.globalConfig.mapsettings.areasettings.extent = layer.extent;
if (layer.basemaps && layer.basemaps.length > 0) if (layer.basemaps && layer.basemaps.length > 0) {
this.globalConfig.mapsettings.basemaps = layer.basemaps; this.globalConfig.mapsettings.basemaps = layer.basemaps;
this.updateConfig && this.updateConfig(this.globalConfig); }
return Promise.resolve({});
// this.updateConfig && this.updateConfig(Object.assign({}, this.globalConfig, {
// mapsettings: this.globalConfig.mapsettings
// }));
// console.log("mapsettings", this.globalConfig.mapsettings)
return Promise.resolve(this.globalConfig.mapsettings);
} }
handleLoginError(callback) { handleLoginError(callback) {
......
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