仿真调整

This commit is contained in:
joylink_fanyuhong 2020-02-25 10:36:18 +08:00
parent 03843cf217
commit 3197641b97
6 changed files with 21 additions and 19 deletions

View File

@ -25,7 +25,7 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { timeFormat } from '@/utils/date'; import { timeFormat } from '@/utils/date';
import { runDiagramGetTime } from '@/api/simulation'; import {toTimeStamp, formatDuring} from '@/utils/date';
import DataTable from '../menusPlan/components/dataTable'; import DataTable from '../menusPlan/components/dataTable';
import echarts from 'echarts'; import echarts from 'echarts';
@ -350,7 +350,8 @@ export default {
this.destroy(); this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime; let startValue = 3600 + this.PlanConvert.TranslationTime;
const offsetTime = 3600; const offsetTime = 3600;
startValue = this.$store.state.training.initTime - this.PlanConvert.TranslationTime; const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime; this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime;
this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime; this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime;
this.option.series = series; this.option.series = series;

View File

@ -27,6 +27,7 @@ import { mapGetters } from 'vuex';
import { timeFormat } from '@/utils/date'; import { timeFormat } from '@/utils/date';
import DataTable from '../menusPlan/components/dataTable'; import DataTable from '../menusPlan/components/dataTable';
import echarts from 'echarts'; import echarts from 'echarts';
import {toTimeStamp, formatDuring} from '@/utils/date';
export default { export default {
name: 'PlanSchedule', name: 'PlanSchedule',
@ -360,7 +361,8 @@ export default {
this.destroy(); this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime; let startValue = 3600 + this.PlanConvert.TranslationTime;
const offsetTime = 3600; const offsetTime = 3600;
startValue = this.$store.state.training.initTime - this.PlanConvert.TranslationTime; const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime; this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime;
this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime; this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime;
this.option.series = series; this.option.series = series;

View File

@ -25,7 +25,7 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { timeFormat } from '@/utils/date'; import { timeFormat } from '@/utils/date';
import { runDiagramGetTime } from '@/api/simulation'; import {toTimeStamp, formatDuring} from '@/utils/date';
import DataTable from '../menusPlan/components/dataTable'; import DataTable from '../menusPlan/components/dataTable';
import echarts from 'echarts'; import echarts from 'echarts';
@ -360,10 +360,10 @@ export default {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
this.destroy(); this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime; let startValue = 3600 + this.PlanConvert.TranslationTime;
const offsetTime = 3600; const offsetTime = 3600;
startValue = this.$store.state.training.initTime - this.PlanConvert.TranslationTime; const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime; this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime;
this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime; this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime;
this.option.series = series; this.option.series = series;

View File

@ -25,7 +25,7 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { timeFormat } from '@/utils/date'; import { timeFormat } from '@/utils/date';
import { runDiagramGetTime } from '@/api/simulation'; import {toTimeStamp, formatDuring} from '@/utils/date';
import DataTable from '../menusPlan/components/dataTable'; import DataTable from '../menusPlan/components/dataTable';
import echarts from 'echarts'; import echarts from 'echarts';
@ -350,7 +350,8 @@ export default {
this.destroy(); this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime; let startValue = 3600 + this.PlanConvert.TranslationTime;
const offsetTime = 3600; const offsetTime = 3600;
startValue = this.$store.state.training.initTime - this.PlanConvert.TranslationTime; const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime; this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = startValue - offsetTime;
this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime; this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = startValue + offsetTime;
this.option.series = series; this.option.series = series;

View File

@ -2,7 +2,7 @@ import store from '@/store';
import { Notification } from 'element-ui'; import { Notification } from 'element-ui';
function handle(state, data) { function handle(state, data) {
console.log(data, 'socket订阅'); // console.log(data, 'socket订阅');
const msg = data.body; const msg = data.body;
const path = window.location.href; const path = window.location.href;
switch (data.type) { switch (data.type) {

View File

@ -39,9 +39,9 @@ export function timeFormat(usedTime) {
export function toTimeStamp(time) { export function toTimeStamp(time) {
let s = 0; let s = 0;
let hour = time.split(':')[0]; const hour = time.split(':')[0];
let min = time.split(':')[1]; const min = time.split(':')[1];
let sec = time.split(':')[2]; const sec = time.split(':')[2];
s = Number(hour * 3600) + Number(min * 60) + Number(sec); s = Number(hour * 3600) + Number(min * 60) + Number(sec);
return s; return s;
} }
@ -49,13 +49,11 @@ export function toTimeStamp(time) {
// 时间戳的只转为时分秒 // 时间戳的只转为时分秒
export function formatDuring(mss) { export function formatDuring(mss) {
let hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const now = new Date(mss);
let minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60)); const hour = now.getHours(); // 返回日期中的小时数0到23
let seconds = (mss % (1000 * 60)) / 1000; const minute = now.getMinutes(); // 返回日期中的分钟数0到59
hours = hours < 10 ? ('0' + hours) : hours; const second = now.getSeconds(); // 返回日期中的秒数0到59
minutes = minutes < 10 ? ('0' + minutes) : minutes; return hour + ':' + minute + ':' + second;
seconds = seconds < 10 ? ('0' + seconds) : seconds;
return hours + ":" + minutes + ":" + seconds;
} }
export function prefixIntrger(num, length) { export function prefixIntrger(num, length) {