Commit b122d3d9 authored by 杨思琦's avatar 杨思琦

fix: 站点修改

parent 502148b5
Pipeline #86084 passed with stages
......@@ -180,9 +180,11 @@ const Stations = props => {
const renderSite = ({ data, config, loading, setLoading, action, actionRef, setMenuLoading }) => {
const [visible, setVisible] = useState(false);
const [stationName, setStationName] = useState('');
useEffect(() => {
window.share.event.on('changeSiteVisible', res => {
setVisible(res);
window.share.event.on('changeSiteVisible', (res) => {
setStationName(res.currentStationName);
setVisible(res.visible);
});
return () => {
window.share.event.removeAllListeners('changeSiteVisible');
......@@ -226,7 +228,7 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM
{Array.isArray(data.stations) ? (
<div className={layoutStyles.toggleSite}>
<img src={require('../assets/basic/site.png')} className={layoutStyles.site} alt="" />
<span className={layoutStyles.name}>{data.currentStationName}</span>
<span className={layoutStyles.name}>{stationName === '' ? data.currentStationName : stationName}</span>
<ArrowIcon
className={layoutStyles.arrow}
// fillColor="#fff"
......@@ -403,7 +405,7 @@ const Layout = props => {
GetIntegrationConfig();
}
window.share.event.on('updateSite', res => {
setCityData({...cityData, ...res});
setCityData(res);
});
const handleToggleIndustry = event => {
......
......@@ -288,7 +288,7 @@ class Site {
return arr;
}
writeCookie(token, site, onChangeVisible, actionRef, accessToken) {
writeCookie(token, site, onChangeVisible, actionRef, accessToken, item) {
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString();
......@@ -348,7 +348,7 @@ class Site {
self.props.history && self.props.history.push(url);
self.props && self.props.updateCollapsed && self.props.updateCollapsed(false);
window.share.event.emit('triggerMicro', this.props.global);
onChangeVisible ? onChangeVisible(false) : window.share.event.emit('changeSiteVisible', false);
window.share.event.emit('changeSiteVisible', { currentStationName: item.groupName, visible: false });
});
login.init();
}
......@@ -359,15 +359,14 @@ class Site {
const { token } = this.globalConfig.userInfo;
this.setLoading(true);
if (token) {
window.share.event.emit('updateSite', { ...item, currentStationName: item.groupName });
this.beforeChangeCheck(token, site, onChangeVisible, actionRef);
this.beforeChangeCheck(token, site, onChangeVisible, actionRef, item);
} else {
this.setLoading(false);
message.warning('切换企业失败');
}
}
beforeChangeCheck(token, site, onChangeVisible, actionRef) {
beforeChangeCheck(token, site, onChangeVisible, actionRef, item) {
const userParam = {
token,
subOID: 'subOID',
......@@ -405,17 +404,17 @@ class Site {
const accessToken = tokenRes.data?.access_token ?? null;
config.access_token = accessToken;
localStorage.setItem('access_token', accessToken);
this.writeCookie(token, site, onChangeVisible, actionRef, accessToken);
this.writeCookie(token, site, onChangeVisible, actionRef, accessToken, item);
})
.catch(err => {
this.setLoading(false);
config.access_token = null;
this.writeCookie(token, site, onChangeVisible, actionRef, null);
this.writeCookie(token, site, onChangeVisible, actionRef, null, item);
});
} else {
config.access_token = null;
localStorage.setItem('access_token', null);
this.writeCookie(token, site, onChangeVisible, actionRef, null);
this.writeCookie(token, site, onChangeVisible, actionRef, null, item);
}
})
.catch(err => {
......
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