rt-sim-training-client/src/utils/loaddata.js
joylink_cuiweidong 0cf0caef1d 裁判系统代码调整
佛山左下角信息窗口调整
2020-06-04 11:12:55 +08:00

82 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import store from '@/store/index_APP_TARGET';
import { getPublishMapVersionById, getPublishMapDetailById} from '@/api/jmap/map';
import { getNewMapDataByGroup, getNewMapDataByMapId } from '@/api/simulation';
// 获取地图版本数据和store里面的map版本做比较如果不同
// 获取发布的地图数据
// 先设置地图数据
// 清除列车数据
export function loadMapDataById(mapId) {
return new Promise((resolve, reject) => {
getPublishMapVersionById(mapId).then(resp => {
var version = resp.data;
var mapData = store.state.map.mapIdList[`mapDate_${mapId}`];
if (mapData && mapData.version == version) {
store.dispatch('map/setMapData', mapData).then(() => {
store.dispatch('map/clearJlmapTrainView').then(() => {
resolve();
});
});
} else {
getPublishMapDetailById(mapId).then(res => {
mapData = res.data;
store.dispatch('map/setMapDataIdList', {mapData, mapId});
store.dispatch('map/setMapData', mapData).then(() => {
store.dispatch('map/clearJlmapTrainView').then(() => {
resolve();
});
});
}).catch(error => {
reject(error);
});
}
}).catch(error => {
reject(error);
});
});
}
export function loadNewMapDataByMapId(mapId) {
return new Promise((resolve, reject) => {
getNewMapDataByMapId(mapId).then(resp => {
covertData(resp, resolve);
}).catch(error => {
reject(error);
});
});
}
export function loadNewMapDataByGroup(group) {
return new Promise((resolve, reject) => {
getNewMapDataByGroup(group).then(resp => {
covertData(resp, resolve);
}).catch(error => {
reject(error);
});
});
}
export function covertData(resp, resolve) {
resp.data.graphDataNew && resp.data.graphDataNew.trainList && resp.data.graphDataNew.trainList.forEach(item => {
item.code = item.groupNumber;
});
const mapData = resp.data.graphDataNew;
store.dispatch('map/setMapData', mapData).then(() => {
store.dispatch('map/clearJlmapTrainView').then(() => {
resolve();
});
});
const routeData = resp.data.logicDataNew.routeList; // 设置进路数据
const overlapData = resp.data.logicDataNew.overlapList;
const autoReentryData = resp.data.logicDataNew.autoReentryList; // 自动折返数据
const signalApproachSectionData = resp.data.logicDataNew.signalApproachSectionList; // 信号机接近区段数据
store.dispatch('map/setRouteData', routeData);
store.dispatch('map/setOverlapData', overlapData);
store.dispatch('map/setAutoReentryData', autoReentryData);
store.dispatch('map/setSignalApproachSectionData', signalApproachSectionData);
const mapConfig = resp.data.configVO;
store.dispatch('map/setMapConfig', mapConfig);
store.dispatch('map/setMapVersion', resp.data.version);
}