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