This commit is contained in:
zyy 2020-08-03 10:16:23 +08:00
commit 317ea995e7
2 changed files with 31 additions and 47 deletions

View File

@ -8,8 +8,6 @@ const runPlan = {
planSizeCount: 0, // 运行图canvas 大小变更标识
planLoadedCount: 0, // 运行图数据更新
planUpdateCount: 0, // 运行图更新标识
allowUpdate:true, // 允许运行图更新
updateDataList:[], // 运行图数据更新池
selected: {}, // 选择的对象
width: 800, // 运行图canvas 容器 宽度
height: 600, // 运行图canvas 容器 高度
@ -103,18 +101,6 @@ const runPlan = {
state.planLoadedCount++;
}
},
updateRunPlanData: (state, data) => {
state.updateDataList.push(data);
},
updateAllowUpdate: (state, data) => {
state.allowUpdate = data;
},
shiftRunPlanData: (state) => {
state.updateDataList.shift();
},
resetRunPlanData:(state) => {
state.updateDataList = [];
},
clear: (state) => {
state.stations = [];
state.planData = {};
@ -139,10 +125,6 @@ const runPlan = {
setStations: ({ commit }, mapModel) => {
commit('setStations', mapModel);
},
/** 更新是否更新运行图状态 */
updateAllowUpdate:({ commit }, data) => {
commit('updateAllowUpdate', data);
},
/** 重置运行图数据更新池 */
resetRunPlanData:({ commit }) => {
commit('resetRunPlanData');

View File

@ -202,7 +202,8 @@ export default {
oldseries:[],
trainLabelPosition:0,
updateCount: 0,
op: null
op: null,
updateData: []
};
},
computed: {
@ -260,7 +261,6 @@ export default {
}
},
mounted() {
// this.PlanConvert = this.$theme.loadPlanConvert(this.lineCode);
getPublishMapInfo(this.$route.query.mapId).then(res=>{
this.PlanConvert = this.$theme.loadPlanConvert(res.data.lineCode);
// this.loadChartPage();
@ -277,9 +277,6 @@ export default {
this.setPosition();
this.loadInitData(this.series);
this.inter && clearInterval(this.inter);
// this.inter = setInterval(() => {
// this.updateRunningData();
// }, 1000);
} catch (e) {
console.error(e);
} finally {
@ -289,19 +286,6 @@ export default {
async doClose() {
this.dialogShow = false;
this.inter && clearInterval(this.inter);
// this.inter = null;
},
updateRunningData() {
console.log('外层更新触发');
if (this.$store.state.runPlan.allowUpdate) {
console.log('里层更新触发');
const updateDataList = this.$store.state.runPlan.updateDataList;
// console.log(updateDataList.length);
if (updateDataList.length > 0) {
this.updateRunPlanData(updateDataList[0]);
this.$store.dispatch('runPlan/shiftRunPlanData');
}
}
},
serviceNumberChange(row) {
if (row) {
@ -352,11 +336,11 @@ export default {
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
const initialPlanData = this.$store.state.runPlan.initialPlanData;
data && data.length && data.forEach(item => {
data.forEach(item => {
if (item && initialPlanData[item.serviceNumber]) {
Object.keys(initialPlanData[item.serviceNumber].trainMap).forEach(ele => {
if (initialPlanData[data[0].serviceNumber].trainMap[ele + ''].tripNumber == item.tripNumber) {
data[0].directionCode = initialPlanData[item.serviceNumber].trainMap[ele + ''].directionCode;
if (initialPlanData[item.serviceNumber].trainMap[ele + ''].tripNumber == item.tripNumber) {
item.directionCode = initialPlanData[item.serviceNumber].trainMap[ele + ''].directionCode;
}
});
item.secondTime = item.second;
@ -369,25 +353,43 @@ export default {
this.series = op.series;
this.op = op;
this.updateCount++;
// this.myChart.setOption(op, true);
} else {
this.updateData = [...this.updateData, ...data];
}
},
handlerUpdateData() {
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
const initialPlanData = this.$store.state.runPlan.initialPlanData;
this.updateData.forEach(item => {
if (item && initialPlanData[item.serviceNumber]) {
Object.keys(initialPlanData[item.serviceNumber].trainMap).forEach(ele => {
if (initialPlanData[item.serviceNumber].trainMap[ele + ''].tripNumber == item.tripNumber) {
item.directionCode = initialPlanData[item.serviceNumber].trainMap[ele + ''].directionCode;
}
});
item.secondTime = item.second;
}
});
const op = this.myChart.getOption();
op.series = this.PlanConvert.updateDataToModels(this.updateData, stations, this.kmRangeCoordMap,
planData, op.series, { color: '#FF00DE', width: 2 }
);
this.series = op.series;
this.op = op;
this.updateCount++;
this.updateData = [];
},
async loadChartPage() {
try {
this.series = [];
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
this.viewDisabled = true;
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.pushModels(this.series, [this.PlanConvert.initializeYaxis(stations)]);
this.oldseries = this.pushModels(this.series, this.PlanConvert.convertDataToModels(planData, stations, this.kmRangeCoordMap, { color: '#000', width: 1 }));
// await this.loadInitData(series);
await this.analyticalServiceNumber(this.$store.state.runPlan.editData);
this.viewDisabled = false;
} catch (error) {
this.viewDisabled = false;
this.$messageBox(`加载运行图数据失败`);
}
},
@ -398,6 +400,7 @@ export default {
await this.yAxisInit();
await this.loadInitChart(series);
this.myChart && this.myChart.hideLoading();
this.handlerUpdateData();
},
pushModels(series, models) {
@ -494,7 +497,6 @@ export default {
].join('');
},
renderTripNumber(params) {
this.$store.dispatch('runPlan/updateAllowUpdate', false);
const tripNumber = params.tripNumber; //
const serviceNumber = params.serviceNumber; //
let data, markPoint;