8355-testToMaster #1177
|
@ -38,6 +38,10 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
keepData: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
||||||
|
@ -46,6 +50,7 @@ onBeforeMount(() => {
|
||||||
if ($props.dataKey)
|
if ($props.dataKey)
|
||||||
arrayData = useArrayData($props.dataKey, {
|
arrayData = useArrayData($props.dataKey, {
|
||||||
searchUrl: 'table',
|
searchUrl: 'table',
|
||||||
|
keepData: $props.keepData,
|
||||||
...$props.arrayDataProps,
|
...$props.arrayDataProps,
|
||||||
navigate: $props.redirect,
|
navigate: $props.redirect,
|
||||||
});
|
});
|
||||||
|
|
|
@ -111,14 +111,9 @@ onMounted(async () => {
|
||||||
mounted.value = true;
|
mounted.value = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// onBeforeRouteUpdate((to, from, next) => {
|
|
||||||
// if (to.name === from.name && to.path !== from.path) {
|
|
||||||
// arrayData.reset(['data']);
|
|
||||||
// }
|
|
||||||
// next();
|
|
||||||
// });
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
console.log('store.keepData: ', store.keepData);
|
||||||
|
if (!store.keepData) arrayData.reset(['data']);
|
||||||
arrayData.resetPagination();
|
arrayData.resetPagination();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
'searchUrl',
|
'searchUrl',
|
||||||
'navigate',
|
'navigate',
|
||||||
'mapKey',
|
'mapKey',
|
||||||
|
'keepData',
|
||||||
];
|
];
|
||||||
if (typeof userOptions === 'object') {
|
if (typeof userOptions === 'object') {
|
||||||
for (const option in userOptions) {
|
for (const option in userOptions) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
|
||||||
navigate: null,
|
navigate: null,
|
||||||
page: 1,
|
page: 1,
|
||||||
mapKey: 'id',
|
mapKey: 'id',
|
||||||
|
keepData: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
function get(key) {
|
function get(key) {
|
||||||
|
|
Loading…
Reference in New Issue