运行图调整

This commit is contained in:
fan 2020-07-31 18:57:27 +08:00
parent 988f38fbb3
commit 3215bec260
2 changed files with 34 additions and 22 deletions

View File

@ -46,8 +46,9 @@ function handle(state, data) {
break; break;
case 'Simulation_RunFact': // 仿真-列车实际到发车站消息 case 'Simulation_RunFact': // 仿真-列车实际到发车站消息
if (!Array.isArray(msg)) { if (!Array.isArray(msg)) {
// console.log([msg], '列车实际到发车站消息');
state.trainStationList = [msg]; state.trainStationList = [msg];
} else {
state.trainStationList = msg;
} }
break; break;
case 'Simulation_Error': // 仿真-异常消息 case 'Simulation_Error': // 仿真-异常消息

View File

@ -200,7 +200,9 @@ export default {
dialogShow: false, dialogShow: false,
series: [], series: [],
oldseries:[], oldseries:[],
trainLabelPosition:0 trainLabelPosition:0,
updateCount: 0,
op: null
}; };
}, },
computed: { computed: {
@ -224,6 +226,12 @@ export default {
maxHeight() { maxHeight() {
this.setPosition(); this.setPosition();
}, },
updateCount() {
if (this.updateCount > 0) {
this.myChart && this.myChart.setOption(this.op, true);
this.updateCount = 0;
}
},
'$store.state.runPlan.planLoadedCount': async function () { '$store.state.runPlan.planLoadedCount': async function () {
try { try {
await this.loadChartPage(); await this.loadChartPage();
@ -244,6 +252,11 @@ export default {
if (!val) { if (!val) {
this.$store.dispatch('runPlan/resetRunPlanData'); this.$store.dispatch('runPlan/resetRunPlanData');
} }
},
'$store.state.socket.trainStationList': function (val) {
if (val.length) {
this.updateRunPlanData(val);
}
} }
}, },
mounted() { mounted() {
@ -264,9 +277,9 @@ export default {
this.setPosition(); this.setPosition();
this.loadInitData(this.series); this.loadInitData(this.series);
this.inter && clearInterval(this.inter); this.inter && clearInterval(this.inter);
this.inter = setInterval(() => { // this.inter = setInterval(() => {
this.updateRunningData(); // this.updateRunningData();
}, 1000); // }, 1000);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} finally { } finally {
@ -339,22 +352,24 @@ export default {
const stations = this.$store.state.runPlan.stations; const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData; const planData = this.$store.state.runPlan.planData;
const initialPlanData = this.$store.state.runPlan.initialPlanData; const initialPlanData = this.$store.state.runPlan.initialPlanData;
if (data[0] && initialPlanData[data[0].serviceNumber]) { data && data.length && data.forEach(item => {
Object.keys(initialPlanData[data[0].serviceNumber].trainMap).forEach(item => { if (item && initialPlanData[item.serviceNumber]) {
if (initialPlanData[data[0].serviceNumber].trainMap[item + ''].tripNumber == data[0].tripNumber) { Object.keys(initialPlanData[item.serviceNumber].trainMap).forEach(ele => {
data[0].directionCode = initialPlanData[data[0].serviceNumber].trainMap[item + ''].directionCode; if (initialPlanData[data[0].serviceNumber].trainMap[ele + ''].tripNumber == item.tripNumber) {
data[0].directionCode = initialPlanData[item.serviceNumber].trainMap[ele + ''].directionCode;
} }
}); });
item.secondTime = item.second;
} }
if (data[0]) { });
data[0].secondTime = data[0].second;
}
const op = this.myChart.getOption(); const op = this.myChart.getOption();
op.series = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap, op.series = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap,
planData, op.series, { color: '#FF00DE', width: 2 } planData, op.series, { color: '#FF00DE', width: 2 }
); );
this.series = op.series; this.series = op.series;
this.myChart.setOption(op, true); this.op = op;
this.updateCount++;
// this.myChart.setOption(op, true);
} }
}, },
async loadChartPage() { async loadChartPage() {
@ -525,12 +540,8 @@ export default {
data: data data: data
}); });
this.trainLabelPosition = op.series.length; this.trainLabelPosition = op.series.length;
setTimeout(() => { this.op = op;
this.myChart && this.myChart.setOption(op, true); this.updateCount++;
setTimeout(()=>{
this.$store.dispatch('runPlan/updateAllowUpdate', true);
}, 300);
}, 50);
}, },
mouseClick(params) { mouseClick(params) {
const model = { const model = {