Commit 0276c2d9 authored by 张伯涛's avatar 张伯涛

记住筛选项功能

parent ff3406c4
import { defineStore } from 'pinia';
import {UserInfo} from "#/store";
import {getAuthCache} from "@/utils/auth";
import {USER_INFO_KEY} from "@/enums/cacheEnum";
export const useFilterStore = defineStore('filter', {
state: () => ({
searchParams: {
},
}),
getters: {
getSearchParams(state): any {
return state.searchParams ;
},
},
actions: {
setSearchParams(config: any) {
if (!config || typeof config !== 'object') { return }
if (!config.path) { return }
if (config.param && typeof config.param === 'object' && Object.keys(config.param).length > 0) {
this.searchParams[config.path] = JSON.stringify(config.param)
console.log('this.searchParams',this.searchParams)
}
},
},
});
......@@ -42,7 +42,7 @@
</PageWrapper>
</template>
<script lang="ts" setup>
import { reactive,unref } from 'vue';
import { reactive,unref,onDeactivated,onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import {getAccountList, deleteUser,exportUserList} from '@/api/system/user/user';
import { PageWrapper } from '@/components/Page';
......@@ -55,8 +55,13 @@
import { columns, searchFormSchema } from './account.data';
import { useGo } from '@/hooks/web/usePage';
import { downloadByData } from '@/utils/file/download';
import { useRoute,onBeforeRouteLeave } from 'vue-router';
import { useFilterStore } from '@/store/modules/filterData';
import {useUserStore} from "@/store/modules/user";
defineOptions({ name: 'AccountManagement' });
const { createMessage } = useMessage();
const filterStore = useFilterStore();
const route = useRoute();
const go = useGo();
const [registerModal, { openModal }] = useModal();
const [registerResetPassword, { openModal: openResetPasswordModal }] = useModal();
......@@ -71,6 +76,9 @@
labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
resetFunc: () => {
searchInfo.deptId=''
},
},
useSearchForm: true,
showTableSetting: false,
......@@ -148,4 +156,34 @@
function handleView(record: Recordable) {
go('/system/account_detail/' + record.id);
}
onMounted(() => {
const path = route.path
if(filterStore.getSearchParams[path]) {
if(JSON.parse(filterStore.getSearchParams[path] !== {})){
const params = JSON.parse(filterStore.getSearchParams[path])
console.log('11111111111111111111111111111',params)
getForm().setFieldsValue({
page: params.page,
pageSize: params.pageSize,
username: params.username,
flag: params.flag,
})
searchInfo.deptId = params.deptId
}
}
});
onBeforeRouteLeave((to, from, next) => {
const params = Object.assign({},getSearchInfo(),getForm().getFieldsValue());
console.log('path',from.path)
console.log('params',params)
filterStore.setSearchParams(
{
path: from.path,
param: {
...params
}
}
)
next(); // 允许导航
});
</script>
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