页面路由跳转返回后数据回显,记住原先的状态
This commit is contained in:
@@ -65,8 +65,10 @@ import dataTrend from "../productionCostAnalysisComponents/dataTrend.vue";
|
||||
import { mapState } from "vuex";
|
||||
import { getCostAnalysisData } from '@/api/cockpit'
|
||||
import moment from "moment";
|
||||
import navigationStateMixin from "@/utils/mixins/navigationStateMixin";
|
||||
export default {
|
||||
name: "DayReport",
|
||||
mixins: [navigationStateMixin],
|
||||
components: {
|
||||
ReportHeader,
|
||||
changeBase,
|
||||
@@ -84,8 +86,7 @@ export default {
|
||||
beilv: 1,
|
||||
month:'',
|
||||
value: 100,
|
||||
factory: null,
|
||||
dateData: {},
|
||||
// factory 和 dateData 由 mixin 提供
|
||||
monData: {},
|
||||
totalData: {},
|
||||
trend: [],
|
||||
@@ -97,6 +98,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({
|
||||
@@ -162,15 +169,6 @@ export default {
|
||||
this.beilv = _this.clientWidth / 1920;
|
||||
})();
|
||||
};
|
||||
console.log('this.$route.query.factory', this.$route.query.factory);
|
||||
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: {
|
||||
changeItem(item) {
|
||||
@@ -188,9 +186,7 @@ export default {
|
||||
analysisObject: [
|
||||
"原片成本",
|
||||
],
|
||||
// paramList: ['制造成本', '财务费用', '销售费用', '管理费用', '运费'],
|
||||
levelId: this.factory,
|
||||
// baseId: Number(this.factory),
|
||||
};
|
||||
// 调用接口
|
||||
getCostAnalysisData(requestParams).then((res) => {
|
||||
|
||||
Reference in New Issue
Block a user