页面路由跳转返回后数据回显,记住原先的状态
This commit is contained in:
@@ -40,6 +40,7 @@ import operatingLineChart from "../electricityCostAnalysisComponents/operatingLi
|
||||
import operatingLineChartCumulative from "../electricityCostAnalysisComponents/operatingLineChartCumulative.vue";
|
||||
|
||||
import { getElectricityCostAnalysisData } from '@/api/cockpit'
|
||||
import { consumeNavigationState, clearNavigation } from '@/utils/navigationReturnState';
|
||||
export default {
|
||||
name: "electricityCostAnalysis",
|
||||
components: {
|
||||
@@ -117,6 +118,10 @@ export default {
|
||||
this.destroy();
|
||||
},
|
||||
mounted() {
|
||||
// 菜单入口时清空导航栈
|
||||
if (this.$route.query.menu === '1') {
|
||||
clearNavigation();
|
||||
}
|
||||
const _this = this;
|
||||
_this.beilv = document.documentElement.clientWidth / 1920;
|
||||
window.onresize = () => {
|
||||
@@ -125,7 +130,25 @@ export default {
|
||||
this.beilv = _this.clientWidth / 1920;
|
||||
})();
|
||||
};
|
||||
this.dateData = this.$route.query.dateData ? this.$route.query.dateData : undefined
|
||||
// 从 sessionStorage 获取本页面保存的状态
|
||||
const currentPath = this.$route.path;
|
||||
const saved = consumeNavigationState(currentPath);
|
||||
if (saved && saved.dateData && saved.dateData.startTime != null && saved.dateData.endTime != null) {
|
||||
this.dateData = {
|
||||
startTime: saved.dateData.startTime,
|
||||
endTime: saved.dateData.endTime
|
||||
};
|
||||
} else if (this.$route.query.startTime && this.$route.query.endTime) {
|
||||
this.dateData = {
|
||||
startTime: Number(this.$route.query.startTime),
|
||||
endTime: Number(this.$route.query.endTime)
|
||||
};
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (this.dateData && this.dateData.startTime != null && this.dateData.endTime != null) {
|
||||
this.getData();
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
|
||||
Reference in New Issue
Block a user