在获取列表的步骤前,把搜索条件进行判断,判断是否保存了该数据
this.queryParams = this.$store.state.sned.StatMentquery || {}
然后一一把每一项进行赋值
this.queryParams.globalNumber =this.queryParams.globalNumber || undefined;
this.queryParams.irNumber =this.queryParams.irNumber || undefined;
this.queryParams.line =this.queryParams.line || undefined;
this.queryParams.size =this.queryParams.size || 10;
this.queryParams.zhuangtai =this.queryParams.zhuangtai || undefined;
this.queryParams.zuzu =this.queryParams.zuzu || undefined;
this.queryParams.current =this.queryParams.current || 1;
在接口搜索完,进行保存
this.$store.commit('sned/SET_StatMentquery',this.queryParams)
总体代码
getList(){
this.queryParams = this.$store.state.sned.StatMentquery || {}
if(this.queryParams.beginFashengriqi){
this.daterangeCreateTime = this.queryParams.beginFashengriqi.split(",")
}
this.loading = true
this.queryParams.beginFashengriqi = '';
this.queryParams.endFashengriqi = '';
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
this.queryParams.beginFashengriqi = this.daterangeCreateTime[0] + ',' + this.daterangeCreateTime[1];
this.queryParams.endFashengriqi = this.daterangeCreateTime[1] + ',' + this.daterangeCreateTime[0];
}
this.queryParams.globalNumber =this.queryParams.globalNumber || undefined;
this.queryParams.irNumber =this.queryParams.irNumber || undefined;
this.queryParams.line =this.queryParams.line || undefined;
this.queryParams.size =this.queryParams.size || 10;
this.queryParams.zhuangtai =this.queryParams.zhuangtai || undefined;
this.queryParams.zuzu =this.queryParams.zuzu || undefined;
this.queryParams.current =this.queryParams.current || 1;
scheduling(this.queryParams).then(res => {
this.$store.commit('sned/SET_StatMentquery',this.queryParams)
this.data = res.data.records
this.total = res.data.total
this.loading = false
})
},
vuex页面
const state = {
Snedquery: {},
SnedcurrentPage: 1,
MyDonequery: {},
MyDonecurrentPage: 1,
StatMentquery: {},
StatMentcurrentPage: 1,
}
const mutations = {
//
SET_query: (state, Snedquery) => {
state.Snedquery = Snedquery
},
SET_currentPage: (state, SnedcurrentPage) => {
state.SnedcurrentPage = SnedcurrentPage
},
DELETE_query: (state, Snedquery) => {
state.Snedquery = {}
},
DELETE_currentPage: (state, SnedcurrentPage) => {
state.SnedcurrentPage = 1
},
SET_MyDonequery: (state, MyDonequery) => {
state.MyDonequery = MyDonequery
},
SET_MyDonecurrentPage: (state, MyDonecurrentPage) => {
state.MyDonecurrentPage = MyDonecurrentPage
},
DELETE_MyDonequery: (state, MyDonequery) => {
state.MyDonequery = {}
},
DELETE_MyDonecurrentPage: (state, MyDonecurrentPage) => {
state.MyDonecurrentPage = 1
},
SET_StatMentquery: (state, StatMentquery) => {
state.StatMentquery = StatMentquery
},
SET_StatMentcurrentPage: (state, StatMentcurrentPage) => {
state.StatMentcurrentPage = StatMentcurrentPage
},
DELETE_StatMentqueryy: (state, StatMentquery) => {
state.StatMentquery = {}
},
DELETE_StatMentcurrentPage: (state, StatMentcurrentPage) => {
state.StatMentcurrentPage = 1
},
}
export default {
namespaced: true,
state,
mutations,
}