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

View File

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