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

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

@@ -2,7 +2,8 @@
<div id="dayReport" class="dayReport" :style="styles">
<div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
<sidebar v-if="!sidebar.hide" class="sidebar-container" />
<ReportHeader :dateData="dateData" size="psi" @timeRangeChange="handleTimeChange" top-title="基地营业收入"
<ReportHeader :dateData="dateData" size="psi"
@timeRangeChange="handleTimeChange" top-title="基地营业收入"
:is-full-screen="isFullScreen" @screenfullChange="screenfullChange" />
<div class="main-body" style="
margin-top: -20px;
@@ -70,8 +71,10 @@ import profitLineChart from "../costComponents/profitLineChart.vue";
import { mapState } from "vuex";
import { getSalesRevenueFactoryData } from '@/api/cockpit'
import moment from "moment";
import navigationStateMixin from "@/utils/mixins/navigationStateMixin";
export default {
name: "DayReport",
mixins: [navigationStateMixin],
components: {
ReportHeader,
changeBase,
@@ -82,7 +85,6 @@ export default {
monthlyRelatedMetrics,
yearRelatedMetrics,
dataTrend
// psiLineChart
},
data() {
return {
@@ -91,8 +93,7 @@ export default {
beilv: 1,
month:'',
value: 100,
factory:null,
dateData:{},
// factory 和 dateData 由 mixin 提供
index: '营业收入',
monthData: undefined,
ytdData: undefined,
@@ -105,7 +106,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({
@@ -157,7 +163,6 @@ export default {
this.destroy();
},
mounted() {
console.log('this.$router.query', this.$route.query);
const _this = this;
_this.beilv = document.documentElement.clientWidth / 1920;
window.onresize = () => {
@@ -166,20 +171,10 @@ 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
}
console.log('this.$route.query.dateData', this.$route.query.dateData);
this.dateData = this.$route.query.dateData ? this.$route.query.dateData : undefined
},
methods: {
handleChange(value) {
this.index =value
console.log('+++++++++++++++++++++++++++++++++111111')
this.getData()
},
getData() {
@@ -197,27 +192,20 @@ export default {
this.monthAnalysis = res.data.monthAnalysis
this.ytdAnalysis = res.data.ytdAnalysis
this.trend = res.data.trend
// this.monthData = res.data.month
});
},
handleTimeChange(obj) {
console.log('=====================================222222222222',obj);
this.month = obj.targetMonth
this.dateData = {
startTime: obj.startTime,
endTime: obj.endTime,
// mode: obj.mode,
}
console.log('+++++++++++++++++++++++++++++++++22222')
this.getData()
},
selectChange(data) {
console.log('选中的数据:', data);
this.factory = data
if (this.dateData.startTime && this.dateData.endTime) {
console.log('+++++++++++++++++++++++++++++++++33333')
this.getData();
}
},
@@ -253,8 +241,6 @@ export default {
},
// 全屏
screenfullChange() {
console.log("screenfull.enabled", screenfull.isEnabled);
if (!screenfull.isEnabled) {
this.$message({
message: "you browser can not work",