This commit is contained in:
parent
8d209c9415
commit
f821949740
|
@ -97,7 +97,7 @@ const $props = defineProps({
|
|||
});
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||
const modelValue = computed(
|
||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`
|
||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
||||
).value;
|
||||
const componentIsRendered = ref(false);
|
||||
const arrayData = useArrayData(modelValue);
|
||||
|
@ -148,7 +148,7 @@ onMounted(async () => {
|
|||
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
||||
isResetting.value = false;
|
||||
},
|
||||
{ deep: true }
|
||||
{ deep: true },
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -156,7 +156,7 @@ onMounted(async () => {
|
|||
if (!$props.url)
|
||||
watch(
|
||||
() => arrayData.store.data,
|
||||
(val) => updateAndEmit('onFetch', val)
|
||||
(val) => updateAndEmit('onFetch', val),
|
||||
);
|
||||
|
||||
watch(
|
||||
|
@ -165,7 +165,7 @@ watch(
|
|||
originalData.value = null;
|
||||
reset();
|
||||
await fetch();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
|
@ -222,7 +222,7 @@ async function save() {
|
|||
|
||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
||||
|
||||
updateAndEmit('onDataSaved', formData.value, response?.data);
|
||||
updateAndEmit('onDataSaved', formData.value, response?.data, originalData.value);
|
||||
if ($props.reload) await arrayData.fetch({});
|
||||
hasChanges.value = false;
|
||||
} finally {
|
||||
|
@ -254,16 +254,16 @@ function filter(value, update, filterOptions) {
|
|||
(ref) => {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function updateAndEmit(evt, val, res) {
|
||||
function updateAndEmit(evt, val, res, old) {
|
||||
state.set(modelValue, val);
|
||||
originalData.value = val && JSON.parse(JSON.stringify(val));
|
||||
if (!$props.url) arrayData.store.data = val;
|
||||
|
||||
emit(evt, state.get(modelValue), res);
|
||||
emit(evt, state.get(modelValue), res, old);
|
||||
}
|
||||
|
||||
function trimData(data) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
|
@ -9,9 +10,13 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnLocation from 'src/components/common/VnLocation.vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
const quasar = useQuasar();
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const { notify } = useNotify();
|
||||
|
||||
const typesTaxes = ref([]);
|
||||
const typesTransactions = ref([]);
|
||||
|
@ -23,6 +28,31 @@ function handleLocation(data, location) {
|
|||
data.provinceFk = provinceFk;
|
||||
data.countryFk = countryFk;
|
||||
}
|
||||
|
||||
async function checkEtChanges(data, _, originalData) {
|
||||
const equalizatedHasChanged = originalData.isEqualizated != data.isEqualizated;
|
||||
const hasToInvoiceByAddress =
|
||||
originalData.hasToInvoiceByAddress || data.hasToInvoiceByAddress;
|
||||
if (equalizatedHasChanged && hasToInvoiceByAddress) {
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('You changed the equalization tax'),
|
||||
message: t('Do you want to spread the change?'),
|
||||
promise: () => acceptPropagate(data),
|
||||
},
|
||||
});
|
||||
} else if (equalizatedHasChanged) {
|
||||
await acceptPropagate(data);
|
||||
}
|
||||
}
|
||||
|
||||
async function acceptPropagate({ isEqualizated }) {
|
||||
await $axios.patch(`Clients/${route.params.id}/addressesPropagateRe`, {
|
||||
isEqualizated,
|
||||
});
|
||||
notify(t('Equivalent tax spreaded'), 'warning');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -36,6 +66,8 @@ function handleLocation(data, location) {
|
|||
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
||||
auto-load
|
||||
model="customer"
|
||||
observe-form-changes
|
||||
@on-data-saved="checkEtChanges"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
|
@ -180,6 +212,9 @@ es:
|
|||
whenActivatingIt: Al activarlo, no informar el código del país en el campo nif
|
||||
inOrderToInvoice: Para facturar no se consulta este campo, sino el RE de consignatario. Al modificar este campo si no esta marcada la casilla Facturar por consignatario, se propagará automaticamente el cambio a todos lo consignatarios, en caso contrario preguntará al usuario si quiere o no propagar
|
||||
Daily invoice: Facturación diaria
|
||||
Equivalent tax spreaded: Recargo de equivalencia propagado
|
||||
You changed the equalization tax: Has cambiado el recargo de equivalencia
|
||||
Do you want to spread the change?: ¿Deseas propagar el cambio a sus consignatarios?
|
||||
en:
|
||||
onlyLetters: Only letters, numbers and spaces can be used
|
||||
whenActivatingIt: When activating it, do not enter the country code in the ID field
|
||||
|
|
|
@ -49,7 +49,7 @@ const getData = async (observations) => {
|
|||
notes.value = originalNotes
|
||||
.map((observation) => {
|
||||
const type = observationTypes.value.find(
|
||||
(type) => type.id === observation.observationTypeFk
|
||||
(type) => type.id === observation.observationTypeFk,
|
||||
);
|
||||
return type
|
||||
? {
|
||||
|
@ -112,8 +112,8 @@ function getPayload() {
|
|||
(oNote) =>
|
||||
oNote.id === note.id &&
|
||||
(note.description !== oNote.description ||
|
||||
note.observationTypeFk !== oNote.observationTypeFk)
|
||||
)
|
||||
note.observationTypeFk !== oNote.observationTypeFk),
|
||||
),
|
||||
)
|
||||
.map((note) => ({
|
||||
data: note,
|
||||
|
@ -130,9 +130,7 @@ async function handleDialog(data) {
|
|||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t(
|
||||
'confirmTicket'
|
||||
),
|
||||
title: t('confirmTicket'),
|
||||
message: t('confirmDeletionMessage'),
|
||||
},
|
||||
})
|
||||
|
@ -154,12 +152,7 @@ async function handleDialog(data) {
|
|||
const toCustomerAddress = () => {
|
||||
notes.value = [];
|
||||
deletes.value = [];
|
||||
router.push({
|
||||
name: 'CustomerAddress',
|
||||
params: {
|
||||
id: route.params.id,
|
||||
},
|
||||
});
|
||||
router.go();
|
||||
};
|
||||
function handleLocation(data, location) {
|
||||
const { town, code, provinceFk, countryFk } = location ?? {};
|
||||
|
|
Loading…
Reference in New Issue