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

fix: 修复mapsetting

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