forked from verdnatura/salix-front
Add reactivity to supplier descriptor icons
This commit is contained in:
parent
59edfe8c0d
commit
f048a1c820
|
@ -59,6 +59,10 @@ const $props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
clearStoreOnUnmount: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
|
@ -91,7 +95,12 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
state.unset($props.model);
|
// Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas.
|
||||||
|
if (hasChanges.value) {
|
||||||
|
state.set($props.model, originalData.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($props.clearStoreOnUnmount) state.unset($props.model);
|
||||||
});
|
});
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
|
||||||
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
|
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
|
@ -35,6 +36,8 @@ const $props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const state = useState();
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
|
@ -64,6 +67,7 @@ async function getData() {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
|
state.set($props.dataKey, data);
|
||||||
emit('onFetch', data);
|
emit('onFetch', data);
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
|
|
@ -26,6 +26,7 @@ const workersOptions = ref([]);
|
||||||
:url-update="`Suppliers/${route.params.id}`"
|
:url-update="`Suppliers/${route.params.id}`"
|
||||||
model="supplier"
|
model="supplier"
|
||||||
auto-load
|
auto-load
|
||||||
|
:clear-store-on-unmount="false"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
|
|
@ -33,6 +33,7 @@ const formatPayDems = (data) => {
|
||||||
:url-update="`Suppliers/${route.params.id}`"
|
:url-update="`Suppliers/${route.params.id}`"
|
||||||
model="supplier"
|
model="supplier"
|
||||||
auto-load
|
auto-load
|
||||||
|
:clear-store-on-unmount="false"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
|
|
@ -9,6 +9,7 @@ import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import { toDateString } from 'src/filters';
|
import { toDateString } from 'src/filters';
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
import useCardDescription from 'src/composables/useCardDescription';
|
||||||
import { getUrl } from 'src/composables/getUrl';
|
import { getUrl } from 'src/composables/getUrl';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
id: {
|
id: {
|
||||||
|
@ -21,6 +22,7 @@ const $props = defineProps({
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const url = ref();
|
const url = ref();
|
||||||
|
const state = useState();
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -71,6 +73,8 @@ const setData = (entity) => {
|
||||||
data.value = useCardDescription(entity.ref, entity.id);
|
data.value = useCardDescription(entity.ref, entity.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const currentSupplier = computed(() => state.get('supplier'));
|
||||||
|
|
||||||
const getEntryQueryParams = (supplier) => {
|
const getEntryQueryParams = (supplier) => {
|
||||||
if (!supplier) return null;
|
if (!supplier) return null;
|
||||||
|
|
||||||
|
@ -101,7 +105,7 @@ const getEntryQueryParams = (supplier) => {
|
||||||
:subtitle="data.subtitle"
|
:subtitle="data.subtitle"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
@on-fetch="setData"
|
@on-fetch="setData"
|
||||||
data-key="Supplier"
|
data-key="supplier"
|
||||||
>
|
>
|
||||||
<template #header-extra-action>
|
<template #header-extra-action>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -133,10 +137,10 @@ const getEntryQueryParams = (supplier) => {
|
||||||
<VnLv :label="t('supplier.summary.payDay')" :value="entity.payDay" />
|
<VnLv :label="t('supplier.summary.payDay')" :value="entity.payDay" />
|
||||||
<VnLv :label="t('supplier.summary.account')" :value="entity.account" />
|
<VnLv :label="t('supplier.summary.account')" :value="entity.account" />
|
||||||
</template>
|
</template>
|
||||||
<template #icons="{ entity }">
|
<template #icons>
|
||||||
<QCardActions class="q-gutter-x-md">
|
<QCardActions v-if="currentSupplier" class="q-gutter-x-md">
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="!entity.isActive"
|
v-if="!currentSupplier.isActive"
|
||||||
name="vn:disabled"
|
name="vn:disabled"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="xs"
|
size="xs"
|
||||||
|
@ -144,7 +148,7 @@ const getEntryQueryParams = (supplier) => {
|
||||||
<QTooltip>{{ t('Inactive supplier') }}</QTooltip>
|
<QTooltip>{{ t('Inactive supplier') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="!entity.isSerious"
|
v-if="!currentSupplier.isSerious"
|
||||||
name="vn:supplierfalse"
|
name="vn:supplierfalse"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="xs"
|
size="xs"
|
||||||
|
|
|
@ -53,6 +53,7 @@ function handleLocation(data, location) {
|
||||||
:url-update="`Suppliers/${route.params.id}/updateFiscalData`"
|
:url-update="`Suppliers/${route.params.id}/updateFiscalData`"
|
||||||
model="supplier"
|
model="supplier"
|
||||||
auto-load
|
auto-load
|
||||||
|
:clear-store-on-unmount="false"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
|
Loading…
Reference in New Issue