Commit 590b624d authored by 张毅辰's avatar 张毅辰

编译通过修改

parent adf8ec91
......@@ -3,13 +3,12 @@ import { useSearchParamsStore } from "@/store/modules/searchParams";
const searchParamsObj = useSearchParamsStore();
// 路由离开前存储筛选条件
export function setDataCache(path, param) {
// store.dispatch('searchSave/searchParamsSet', {
// path: path,
// param: {
// ...param
// }
// }).then(r => {} )
// console.log('store.getters.searchParams', store.getters.searchParams)
searchParamsObj.setSearchParams({
path: path,
param: {
...param
}
});
}
// 获取缓存的筛选条件 分页参数需统一,如需自定义分页参数,在列表页自行修改
export function getDataCache(routerPath) {
......
......@@ -3,13 +3,12 @@ import { useSearchParamsStore } from "@/store/modules/searchParams";
const searchParamsObj = useSearchParamsStore()
// 路由离开前存储筛选条件
export function setDataCache(path: any, param: any) {
// store.dispatch('searchSave/searchParamsSet', {
// path: path,
// param: {
// ...param
// }
// }).then(r => {} )
// console.log('store.getters.searchParams', store.getters.searchParams)
searchParamsObj.setSearchParams({
path: path,
param: {
...param
}
})
}
// 获取缓存的筛选条件 分页参数需统一,如需自定义分页参数,在列表页自行修改
......
......@@ -2,8 +2,22 @@ import { defineStore } from "pinia";
export const useSearchParamsStore = defineStore("searchParams", () => {
const searchParams = ref<object>({});
function setSearchParams(config: any) {
if (!config || typeof config !== 'object') { return }
if (!config.path) { return }
SET_SEARCH_PARAMS(config)
}
function SET_SEARCH_PARAMS(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) {
searchParams[config.path] = JSON.stringify(config.param)
} else {
delete searchParams[config.path]
}
}
return {
searchParams,
setSearchParams
};
});
......@@ -240,6 +240,11 @@ onMounted(() => {
Object.assign(queryParams, JSON.parse(getDataCache(route.path)));
getList();
});
onBeforeRouteLeave((to, from, next) => {
setDataCache(route.path, queryParams)
next()
})
</script>
<template>
<div class="app-container">
......
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