From d1a5669999d98420876ac24f61cd89afe07c4fc1 Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Mon, 3 Aug 2020 10:02:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=9B=BE=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/runplan.js | 18 ------ .../newMap/displayNew/demon/runPlanView.vue | 60 ++++++++++--------- 2 files changed, 31 insertions(+), 47 deletions(-) diff --git a/src/store/modules/runplan.js b/src/store/modules/runplan.js index 01000a308..f25d034d8 100644 --- a/src/store/modules/runplan.js +++ b/src/store/modules/runplan.js @@ -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'); diff --git a/src/views/newMap/displayNew/demon/runPlanView.vue b/src/views/newMap/displayNew/demon/runPlanView.vue index dc7ac30d3..1eca6cbe3 100644 --- a/src/views/newMap/displayNew/demon/runPlanView.vue +++ b/src/views/newMap/displayNew/demon/runPlanView.vue @@ -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;