fixes: fix vnFilter params and redirect
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
parent
685267e177
commit
4cf389e00c
|
@ -70,14 +70,11 @@ const makeInvoice = async () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (!response) {
|
if (!response) {
|
||||||
console.log('entra cuando no checkbox');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('params: ', params);
|
|
||||||
const { data } = await axios.post('InvoiceOuts/transferInvoice', params);
|
const { data } = await axios.post('InvoiceOuts/transferInvoice', params);
|
||||||
console.log('data: ', data);
|
|
||||||
notify(t('Transferred invoice'), 'positive');
|
notify(t('Transferred invoice'), 'positive');
|
||||||
const id = data?.[0];
|
const id = data?.[0];
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||||
|
|
|
@ -7,8 +7,11 @@ import toDate from 'filters/toDate';
|
||||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const params = defineModel({ default: {}, required: true, type: Object });
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {}
|
||||||
|
},
|
||||||
dataKey: {
|
dataKey: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -64,9 +67,10 @@ const arrayData = useArrayData($props.dataKey, {
|
||||||
});
|
});
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
|
const userParams = ref({})
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
emit('init', { params: params.value });
|
userParams.value = $props.modelValue ?? {}
|
||||||
|
emit('init', { params: userParams.value });
|
||||||
});
|
});
|
||||||
|
|
||||||
function setUserParams(watchedParams) {
|
function setUserParams(watchedParams) {
|
||||||
|
@ -75,7 +79,7 @@ function setUserParams(watchedParams) {
|
||||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||||
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
||||||
delete watchedParams.filter;
|
delete watchedParams.filter;
|
||||||
params.value = { ...params.value, ...watchedParams };
|
userParams.value = { ...userParams.value, ...watchedParams };
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -94,12 +98,12 @@ async function search(evt) {
|
||||||
|
|
||||||
store.filter.where = {};
|
store.filter.where = {};
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
const filter = { ...params.value };
|
const filter = { ...userParams.value };
|
||||||
store.userParamsChanged = true;
|
store.userParamsChanged = true;
|
||||||
store.filter.skip = 0;
|
store.filter.skip = 0;
|
||||||
store.skip = 0;
|
store.skip = 0;
|
||||||
const { params: newParams } = await arrayData.addFilter({ params: params.value });
|
const { params: newParams } = await arrayData.addFilter({ params: userParams.value });
|
||||||
params.value = newParams;
|
userParams.value = newParams;
|
||||||
|
|
||||||
if (!$props.showAll && !Object.values(filter).length) store.data = [];
|
if (!$props.showAll && !Object.values(filter).length) store.data = [];
|
||||||
|
|
||||||
|
@ -109,7 +113,7 @@ async function search(evt) {
|
||||||
|
|
||||||
async function reload() {
|
async function reload() {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
const params = Object.values(params.value).filter((param) => param);
|
const params = Object.values(userParams.value).filter((param) => param);
|
||||||
|
|
||||||
await arrayData.fetch({ append: false });
|
await arrayData.fetch({ append: false });
|
||||||
if (!$props.showAll && !params.length) store.data = [];
|
if (!$props.showAll && !params.length) store.data = [];
|
||||||
|
@ -123,17 +127,17 @@ async function clearFilters() {
|
||||||
store.filter.skip = 0;
|
store.filter.skip = 0;
|
||||||
store.skip = 0;
|
store.skip = 0;
|
||||||
// Filtrar los params no removibles
|
// Filtrar los params no removibles
|
||||||
const removableFilters = Object.keys(params.value).filter((param) =>
|
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||||
$props.unremovableParams.includes(param)
|
$props.unremovableParams.includes(param)
|
||||||
);
|
);
|
||||||
const newParams = {};
|
const newParams = {};
|
||||||
// Conservar solo los params que no son removibles
|
// Conservar solo los params que no son removibles
|
||||||
for (const key of removableFilters) {
|
for (const key of removableFilters) {
|
||||||
newParams[key] = params.value[key];
|
newParams[key] = userParams.value[key];
|
||||||
}
|
}
|
||||||
params.value = {};
|
userParams.value = {};
|
||||||
params.value = { ...newParams }; // Actualizar los params con los removibles
|
userParams.value = { ...newParams }; // Actualizar los params con los removibles
|
||||||
await arrayData.applyFilter({ params: params.value });
|
await arrayData.applyFilter({ params: userParams.value });
|
||||||
|
|
||||||
if (!$props.showAll) {
|
if (!$props.showAll) {
|
||||||
store.data = [];
|
store.data = [];
|
||||||
|
@ -145,8 +149,8 @@ async function clearFilters() {
|
||||||
|
|
||||||
const tagsList = computed(() => {
|
const tagsList = computed(() => {
|
||||||
const tagList = [];
|
const tagList = [];
|
||||||
for (const key of Object.keys(params.value)) {
|
for (const key of Object.keys(userParams.value)) {
|
||||||
const value = params.value[key];
|
const value = userParams.value[key];
|
||||||
if (value == null || ($props.hiddenTags || []).includes(key)) continue;
|
if (value == null || ($props.hiddenTags || []).includes(key)) continue;
|
||||||
tagList.push({ label: key, value });
|
tagList.push({ label: key, value });
|
||||||
}
|
}
|
||||||
|
@ -161,7 +165,7 @@ const customTags = computed(() =>
|
||||||
);
|
);
|
||||||
|
|
||||||
async function remove(key) {
|
async function remove(key) {
|
||||||
params.value[key] = undefined;
|
userParams.value[key] = undefined;
|
||||||
search();
|
search();
|
||||||
emit('remove', key);
|
emit('remove', key);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +240,7 @@ function formatValue(value) {
|
||||||
<slot
|
<slot
|
||||||
v-if="$slots.customTags"
|
v-if="$slots.customTags"
|
||||||
name="customTags"
|
name="customTags"
|
||||||
:params="params"
|
:params="userParams"
|
||||||
:tags="customTags"
|
:tags="customTags"
|
||||||
:format-fn="formatValue"
|
:format-fn="formatValue"
|
||||||
:search-fn="search"
|
:search-fn="search"
|
||||||
|
@ -246,7 +250,7 @@ function formatValue(value) {
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
</QList>
|
</QList>
|
||||||
<QList dense class="list q-gutter-y-sm q-mt-sm">
|
<QList dense class="list q-gutter-y-sm q-mt-sm">
|
||||||
<slot name="body" :params="params" :search-fn="search"></slot>
|
<slot name="body" :params="userParams" :search-fn="search"></slot>
|
||||||
</QList>
|
</QList>
|
||||||
<template v-if="$props.searchButton">
|
<template v-if="$props.searchButton">
|
||||||
<QItem>
|
<QItem>
|
||||||
|
|
|
@ -29,7 +29,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
const filter = params?.filter;
|
const filter = params?.filter;
|
||||||
delete params.filter;
|
delete params.filter;
|
||||||
store.userParams = { ...params, ...store.userParams };
|
store.userParams = { ...params, ...store.userParams };
|
||||||
store.userFilter = { ...JSON.parse(filter), ...store.userFilter };
|
store.userFilter = { ...JSON.parse(filter ?? '{}'), ...store.userFilter };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -156,22 +156,18 @@ const onOrderFieldChange = (value, params) => {
|
||||||
case 'Relevancy':
|
case 'Relevancy':
|
||||||
tagObj.field = value + ' DESC, name';
|
tagObj.field = value + ' DESC, name';
|
||||||
params.orderBy = JSON.stringify(tagObj);
|
params.orderBy = JSON.stringify(tagObj);
|
||||||
console.log('params: ', params);
|
|
||||||
break;
|
break;
|
||||||
case 'ColorAndPrice':
|
case 'ColorAndPrice':
|
||||||
tagObj.field = 'showOrder, price';
|
tagObj.field = 'showOrder, price';
|
||||||
params.orderBy = JSON.stringify(tagObj);
|
params.orderBy = JSON.stringify(tagObj);
|
||||||
console.log('params: ', params);
|
|
||||||
break;
|
break;
|
||||||
case 'Name':
|
case 'Name':
|
||||||
tagObj.field = 'name';
|
tagObj.field = 'name';
|
||||||
params.orderBy = JSON.stringify(tagObj);
|
params.orderBy = JSON.stringify(tagObj);
|
||||||
console.log('params: ', params);
|
|
||||||
break;
|
break;
|
||||||
case 'Price':
|
case 'Price':
|
||||||
tagObj.field = 'price';
|
tagObj.field = 'price';
|
||||||
params.orderBy = JSON.stringify(tagObj);
|
params.orderBy = JSON.stringify(tagObj);
|
||||||
console.log('params: ', params);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -122,8 +122,6 @@ const orderFilter = {
|
||||||
const onClientChange = async (clientId) => {
|
const onClientChange = async (clientId) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(`Clients/${clientId}`);
|
const { data } = await axios.get(`Clients/${clientId}`);
|
||||||
console.log('info cliente: ', data);
|
|
||||||
|
|
||||||
await fetchAddressList(data.defaultAddressFk);
|
await fetchAddressList(data.defaultAddressFk);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error al cambiar el cliente:', error);
|
console.error('Error al cambiar el cliente:', error);
|
||||||
|
|
|
@ -56,7 +56,6 @@ const swapEntry = (from, to, key) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function setNotifications(data) {
|
function setNotifications(data) {
|
||||||
console.log('data: ', data);
|
|
||||||
active.value = new Map(data.active);
|
active.value = new Map(data.active);
|
||||||
available.value = new Map(data.available);
|
available.value = new Map(data.available);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue