This commit is contained in:
parent
a6944561de
commit
50eed83d05
|
@ -474,10 +474,6 @@ entry:
|
|||
landing: Landing
|
||||
isExcludedFromAvailable: Es inventory
|
||||
isRaid: Raid
|
||||
wasteRecalc:
|
||||
dateRequired: The date fields are required
|
||||
dateIncoherent: The "from" date cannot be later than the "to" date
|
||||
recalcOk: The wastes were successfully recalculated
|
||||
ticket:
|
||||
pageTitles:
|
||||
tickets: Tickets
|
||||
|
|
|
@ -476,10 +476,6 @@ entry:
|
|||
landing: Llegada
|
||||
isExcludedFromAvailable: Es inventario
|
||||
isRaid: Redada
|
||||
wasteRecalc:
|
||||
dateRequired: Los campos de tipo fecha son obligatorios
|
||||
dateIncoherent: La fecha "desde" no puede ser superior a la fecha "hasta"
|
||||
recalcOk: Se han recalculado las mermas correctamente
|
||||
ticket:
|
||||
pageTitles:
|
||||
tickets: Tickets
|
||||
|
|
|
@ -1,42 +1,37 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const isLoading = ref(false);
|
||||
const dateFrom = ref();
|
||||
const dateTo = ref();
|
||||
|
||||
const optionsTo = computed(() => (date) => {
|
||||
if (!dateFrom.value) return true;
|
||||
return new Date(date) >= new Date(dateFrom.value);
|
||||
});
|
||||
|
||||
watch(dateFrom, (newDateFrom) => {
|
||||
if (dateTo.value && new Date(dateTo.value) < new Date(newDateFrom))
|
||||
dateTo.value = newDateFrom;
|
||||
});
|
||||
|
||||
const recalc = async () => {
|
||||
const { notify } = useNotify();
|
||||
if (!dateFrom.value || !dateTo.value) {
|
||||
notify('entry.wasteRecalc.dateRequired', 'negative');
|
||||
return;
|
||||
}
|
||||
|
||||
const from = new Date(dateFrom.value);
|
||||
const to = new Date(dateTo.value);
|
||||
|
||||
if (from > to) {
|
||||
notify('entry.wasteRecalc.dateIncoherent', 'negative');
|
||||
return;
|
||||
}
|
||||
|
||||
const params = {
|
||||
schema: 'bs',
|
||||
params: [from, to],
|
||||
params: [new Date(dateFrom.value), new Date(dateTo.value)],
|
||||
};
|
||||
|
||||
try {
|
||||
isLoading.value = true;
|
||||
await axios.post('Applications/waste_addSales/execute-proc', params);
|
||||
notify('entry.wasteRecalc.recalcOk', 'positive');
|
||||
notify('wasteRecalc.recalcOk', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error in execution:', err);
|
||||
notify('entry.wasteRecalc.recalcOk', 'negative');
|
||||
console.error(err);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
@ -50,23 +45,25 @@ const recalc = async () => {
|
|||
<VnInputDate
|
||||
class="q-mb-lg"
|
||||
v-model="dateFrom"
|
||||
:label="t('globals.from')"
|
||||
:label="$t('globals.from')"
|
||||
rounded
|
||||
dense
|
||||
/>
|
||||
<VnInputDate
|
||||
class="q-mb-lg"
|
||||
v-model="dateTo"
|
||||
:label="t('globals.to')"
|
||||
:options="optionsTo"
|
||||
:label="$t('globals.to')"
|
||||
:disable="!dateFrom"
|
||||
rounded
|
||||
dense
|
||||
/>
|
||||
<QBtn
|
||||
color="primary"
|
||||
text-color="white"
|
||||
:label="t('globals.recalc')"
|
||||
:label="$t('globals.recalc')"
|
||||
:loading="isLoading"
|
||||
:disable="isLoading"
|
||||
:disable="isLoading || !(dateFrom && dateTo)"
|
||||
@click="recalc()"
|
||||
/>
|
||||
</QCardSection>
|
||||
|
|
|
@ -18,3 +18,5 @@ myEntries:
|
|||
warehouseInFk: Warehouse in
|
||||
daysOnward: Days onward
|
||||
daysAgo: Days ago
|
||||
wasteRecalc:
|
||||
recalcOk: The wastes were successfully recalculated
|
||||
|
|
|
@ -21,3 +21,5 @@ myEntries:
|
|||
warehouseInFk: Alm. entrada
|
||||
daysOnward: Días adelante
|
||||
daysAgo: Días atras
|
||||
wasteRecalc:
|
||||
recalcOk: Se han recalculado las mermas correctamente
|
||||
|
|
Loading…
Reference in New Issue