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

页面离开前记住筛选项

parent cd61d0eb
......@@ -8,6 +8,7 @@ const getters = {
roles: state => state.user.roles,
introduction: state => state.user.introduction,
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
......@@ -3,6 +3,7 @@ import Vuex from 'vuex'
import app from './modules/app'
import user from './modules/user'
import tagsView from './modules/tagsView'
import searchSave from './modules/searchSave'
import permission from './modules/permission'
import settings from './modules/settings'
import getters from './getters'
......@@ -15,6 +16,7 @@ const store = new Vuex.Store({
user,
tagsView,
permission,
searchSave,
settings
},
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 {
}
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...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.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList()
this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
......
......@@ -175,7 +175,22 @@ export default {
}
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...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.queryParams.loginTime = this.$parseDate(new Date(), 'YYYY-MM-DD HH:mm:ss')
this.getList()
this.getDicts(dictCons['COMMON_STATUS']).then(response => {
......
......@@ -245,7 +245,22 @@ export default {
}
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...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.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList()
this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
......
......@@ -251,7 +251,22 @@ export default {
}
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...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.getList()
this.getDicts('sys_normal_disable'.toUpperCase()).then(response => {
this.statusOptions = response.data
......
......@@ -353,7 +353,22 @@ export default {
manageLoading: false
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...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.getList()
this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
this.statusOptions = response.data
......
......@@ -346,8 +346,25 @@ export default {
// this.workFlows = response.data
// })
// },
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
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.visibleOptions = response.data
})
......
......@@ -361,7 +361,22 @@ export default {
deptOptions: []
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...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.getList()
// this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
// this.statusOptions = response.data;
......
<template>
<div class="user-manage">
<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-item label="用户类型" prop="name" class="noMargin">-->
<!-- <el-input-->
<!-- v-model="queryParams.name"-->
<!-- placeholder="请输入用户类型"-->
<!-- clearable-->
<!-- :maxlength="30"-->
<!-- size="small"-->
<!-- style="width: 150px"-->
<!-- />-->
<!-- </el-form-item>-->
<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-input-->
<!-- v-model="queryParams.name"-->
<!-- placeholder="请输入用户类型"-->
<!-- clearable-->
<!-- :maxlength="30"-->
<!-- size="small"-->
<!-- style="width: 150px"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="登录名" prop="username">
<el-input
v-model="queryParams.username"
......@@ -44,8 +44,8 @@
</el-form-item>
<el-form-item style="float: right">
<el-button
style="padding: 8px 7px;"
v-hasPermi="['sys:user:add']"
style="padding: 8px 7px;"
type="primary"
size="small"
icon="el-icon-plus"
......@@ -59,8 +59,8 @@
@click="handleImport"
>导入</el-button>
<el-button
style="padding: 8px 7px;"
v-hasPermi="['sys:user:export']"
style="padding: 8px 7px;"
type="success"
size="small"
icon="el-icon-download"
......@@ -211,16 +211,17 @@
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="手机号码" prop="phone">
<el-form-item label="手机号码" prop="phone">
<el-input
value="phone"
v-model.trim="form.phone"
value="phone"
placeholder="请输入手机号码"
maxlength="11" />
maxlength="11"
/>
</el-form-item>
</el-col>
<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-form-item>
</el-col>
......@@ -239,13 +240,13 @@
</el-row>
<el-row>
<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-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="身份证号" prop="idNumber">
<el-input v-model.trim="form.idNumber" placeholder="请输入身份证号" maxlength="18" />
<el-form-item label="身份证号" prop="idNumber">
<el-input v-model.trim="form.idNumber" placeholder="请输入身份证号" maxlength="18" />
</el-form-item>
</el-col>
</el-row>
......@@ -582,6 +583,16 @@ export default {
addLoading: false
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
watch: {
// 根据名称筛选部门树
deptName(val) {
......@@ -589,6 +600,11 @@ 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 }
}
this.getList()
this.getTreeSelect()
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