2020-04-01 13:47:29 +08:00
|
|
|
|
import store from '@/store/index_APP_TARGET';
|
2019-10-30 13:07:07 +08:00
|
|
|
|
import { getPublishMapVersionById, getPublishMapDetailById} from '@/api/jmap/map';
|
2019-12-30 09:00:16 +08:00
|
|
|
|
import { getNewMapDataByGroup } from '@/api/simulation';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
|
|
|
|
|
// 获取地图版本数据,和store里面的map版本做比较,如果不同
|
|
|
|
|
// 获取发布的地图数据
|
|
|
|
|
// 先设置地图数据
|
|
|
|
|
// 清除列车数据
|
2019-08-29 17:16:33 +08:00
|
|
|
|
export function loadMapDataById(mapId) {
|
2019-10-30 11:18:41 +08:00
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-08-12 17:35:55 +08:00
|
|
|
|
}
|
2019-12-30 09:00:16 +08:00
|
|
|
|
export function loadNewMapDataByGroup(group) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
getNewMapDataByGroup(group).then(resp => {
|
2020-03-06 11:31:09 +08:00
|
|
|
|
resp.data.graphDataNew && resp.data.graphDataNew.trainList && resp.data.graphDataNew.trainList.forEach(item => {
|
|
|
|
|
item.code = item.groupNumber;
|
|
|
|
|
});
|
2019-12-30 09:00:16 +08:00
|
|
|
|
const mapData = resp.data.graphDataNew;
|
|
|
|
|
store.dispatch('map/setMapData', mapData).then(() => {
|
|
|
|
|
store.dispatch('map/clearJlmapTrainView').then(() => {
|
|
|
|
|
resolve();
|
|
|
|
|
});
|
|
|
|
|
});
|
2020-01-19 11:22:48 +08:00
|
|
|
|
const routeData = resp.data.logicDataNew.routeList; // 设置进路数据
|
2020-05-21 15:58:23 +08:00
|
|
|
|
const overlapData = resp.data.logicDataNew.overlapList;
|
2020-03-16 17:16:59 +08:00
|
|
|
|
const autoReentryData = resp.data.logicDataNew.autoReentryList; // 自动折返数据
|
2020-03-18 17:02:07 +08:00
|
|
|
|
const signalApproachSectionData = resp.data.logicDataNew.signalApproachSectionList; // 信号机接近区段数据
|
2020-01-19 11:22:48 +08:00
|
|
|
|
store.dispatch('map/setRouteData', routeData);
|
2020-05-21 15:58:23 +08:00
|
|
|
|
store.dispatch('map/setOverlapData', overlapData);
|
2020-03-16 17:16:59 +08:00
|
|
|
|
store.dispatch('map/setAutoReentryData', autoReentryData);
|
2020-03-18 17:02:07 +08:00
|
|
|
|
store.dispatch('map/setSignalApproachSectionData', signalApproachSectionData);
|
2020-02-12 15:14:14 +08:00
|
|
|
|
const mapConfig = resp.data.configVO;
|
|
|
|
|
store.dispatch('map/setMapConfig', mapConfig);
|
2020-03-13 13:01:58 +08:00
|
|
|
|
store.dispatch('map/setMapVersion', resp.data.version);
|
2019-12-30 09:00:16 +08:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
reject(error);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|