Commit c6b4109f authored by 张伯涛's avatar 张伯涛

页面离开前记住筛选项

parent cd61d0eb
...@@ -8,6 +8,7 @@ const getters = { ...@@ -8,6 +8,7 @@ const getters = {
roles: state => state.user.roles, roles: state => state.user.roles,
introduction: state => state.user.introduction, introduction: state => state.user.introduction,
permissions: state => state.user.permissions, permissions: state => state.user.permissions,
permission_routes: state => state.permission.routes permission_routes: state => state.permission.routes,
searchParams: state => state.searchSave.searchParams
} }
export default getters export default getters
...@@ -3,6 +3,7 @@ import Vuex from 'vuex' ...@@ -3,6 +3,7 @@ import Vuex from 'vuex'
import app from './modules/app' import app from './modules/app'
import user from './modules/user' import user from './modules/user'
import tagsView from './modules/tagsView' import tagsView from './modules/tagsView'
import searchSave from './modules/searchSave'
import permission from './modules/permission' import permission from './modules/permission'
import settings from './modules/settings' import settings from './modules/settings'
import getters from './getters' import getters from './getters'
...@@ -15,6 +16,7 @@ const store = new Vuex.Store({ ...@@ -15,6 +16,7 @@ const store = new Vuex.Store({
user, user,
tagsView, tagsView,
permission, permission,
searchSave,
settings settings
}, },
getters getters
......
const state = {
searchParams: {
// [route.path]: { ...searchContent }
}
}
const mutations = {
SET_SEARCH_PARAMS: (state, config) => {
if (!config || typeof config !== 'object') { return }
if (!config.path) { return }
if (config.param && typeof config.param === 'object' && Object.keys(config.param).length > 0) {
state.searchParams[config.path] = JSON.stringify(config.param)
} else {
delete state.searchParams[config.path]
}
},
RSET_SEARCH_PARAMS: (state) => {
state.searchParams = {}
},
CLEAR_ONE_PARAMS: (state, path) => {
path && state.searchParams[path] && delete state.searchParams[path]
}
}
const actions = {
searchParamsSet({ commit }, config) {
if (!config || typeof config !== 'object') { return }
if (!config.path) { return }
commit('SET_SEARCH_PARAMS', config)
},
restSearchParams({ commit }) {
commit('RSET_SEARCH_PARAMS')
},
clearOneParams({ commit }, path) {
commit('CLEAR_ONE_PARAMS', path)
}
}
export default {
namespaced: true,
state,
mutations,
actions
}
...@@ -244,7 +244,22 @@ export default { ...@@ -244,7 +244,22 @@ export default {
} }
} }
}, },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() { 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.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM') // this.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList() this.getList()
this.getDicts('sys_oper_type'.toUpperCase()).then(response => { this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
......
...@@ -175,7 +175,22 @@ export default { ...@@ -175,7 +175,22 @@ export default {
} }
} }
}, },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() { 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.queryParams.loginTime = this.$parseDate(new Date(), 'YYYY-MM-DD HH:mm:ss') // this.queryParams.loginTime = this.$parseDate(new Date(), 'YYYY-MM-DD HH:mm:ss')
this.getList() this.getList()
this.getDicts(dictCons['COMMON_STATUS']).then(response => { this.getDicts(dictCons['COMMON_STATUS']).then(response => {
......
...@@ -245,7 +245,22 @@ export default { ...@@ -245,7 +245,22 @@ export default {
} }
} }
}, },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() { 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.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM') // this.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList() this.getList()
this.getDicts('sys_oper_type'.toUpperCase()).then(response => { this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
......
...@@ -251,7 +251,22 @@ export default { ...@@ -251,7 +251,22 @@ export default {
} }
} }
}, },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() { 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.getList() this.getList()
this.getDicts('sys_normal_disable'.toUpperCase()).then(response => { this.getDicts('sys_normal_disable'.toUpperCase()).then(response => {
this.statusOptions = response.data this.statusOptions = response.data
......
...@@ -353,7 +353,22 @@ export default { ...@@ -353,7 +353,22 @@ export default {
manageLoading: false manageLoading: false
} }
}, },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() { 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.getList() this.getList()
this.getDicts(dictCons['NORMAL_DISABLE']).then(response => { this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
this.statusOptions = response.data this.statusOptions = response.data
......
...@@ -346,8 +346,25 @@ export default { ...@@ -346,8 +346,25 @@ export default {
// this.workFlows = response.data // this.workFlows = response.data
// }) // })
// }, // },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() { created() {
this.getList() 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 {
this.getList()
}
this.getDicts(dictCons['SHOW_HIDE']).then(response => { this.getDicts(dictCons['SHOW_HIDE']).then(response => {
this.visibleOptions = response.data this.visibleOptions = response.data
}) })
......
...@@ -361,7 +361,22 @@ export default { ...@@ -361,7 +361,22 @@ export default {
deptOptions: [] deptOptions: []
} }
}, },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() { 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.getList() this.getList()
// this.getDicts(dictCons['NORMAL_DISABLE']).then(response => { // this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
// this.statusOptions = response.data; // this.statusOptions = response.data;
......
<template> <template>
<div class="user-manage"> <div class="user-manage">
<div class="search" style="border-bottom: 14px solid #f4f4f4"> <div class="search" style="border-bottom: 14px solid #f4f4f4">
<el-form ref="queryForm" style="padding: 0 0 0 10px" class="formClass" :model="queryParams" v-show="showSearch" :inline="true" label-width="auto"> <el-form v-show="showSearch" ref="queryForm" style="padding: 0 0 0 10px" class="formClass" :model="queryParams" :inline="true" label-width="auto">
<!-- <el-form-item label="用户类型" prop="name" class="noMargin">--> <!-- <el-form-item label="用户类型" prop="name" class="noMargin">-->
<!-- <el-input--> <!-- <el-input-->
<!-- v-model="queryParams.name"--> <!-- v-model="queryParams.name"-->
<!-- placeholder="请输入用户类型"--> <!-- placeholder="请输入用户类型"-->
<!-- clearable--> <!-- clearable-->
<!-- :maxlength="30"--> <!-- :maxlength="30"-->
<!-- size="small"--> <!-- size="small"-->
<!-- style="width: 150px"--> <!-- style="width: 150px"-->
<!-- />--> <!-- />-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item label="登录名" prop="username"> <el-form-item label="登录名" prop="username">
<el-input <el-input
v-model="queryParams.username" v-model="queryParams.username"
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
</el-form-item> </el-form-item>
<el-form-item style="float: right"> <el-form-item style="float: right">
<el-button <el-button
style="padding: 8px 7px;"
v-hasPermi="['sys:user:add']" v-hasPermi="['sys:user:add']"
style="padding: 8px 7px;"
type="primary" type="primary"
size="small" size="small"
icon="el-icon-plus" icon="el-icon-plus"
...@@ -59,8 +59,8 @@ ...@@ -59,8 +59,8 @@
@click="handleImport" @click="handleImport"
>导入</el-button> >导入</el-button>
<el-button <el-button
style="padding: 8px 7px;"
v-hasPermi="['sys:user:export']" v-hasPermi="['sys:user:export']"
style="padding: 8px 7px;"
type="success" type="success"
size="small" size="small"
icon="el-icon-download" icon="el-icon-download"
...@@ -211,16 +211,17 @@ ...@@ -211,16 +211,17 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="手机号码" prop="phone"> <el-form-item label="手机号码" prop="phone">
<el-input <el-input
value="phone"
v-model.trim="form.phone" v-model.trim="form.phone"
value="phone"
placeholder="请输入手机号码" placeholder="请输入手机号码"
maxlength="11" /> maxlength="11"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="邮箱" prop="email"> <el-form-item label="邮箱" prop="email">
<el-input v-model.trim="form.email" placeholder="请输入邮箱" maxlength="25" /> <el-input v-model.trim="form.email" placeholder="请输入邮箱" maxlength="25" />
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -239,13 +240,13 @@ ...@@ -239,13 +240,13 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="用户类型" prop="name"> <el-form-item label="用户类型" prop="name">
<el-input v-model.trim="form.name" placeholder="请输入用户类型" /> <el-input v-model.trim="form.name" placeholder="请输入用户类型" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="身份证号" prop="idNumber"> <el-form-item label="身份证号" prop="idNumber">
<el-input v-model.trim="form.idNumber" placeholder="请输入身份证号" maxlength="18" /> <el-input v-model.trim="form.idNumber" placeholder="请输入身份证号" maxlength="18" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
...@@ -582,6 +583,16 @@ export default { ...@@ -582,6 +583,16 @@ export default {
addLoading: false addLoading: false
} }
}, },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
watch: { watch: {
// 根据名称筛选部门树 // 根据名称筛选部门树
deptName(val) { deptName(val) {
...@@ -589,6 +600,11 @@ export default { ...@@ -589,6 +600,11 @@ export default {
} }
}, },
created() { 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.getList() this.getList()
this.getTreeSelect() this.getTreeSelect()
this.getConfigKey('sys.user.initPassword').then(response => { this.getConfigKey('sys.user.initPassword').then(response => {
......
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