页面路由跳转返回后数据回显,记住原先的状态

This commit is contained in:
2026-05-12 08:57:26 +08:00
parent c2b64d5e22
commit ad1cbee74a
164 changed files with 5150 additions and 2246 deletions

View File

@@ -67,8 +67,10 @@ import dataTrend from "../inputOutputRatioComponents/dataTrend.vue";
import { mapState } from "vuex";
import { getInputOutputRateFactoryData } from '@/api/cockpit'
import moment from "moment";
import navigationStateMixin from "@/utils/mixins/navigationStateMixin";
export default {
name: "DayReport",
mixins: [navigationStateMixin],
components: {
ReportHeader,
changeBase,
@@ -87,8 +89,7 @@ export default {
beilv: 1,
month: '',
value: 100,
factory: null,
dateData: {},
// factory 和 dateData 由 mixin 提供
index: '投入产出率',
monthData: undefined,
ytdData: undefined,
@@ -101,7 +102,12 @@ export default {
created() {
this.init();
this.windowWidth(document.documentElement.clientWidth);
// 使用 mixin 初始化导航状态恢复
this._initNavigationStateMixin(({ factory, dateData }) => {
if (factory != null && dateData && dateData.startTime != null) {
this.getData();
}
});
},
computed: {
...mapState({
@@ -153,7 +159,6 @@ export default {
this.destroy();
},
mounted() {
console.log('this.$router.query', this.$router.query);
const _this = this;
_this.beilv = document.documentElement.clientWidth / 1920;
window.onresize = () => {
@@ -162,14 +167,6 @@ export default {
this.beilv = _this.clientWidth / 1920;
})();
};
if(this.$route.query.factory){
this.factory =Number(this.$route.query.factory)
}else if(this.$store.getters.levelList.length > 0 && this.$store.getters.levelList[0].id !== 1) {
this.factory = this.$store.getters.levelList[0].id
}else{
this.factory = this.$store.getters.levelList[1].id
}
this.dateData = this.$route.query.dateData ? this.$route.query.dateData : undefined
},
methods: {
handleChange(value) {
@@ -191,8 +188,6 @@ export default {
this.monthAnalysis = res.data.monthAnalysis
this.ytdAnalysis = res.data.ytdAnalysis
this.trend = res.data.trend
// this.monthData = res.data.month
});
},
@@ -200,8 +195,7 @@ export default {
this.month = obj.targetMonth
this.dateData = {
startTime: obj.startTime,
endTime: obj.endTime,
// mode: obj.mode,
endTime: obj.endTime
}
this.getData()