fix: refs #7957 rollback
This commit is contained in:
parent
6e655b37a1
commit
4cf13a83a4
|
@ -3,8 +3,6 @@ import { useRouter, useRoute } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useArrayDataStore } from 'stores/useArrayDataStore';
|
import { useArrayDataStore } from 'stores/useArrayDataStore';
|
||||||
import { buildFilter } from 'filters/filterPanel';
|
import { buildFilter } from 'filters/filterPanel';
|
||||||
import { isDialogOpened } from 'src/filters';
|
|
||||||
import useOpenURL from './useOpenURL';
|
|
||||||
|
|
||||||
const arrayDataStore = useArrayDataStore();
|
const arrayDataStore = useArrayDataStore();
|
||||||
|
|
||||||
|
@ -66,7 +64,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetch({ append = false, updateRouter = true, newTab = false }) {
|
async function fetch({ append = false, updateRouter = true }) {
|
||||||
if (!store.url) return;
|
if (!store.url) return;
|
||||||
|
|
||||||
cancelRequest();
|
cancelRequest();
|
||||||
|
@ -111,8 +109,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
params.filter.where = { ...params.filter.where, ...exprFilter };
|
params.filter.where = { ...params.filter.where, ...exprFilter };
|
||||||
params.filter = JSON.stringify(params.filter);
|
params.filter = JSON.stringify(params.filter);
|
||||||
|
|
||||||
if (newTab) return updateStateParams(true);
|
|
||||||
|
|
||||||
store.isLoading = true;
|
store.isLoading = true;
|
||||||
const response = await axios.get(store.url, {
|
const response = await axios.get(store.url, {
|
||||||
signal: canceller.signal,
|
signal: canceller.signal,
|
||||||
|
@ -127,7 +123,8 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
for (const row of response.data) store.data.push(row);
|
for (const row of response.data) store.data.push(row);
|
||||||
} else {
|
} else {
|
||||||
store.data = response.data;
|
store.data = response.data;
|
||||||
if (!isDialogOpened()) updateRouter && updateStateParams();
|
if (!document.querySelectorAll('[role="dialog"][aria-modal="true"]').length)
|
||||||
|
updateRouter && updateStateParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
store.isLoading = false;
|
store.isLoading = false;
|
||||||
|
@ -157,12 +154,12 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyFilter({ filter, params, newTab }) {
|
async function applyFilter({ filter, params }) {
|
||||||
if (filter) store.userFilter = filter;
|
if (filter) store.userFilter = filter;
|
||||||
store.filter = {};
|
store.filter = {};
|
||||||
if (params) store.userParams = { ...params };
|
if (params) store.userParams = { ...params };
|
||||||
|
|
||||||
const response = await fetch({ newTab });
|
const response = await fetch({});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,14 +255,12 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
if (Object.values(store.userParams).length) await fetch({});
|
if (Object.values(store.userParams).length) await fetch({});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStateParams(newTab) {
|
function updateStateParams() {
|
||||||
if (!route?.path) return;
|
if (!route?.path) return;
|
||||||
const newUrl = { path: route.path, query: { ...(route.query ?? {}) } };
|
const newUrl = { path: route.path, query: { ...(route.query ?? {}) } };
|
||||||
if (store?.searchUrl)
|
if (store?.searchUrl)
|
||||||
newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter);
|
newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter);
|
||||||
|
|
||||||
if (newTab) useOpenURL(router.resolve(newUrl).href);
|
|
||||||
|
|
||||||
if (store.navigate) {
|
if (store.navigate) {
|
||||||
const { customRouteRedirectName, searchText } = store.navigate;
|
const { customRouteRedirectName, searchText } = store.navigate;
|
||||||
if (customRouteRedirectName)
|
if (customRouteRedirectName)
|
||||||
|
|
Loading…
Reference in New Issue