Commit 2ae12971 authored by 杨硕's avatar 杨硕

路由离开前存储筛选条件

parent 3afade40
// export default {
import store from '@/store'
// 路由离开前存储筛选条件
export function setDataCache(path,param) {
store.dispatch('searchSave/searchParamsSet', {
path: path,
param: {
...param
}
}).then(r => {} )
// console.log('store.getters.searchParams', store.getters.searchParams)
}
// 获取缓存的筛选条件 分页参数需统一,如需自定义分页参数,在列表页自行修改
export function getDataCache(routerPath) {
if (store.getters.searchParams[routerPath]) {
const { searchParams } = store.getters;
const path = routerPath
const param = searchParams[path] // 保留着的查询条件
if (param){
return param
} else {
const paramNew = '{"page":1,"rows":10}'
return paramNew
}
} else {
const paramNew = '{"page":1,"rows":10}'
return paramNew
}
}
// }
......@@ -150,6 +150,8 @@ export default {
})
},
closeSelectedTag(view) {
// 关闭标签页清除存储的筛选条件数据
this.$store.dispatch('searchSave/clearOneParams',this.$route.path)
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
if (this.isActive(view)) {
this.toLastView(visitedViews, view)
......
......@@ -18,7 +18,8 @@ const mutations = {
state.searchParams = {}
},
CLEAR_ONE_PARAMS: (state, path) => {
path && state.searchParams[path] && delete state.searchParams[path]
// path && state.searchParams[path] && delete state.searchParams[path]
state.searchParams[path] = ''
}
}
......@@ -32,7 +33,10 @@ const actions = {
commit('RSET_SEARCH_PARAMS')
},
clearOneParams({ commit }, path) {
// 延时清除缓存数据,防止路由离开前重新赋值
setTimeout(() => {
commit('CLEAR_ONE_PARAMS', path)
}, 1000)
}
}
......
......@@ -273,6 +273,7 @@
import { list, delErrLog, cleanErrLog, exportErrLog } from '@/api/monitor/errorLog'
import Coolbutton from '@/components/coolbutton'
import { cleanOperLog, exportOperLog } from '@/api/monitor/operLog'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Operlog',
......@@ -353,20 +354,25 @@ export default {
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// // const { searchParams } = this.$store.getters; const { path } = this.$route
// // const param = JSON.parse(searchParams[path]) // 保留着的查询条件
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
// this.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList()
// this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
......
......@@ -224,6 +224,7 @@ import { list, delLogininfo, cleanLogininfo, exportLogininfo } from '@/api/monit
import dictCons from '@/utils/dictCons'
// import Template from '@/views/instance/Template'
import Coolbutton from '@/components/coolbutton'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'LoginInfo',
components: { Coolbutton },
......@@ -296,20 +297,25 @@ export default {
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// // const { searchParams } = this.$store.getters; const { path } = this.$route
// // const param = JSON.parse(searchParams[path]) // 保留着的查询条件
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
// this.queryParams.loginTime = this.$parseDate(new Date(), 'YYYY-MM-DD HH:mm:ss')
this.getList()
// this.getDicts(dictCons['COMMON_STATUS']).then(response => {
......
......@@ -272,6 +272,7 @@
import { list, delOperLog, cleanOperLog, exportOperLog } from '@/api/monitor/operLog'
import Coolbutton from '@/components/coolbutton'
import { cleanLogininfo, exportLogininfo } from '@/api/monitor/loginInfo'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Operlog',
......@@ -353,20 +354,23 @@ export default {
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
// this.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList()
// this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
......
......@@ -207,6 +207,7 @@ import { addDept, delDept, getDept, listDept, listDeptExcludeChild, updateDept }
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import Coolbutton from '@/components/coolbutton'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Dept',
components: { Treeselect, Coolbutton },
......@@ -294,20 +295,23 @@ export default {
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
// this.getDicts('sys_normal_disable'.toUpperCase()).then(response => {
// this.statusOptions = response.data
......
......@@ -241,6 +241,7 @@ import dictCons from '@/utils/dictCons'
import Coolbutton from '@/components/coolbutton'
import { getToken } from '@/utils/auth'
import { uploadFalseFile } from '@/api/system/user'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Data',
......@@ -368,7 +369,25 @@ export default {
manageLoading: false
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
const dictId = this.$route.params && this.$route.params.dictId
this.getType(dictId)
this.getTypeList()
......
......@@ -247,6 +247,7 @@ import { listType,
import dictCons from '@/utils/dictCons'
// import Template from '@/views/instance/Template'
import Coolbutton from '@/components/coolbutton'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Dict',
components: { Coolbutton },
......@@ -385,20 +386,23 @@ export default {
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
this.statusOptions = response.data
......
......@@ -265,6 +265,7 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import IconSelect from '@/components/IconSelect'
import dictCons from '@/utils/dictCons'
import Coolbutton from '@/components/coolbutton'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Menu',
components: { Treeselect, IconSelect,Coolbutton },
......@@ -375,23 +376,25 @@ export default {
// },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
this.handleQuery()
} else {
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// this.handleQuery()
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
}
this.getDicts(dictCons['SHOW_HIDE']).then(response => {
this.visibleOptions = response.data
})
......
......@@ -131,6 +131,7 @@
</template>
<script>
import { treeselect, queryUserByDeptId, queryUserWithoutDept, transformDept, queryUserByName } from '../../../api/system/dept'
import { getDataCache } from '@/assets/js/filterData'
export default {
name: 'Otree',
data() {
......
......@@ -228,6 +228,7 @@ import dictCons from '@/utils/dictCons'
import { listDept } from '@/api/system/dept'
import { listRole } from '@/api/system/role'
import {updateType} from "@/api/system/dict/type";
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Post',
components: { Treeselect },
......@@ -337,7 +338,25 @@ export default {
}
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
this.getDicts(dictCons.NORMAL_DISABLE).then(response => {
this.statusOptions = response.data
......
......@@ -263,6 +263,7 @@ import { roleMenuTreeselectMC, treeselect as menuTreeselect, roleMenuTreeselect
import { treeselect as deptTreeselect, roleDeptTreeselect } from '@/api/system/dept'
// import { getRolesByInsId } from '../../../api/businessManage/template'
import Coolbutton from '@/components/coolbutton'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Role',
components: { Coolbutton },
......@@ -384,20 +385,23 @@ export default {
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
// this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
// this.statusOptions = response.data;
......
......@@ -66,14 +66,14 @@
size="small"
@click="handleImport"
>导入</el-button>
<!-- <el-button-->
<!-- v-hasPermi="['sys:user:export']"-->
<!-- style="padding: 8px 7px;"-->
<!-- type="success"-->
<!-- size="small"-->
<!-- icon="el-icon-download"-->
<!-- @click="handleExport"-->
<!-- >导出</el-button>-->
<!-- <el-button-->
<!-- v-hasPermi="['sys:user:export']"-->
<!-- style="padding: 8px 7px;"-->
<!-- type="success"-->
<!-- size="small"-->
<!-- icon="el-icon-download"-->
<!-- @click="handleExport"-->
<!-- >导出</el-button>-->
<coolbutton :type="typeSuccess" :name="exportName" :size="smallSize" :icon="exportIcon" :haspermi="addHaspermi" @btn-click="handleExport" />
</el-form-item>
</el-form>
......@@ -396,6 +396,7 @@ import TreeSelect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { getlistRole } from '@/api/system/role'
import Coolbutton from '@/components/coolbutton'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'User',
components: { TreeSelect, Coolbutton },
......@@ -621,12 +622,13 @@ export default {
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
// this.$store.dispatch('searchSave/searchParamsSet', {
// path: this.$route.path,
// param: {
// ...this.queryParams
// }
// })
setDataCache(this.$route.path, this.queryParams)
next()
},
watch: {
......@@ -636,11 +638,15 @@ export default {
}
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// const filterData = getDataCache(this.$route.path)
// if (filterData) {
// // const { searchParams } = this.$store.getters; const { path } = this.$route
// // const param = JSON.parse(searchParams[path]) // 保留着的查询条件
// const param = JSON.parse(filterData)
// this.queryParams = { ...param }
// }
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
this.getTreeSelect()
this.getRole()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment