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

编译通过修改

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