Merge branch 'dev' into 7385-addDeliveredAndForecastColumnsOnRouteTicketsList
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
ccbcaa13b7
|
@ -125,7 +125,7 @@ pipeline {
|
|||
sh "docker-compose ${env.COMPOSE_PARAMS} pull db"
|
||||
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
|
||||
|
||||
def modules = sh(script: 'node test/cypress/docker/find/find.js', returnStdout: true).trim()
|
||||
def modules = sh(script: "node test/cypress/docker/find/find.js ${env.COMPOSE_TAG}", returnStdout: true).trim()
|
||||
echo "E2E MODULES: ${modules}"
|
||||
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ --init") {
|
||||
sh "sh test/cypress/docker/cypressParallel.sh 1 '${modules}'"
|
||||
|
|
|
@ -44,6 +44,7 @@ export default defineConfig({
|
|||
supportFile: 'test/cypress/support/index.js',
|
||||
videosFolder: 'test/cypress/videos',
|
||||
downloadsFolder: 'test/cypress/downloads',
|
||||
tmpUploadFolder: 'test/cypress/storage/tmp/dms',
|
||||
video: false,
|
||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
||||
experimentalRunAllSpecs: true,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "salix-front",
|
||||
"version": "25.16.0",
|
||||
"version": "25.18.0",
|
||||
"description": "Salix frontend",
|
||||
"productName": "Salix",
|
||||
"author": "Verdnatura",
|
||||
|
@ -89,4 +89,4 @@
|
|||
"vite": "^6.0.11",
|
||||
"vitest": "^0.31.1"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
import { onMounted } from 'vue';
|
||||
import { useQuasar, Dark } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnScroll from './components/common/VnScroll.vue';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const { availableLocales, locale, fallbackLocale } = useI18n();
|
||||
|
@ -38,6 +39,7 @@ quasar.iconMapFn = (iconName) => {
|
|||
|
||||
<template>
|
||||
<RouterView />
|
||||
<VnScroll/>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
@ -67,7 +67,7 @@ describe('Axios boot', () => {
|
|||
};
|
||||
|
||||
const result = onResponseError(error);
|
||||
expect(result).rejects.toEqual(expect.objectContaining(error));
|
||||
await expect(result).rejects.toEqual(expect.objectContaining(error));
|
||||
});
|
||||
|
||||
it('should call to the Notify plugin with a message from the response property', async () => {
|
||||
|
@ -83,7 +83,7 @@ describe('Axios boot', () => {
|
|||
};
|
||||
|
||||
const result = onResponseError(error);
|
||||
expect(result).rejects.toEqual(expect.objectContaining(error));
|
||||
await expect(result).rejects.toEqual(expect.objectContaining(error));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { boot } from 'quasar/wrappers';
|
||||
import { date as quasarDate } from 'quasar';
|
||||
const { formatDate } = quasarDate;
|
||||
|
||||
export default boot(() => {
|
||||
Date.vnUTC = () => {
|
||||
|
@ -25,4 +27,34 @@ export default boot(() => {
|
|||
const date = new Date(Date.vnUTC());
|
||||
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
||||
};
|
||||
|
||||
Date.getCurrentDateTimeFormatted = (
|
||||
options = {
|
||||
startOfDay: false,
|
||||
endOfDay: true,
|
||||
iso: true,
|
||||
mask: 'DD-MM-YYYY HH:mm',
|
||||
},
|
||||
) => {
|
||||
const date = Date.vnUTC();
|
||||
if (options.startOfDay) {
|
||||
date.setHours(0, 0, 0);
|
||||
}
|
||||
if (options.endOfDay) {
|
||||
date.setHours(23, 59, 0);
|
||||
}
|
||||
if (options.iso) {
|
||||
return date.toISOString();
|
||||
}
|
||||
return formatDate(date, options.mask);
|
||||
};
|
||||
|
||||
Date.convertToISODateTime = (dateTimeStr) => {
|
||||
const [datePart, timePart] = dateTimeStr.split(' ');
|
||||
const [day, month, year] = datePart.split('-');
|
||||
const [hours, minutes] = timePart.split(':');
|
||||
|
||||
const isoDate = new Date(year, month - 1, day, hours, minutes);
|
||||
return isoDate.toISOString();
|
||||
};
|
||||
});
|
||||
|
|
|
@ -20,7 +20,6 @@ const postcodeFormData = reactive({
|
|||
provinceFk: null,
|
||||
townFk: null,
|
||||
});
|
||||
const townFilter = ref({});
|
||||
|
||||
const countriesRef = ref(false);
|
||||
const provincesOptions = ref([]);
|
||||
|
@ -33,11 +32,11 @@ function onDataSaved(formData) {
|
|||
newPostcode.town = town.value.name;
|
||||
newPostcode.townFk = town.value.id;
|
||||
const provinceObject = provincesOptions.value.find(
|
||||
({ id }) => id === formData.provinceFk
|
||||
({ id }) => id === formData.provinceFk,
|
||||
);
|
||||
newPostcode.province = provinceObject?.name;
|
||||
const countryObject = countriesRef.value.opts.find(
|
||||
({ id }) => id === formData.countryFk
|
||||
({ id }) => id === formData.countryFk,
|
||||
);
|
||||
newPostcode.country = countryObject?.name;
|
||||
emit('onDataSaved', newPostcode);
|
||||
|
@ -67,21 +66,11 @@ function setTown(newTown, data) {
|
|||
}
|
||||
async function onCityCreated(newTown, formData) {
|
||||
newTown.province = provincesOptions.value.find(
|
||||
(province) => province.id === newTown.provinceFk
|
||||
(province) => province.id === newTown.provinceFk,
|
||||
);
|
||||
formData.townFk = newTown;
|
||||
setTown(newTown, formData);
|
||||
}
|
||||
|
||||
async function filterTowns(name) {
|
||||
if (name !== '') {
|
||||
townFilter.value.where = {
|
||||
name: {
|
||||
like: `%${name}%`,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -107,7 +96,6 @@ async function filterTowns(name) {
|
|||
<VnSelectDialog
|
||||
:label="t('City')"
|
||||
@update:model-value="(value) => setTown(value, data)"
|
||||
@filter="filterTowns"
|
||||
:tooltip="t('Create city')"
|
||||
v-model="data.townFk"
|
||||
url="Towns/location"
|
||||
|
|
|
@ -65,7 +65,7 @@ const $props = defineProps({
|
|||
default: null,
|
||||
},
|
||||
beforeSaveFn: {
|
||||
type: Function,
|
||||
type: [String, Function],
|
||||
default: null,
|
||||
},
|
||||
goTo: {
|
||||
|
@ -83,7 +83,7 @@ const isLoading = ref(false);
|
|||
const hasChanges = ref(false);
|
||||
const originalData = ref();
|
||||
const vnPaginateRef = ref();
|
||||
const formData = ref([]);
|
||||
const formData = ref();
|
||||
const saveButtonRef = ref(null);
|
||||
const watchChanges = ref();
|
||||
const formUrl = computed(() => $props.url);
|
||||
|
@ -298,6 +298,10 @@ watch(formUrl, async () => {
|
|||
});
|
||||
</script>
|
||||
<template>
|
||||
<SkeletonTable
|
||||
v-if="!formData && ($attrs['auto-load'] === '' || $attrs['auto-load'])"
|
||||
:columns="$attrs.columns?.length"
|
||||
/>
|
||||
<VnPaginate
|
||||
:url="url"
|
||||
:limit="limit"
|
||||
|
@ -316,10 +320,6 @@ watch(formUrl, async () => {
|
|||
></slot>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
<SkeletonTable
|
||||
v-if="!formData && $attrs.autoLoad"
|
||||
:columns="$attrs.columns?.length"
|
||||
/>
|
||||
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && hasSubToolbar">
|
||||
<QBtnGroup push style="column-gap: 10px">
|
||||
<slot name="moreBeforeActions" />
|
||||
|
|
|
@ -140,7 +140,7 @@ const updatePhotoPreview = (value) => {
|
|||
img.onerror = () => {
|
||||
notify(
|
||||
t("This photo provider doesn't allow remote downloads"),
|
||||
'negative'
|
||||
'negative',
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -219,11 +219,7 @@ const makeRequest = async () => {
|
|||
color="primary"
|
||||
class="cursor-pointer"
|
||||
@click="rotateLeft()"
|
||||
>
|
||||
<!-- <QTooltip class="no-pointer-events">
|
||||
{{ t('Rotate left') }}
|
||||
</QTooltip> -->
|
||||
</QIcon>
|
||||
/>
|
||||
<div>
|
||||
<div ref="photoContainerRef" />
|
||||
</div>
|
||||
|
@ -233,11 +229,7 @@ const makeRequest = async () => {
|
|||
color="primary"
|
||||
class="cursor-pointer"
|
||||
@click="rotateRight()"
|
||||
>
|
||||
<!-- <QTooltip class="no-pointer-events">
|
||||
{{ t('Rotate right') }}
|
||||
</QTooltip> -->
|
||||
</QIcon>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
|
@ -265,7 +257,6 @@ const makeRequest = async () => {
|
|||
class="cursor-pointer q-mr-sm"
|
||||
@click="openInputFile()"
|
||||
>
|
||||
<!-- <QTooltip>{{ t('globals.selectFile') }}</QTooltip> -->
|
||||
</QIcon>
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip>{{
|
||||
|
|
|
@ -0,0 +1,152 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { date } from 'quasar';
|
||||
import QCalendarMonthWrapper from 'src/components/ui/QCalendarMonthWrapper.vue';
|
||||
import { QCalendarMonth } from '@quasar/quasar-ui-qcalendar/src/index.js';
|
||||
import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.scss';
|
||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||
import useWeekdaysOrder from 'src/composables/getWeekdays';
|
||||
|
||||
const formatDate = (dateToFormat, format = 'YYYY-MM-DD') => (
|
||||
date.formatDate(dateToFormat, format)
|
||||
);
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
year: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
month: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
monthDate: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
daysMap: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['onDateSelected']);
|
||||
|
||||
const { locale } = useI18n();
|
||||
const weekdayStore = useWeekdayStore();
|
||||
const weekDays = useWeekdaysOrder();
|
||||
const calendarRef = ref(null);
|
||||
const today = ref(formatDate(Date.vnNew()));
|
||||
const todayTimestamp = computed(() => {
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
return date.getTime();
|
||||
});
|
||||
const _monthDate = computed(() => formatDate(props.monthDate));
|
||||
|
||||
const calendarHeaderTitle = computed(() => {
|
||||
return `${weekdayStore.getLocaleMonths[props.month - 1].locale} ${props.year}`;
|
||||
});
|
||||
|
||||
const isToday = (timestamp) => {
|
||||
const { year, month, day } = timestamp;
|
||||
return todayTimestamp.value === new Date(year, month - 1, day).getTime();
|
||||
};
|
||||
|
||||
const getEventByTimestamp = ({ year, month, day }) => {
|
||||
const stamp = new Date(year, month - 1, day).getTime();
|
||||
return props.daysMap?.[stamp] || null;
|
||||
};
|
||||
|
||||
const handleDateClick = (timestamp) => {
|
||||
const event = getEventByTimestamp(timestamp);
|
||||
const { year, month, day } = timestamp;
|
||||
const date = new Date(year, month - 1, day);
|
||||
emit('onDateSelected', {
|
||||
date,
|
||||
isNewMode: !event,
|
||||
event: event?.[0] || null
|
||||
});
|
||||
};
|
||||
|
||||
const getEventAttrs = (timestamp) => {
|
||||
return {
|
||||
class: '--event',
|
||||
label: timestamp.day,
|
||||
};
|
||||
};
|
||||
|
||||
defineExpose({ getEventByTimestamp, handleDateClick });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QCalendarMonthWrapper
|
||||
style="height: 290px; width: 290px"
|
||||
transparent-background
|
||||
view-customization="workerCalendar"
|
||||
>
|
||||
<template #header>
|
||||
<span class="full-width text-center text-body1 q-py-sm">{{
|
||||
calendarHeaderTitle
|
||||
}}</span>
|
||||
</template>
|
||||
<template #calendar>
|
||||
<QCalendarMonth
|
||||
ref="calendarRef"
|
||||
:model-value="_monthDate"
|
||||
show-work-weeks
|
||||
no-outside-days
|
||||
no-active-date
|
||||
:weekdays="weekDays"
|
||||
short-weekday-label
|
||||
:locale="locale"
|
||||
:now="today"
|
||||
@click-date="handleDateClick($event.scope.timestamp)"
|
||||
mini-mode
|
||||
>
|
||||
<template #day="{ scope: { timestamp } }">
|
||||
<slot name="day" :timestamp="timestamp" :getEventAttrs="getEventAttrs">
|
||||
<QBtn
|
||||
v-if="getEventByTimestamp(timestamp)"
|
||||
v-bind="{ ...getEventAttrs(timestamp) }"
|
||||
@click="handleDateClick(timestamp)"
|
||||
rounded
|
||||
dense
|
||||
flat
|
||||
class="calendar-event"
|
||||
:class="{ '--today': isToday(timestamp) }"
|
||||
/>
|
||||
</slot>
|
||||
</template>
|
||||
</QCalendarMonth>
|
||||
</template>
|
||||
</QCalendarMonthWrapper>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.calendar-event {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
font-size: 13px;
|
||||
line-height: 1.715em;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
|
||||
&.--today {
|
||||
border: 2px solid $info;
|
||||
}
|
||||
|
||||
&.--event {
|
||||
background-color: $positive;
|
||||
color: black;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,126 @@
|
|||
<script setup>
|
||||
import { computed, onMounted, ref, onUnmounted, nextTick } from 'vue';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
calendarComponent: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
additionalProps: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
}
|
||||
});
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const weekdayStore = useWeekdayStore();
|
||||
const nMonths = ref(4);
|
||||
const _date = ref(Date.vnNew());
|
||||
const firstDay = ref(Date.vnNew());
|
||||
const lastDay = ref(Date.vnNew());
|
||||
const months = ref([]);
|
||||
const arrayData = useArrayData(props.dataKey);
|
||||
onMounted(async () => {
|
||||
const initialDate = Date.vnNew();
|
||||
initialDate.setDate(1);
|
||||
initialDate.setHours(0, 0, 0, 0);
|
||||
date.value = initialDate;
|
||||
await nextTick();
|
||||
stateStore.rightDrawer = true;
|
||||
});
|
||||
|
||||
onUnmounted(() => arrayData.destroy());
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:firstDay',
|
||||
'update:lastDay',
|
||||
'update:events',
|
||||
'onDateSelected',
|
||||
]);
|
||||
|
||||
const date = computed({
|
||||
get: () => _date.value,
|
||||
set: (value) => {
|
||||
if (!(value instanceof Date)) return;
|
||||
_date.value = value;
|
||||
const stamp = value.getTime();
|
||||
|
||||
firstDay.value = new Date(stamp);
|
||||
firstDay.value.setDate(1);
|
||||
|
||||
lastDay.value = new Date(stamp);
|
||||
lastDay.value.setMonth(lastDay.value.getMonth() + nMonths.value);
|
||||
lastDay.value.setDate(0);
|
||||
|
||||
months.value = [];
|
||||
for (let i = 0; i < nMonths.value; i++) {
|
||||
const monthDate = new Date(stamp);
|
||||
monthDate.setMonth(value.getMonth() + i);
|
||||
months.value.push(monthDate);
|
||||
}
|
||||
|
||||
emit('update:firstDay', firstDay.value);
|
||||
emit('update:lastDay', lastDay.value);
|
||||
emit('refresh-events');
|
||||
},
|
||||
});
|
||||
|
||||
const headerTitle = computed(() => {
|
||||
if (!months.value?.length) return '';
|
||||
const getMonthName = date =>
|
||||
`${weekdayStore.getLocaleMonths[date.getMonth()].locale} ${date.getFullYear()}`;
|
||||
return `${getMonthName(months.value[0])} - ${getMonthName(months.value[months.value.length - 1])}`;
|
||||
});
|
||||
|
||||
const step = (direction) => {
|
||||
const newDate = new Date(date.value);
|
||||
newDate.setMonth(newDate.getMonth() + nMonths.value * direction);
|
||||
date.value = newDate;
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
firstDay,
|
||||
lastDay
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QCard style="height: max-content">
|
||||
<div class="calendars-header">
|
||||
<QBtn
|
||||
icon="arrow_left"
|
||||
size="sm"
|
||||
flat
|
||||
class="full-height"
|
||||
@click="step(-1)"
|
||||
/>
|
||||
<span>{{ headerTitle }}</span>
|
||||
<QBtn
|
||||
icon="arrow_right"
|
||||
size="sm"
|
||||
flat
|
||||
class="full-height"
|
||||
@click="step(1)"
|
||||
/>
|
||||
</div>
|
||||
<div class="calendars-container">
|
||||
<component
|
||||
:is="calendarComponent"
|
||||
v-for="(month, index) in months"
|
||||
:key="index"
|
||||
:month="month.getMonth() + 1"
|
||||
:year="month.getFullYear()"
|
||||
:month-date="month"
|
||||
v-bind="additionalProps"
|
||||
@on-date-selected="data => emit('onDateSelected', data)"
|
||||
/>
|
||||
</div>
|
||||
</QCard>
|
||||
</template>
|
|
@ -156,6 +156,9 @@ const selectTravel = ({ id }) => {
|
|||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="travelFilterParams.warehouseOutFk"
|
||||
:where="{
|
||||
isOrigin: true,
|
||||
}"
|
||||
/>
|
||||
<VnSelect
|
||||
:label="t('globals.warehouseIn')"
|
||||
|
@ -164,6 +167,9 @@ const selectTravel = ({ id }) => {
|
|||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="travelFilterParams.warehouseInFk"
|
||||
:where="{
|
||||
isDestiny: true,
|
||||
}"
|
||||
/>
|
||||
<VnInputDate
|
||||
:label="t('globals.shipped')"
|
||||
|
|
|
@ -22,7 +22,6 @@ const { validate, validations } = useValidator();
|
|||
const { notify } = useNotify();
|
||||
const route = useRoute();
|
||||
const myForm = ref(null);
|
||||
const attrs = useAttrs();
|
||||
const $props = defineProps({
|
||||
url: {
|
||||
type: String,
|
||||
|
@ -99,8 +98,12 @@ const $props = defineProps({
|
|||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
preventSubmit: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved', 'submit']);
|
||||
const modelValue = computed(
|
||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
||||
).value;
|
||||
|
@ -301,7 +304,7 @@ function onBeforeSave(formData, originalData) {
|
|||
);
|
||||
}
|
||||
async function onKeyup(evt) {
|
||||
if (evt.key === 'Enter' && !('prevent-submit' in attrs)) {
|
||||
if (evt.key === 'Enter' && !$props.preventSubmit) {
|
||||
const input = evt.target;
|
||||
if (input.type == 'textarea' && evt.shiftKey) {
|
||||
let { selectionStart, selectionEnd } = input;
|
||||
|
@ -330,6 +333,7 @@ defineExpose({
|
|||
<template>
|
||||
<div class="column items-center full-width">
|
||||
<QForm
|
||||
v-on="$attrs"
|
||||
ref="myForm"
|
||||
v-if="formData"
|
||||
@submit.prevent="save"
|
||||
|
@ -406,6 +410,7 @@ defineExpose({
|
|||
</QBtnDropdown>
|
||||
<QBtn
|
||||
v-else
|
||||
data-cy="saveDefaultBtn"
|
||||
:label="tMobile('globals.save')"
|
||||
color="primary"
|
||||
icon="save"
|
||||
|
|
|
@ -181,7 +181,7 @@ const searchModule = () => {
|
|||
<template>
|
||||
<QList padding class="column-max-width">
|
||||
<template v-if="$props.source === 'main'">
|
||||
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
||||
<template v-if="route?.matched[1]?.name === 'Dashboard'">
|
||||
<QItem class="q-pb-md">
|
||||
<VnInput
|
||||
v-model="search"
|
||||
|
@ -262,7 +262,7 @@ const searchModule = () => {
|
|||
</template>
|
||||
|
||||
<template v-for="item in items" :key="item.name">
|
||||
<template v-if="item.name === $route?.matched[1]?.name">
|
||||
<template v-if="item.name === route?.matched[1]?.name">
|
||||
<QItem class="header">
|
||||
<QItemSection avatar v-if="item.icon">
|
||||
<QIcon :name="item.icon" />
|
||||
|
|
|
@ -69,7 +69,7 @@ const refresh = () => window.location.reload();
|
|||
'no-visible': !stateQuery.isLoading().value,
|
||||
}"
|
||||
size="sm"
|
||||
data-cy="loading-spinner"
|
||||
data-cy="navBar-spinner"
|
||||
/>
|
||||
<QSpace />
|
||||
<div id="searchbar" class="searchbar"></div>
|
||||
|
|
|
@ -40,6 +40,9 @@ const onDataSaved = (data) => {
|
|||
url="Warehouses"
|
||||
@on-fetch="(data) => (warehousesOptions = data)"
|
||||
auto-load
|
||||
:where="{
|
||||
isInventory: true,
|
||||
}"
|
||||
/>
|
||||
<FormModelPopup
|
||||
url-create="Items/regularize"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { markRaw, computed } from 'vue';
|
||||
import { QCheckbox, QToggle } from 'quasar';
|
||||
import { markRaw, computed, onBeforeMount } from 'vue';
|
||||
import { QToggle } from 'quasar';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
import VnInput from 'components/common/VnInput.vue';
|
||||
|
@ -150,6 +150,16 @@ const showFilter = computed(
|
|||
const onTabPressed = async () => {
|
||||
if (model.value) enterEvent['keyup.enter']();
|
||||
};
|
||||
|
||||
onBeforeMount(() => {
|
||||
const columnFilter = $props.column?.columnFilter;
|
||||
const component = columnFilter?.component;
|
||||
const defaultComponent = components[component];
|
||||
const events = { update: updateEvent, enter: enterEvent };
|
||||
|
||||
if (!columnFilter || defaultComponent) return;
|
||||
$props.column.columnFilter.event = events[columnFilter.event];
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div v-if="showFilter" class="full-width" style="overflow: hidden">
|
||||
|
|
|
@ -16,7 +16,7 @@ const $props = defineProps({
|
|||
required: true,
|
||||
},
|
||||
searchUrl: {
|
||||
type: String,
|
||||
type: [String, Boolean],
|
||||
default: 'table',
|
||||
},
|
||||
vertical: {
|
||||
|
|
|
@ -33,6 +33,8 @@ import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
|||
import VnTableFilter from './VnTableFilter.vue';
|
||||
import { getColAlign } from 'src/composables/getColAlign';
|
||||
import RightMenu from '../common/RightMenu.vue';
|
||||
import VnScroll from '../common/VnScroll.vue';
|
||||
import VnMultiCheck from '../common/VnMultiCheck.vue';
|
||||
|
||||
const arrayData = useArrayData(useAttrs()['data-key']);
|
||||
const $props = defineProps({
|
||||
|
@ -65,7 +67,7 @@ const $props = defineProps({
|
|||
default: null,
|
||||
},
|
||||
create: {
|
||||
type: Object,
|
||||
type: [Boolean, Object],
|
||||
default: null,
|
||||
},
|
||||
createAsDialog: {
|
||||
|
@ -112,6 +114,10 @@ const $props = defineProps({
|
|||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
multiCheck: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
crudModel: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
|
@ -156,6 +162,7 @@ const CARD_MODE = 'card';
|
|||
const TABLE_MODE = 'table';
|
||||
const mode = ref(CARD_MODE);
|
||||
const selected = ref([]);
|
||||
const selectAll = ref(false);
|
||||
const hasParams = ref(false);
|
||||
const CrudModelRef = ref({});
|
||||
const showForm = ref(false);
|
||||
|
@ -168,6 +175,7 @@ const params = ref(useFilterParams($attrs['data-key']).params);
|
|||
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
||||
const app = inject('app');
|
||||
const tableHeight = useTableHeight();
|
||||
const vnScrollRef = ref(null);
|
||||
|
||||
const editingRow = ref(null);
|
||||
const editingField = ref(null);
|
||||
|
@ -189,6 +197,17 @@ const tableModes = [
|
|||
},
|
||||
];
|
||||
|
||||
const onVirtualScroll = ({ to }) => {
|
||||
handleScroll();
|
||||
const virtualScrollContainer = tableRef.value?.$el?.querySelector('.q-table__middle');
|
||||
if (virtualScrollContainer) {
|
||||
virtualScrollContainer.dispatchEvent(new CustomEvent('scroll'));
|
||||
if (vnScrollRef.value) {
|
||||
vnScrollRef.value.updateScrollContainer(virtualScrollContainer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onBeforeMount(() => {
|
||||
const urlParams = route.query[$props.searchUrl];
|
||||
hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
|
||||
|
@ -327,16 +346,13 @@ function handleOnDataSaved(_) {
|
|||
if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value });
|
||||
else $props.create.onDataSaved(_);
|
||||
}
|
||||
|
||||
function handleScroll() {
|
||||
if ($props.crudModel.disableInfiniteScroll) return;
|
||||
|
||||
const tMiddle = tableRef.value.$el.querySelector('.q-table__middle');
|
||||
const { scrollHeight, scrollTop, clientHeight } = tMiddle;
|
||||
const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40;
|
||||
if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
|
||||
}
|
||||
|
||||
function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||
if (evt?.shiftKey && added) {
|
||||
const rowIndex = selectedRows[0].$index;
|
||||
|
@ -628,6 +644,23 @@ const rowCtrlClickFunction = computed(() => {
|
|||
};
|
||||
return () => {};
|
||||
});
|
||||
const handleMultiCheck = (value) => {
|
||||
if (value) {
|
||||
selected.value = tableRef.value.rows;
|
||||
} else {
|
||||
selected.value = [];
|
||||
}
|
||||
emit('update:selected', selected.value);
|
||||
};
|
||||
|
||||
const handleSelectedAll = (data) => {
|
||||
if (data) {
|
||||
selected.value = data;
|
||||
} else {
|
||||
selected.value = [];
|
||||
}
|
||||
emit('update:selected', selected.value);
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<RightMenu v-if="$props.rightSearch" :overlay="overlay">
|
||||
|
@ -683,13 +716,24 @@ const rowCtrlClickFunction = computed(() => {
|
|||
flat
|
||||
:style="isTableMode && `max-height: ${$props.tableHeight || tableHeight}`"
|
||||
:virtual-scroll="isTableMode"
|
||||
@virtual-scroll="handleScroll"
|
||||
@virtual-scroll="onVirtualScroll"
|
||||
@row-click="(event, row) => handleRowClick(event, row)"
|
||||
@update:selected="emit('update:selected', $event)"
|
||||
@selection="(details) => handleSelection(details, rows)"
|
||||
:hide-selected-banner="true"
|
||||
:data-cy
|
||||
>
|
||||
<template #header-selection>
|
||||
<VnMultiCheck
|
||||
:searchUrl="searchUrl"
|
||||
:expand="$props.multiCheck.expand"
|
||||
v-model="selectAll"
|
||||
:url="$attrs['url']"
|
||||
@update:selected="handleMultiCheck"
|
||||
@select:all="handleSelectedAll"
|
||||
></VnMultiCheck>
|
||||
</template>
|
||||
|
||||
<template #top-left v-if="!$props.withoutHeader">
|
||||
<slot name="top-left"> </slot>
|
||||
</template>
|
||||
|
@ -741,6 +785,7 @@ const rowCtrlClickFunction = computed(() => {
|
|||
withFilters
|
||||
"
|
||||
:column="col"
|
||||
:data-cy="`column-filter-${col.name}`"
|
||||
:show-title="true"
|
||||
:data-key="$attrs['data-key']"
|
||||
v-model="params[columnName(col)]"
|
||||
|
@ -1087,6 +1132,11 @@ const rowCtrlClickFunction = computed(() => {
|
|||
</template>
|
||||
</FormModelPopup>
|
||||
</QDialog>
|
||||
<VnScroll
|
||||
ref="vnScrollRef"
|
||||
v-if="isTableMode"
|
||||
:scroll-target="tableRef?.$el?.querySelector('.q-table__middle')"
|
||||
/>
|
||||
</template>
|
||||
<i18n>
|
||||
en:
|
||||
|
|
|
@ -30,6 +30,7 @@ function columnName(col) {
|
|||
v-bind="$attrs"
|
||||
:search-button="true"
|
||||
:disable-submit-event="true"
|
||||
:data-key="$attrs['data-key']"
|
||||
:search-url
|
||||
>
|
||||
<template #body="{ params, orders, searchFn }">
|
||||
|
|
|
@ -58,7 +58,7 @@ async function getConfig(url, filter) {
|
|||
const response = await axios.get(url, {
|
||||
params: { filter: filter },
|
||||
});
|
||||
return response.data && response.data.length > 0 ? response.data[0] : null;
|
||||
return response?.data && response?.data?.length > 0 ? response.data[0] : null;
|
||||
}
|
||||
|
||||
async function fetchViewConfigData() {
|
||||
|
|
|
@ -11,6 +11,9 @@ describe('VnTable', () => {
|
|||
propsData: {
|
||||
columns: [],
|
||||
},
|
||||
attrs: {
|
||||
'data-key': 'test',
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
|
||||
|
|
|
@ -11,13 +11,7 @@ describe('CrudModel', () => {
|
|||
beforeAll(() => {
|
||||
wrapper = createWrapper(CrudModel, {
|
||||
global: {
|
||||
stubs: [
|
||||
'vnPaginate',
|
||||
'useState',
|
||||
'arrayData',
|
||||
'useStateStore',
|
||||
'vue-i18n',
|
||||
],
|
||||
stubs: ['vnPaginate', 'vue-i18n'],
|
||||
mocks: {
|
||||
validate: vi.fn(),
|
||||
},
|
||||
|
@ -29,7 +23,7 @@ describe('CrudModel', () => {
|
|||
dataKey: 'crudModelKey',
|
||||
model: 'crudModel',
|
||||
url: 'crudModelUrl',
|
||||
saveFn: '',
|
||||
saveFn: vi.fn(),
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
|
@ -231,7 +225,7 @@ describe('CrudModel', () => {
|
|||
expect(vm.isLoading).toBe(false);
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
|
||||
await wrapper.setProps({ saveFn: '' });
|
||||
await wrapper.setProps({ saveFn: null });
|
||||
});
|
||||
|
||||
it("should use default url if there's not saveFn", async () => {
|
||||
|
|
|
@ -170,7 +170,7 @@ describe('LeftMenu as card', () => {
|
|||
vm = mount('card').vm;
|
||||
});
|
||||
|
||||
it('should get routes for card source', async () => {
|
||||
it('should get routes for card source', () => {
|
||||
vm.getRoutes();
|
||||
});
|
||||
});
|
||||
|
@ -251,7 +251,6 @@ describe('LeftMenu as main', () => {
|
|||
});
|
||||
|
||||
it('should get routes for main source', () => {
|
||||
vm.props.source = 'main';
|
||||
vm.getRoutes();
|
||||
expect(navigation.getModules).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -8,7 +8,8 @@ const model = defineModel({ prop: 'modelValue' });
|
|||
<VnInput
|
||||
v-model="model"
|
||||
ref="inputRef"
|
||||
@keydown.tab="model = useAccountShortToStandard($event.target.value) ?? model"
|
||||
@keydown.tab="$refs.inputRef.vnInputRef.blur()"
|
||||
@blur="model = useAccountShortToStandard(model) ?? model"
|
||||
@input="model = $event.target.value.replace(/[^\d.]/g, '')"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import FetchData from '../FetchData.vue';
|
||||
import VnSelectDialog from './VnSelectDialog.vue';
|
||||
|
||||
import CreateBankEntityForm from '../CreateBankEntityForm.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
iban: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
bankEntityFk: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
disableElement: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
const filter = {
|
||||
fields: ['id', 'bic', 'name'],
|
||||
order: 'bic ASC',
|
||||
};
|
||||
const { t } = useI18n();
|
||||
const emit = defineEmits(['updateBic']);
|
||||
const iban = ref($props.iban);
|
||||
const bankEntityFk = ref($props.bankEntityFk);
|
||||
const bankEntities = ref([]);
|
||||
|
||||
const autofillBic = async (bic) => {
|
||||
if (!bic) return;
|
||||
const bankEntityId = parseInt(bic.substr(4, 4));
|
||||
const ibanCountry = bic.substr(0, 2);
|
||||
if (ibanCountry != 'ES') return;
|
||||
|
||||
const existBank = bankEntities.value.find((b) => b.id === bankEntityId);
|
||||
bankEntityFk.value = existBank ? bankEntityId : null;
|
||||
emit('updateBic', { iban: iban.value, bankEntityFk: bankEntityFk.value });
|
||||
};
|
||||
|
||||
const getBankEntities = (data) => {
|
||||
bankEntityFk.value = data.id;
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
url="BankEntities"
|
||||
:filter="filter"
|
||||
auto-load
|
||||
@on-fetch="(data) => (bankEntities = data)"
|
||||
/>
|
||||
<VnInput
|
||||
:label="t('IBAN')"
|
||||
clearable
|
||||
v-model="iban"
|
||||
@update:model-value="autofillBic($event)"
|
||||
:disable="disableElement"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-info">
|
||||
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
<VnSelectDialog
|
||||
:label="t('Swift / BIC')"
|
||||
:acls="[{ model: 'BankEntity', props: '*', accessType: 'WRITE' }]"
|
||||
:options="bankEntities"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="bankEntityFk"
|
||||
@update:model-value="$emit('updateBic', { iban, bankEntityFk })"
|
||||
:disable="disableElement"
|
||||
>
|
||||
<template #form>
|
||||
<CreateBankEntityForm @on-data-saved="getBankEntities($event)" />
|
||||
</template>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection v-if="scope.opt">
|
||||
<QItemLabel>{{ scope.opt.bic }} </QItemLabel>
|
||||
<QItemLabel caption> {{ scope.opt.name }}</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelectDialog>
|
||||
</template>
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
const model = defineModel({ type: [String, Number], required: true });
|
||||
const model = defineModel({ type: [String, Number], default: '' });
|
||||
</script>
|
||||
<template>
|
||||
<QDate v-model="model" :today-btn="true" :options="$attrs.options" />
|
||||
|
|
|
@ -4,6 +4,7 @@ import { useRoute } from 'vue-router';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import axios from 'axios';
|
||||
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
|
@ -12,6 +13,7 @@ import FormModelPopup from 'components/FormModelPopup.vue';
|
|||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const emit = defineEmits(['onDataSaved']);
|
||||
|
||||
const $props = defineProps({
|
||||
|
@ -61,8 +63,11 @@ function onFileChange(files) {
|
|||
|
||||
function mapperDms(data) {
|
||||
const formData = new FormData();
|
||||
const { files } = data;
|
||||
if (files) formData.append(files?.name, files);
|
||||
let files = data.files;
|
||||
if (files) {
|
||||
files = Array.isArray(files) ? files : [files];
|
||||
files.forEach((file) => formData.append(file?.name, file));
|
||||
}
|
||||
|
||||
const dms = {
|
||||
hasFile: !!data.hasFile,
|
||||
|
@ -83,11 +88,16 @@ function getUrl() {
|
|||
}
|
||||
|
||||
async function save() {
|
||||
const body = mapperDms(dms.value);
|
||||
const response = await axios.post(getUrl(), body[0], body[1]);
|
||||
emit('onDataSaved', body[1].params, response);
|
||||
delete dms.value.files;
|
||||
return response;
|
||||
try {
|
||||
const body = mapperDms(dms.value);
|
||||
const response = await axios.post(getUrl(), body[0], body[1]);
|
||||
emit('onDataSaved', body[1].params, response);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
delete dms.value.files;
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function defaultData() {
|
||||
|
@ -208,7 +218,7 @@ function addDefaultData(data) {
|
|||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
en:
|
||||
contentTypesInfo: Allowed file types {allowedContentTypes}
|
||||
EntryDmsDescription: Reference {reference}
|
||||
WorkersDescription: Working of employee id {reference}
|
||||
|
|
|
@ -13,10 +13,12 @@ import VnDms from 'src/components/common/VnDms.vue';
|
|||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
const route = useRoute();
|
||||
const quasar = useQuasar();
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const rows = ref([]);
|
||||
const dmsRef = ref();
|
||||
const formDialog = ref({});
|
||||
|
@ -88,7 +90,6 @@ const dmsFilter = {
|
|||
],
|
||||
},
|
||||
},
|
||||
where: { [$props.filter]: route.params.id },
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
|
@ -258,9 +259,16 @@ function deleteDms(dmsFk) {
|
|||
},
|
||||
})
|
||||
.onOk(async () => {
|
||||
await axios.post(`${$props.deleteModel ?? $props.model}/${dmsFk}/removeFile`);
|
||||
const index = rows.value.findIndex((row) => row.id == dmsFk);
|
||||
rows.value.splice(index, 1);
|
||||
try {
|
||||
await axios.post(
|
||||
`${$props.deleteModel ?? $props.model}/${dmsFk}/removeFile`,
|
||||
);
|
||||
const index = rows.value.findIndex((row) => row.id == dmsFk);
|
||||
rows.value.splice(index, 1);
|
||||
notify(t('globals.dataDeleted'), 'positive');
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -298,7 +306,9 @@ defineExpose({
|
|||
:data-key="$props.model"
|
||||
:url="$props.model"
|
||||
:user-filter="dmsFilter"
|
||||
search-url="dmsFilter"
|
||||
:order="['dmsFk DESC']"
|
||||
:filter="{ where: { [$props.filter]: route.params.id } }"
|
||||
auto-load
|
||||
@on-fetch="setData"
|
||||
>
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import axios from 'axios';
|
||||
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const model = defineModel({ type: [Number, String] });
|
||||
const emit = defineEmits(['updateBic']);
|
||||
|
||||
const getIbanCountry = (bank) => {
|
||||
return bank.substr(0, 2);
|
||||
};
|
||||
|
||||
const autofillBic = async (iban) => {
|
||||
if (!iban) return;
|
||||
|
||||
const bankEntityId = parseInt(iban.substr(4, 4));
|
||||
const ibanCountry = getIbanCountry(iban);
|
||||
|
||||
if (ibanCountry != 'ES') return;
|
||||
|
||||
const filter = { where: { id: bankEntityId } };
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
|
||||
const { data } = await axios.get(`BankEntities`, { params });
|
||||
|
||||
emit('updateBic', data[0]?.id);
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnInput
|
||||
:label="t('IBAN')"
|
||||
clearable
|
||||
v-model="model"
|
||||
@update:model-value="autofillBic($event)"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-info">
|
||||
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
</template>
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { onMounted, watch, computed, ref, useAttrs } from 'vue';
|
||||
import { date } from 'quasar';
|
||||
import { nextTick, watch, computed, ref, useAttrs } from 'vue';
|
||||
import { date, getCssVar } from 'quasar';
|
||||
import VnDate from './VnDate.vue';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
|
||||
|
@ -20,61 +20,18 @@ const $props = defineProps({
|
|||
});
|
||||
|
||||
const vnInputDateRef = ref(null);
|
||||
const errColor = getCssVar('negative');
|
||||
const textColor = ref('');
|
||||
|
||||
const dateFormat = 'DD/MM/YYYY';
|
||||
const isPopupOpen = ref();
|
||||
const hover = ref();
|
||||
const mask = ref();
|
||||
|
||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
||||
|
||||
const formattedDate = computed({
|
||||
get() {
|
||||
if (!model.value) return model.value;
|
||||
return date.formatDate(new Date(model.value), dateFormat);
|
||||
},
|
||||
set(value) {
|
||||
if (value == model.value) return;
|
||||
let newDate;
|
||||
if (value) {
|
||||
// parse input
|
||||
if (value.includes('/') && value.length >= 10) {
|
||||
if (value.at(2) == '/') value = value.split('/').reverse().join('/');
|
||||
value = date.formatDate(
|
||||
new Date(value).toISOString(),
|
||||
'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
||||
);
|
||||
}
|
||||
const [year, month, day] = value.split('-').map((e) => parseInt(e));
|
||||
newDate = new Date(year, month - 1, day);
|
||||
if (model.value) {
|
||||
const orgDate =
|
||||
model.value instanceof Date ? model.value : new Date(model.value);
|
||||
|
||||
newDate.setHours(
|
||||
orgDate.getHours(),
|
||||
orgDate.getMinutes(),
|
||||
orgDate.getSeconds(),
|
||||
orgDate.getMilliseconds(),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!isNaN(newDate)) model.value = newDate.toISOString();
|
||||
},
|
||||
});
|
||||
|
||||
const popupDate = computed(() =>
|
||||
model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value,
|
||||
);
|
||||
onMounted(() => {
|
||||
// fix quasar bug
|
||||
mask.value = '##/##/####';
|
||||
});
|
||||
watch(
|
||||
() => model.value,
|
||||
(val) => (formattedDate.value = val),
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const styleAttrs = computed(() => {
|
||||
return $props.isOutlined
|
||||
|
@ -86,28 +43,138 @@ const styleAttrs = computed(() => {
|
|||
: {};
|
||||
});
|
||||
|
||||
const inputValue = ref('');
|
||||
|
||||
const validateAndCleanInput = (value) => {
|
||||
inputValue.value = value.replace(/[^0-9./-]/g, '');
|
||||
};
|
||||
|
||||
const manageDate = (date) => {
|
||||
formattedDate.value = date;
|
||||
inputValue.value = date.split('/').reverse().join('/');
|
||||
isPopupOpen.value = false;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => model.value,
|
||||
(nVal) => {
|
||||
if (nVal) inputValue.value = date.formatDate(new Date(model.value), dateFormat);
|
||||
else inputValue.value = '';
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const formatDate = () => {
|
||||
let value = inputValue.value;
|
||||
if (!value || value === model.value) {
|
||||
textColor.value = '';
|
||||
return;
|
||||
}
|
||||
const regex =
|
||||
/^([0]?[1-9]|[12][0-9]|3[01])([./-])([0]?[1-9]|1[0-2])([./-](\d{1,4}))?$/;
|
||||
if (!regex.test(value)) {
|
||||
textColor.value = errColor;
|
||||
return;
|
||||
}
|
||||
|
||||
value = value.replace(/[.-]/g, '/');
|
||||
const parts = value.split('/');
|
||||
if (parts.length < 2) {
|
||||
textColor.value = errColor;
|
||||
return;
|
||||
}
|
||||
|
||||
let [day, month, year] = parts;
|
||||
if (day.length === 1) day = '0' + day;
|
||||
if (month.length === 1) month = '0' + month;
|
||||
|
||||
const currentYear = Date.vnNew().getFullYear();
|
||||
if (!year) year = currentYear;
|
||||
const millennium = currentYear.toString().slice(0, 1);
|
||||
|
||||
switch (year.length) {
|
||||
case 1:
|
||||
year = `${millennium}00${year}`;
|
||||
break;
|
||||
case 2:
|
||||
year = `${millennium}0${year}`;
|
||||
break;
|
||||
case 3:
|
||||
year = `${millennium}${year}`;
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
}
|
||||
|
||||
let isoCandidate = `${year}/${month}/${day}`;
|
||||
isoCandidate = date.formatDate(
|
||||
new Date(isoCandidate).toISOString(),
|
||||
'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
||||
);
|
||||
const [isoYear, isoMonth, isoDay] = isoCandidate.split('-').map((e) => parseInt(e));
|
||||
const parsedDate = new Date(isoYear, isoMonth - 1, isoDay);
|
||||
|
||||
const isValidDate =
|
||||
parsedDate instanceof Date &&
|
||||
!isNaN(parsedDate) &&
|
||||
parsedDate.getFullYear() === parseInt(year) &&
|
||||
parsedDate.getMonth() === parseInt(month) - 1 &&
|
||||
parsedDate.getDate() === parseInt(day);
|
||||
|
||||
if (!isValidDate) {
|
||||
textColor.value = errColor;
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.value) {
|
||||
const original =
|
||||
model.value instanceof Date ? model.value : new Date(model.value);
|
||||
parsedDate.setHours(
|
||||
original.getHours(),
|
||||
original.getMinutes(),
|
||||
original.getSeconds(),
|
||||
original.getMilliseconds(),
|
||||
);
|
||||
}
|
||||
|
||||
model.value = parsedDate.toISOString();
|
||||
|
||||
textColor.value = '';
|
||||
};
|
||||
|
||||
const handleEnter = (event) => {
|
||||
formatDate();
|
||||
|
||||
nextTick(() => {
|
||||
const newEvent = new KeyboardEvent('keydown', {
|
||||
key: 'Enter',
|
||||
code: 'Enter',
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
});
|
||||
vnInputDateRef.value?.$el?.dispatchEvent(newEvent);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||
<QInput
|
||||
ref="vnInputDateRef"
|
||||
v-model="formattedDate"
|
||||
v-model="inputValue"
|
||||
class="vn-input-date"
|
||||
:mask="mask"
|
||||
placeholder="dd/mm/aaaa"
|
||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||
:class="{ required: isRequired }"
|
||||
:rules="mixinRules"
|
||||
:clearable="false"
|
||||
:input-style="{ color: textColor }"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
@keydown="isPopupOpen = false"
|
||||
@blur="formatDate"
|
||||
@keydown.enter.prevent="handleEnter"
|
||||
hide-bottom-space
|
||||
:data-cy="($attrs['data-cy'] ?? $attrs.label) + '_inputDate'"
|
||||
@update:model-value="validateAndCleanInput"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon
|
||||
|
@ -116,11 +183,12 @@ const manageDate = (date) => {
|
|||
v-if="
|
||||
($attrs.clearable == undefined || $attrs.clearable) &&
|
||||
hover &&
|
||||
model &&
|
||||
inputValue &&
|
||||
!$attrs.disable
|
||||
"
|
||||
@click="
|
||||
vnInputDateRef.focus();
|
||||
inputValue = null;
|
||||
model = null;
|
||||
isPopupOpen = false;
|
||||
"
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<script setup>
|
||||
import { computed, useAttrs } from 'vue';
|
||||
import { date } from 'quasar';
|
||||
import VnDate from './VnDate.vue';
|
||||
import VnTime from './VnTime.vue';
|
||||
|
||||
const $attrs = useAttrs();
|
||||
const model = defineModel({ type: [Date, String] });
|
||||
|
||||
const $props = defineProps({
|
||||
isOutlined: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
showEvent: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
const styleAttrs = computed(() => {
|
||||
return $props.isOutlined
|
||||
? {
|
||||
dense: true,
|
||||
outlined: true,
|
||||
rounded: true,
|
||||
}
|
||||
: {};
|
||||
});
|
||||
const mask = 'DD-MM-YYYY HH:mm';
|
||||
const selectedDate = computed({
|
||||
get() {
|
||||
if (!model.value) return JSON.stringify(new Date(model.value));
|
||||
return date.formatDate(new Date(model.value), mask);
|
||||
},
|
||||
set(value) {
|
||||
model.value = Date.convertToISODateTime(value);
|
||||
},
|
||||
});
|
||||
const manageDate = (date) => {
|
||||
selectedDate.value = date;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||
<QInput
|
||||
ref="vnInputDateRef"
|
||||
v-model="selectedDate"
|
||||
class="vn-input-date"
|
||||
placeholder="dd/mm/aaaa HH:mm"
|
||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||
:clearable="false"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
@keydown="isPopupOpen = false"
|
||||
hide-bottom-space
|
||||
@update:model-value="manageDate"
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_inputDateTime'"
|
||||
>
|
||||
<template #prepend>
|
||||
<QIcon name="today" size="xs">
|
||||
<QPopupProxy cover transition-show="scale" transition-hide="scale">
|
||||
<VnDate :mask="mask" v-model="selectedDate" />
|
||||
</QPopupProxy>
|
||||
</QIcon>
|
||||
</template>
|
||||
<template #append>
|
||||
<QIcon name="access_time" size="xs">
|
||||
<QPopupProxy cover transition-show="scale" transition-hide="scale">
|
||||
<VnTime format24h :mask="mask" v-model="selectedDate" />
|
||||
</QPopupProxy>
|
||||
</QIcon>
|
||||
</template>
|
||||
</QInput>
|
||||
</div>
|
||||
</template>
|
||||
<i18n>
|
||||
es:
|
||||
Open date: Abrir fecha
|
||||
</i18n>
|
|
@ -0,0 +1,80 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import VnCheckbox from './VnCheckbox.vue';
|
||||
import axios from 'axios';
|
||||
import { toRaw } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const model = defineModel({ type: [Boolean] });
|
||||
const props = defineProps({
|
||||
expand: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: true,
|
||||
},
|
||||
searchUrl: {
|
||||
type: [String, Boolean],
|
||||
default: 'table',
|
||||
},
|
||||
});
|
||||
const value = ref(false);
|
||||
const rows = ref(0);
|
||||
const onClick = () => {
|
||||
if (value.value) {
|
||||
const { filter } = JSON.parse(route.query[props.searchUrl]);
|
||||
filter.limit = 0;
|
||||
const params = {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
};
|
||||
axios
|
||||
.get(props.url, params)
|
||||
.then(({ data }) => {
|
||||
rows.value = data;
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
};
|
||||
defineEmits(['update:selected', 'select:all']);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: flex">
|
||||
<VnCheckbox v-model="value" @click="$emit('update:selected', value)" />
|
||||
<QBtn
|
||||
v-if="value && $props.expand"
|
||||
flat
|
||||
dense
|
||||
icon="expand_more"
|
||||
@click="onClick"
|
||||
>
|
||||
<QMenu anchor="bottom right" self="top right">
|
||||
<QList>
|
||||
<QItem v-ripple clickable @click="$emit('select:all', toRaw(rows))">
|
||||
{{ t('Select all', { rows: rows.length }) }}
|
||||
</QItem>
|
||||
<slot name="more-options"></slot>
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
</div>
|
||||
</template>
|
||||
<i18n lang="yml">
|
||||
en:
|
||||
Select all: 'Select all ({rows})'
|
||||
fr:
|
||||
Select all: 'Sélectionner tout ({rows})'
|
||||
es:
|
||||
Select all: 'Seleccionar todo ({rows})'
|
||||
de:
|
||||
Select all: 'Alle auswählen ({rows})'
|
||||
it:
|
||||
Select all: 'Seleziona tutto ({rows})'
|
||||
pt:
|
||||
Select all: 'Selecionar tudo ({rows})'
|
||||
</i18n>
|
|
@ -0,0 +1,100 @@
|
|||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
scrollTarget: { type: [String, Object], default: 'window' }
|
||||
});
|
||||
|
||||
const scrollPosition = ref(0);
|
||||
const showButton = ref(false);
|
||||
let scrollContainer = null;
|
||||
|
||||
const onScroll = () => {
|
||||
if (!scrollContainer) return;
|
||||
scrollPosition.value =
|
||||
typeof props.scrollTarget === 'object'
|
||||
? scrollContainer.scrollTop
|
||||
: window.scrollY;
|
||||
};
|
||||
|
||||
watch(scrollPosition, (newValue) => {
|
||||
showButton.value = newValue > 0;
|
||||
});
|
||||
|
||||
const scrollToTop = () => {
|
||||
if (scrollContainer) {
|
||||
scrollContainer.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
}
|
||||
};
|
||||
|
||||
const updateScrollContainer = (container) => {
|
||||
if (container) {
|
||||
if (scrollContainer) {
|
||||
scrollContainer.removeEventListener('scroll', onScroll);
|
||||
}
|
||||
scrollContainer = container;
|
||||
scrollContainer.addEventListener('scroll', onScroll);
|
||||
onScroll();
|
||||
}
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
updateScrollContainer
|
||||
});
|
||||
|
||||
const initScrollContainer = async () => {
|
||||
await nextTick();
|
||||
|
||||
if (typeof props.scrollTarget === 'object') {
|
||||
scrollContainer = props.scrollTarget;
|
||||
} else {
|
||||
scrollContainer = window;
|
||||
}
|
||||
|
||||
if (!scrollContainer) return
|
||||
scrollContainer.addEventListener('scroll', onScroll);
|
||||
};
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
initScrollContainer();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (scrollContainer) {
|
||||
scrollContainer.removeEventListener('scroll', onScroll);
|
||||
scrollContainer = null;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QIcon
|
||||
v-if="showButton"
|
||||
color="primary"
|
||||
name="keyboard_arrow_up"
|
||||
class="scroll-to-top"
|
||||
@click="scrollToTop"
|
||||
>
|
||||
<QTooltip>{{ $t('globals.scrollToTop') }}</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.scroll-to-top {
|
||||
position: fixed;
|
||||
top: 70px;
|
||||
font-size: 65px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 1000;
|
||||
transition: transform 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.scroll-to-top:hover {
|
||||
transform: translateX(-50%) scale(1.2);
|
||||
cursor: pointer;
|
||||
filter: brightness(0.8);
|
||||
}
|
||||
</style>
|
||||
|
|
@ -54,6 +54,10 @@ const $props = defineProps({
|
|||
type: [Array],
|
||||
default: () => [],
|
||||
},
|
||||
filterFn: {
|
||||
type: Function,
|
||||
default: null,
|
||||
},
|
||||
exprBuilder: {
|
||||
type: Function,
|
||||
default: null,
|
||||
|
@ -62,16 +66,12 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
defaultFilter: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
fields: {
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
include: {
|
||||
type: [Object, Array],
|
||||
type: [Object, Array, String],
|
||||
default: null,
|
||||
},
|
||||
where: {
|
||||
|
@ -79,7 +79,7 @@ const $props = defineProps({
|
|||
default: null,
|
||||
},
|
||||
sortBy: {
|
||||
type: String,
|
||||
type: [String, Array],
|
||||
default: null,
|
||||
},
|
||||
limit: {
|
||||
|
@ -152,10 +152,22 @@ const value = computed({
|
|||
},
|
||||
});
|
||||
|
||||
const arrayDataKey =
|
||||
$props.dataKey ??
|
||||
($props.url?.length > 0 ? $props.url : ($attrs.name ?? $attrs.label));
|
||||
|
||||
const arrayData = useArrayData(arrayDataKey, {
|
||||
url: $props.url,
|
||||
searchUrl: false,
|
||||
mapKey: $attrs['map-key'],
|
||||
});
|
||||
|
||||
const computedSortBy = computed(() => {
|
||||
return $props.sortBy || $props.optionLabel + ' ASC';
|
||||
});
|
||||
|
||||
const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val);
|
||||
|
||||
watch(options, (newValue) => {
|
||||
setOptions(newValue);
|
||||
});
|
||||
|
@ -174,16 +186,7 @@ onMounted(() => {
|
|||
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
||||
});
|
||||
|
||||
const arrayDataKey =
|
||||
$props.dataKey ??
|
||||
($props.url?.length > 0 ? $props.url : ($attrs.name ?? $attrs.label));
|
||||
|
||||
const arrayData = useArrayData(arrayDataKey, {
|
||||
url: $props.url,
|
||||
searchUrl: false,
|
||||
mapKey: $attrs['map-key'],
|
||||
});
|
||||
|
||||
const someIsLoading = computed(() => isLoading.value || !!arrayData?.isLoading?.value);
|
||||
function findKeyInOptions() {
|
||||
if (!$props.options) return;
|
||||
return filter($props.modelValue, $props.options)?.length;
|
||||
|
@ -252,43 +255,41 @@ async function fetchFilter(val) {
|
|||
}
|
||||
|
||||
async function filterHandler(val, update) {
|
||||
if (isLoading.value) return update();
|
||||
if (!val && lastVal.value === val) {
|
||||
lastVal.value = val;
|
||||
return update();
|
||||
}
|
||||
lastVal.value = val;
|
||||
let newOptions;
|
||||
|
||||
if (!$props.defaultFilter) return update();
|
||||
if (
|
||||
$props.url &&
|
||||
($props.limit || (!$props.limit && Object.keys(myOptions.value).length === 0))
|
||||
) {
|
||||
newOptions = await fetchFilter(val);
|
||||
} else newOptions = filter(val, myOptionsOriginal.value);
|
||||
update(
|
||||
() => {
|
||||
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
||||
newOptions.unshift(noOneOpt.value);
|
||||
if ($props.filterFn) update($props.filterFn(val));
|
||||
else if (!val && lastVal.value === val) update();
|
||||
else {
|
||||
const makeRequest =
|
||||
($props.url && $props.limit) ||
|
||||
(!$props.limit && Object.keys(myOptions.value).length === 0);
|
||||
newOptions = makeRequest
|
||||
? await fetchFilter(val)
|
||||
: filter(val, myOptionsOriginal.value);
|
||||
|
||||
myOptions.value = newOptions;
|
||||
},
|
||||
(ref) => {
|
||||
if (val !== '' && ref.options.length > 0) {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
update(
|
||||
() => {
|
||||
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
||||
newOptions.unshift(noOneOpt.value);
|
||||
|
||||
myOptions.value = newOptions;
|
||||
},
|
||||
(ref) => {
|
||||
if (val !== '' && ref.options.length > 0) {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
lastVal.value = val;
|
||||
}
|
||||
|
||||
function nullishToTrue(value) {
|
||||
return value ?? true;
|
||||
}
|
||||
|
||||
const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val);
|
||||
|
||||
async function onScroll({ to, direction, from, index }) {
|
||||
const lastIndex = myOptions.value.length - 1;
|
||||
|
||||
|
@ -366,7 +367,7 @@ function getCaption(opt) {
|
|||
virtual-scroll-slice-size="options.length"
|
||||
hide-bottom-space
|
||||
:input-debounce="useURL ? '300' : '0'"
|
||||
:loading="isLoading"
|
||||
:loading="someIsLoading"
|
||||
@virtual-scroll="onScroll"
|
||||
@keydown="handleKeyDown"
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
||||
|
@ -374,7 +375,7 @@ function getCaption(opt) {
|
|||
>
|
||||
<template #append>
|
||||
<QIcon
|
||||
v-show="isClearable && value"
|
||||
v-show="isClearable && value != null && value !== ''"
|
||||
name="close"
|
||||
@click="
|
||||
() => {
|
||||
|
@ -389,7 +390,7 @@ function getCaption(opt) {
|
|||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
||||
<div v-if="slotName == 'append'">
|
||||
<QIcon
|
||||
v-show="isClearable && value"
|
||||
v-show="isClearable && value != null && value !== ''"
|
||||
name="close"
|
||||
@click.stop="
|
||||
() => {
|
||||
|
@ -414,7 +415,7 @@ function getCaption(opt) {
|
|||
<QItemLabel>
|
||||
{{ opt[optionLabel] }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption v-if="getCaption(opt)">
|
||||
<QItemLabel caption v-if="getCaption(opt) !== false">
|
||||
{{ `#${getCaption(opt)}` }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
|
|
|
@ -232,7 +232,7 @@ fr:
|
|||
pt: Portugais
|
||||
pt:
|
||||
Send SMS: Enviar SMS
|
||||
CustomerDefaultLanguage: Este cliente utiliza o <strong>{locale}</strong> como seu idioma padrão
|
||||
CustomerDefaultLanguage: Este cliente utiliza o {locale} como seu idioma padrão
|
||||
Language: Linguagem
|
||||
Phone: Móvel
|
||||
Subject: Assunto
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnBankDetailsForm from 'components/common/VnBankDetailsForm.vue';
|
||||
import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest';
|
||||
|
||||
describe('VnBankDetail Component', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
const bankEntities = [
|
||||
{ id: 2100, bic: 'CAIXESBBXXX', name: 'CaixaBank' },
|
||||
{ id: 1234, bic: 'TESTBIC', name: 'Test Bank' },
|
||||
];
|
||||
const correctIban = 'ES6621000418401234567891';
|
||||
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(VnBankDetailsForm, {
|
||||
$props: {
|
||||
iban: null,
|
||||
bankEntityFk: null,
|
||||
disableElement: false,
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
wrapper = wrapper.wrapper;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should update bankEntityFk when IBAN exists in bankEntities', async () => {
|
||||
vm.bankEntities = bankEntities;
|
||||
|
||||
await vm.autofillBic(correctIban);
|
||||
expect(vm.bankEntityFk).toBe(2100);
|
||||
});
|
||||
|
||||
it('should set bankEntityFk to null when IBAN bank code is not found', async () => {
|
||||
vm.bankEntities = bankEntities;
|
||||
|
||||
await vm.autofillBic('ES1234567891324567891234');
|
||||
expect(vm.bankEntityFk).toBe(null);
|
||||
});
|
||||
});
|
|
@ -4,7 +4,7 @@ import VnDiscount from 'components/common/vnDiscount.vue';
|
|||
|
||||
describe('VnDiscount', () => {
|
||||
let vm;
|
||||
|
||||
|
||||
beforeAll(() => {
|
||||
vm = createWrapper(VnDiscount, {
|
||||
props: {
|
||||
|
@ -12,7 +12,9 @@ describe('VnDiscount', () => {
|
|||
price: 100,
|
||||
quantity: 2,
|
||||
discount: 10,
|
||||
}
|
||||
mana: 10,
|
||||
promise: vi.fn(),
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
|
@ -21,8 +23,8 @@ describe('VnDiscount', () => {
|
|||
});
|
||||
|
||||
describe('total', () => {
|
||||
it('should calculate total correctly', () => {
|
||||
it('should calculate total correctly', () => {
|
||||
expect(vm.total).toBe(180);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,10 +41,12 @@ describe('VnDms', () => {
|
|||
companyFk: 2,
|
||||
dmsTypeFk: 3,
|
||||
description: 'This is a test description',
|
||||
files: {
|
||||
name: 'example.txt',
|
||||
content: new Blob(['file content'], { type: 'text/plain' }),
|
||||
},
|
||||
files: [
|
||||
{
|
||||
name: 'example.txt',
|
||||
content: new Blob(['file content'], { type: 'text/plain' }),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const expectedBody = {
|
||||
|
@ -83,7 +85,7 @@ describe('VnDms', () => {
|
|||
it('should map DMS data correctly and add file to FormData', () => {
|
||||
const [formData, params] = vm.mapperDms(data);
|
||||
|
||||
expect(formData.get('example.txt')).toBe(data.files);
|
||||
expect([formData.get('example.txt')]).toStrictEqual(data.files);
|
||||
expect(expectedBody).toEqual(params.params);
|
||||
});
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import { createWrapper } from 'app/test/vitest/helper';
|
|||
import { vi, describe, expect, it } from 'vitest';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
|
||||
describe('VnInput', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
@ -11,26 +10,28 @@ describe('VnInput', () => {
|
|||
function generateWrapper(value, isOutlined, emptyToNull, insertable) {
|
||||
wrapper = createWrapper(VnInput, {
|
||||
props: {
|
||||
modelValue: value,
|
||||
isOutlined, emptyToNull, insertable,
|
||||
maxlength: 101
|
||||
modelValue: value,
|
||||
isOutlined,
|
||||
emptyToNull,
|
||||
insertable,
|
||||
maxlength: 101,
|
||||
},
|
||||
attrs: {
|
||||
label: 'test',
|
||||
required: true,
|
||||
maxlength: 101,
|
||||
maxLength: 10,
|
||||
'max-length':20
|
||||
'max-length': 20,
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
input = wrapper.find('[data-cy="test_input"]');
|
||||
};
|
||||
}
|
||||
|
||||
describe('value', () => {
|
||||
it('should emit update:modelValue when value changes', async () => {
|
||||
generateWrapper('12345', false, false, true)
|
||||
generateWrapper('12345', false, false, true);
|
||||
await input.setValue('123');
|
||||
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
||||
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['123']);
|
||||
|
@ -46,37 +47,36 @@ describe('VnInput', () => {
|
|||
describe('styleAttrs', () => {
|
||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
||||
generateWrapper('123', false, false, false);
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
});
|
||||
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
generateWrapper('123', true, false, false);
|
||||
expect(vm.styleAttrs.outlined).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleKeydown', () => {
|
||||
describe('handleKeydown', () => {
|
||||
it('should do nothing when "Backspace" key is pressed', async () => {
|
||||
generateWrapper('12345', false, false, true);
|
||||
await input.trigger('keydown', { key: 'Backspace' });
|
||||
expect(wrapper.emitted('update:modelValue')).toBeUndefined();
|
||||
const spyhandler = vi.spyOn(vm, 'handleInsertMode');
|
||||
expect(spyhandler).not.toHaveBeenCalled();
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
TODO: #8399 REDMINE
|
||||
*/
|
||||
it.skip('handleKeydown respects insertable behavior', async () => {
|
||||
const expectedValue = '12345';
|
||||
generateWrapper('1234', false, false, true);
|
||||
vm.focus()
|
||||
vm.focus();
|
||||
await input.trigger('keydown', { key: '5' });
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
||||
expect(wrapper.emitted('update:modelValue')[0]).toEqual([expectedValue ]);
|
||||
expect(vm.value).toBe( expectedValue);
|
||||
expect(wrapper.emitted('update:modelValue')[0]).toEqual([expectedValue]);
|
||||
expect(vm.value).toBe(expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -86,6 +86,6 @@ describe('VnInput', () => {
|
|||
const focusSpy = vi.spyOn(input.element, 'focus');
|
||||
vm.focus();
|
||||
expect(focusSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,52 +5,71 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
|||
let vm;
|
||||
let wrapper;
|
||||
|
||||
function generateWrapper(date, outlined, required) {
|
||||
function generateWrapper(outlined = false, required = false) {
|
||||
wrapper = createWrapper(VnInputDate, {
|
||||
props: {
|
||||
modelValue: date,
|
||||
modelValue: '2000-12-31T23:00:00.000Z',
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }),
|
||||
},
|
||||
attrs: {
|
||||
isOutlined: outlined,
|
||||
required: required
|
||||
required: required,
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
};
|
||||
}
|
||||
|
||||
describe('VnInputDate', () => {
|
||||
|
||||
describe('formattedDate', () => {
|
||||
it('formats a valid date correctly', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
describe('formattedDate', () => {
|
||||
it('validateAndCleanInput should remove non-numeric characters', async () => {
|
||||
generateWrapper();
|
||||
vm.validateAndCleanInput('10a/1s2/2dd0a23');
|
||||
await vm.$nextTick();
|
||||
expect(vm.formattedDate).toBe('25/12/2023');
|
||||
expect(vm.inputValue).toBe('10/12/2023');
|
||||
});
|
||||
|
||||
it('updates the model value when a new date is set', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('31/12/2023');
|
||||
expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
|
||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||
it('manageDate should reverse the date', async () => {
|
||||
generateWrapper();
|
||||
vm.manageDate('10/12/2023');
|
||||
await vm.$nextTick();
|
||||
expect(vm.inputValue).toBe('2023/12/10');
|
||||
});
|
||||
|
||||
it('should not update the model value when an invalid date is set', async () => {
|
||||
it('formatDate should format the date correctly when a valid date is entered with full year', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('invalid-date');
|
||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||
});
|
||||
await input.setValue('25.12/2002');
|
||||
await vm.$nextTick();
|
||||
await vm.formatDate();
|
||||
expect(vm.model).toBe('2002-12-24T23:00:00.000Z');
|
||||
});
|
||||
|
||||
it('should format the date correctly when a valid date is entered with short year', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('31.12-23');
|
||||
await vm.$nextTick();
|
||||
await vm.formatDate();
|
||||
expect(vm.model).toBe('2023-12-30T23:00:00.000Z');
|
||||
});
|
||||
|
||||
it('should format the date correctly when a valid date is entered without year', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('12.03');
|
||||
await vm.$nextTick();
|
||||
await vm.formatDate();
|
||||
expect(vm.model).toBe('2001-03-11T23:00:00.000Z');
|
||||
});
|
||||
});
|
||||
|
||||
describe('styleAttrs', () => {
|
||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
});
|
||||
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
generateWrapper('2023-12-25', true, false);
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
generateWrapper(true, false);
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs.outlined).toBe(true);
|
||||
});
|
||||
|
@ -58,15 +77,15 @@ describe('VnInputDate', () => {
|
|||
|
||||
describe('required', () => {
|
||||
it('should not applies required class when isRequired is false', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.find('.vn-input-date').classes()).not.toContain('required');
|
||||
});
|
||||
|
||||
|
||||
it('should applies required class when isRequired is true', async () => {
|
||||
generateWrapper('2023-12-25', false, true);
|
||||
generateWrapper(false, true);
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.find('.vn-input-date').classes()).toContain('required');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper.js';
|
||||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import VnInputDateTime from 'components/common/VnInputDateTime.vue';
|
||||
import vnDateBoot from 'src/boot/vnDate';
|
||||
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
||||
beforeAll(() => {
|
||||
// Initialize the vnDate boot
|
||||
vnDateBoot();
|
||||
});
|
||||
function generateWrapper(date, outlined, showEvent) {
|
||||
wrapper = createWrapper(VnInputDateTime, {
|
||||
props: {
|
||||
modelValue: date,
|
||||
isOutlined: outlined,
|
||||
showEvent: showEvent,
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
}
|
||||
|
||||
describe('VnInputDateTime', () => {
|
||||
describe('selectedDate', () => {
|
||||
it('formats a valid datetime correctly', async () => {
|
||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
||||
await vm.$nextTick();
|
||||
expect(vm.selectedDate).toBe('25-12-2023 10:30');
|
||||
});
|
||||
|
||||
it('handles null date value', async () => {
|
||||
generateWrapper(null, false, true);
|
||||
await vm.$nextTick();
|
||||
expect(vm.selectedDate).not.toBe(null);
|
||||
});
|
||||
|
||||
it('updates the model value when a new datetime is set', async () => {
|
||||
vm.selectedDate = '31-12-2023 15:45';
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('styleAttrs', () => {
|
||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
});
|
||||
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
generateWrapper('2023-12-25T10:30:00', true, true);
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs).toEqual({
|
||||
dense: true,
|
||||
outlined: true,
|
||||
rounded: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('component rendering', () => {
|
||||
it('should render date and time icons', async () => {
|
||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
||||
await vm.$nextTick();
|
||||
const icons = wrapper.findAllComponents({ name: 'QIcon' });
|
||||
expect(icons.length).toBe(2);
|
||||
expect(icons[0].props('name')).toBe('today');
|
||||
expect(icons[1].props('name')).toBe('access_time');
|
||||
});
|
||||
|
||||
it('should render popup proxies for date and time', async () => {
|
||||
generateWrapper('2023-12-25T10:30:00', false, true);
|
||||
await vm.$nextTick();
|
||||
const popups = wrapper.findAllComponents({ name: 'QPopupProxy' });
|
||||
expect(popups.length).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -90,8 +90,10 @@ describe('VnLog', () => {
|
|||
|
||||
vm = createWrapper(VnLog, {
|
||||
global: {
|
||||
stubs: [],
|
||||
mocks: {},
|
||||
stubs: ['FetchData', 'vue-i18n'],
|
||||
mocks: {
|
||||
fetch: vi.fn(),
|
||||
},
|
||||
},
|
||||
propsData: {
|
||||
model: 'Claim',
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('VnNotes', () => {
|
|||
) {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||
wrapper = createWrapper(VnNotes, {
|
||||
propsData: options,
|
||||
propsData: { ...defaultOptions, ...options },
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
|
|
|
@ -58,7 +58,8 @@ async function getData() {
|
|||
store.filter = $props.filter ?? {};
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
const { data } = store;
|
||||
state.set($props.dataKey, data);
|
||||
emit('onFetch', data);
|
||||
} finally {
|
||||
|
|
|
@ -89,24 +89,26 @@ function cancel() {
|
|||
<slot name="customHTML"></slot>
|
||||
</QCardSection>
|
||||
<QCardActions align="right">
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
color="primary"
|
||||
:disable="isLoading"
|
||||
flat
|
||||
@click="cancel()"
|
||||
data-cy="VnConfirm_cancel"
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.confirm')"
|
||||
:title="t('globals.confirm')"
|
||||
color="primary"
|
||||
:loading="isLoading"
|
||||
@click="confirm()"
|
||||
unelevated
|
||||
autofocus
|
||||
data-cy="VnConfirm_confirm"
|
||||
/>
|
||||
<slot name="actions" :actions="{ confirm, cancel }">
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
color="primary"
|
||||
:disable="isLoading"
|
||||
flat
|
||||
@click="cancel()"
|
||||
data-cy="VnConfirm_cancel"
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.confirm')"
|
||||
:title="t('globals.confirm')"
|
||||
color="primary"
|
||||
:loading="isLoading"
|
||||
@click="confirm()"
|
||||
unelevated
|
||||
autofocus
|
||||
data-cy="VnConfirm_confirm"
|
||||
/>
|
||||
</slot>
|
||||
</QCardActions>
|
||||
</QCard>
|
||||
</QDialog>
|
||||
|
|
|
@ -212,6 +212,7 @@ const getLocale = (label) => {
|
|||
color="primary"
|
||||
style="position: fixed; z-index: 1; right: 0; bottom: 0"
|
||||
icon="search"
|
||||
data-cy="vnFilterPanel_search"
|
||||
@click="search()"
|
||||
>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
|
@ -229,6 +230,7 @@ const getLocale = (label) => {
|
|||
<QItemSection top side>
|
||||
<QBtn
|
||||
@click="clearFilters"
|
||||
data-cy="clearFilters"
|
||||
color="primary"
|
||||
dense
|
||||
flat
|
||||
|
@ -292,6 +294,7 @@ const getLocale = (label) => {
|
|||
</QList>
|
||||
</QForm>
|
||||
<QInnerLoading
|
||||
data-cy="filterPanel-spinner"
|
||||
:label="t('globals.pleaseWait')"
|
||||
:showing="isLoading"
|
||||
color="primary"
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { useAttrs } from 'vue';
|
||||
|
||||
const attrs = useAttrs();
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps({
|
||||
|
@ -67,7 +69,7 @@ const props = defineProps({
|
|||
default: null,
|
||||
},
|
||||
searchUrl: {
|
||||
type: String,
|
||||
type: [String, Boolean],
|
||||
default: null,
|
||||
},
|
||||
disableInfiniteScroll: {
|
||||
|
@ -75,7 +77,7 @@ const props = defineProps({
|
|||
default: false,
|
||||
},
|
||||
mapKey: {
|
||||
type: String,
|
||||
type: [String, Boolean],
|
||||
default: '',
|
||||
},
|
||||
keyData: {
|
||||
|
|
|
@ -46,7 +46,7 @@ const props = defineProps({
|
|||
default: null,
|
||||
},
|
||||
order: {
|
||||
type: String,
|
||||
type: [String, Array],
|
||||
default: '',
|
||||
},
|
||||
limit: {
|
||||
|
|
|
@ -23,10 +23,15 @@ describe('CardSummary', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
wrapper = createWrapper(CardSummary, {
|
||||
global: {
|
||||
mocks: {
|
||||
validate: vi.fn(),
|
||||
},
|
||||
},
|
||||
propsData: {
|
||||
dataKey: 'cardSummaryKey',
|
||||
url: 'cardSummaryUrl',
|
||||
filter: 'cardFilter',
|
||||
filter: { key: 'cardFilter' },
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
|
@ -50,7 +55,7 @@ describe('CardSummary', () => {
|
|||
|
||||
it('should set correct props to the store', () => {
|
||||
expect(vm.store.url).toEqual('cardSummaryUrl');
|
||||
expect(vm.store.filter).toEqual('cardFilter');
|
||||
expect(vm.store.filter).toEqual({ key: 'cardFilter' });
|
||||
});
|
||||
|
||||
it('should respond to prop changes and refetch data', async () => {
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('VnSearchbar', () => {
|
|||
let wrapper;
|
||||
let applyFilterSpy;
|
||||
const searchText = 'Bolas de madera';
|
||||
const userParams = {staticKey: 'staticValue'};
|
||||
const userParams = { staticKey: 'staticValue' };
|
||||
|
||||
beforeEach(async () => {
|
||||
wrapper = createWrapper(VnSearchbar, {
|
||||
|
@ -23,8 +23,9 @@ describe('VnSearchbar', () => {
|
|||
|
||||
vm.searchText = searchText;
|
||||
vm.arrayData.store.userParams = userParams;
|
||||
applyFilterSpy = vi.spyOn(vm.arrayData, 'applyFilter').mockImplementation(() => {});
|
||||
|
||||
applyFilterSpy = vi
|
||||
.spyOn(vm.arrayData, 'applyFilter')
|
||||
.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -32,7 +33,9 @@ describe('VnSearchbar', () => {
|
|||
});
|
||||
|
||||
it('search resets pagination and applies filter', async () => {
|
||||
const resetPaginationSpy = vi.spyOn(vm.arrayData, 'resetPagination').mockImplementation(() => {});
|
||||
const resetPaginationSpy = vi
|
||||
.spyOn(vm.arrayData, 'resetPagination')
|
||||
.mockImplementation(() => {});
|
||||
await vm.search();
|
||||
|
||||
expect(resetPaginationSpy).toHaveBeenCalled();
|
||||
|
@ -48,7 +51,7 @@ describe('VnSearchbar', () => {
|
|||
|
||||
expect(applyFilterSpy).toHaveBeenCalledWith({
|
||||
params: { staticKey: 'staticValue', search: searchText },
|
||||
filter: {skip: 0},
|
||||
filter: { skip: 0 },
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -68,4 +71,4 @@ describe('VnSearchbar', () => {
|
|||
});
|
||||
expect(vm.to.query.searchParam).toBe(expectedQuery);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import axios from 'axios';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnSms from 'src/components/ui/VnSms.vue';
|
||||
|
||||
|
@ -12,6 +11,9 @@ describe('VnSms', () => {
|
|||
stubs: ['VnPaginate'],
|
||||
mocks: {},
|
||||
},
|
||||
propsData: {
|
||||
url: 'SmsUrl',
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import { useArrayData } from 'composables/useArrayData';
|
|||
import { useRouter } from 'vue-router';
|
||||
import * as vueRouter from 'vue-router';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import { defineComponent, h } from 'vue';
|
||||
import { mount } from '@vue/test-utils';
|
||||
|
||||
describe('useArrayData', () => {
|
||||
const filter = '{"limit":20,"skip":0}';
|
||||
|
@ -43,7 +45,7 @@ describe('useArrayData', () => {
|
|||
it('should fetch and replace url with new params', async () => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValueOnce({ data: [] });
|
||||
|
||||
const arrayData = useArrayData('ArrayData', {
|
||||
const arrayData = mountArrayData('ArrayData', {
|
||||
url: 'mockUrl',
|
||||
searchUrl: 'params',
|
||||
});
|
||||
|
@ -72,7 +74,7 @@ describe('useArrayData', () => {
|
|||
data: [{ id: 1 }],
|
||||
});
|
||||
|
||||
const arrayData = useArrayData('ArrayData', {
|
||||
const arrayData = mountArrayData('ArrayData', {
|
||||
url: 'mockUrl',
|
||||
navigate: {},
|
||||
});
|
||||
|
@ -94,7 +96,7 @@ describe('useArrayData', () => {
|
|||
],
|
||||
});
|
||||
|
||||
const arrayData = useArrayData('ArrayData', {
|
||||
const arrayData = mountArrayData('ArrayData', {
|
||||
url: 'mockUrl',
|
||||
oneRecord: true,
|
||||
});
|
||||
|
@ -107,3 +109,17 @@ describe('useArrayData', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
function mountArrayData(...args) {
|
||||
let arrayData;
|
||||
|
||||
const TestComponent = defineComponent({
|
||||
setup() {
|
||||
arrayData = useArrayData(...args);
|
||||
return () => h('div');
|
||||
},
|
||||
});
|
||||
|
||||
const asd = mount(TestComponent);
|
||||
return arrayData;
|
||||
}
|
||||
|
|
|
@ -64,88 +64,84 @@ describe('session', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe(
|
||||
'login',
|
||||
() => {
|
||||
const expectedUser = {
|
||||
id: 999,
|
||||
name: `T'Challa`,
|
||||
nickname: 'Black Panther',
|
||||
lang: 'en',
|
||||
userConfig: {
|
||||
darkMode: false,
|
||||
describe('login', () => {
|
||||
const expectedUser = {
|
||||
id: 999,
|
||||
name: `T'Challa`,
|
||||
nickname: 'Black Panther',
|
||||
lang: 'en',
|
||||
userConfig: {
|
||||
darkMode: false,
|
||||
},
|
||||
worker: { department: { departmentFk: 155 } },
|
||||
};
|
||||
const rolesData = [
|
||||
{
|
||||
role: {
|
||||
name: 'salesPerson',
|
||||
},
|
||||
worker: { department: { departmentFk: 155 } },
|
||||
};
|
||||
const rolesData = [
|
||||
{
|
||||
role: {
|
||||
name: 'salesPerson',
|
||||
},
|
||||
},
|
||||
{
|
||||
role: {
|
||||
name: 'admin',
|
||||
},
|
||||
{
|
||||
role: {
|
||||
name: 'admin',
|
||||
},
|
||||
},
|
||||
];
|
||||
beforeEach(() => {
|
||||
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||
if (url === 'VnUsers/acls') return Promise.resolve({ data: [] });
|
||||
return Promise.resolve({
|
||||
data: { roles: rolesData, user: expectedUser },
|
||||
});
|
||||
},
|
||||
];
|
||||
beforeEach(() => {
|
||||
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||
if (url === 'VnUsers/acls') return Promise.resolve({ data: [] });
|
||||
return Promise.resolve({
|
||||
data: { roles: rolesData, user: expectedUser },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch the user roles and then set token in the sessionStorage', async () => {
|
||||
const expectedRoles = ['salesPerson', 'admin'];
|
||||
const expectedToken = 'mySessionToken';
|
||||
const expectedTokenMultimedia = 'mySessionTokenMultimedia';
|
||||
const keepLogin = false;
|
||||
it('should fetch the user roles and then set token in the sessionStorage', async () => {
|
||||
const expectedRoles = ['salesPerson', 'admin'];
|
||||
const expectedToken = 'mySessionToken';
|
||||
const expectedTokenMultimedia = 'mySessionTokenMultimedia';
|
||||
const keepLogin = false;
|
||||
|
||||
await session.login({
|
||||
token: expectedToken,
|
||||
tokenMultimedia: expectedTokenMultimedia,
|
||||
keepLogin,
|
||||
});
|
||||
|
||||
const roles = state.getRoles();
|
||||
const localToken = localStorage.getItem('token');
|
||||
const sessionToken = sessionStorage.getItem('token');
|
||||
|
||||
expect(roles.value).toEqual(expectedRoles);
|
||||
expect(localToken).toBeNull();
|
||||
expect(sessionToken).toEqual(expectedToken);
|
||||
|
||||
await session.destroy(); // this clears token and user for any other test
|
||||
await session.login({
|
||||
token: expectedToken,
|
||||
tokenMultimedia: expectedTokenMultimedia,
|
||||
keepLogin,
|
||||
});
|
||||
|
||||
it('should fetch the user roles and then set token in the localStorage', async () => {
|
||||
const expectedRoles = ['salesPerson', 'admin'];
|
||||
const expectedToken = 'myLocalToken';
|
||||
const expectedTokenMultimedia = 'myLocalTokenMultimedia';
|
||||
const keepLogin = true;
|
||||
const roles = state.getRoles();
|
||||
const localToken = localStorage.getItem('token');
|
||||
const sessionToken = sessionStorage.getItem('token');
|
||||
|
||||
await session.login({
|
||||
token: expectedToken,
|
||||
tokenMultimedia: expectedTokenMultimedia,
|
||||
keepLogin,
|
||||
});
|
||||
expect(roles.value).toEqual(expectedRoles);
|
||||
expect(localToken).toBeNull();
|
||||
expect(sessionToken).toEqual(expectedToken);
|
||||
|
||||
const roles = state.getRoles();
|
||||
const localToken = localStorage.getItem('token');
|
||||
const sessionToken = sessionStorage.getItem('token');
|
||||
await session.destroy(); // this clears token and user for any other test
|
||||
});
|
||||
|
||||
expect(roles.value).toEqual(expectedRoles);
|
||||
expect(localToken).toEqual(expectedToken);
|
||||
expect(sessionToken).toBeNull();
|
||||
it('should fetch the user roles and then set token in the localStorage', async () => {
|
||||
const expectedRoles = ['salesPerson', 'admin'];
|
||||
const expectedToken = 'myLocalToken';
|
||||
const expectedTokenMultimedia = 'myLocalTokenMultimedia';
|
||||
const keepLogin = true;
|
||||
|
||||
await session.destroy(); // this clears token and user for any other test
|
||||
await session.login({
|
||||
token: expectedToken,
|
||||
tokenMultimedia: expectedTokenMultimedia,
|
||||
keepLogin,
|
||||
});
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
const roles = state.getRoles();
|
||||
const localToken = localStorage.getItem('token');
|
||||
const sessionToken = sessionStorage.getItem('token');
|
||||
|
||||
expect(roles.value).toEqual(expectedRoles);
|
||||
expect(localToken).toEqual(expectedToken);
|
||||
expect(sessionToken).toBeNull();
|
||||
|
||||
await session.destroy(); // this clears token and user for any other test
|
||||
});
|
||||
});
|
||||
|
||||
describe('RenewToken', () => {
|
||||
const expectedToken = 'myToken';
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import { ref } from 'vue';
|
||||
import moment from 'moment';
|
||||
|
||||
export default function useWeekdaysOrder() {
|
||||
|
||||
const firstDay = moment().weekday(1).day();
|
||||
const weekdays = [...Array(7).keys()].map(i => (i + firstDay) % 7);
|
||||
|
||||
return ref(weekdays);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { onMounted, computed } from 'vue';
|
||||
import { onMounted, computed, ref } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { useArrayDataStore } from 'stores/useArrayDataStore';
|
||||
|
@ -346,7 +346,7 @@ export function useArrayData(key, userOptions) {
|
|||
}
|
||||
|
||||
const totalRows = computed(() => (store.data && store.data.length) || 0);
|
||||
const isLoading = computed(() => store.isLoading || false);
|
||||
const isLoading = ref(store.isLoading || false);
|
||||
|
||||
return {
|
||||
fetch,
|
||||
|
|
|
@ -343,3 +343,20 @@ input::-webkit-inner-spin-button {
|
|||
.q-item__section--main ~ .q-item__section--side {
|
||||
padding-inline: 0;
|
||||
}
|
||||
|
||||
.calendars-header {
|
||||
height: 45px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: $primary;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.calendars-container {
|
||||
max-width: 800px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-evenly;
|
||||
}
|
|
@ -6,6 +6,7 @@ globals:
|
|||
quantity: Quantity
|
||||
entity: Entity
|
||||
preview: Preview
|
||||
scrollToTop: Go up
|
||||
user: User
|
||||
details: Details
|
||||
collapseMenu: Collapse lateral menu
|
||||
|
@ -19,6 +20,7 @@ globals:
|
|||
logOut: Log out
|
||||
date: Date
|
||||
dataSaved: Data saved
|
||||
openDetail: Open detail
|
||||
dataDeleted: Data deleted
|
||||
delete: Delete
|
||||
search: Search
|
||||
|
@ -160,6 +162,9 @@ globals:
|
|||
department: Department
|
||||
noData: No data available
|
||||
vehicle: Vehicle
|
||||
selectDocumentId: Select document id
|
||||
document: Document
|
||||
import: Import from existing
|
||||
pageTitles:
|
||||
logIn: Login
|
||||
addressEdit: Update address
|
||||
|
@ -341,6 +346,7 @@ globals:
|
|||
parking: Parking
|
||||
vehicleList: Vehicles
|
||||
vehicle: Vehicle
|
||||
entryPreAccount: Pre-account
|
||||
unsavedPopup:
|
||||
title: Unsaved changes will be lost
|
||||
subtitle: Are you sure exit without saving?
|
||||
|
|
|
@ -6,6 +6,7 @@ globals:
|
|||
quantity: Cantidad
|
||||
entity: Entidad
|
||||
preview: Vista previa
|
||||
scrollToTop: Ir arriba
|
||||
user: Usuario
|
||||
details: Detalles
|
||||
collapseMenu: Contraer menú lateral
|
||||
|
@ -20,10 +21,11 @@ globals:
|
|||
date: Fecha
|
||||
dataSaved: Datos guardados
|
||||
dataDeleted: Datos eliminados
|
||||
dataCreated: Datos creados
|
||||
openDetail: Ver detalle
|
||||
delete: Eliminar
|
||||
search: Buscar
|
||||
changes: Cambios
|
||||
dataCreated: Datos creados
|
||||
add: Añadir
|
||||
create: Crear
|
||||
edit: Modificar
|
||||
|
@ -164,6 +166,9 @@ globals:
|
|||
noData: Datos no disponibles
|
||||
department: Departamento
|
||||
vehicle: Vehículo
|
||||
selectDocumentId: Seleccione el id de gestión documental
|
||||
document: Documento
|
||||
import: Importar desde existente
|
||||
pageTitles:
|
||||
logIn: Inicio de sesión
|
||||
addressEdit: Modificar consignatario
|
||||
|
@ -344,6 +349,7 @@ globals:
|
|||
parking: Parking
|
||||
vehicleList: Vehículos
|
||||
vehicle: Vehículo
|
||||
entryPreAccount: Precontabilizar
|
||||
unsavedPopup:
|
||||
title: Los cambios que no haya guardado se perderán
|
||||
subtitle: ¿Seguro que quiere salir sin guardar?
|
||||
|
|
|
@ -23,7 +23,7 @@ const claimDms = ref([
|
|||
]);
|
||||
const client = ref({});
|
||||
const inputFile = ref();
|
||||
const files = ref({});
|
||||
const files = ref([]);
|
||||
const spinnerRef = ref();
|
||||
const claimDmsRef = ref();
|
||||
const dmsType = ref({});
|
||||
|
@ -255,9 +255,8 @@ function onDrag() {
|
|||
icon="add"
|
||||
color="primary"
|
||||
>
|
||||
<QInput
|
||||
<QFile
|
||||
ref="inputFile"
|
||||
type="file"
|
||||
style="display: none"
|
||||
multiple
|
||||
v-model="files"
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('ClaimLines', () => {
|
|||
expectedData,
|
||||
{
|
||||
signal: canceller.signal,
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -69,7 +69,7 @@ describe('ClaimLines', () => {
|
|||
expect.objectContaining({
|
||||
message: 'Discount updated',
|
||||
type: 'positive',
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,6 +14,9 @@ describe('ClaimLinesImport', () => {
|
|||
fetch: vi.fn(),
|
||||
},
|
||||
},
|
||||
propsData: {
|
||||
ticketId: 1,
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
|
@ -40,7 +43,7 @@ describe('ClaimLinesImport', () => {
|
|||
expect.objectContaining({
|
||||
message: 'Lines added to claim',
|
||||
type: 'positive',
|
||||
})
|
||||
}),
|
||||
);
|
||||
expect(vm.canceller).toEqual(null);
|
||||
});
|
||||
|
|
|
@ -41,10 +41,10 @@ describe('ClaimPhoto', () => {
|
|||
await vm.deleteDms({ index: 0 });
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(
|
||||
`ClaimDms/${claimMock.claimDms[0].dmsFk}/removeFile`
|
||||
`ClaimDms/${claimMock.claimDms[0].dmsFk}/removeFile`,
|
||||
);
|
||||
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ type: 'positive' })
|
||||
expect.objectContaining({ type: 'positive' }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ describe('ClaimPhoto', () => {
|
|||
data: { index: 1 },
|
||||
promise: vm.deleteDms,
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -102,10 +102,10 @@ describe('ClaimPhoto', () => {
|
|||
new FormData(),
|
||||
expect.objectContaining({
|
||||
params: expect.objectContaining({ hasFile: false }),
|
||||
})
|
||||
}),
|
||||
);
|
||||
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ type: 'positive' })
|
||||
expect.objectContaining({ type: 'positive' }),
|
||||
);
|
||||
|
||||
expect(vm.claimDmsRef.fetch).toHaveBeenCalledOnce();
|
||||
|
|
|
@ -77,10 +77,10 @@ const isDefaultAddress = (address) => {
|
|||
return client?.value?.defaultAddressFk === address.id ? 1 : 0;
|
||||
};
|
||||
|
||||
const setDefault = (address) => {
|
||||
const setDefault = async (address) => {
|
||||
const url = `Clients/${route.params.id}`;
|
||||
const payload = { defaultAddressFk: address.id };
|
||||
axios.patch(url, payload).then((res) => {
|
||||
await axios.patch(url, payload).then((res) => {
|
||||
if (res.data) {
|
||||
client.value.defaultAddressFk = res.data.defaultAddressFk;
|
||||
sortAddresses();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
|
@ -7,29 +6,15 @@ import FormModel from 'components/FormModel.vue';
|
|||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
|
||||
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
|
||||
import VnInputBic from 'src/components/common/VnInputBic.vue';
|
||||
import VnBankDetailsForm from 'src/components/common/VnBankDetailsForm.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const bankEntitiesRef = ref(null);
|
||||
|
||||
const filter = {
|
||||
fields: ['id', 'bic', 'name'],
|
||||
order: 'bic ASC',
|
||||
};
|
||||
|
||||
const getBankEntities = (data, formData) => {
|
||||
bankEntitiesRef.value.fetch();
|
||||
formData.bankEntityFk = Number(data.id);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="Customer">
|
||||
<template #form="{ data, validate }">
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
auto-load
|
||||
|
@ -42,42 +27,19 @@ const getBankEntities = (data, formData) => {
|
|||
/>
|
||||
<VnInput :label="t('Due day')" clearable v-model="data.dueDay" />
|
||||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
<VnInputBic
|
||||
:label="t('IBAN')"
|
||||
v-model="data.iban"
|
||||
@update-bic="(bankEntityFk) => (data.bankEntityFk = bankEntityFk)"
|
||||
<VnBankDetailsForm
|
||||
v-model:iban="data.iban"
|
||||
v-model:bankEntityFk="data.bankEntityFk"
|
||||
@update-bic="
|
||||
({ iban, bankEntityFk }) => {
|
||||
if (!iban || !bankEntityFk) return;
|
||||
data.iban = iban;
|
||||
data.bankEntityFk = bankEntityFk;
|
||||
}
|
||||
"
|
||||
/>
|
||||
<VnSelectDialog
|
||||
:label="t('Swift / BIC')"
|
||||
ref="bankEntitiesRef"
|
||||
:filter="filter"
|
||||
auto-load
|
||||
url="BankEntities"
|
||||
:acls="[{ model: 'BankEntity', props: '*', accessType: 'WRITE' }]"
|
||||
:rules="validate('Worker.bankEntity')"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="data.bankEntityFk"
|
||||
>
|
||||
<template #form>
|
||||
<CreateBankEntityForm
|
||||
@on-data-saved="getBankEntities($event, data)"
|
||||
/>
|
||||
</template>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection v-if="scope.opt">
|
||||
<QItemLabel>{{ scope.opt.bic }} </QItemLabel>
|
||||
<QItemLabel caption> {{ scope.opt.name }}</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelectDialog>
|
||||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
<QCheckbox :label="t('Received LCR')" v-model="data.hasLcr" />
|
||||
<QCheckbox :label="t('VNL core received')" v-model="data.hasCoreVnl" />
|
||||
|
|
|
@ -39,7 +39,7 @@ const route = useRoute();
|
|||
const { t } = useI18n();
|
||||
|
||||
const entityId = computed(() => {
|
||||
return $props.id || route.params.id;
|
||||
return Number($props.id || route.params.id);
|
||||
});
|
||||
|
||||
const data = ref(useCardDescription());
|
||||
|
|
|
@ -11,7 +11,7 @@ const $props = defineProps({
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<QPopupProxy>
|
||||
<QPopupProxy data-cy="CustomerDescriptor">
|
||||
<CustomerDescriptor v-if="$props.id" :id="$props.id" :summary="CustomerSummary" />
|
||||
</QPopupProxy>
|
||||
</template>
|
||||
|
|
|
@ -86,7 +86,7 @@ async function acceptPropagate({ isEqualizated }) {
|
|||
:required="true"
|
||||
:rules="validate('client.socialName')"
|
||||
clearable
|
||||
uppercase="true"
|
||||
:uppercase="true"
|
||||
v-model="data.socialName"
|
||||
>
|
||||
<template #append>
|
||||
|
|
|
@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
|
|||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { QBtn, useQuasar } from 'quasar';
|
||||
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import { toDateTimeFormat } from 'src/filters/date';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
|
@ -74,12 +73,11 @@ const tableRef = ref();
|
|||
<template>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="ClientSamples"
|
||||
data-key="CustomerSamples"
|
||||
auto-load
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
url="ClientSamples"
|
||||
:columns="columns"
|
||||
:pagination="{ rowsPerPage: 12 }"
|
||||
:disable-option="{ card: true }"
|
||||
:right-search="false"
|
||||
:rows="rows"
|
||||
|
|
|
@ -25,7 +25,7 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const entityId = computed(() => Number($props.id || route.params.id));
|
||||
const customer = computed(() => summary.value.entity);
|
||||
const summary = ref();
|
||||
const defaulterAmount = computed(() => customer.value.defaulters[0]?.amount);
|
||||
|
|
|
@ -72,7 +72,7 @@ const exprBuilder = (param, value) => {
|
|||
option-value="id"
|
||||
option-label="name"
|
||||
url="Departments"
|
||||
no-one="true"
|
||||
:no-one="true"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
|
|
@ -100,6 +100,9 @@ const columns = computed(() => [
|
|||
'row-key': 'id',
|
||||
selection: 'multiple',
|
||||
}"
|
||||
:multi-check="{
|
||||
expand: true,
|
||||
}"
|
||||
v-model:selected="selected"
|
||||
:right-search="true"
|
||||
:columns="columns"
|
||||
|
|
|
@ -98,7 +98,9 @@ onMounted(async () => {
|
|||
<QBtn color="primary" icon="show_chart" :disable="!selectedRows">
|
||||
<QPopupProxy ref="popupProxyRef">
|
||||
<QCard class="column q-pa-md">
|
||||
<span class="text-body1 q-mb-sm">{{ t('Campaign consumption') }}</span>
|
||||
<span class="text-body1 q-mb-sm">{{
|
||||
t('Campaign consumption', { rows: $props.clients.length })
|
||||
}}</span>
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
:options="moreFields"
|
||||
|
@ -140,12 +142,13 @@ onMounted(async () => {
|
|||
valentinesDay: Valentine's Day
|
||||
mothersDay: Mother's Day
|
||||
allSaints: All Saints' Day
|
||||
Campaign consumption: Campaign consumption ({rows})
|
||||
es:
|
||||
params:
|
||||
valentinesDay: Día de San Valentín
|
||||
mothersDay: Día de la Madre
|
||||
allSaints: Día de Todos los Santos
|
||||
Campaign consumption: Consumo campaña
|
||||
Campaign consumption: Consumo campaña ({rows})
|
||||
Campaign: Campaña
|
||||
From: Desde
|
||||
To: Hasta
|
||||
|
|
|
@ -32,7 +32,7 @@ describe('CustomerPayments', () => {
|
|||
expect.objectContaining({
|
||||
message: 'Payment confirmed',
|
||||
type: 'positive',
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,7 +41,6 @@ const sampleType = ref({ hasPreview: false });
|
|||
const initialData = reactive({});
|
||||
const entityId = computed(() => route.params.id);
|
||||
const customer = computed(() => useArrayData('Customer').store?.data);
|
||||
const filterEmailUsers = { where: { userFk: user.value.id } };
|
||||
const filterClientsAddresses = {
|
||||
include: [
|
||||
{ relation: 'province', scope: { fields: ['name'] } },
|
||||
|
@ -73,7 +72,7 @@ onBeforeMount(async () => {
|
|||
|
||||
const setEmailUser = (data) => {
|
||||
optionsEmailUsers.value = data;
|
||||
initialData.replyTo = data[0]?.email;
|
||||
initialData.replyTo = data[0]?.notificationEmail;
|
||||
};
|
||||
|
||||
const setClientsAddresses = (data) => {
|
||||
|
@ -182,10 +181,12 @@ const toCustomerSamples = () => {
|
|||
|
||||
<template>
|
||||
<FetchData
|
||||
:filter="filterEmailUsers"
|
||||
:filter="{
|
||||
where: { id: customer.departmentFk },
|
||||
}"
|
||||
@on-fetch="setEmailUser"
|
||||
auto-load
|
||||
url="EmailUsers"
|
||||
url="Departments"
|
||||
/>
|
||||
<FetchData
|
||||
:filter="filterClientsAddresses"
|
||||
|
|
|
@ -162,6 +162,9 @@ const entryFilterPanel = ref();
|
|||
v-model="params.warehouseOutFk"
|
||||
@update:model-value="searchFn()"
|
||||
url="Warehouses"
|
||||
:where="{
|
||||
isOrigin: true,
|
||||
}"
|
||||
:fields="['id', 'name']"
|
||||
sort-by="name ASC"
|
||||
hide-selected
|
||||
|
@ -177,6 +180,9 @@ const entryFilterPanel = ref();
|
|||
v-model="params.warehouseInFk"
|
||||
@update:model-value="searchFn()"
|
||||
url="Warehouses"
|
||||
:where="{
|
||||
isDestiny: true,
|
||||
}"
|
||||
:fields="['id', 'name']"
|
||||
sort-by="name ASC"
|
||||
hide-selected
|
||||
|
|
|
@ -0,0 +1,478 @@
|
|||
<script setup>
|
||||
import { ref, computed, markRaw, useTemplateRef, onBeforeMount, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { toDate, toCurrency } from 'src/filters';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
|
||||
import EntryDescriptorProxy from './Card/EntryDescriptorProxy.vue';
|
||||
import SupplierDescriptorProxy from '../Supplier/Card/SupplierDescriptorProxy.vue';
|
||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
import VnDms from 'src/components/common/VnDms.vue';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useQuasar } from 'quasar';
|
||||
import InvoiceInDescriptorProxy from '../InvoiceIn/Card/InvoiceInDescriptorProxy.vue';
|
||||
import { useStateStore } from 'src/stores/useStateStore';
|
||||
import { downloadFile } from 'src/composables/downloadFile';
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const { notify } = useNotify();
|
||||
const user = useState().getUser();
|
||||
const stateStore = useStateStore();
|
||||
const updateDialog = ref();
|
||||
const uploadDialog = ref();
|
||||
let maxDays;
|
||||
let defaultDays;
|
||||
const dataKey = 'entryPreaccountingFilter';
|
||||
const url = 'Entries/preAccountingFilter';
|
||||
const arrayData = useArrayData(dataKey);
|
||||
const daysAgo = ref();
|
||||
const isBooked = ref();
|
||||
const dmsData = ref();
|
||||
const table = useTemplateRef('table');
|
||||
const companies = ref([]);
|
||||
const countries = ref([]);
|
||||
const entryTypes = ref([]);
|
||||
const supplierFiscalTypes = ref([]);
|
||||
const warehouses = ref([]);
|
||||
const defaultDmsDescription = ref();
|
||||
const dmsTypeId = ref();
|
||||
const selectedRows = ref([]);
|
||||
const totalAmount = ref();
|
||||
const totalSelectedAmount = computed(() => {
|
||||
if (!selectedRows.value.length) return 0;
|
||||
return selectedRows.value.reduce((acc, entry) => acc + entry.amount, 0);
|
||||
});
|
||||
let supplierRef;
|
||||
let dmsFk;
|
||||
const columns = computed(() => [
|
||||
{
|
||||
name: 'id',
|
||||
label: t('entry.preAccount.id'),
|
||||
isId: true,
|
||||
chip: {
|
||||
condition: () => true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'invoiceNumber',
|
||||
label: t('entry.preAccount.invoiceNumber'),
|
||||
},
|
||||
{
|
||||
name: 'company',
|
||||
label: t('globals.company'),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
name: 'companyFk',
|
||||
optionLabel: 'code',
|
||||
options: companies.value,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'warehouse',
|
||||
label: t('globals.warehouse'),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
name: 'warehouseInFk',
|
||||
options: warehouses.value,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'gestDocFk',
|
||||
label: t('entry.preAccount.gestDocFk'),
|
||||
},
|
||||
{
|
||||
name: 'dmsType',
|
||||
label: t('entry.preAccount.dmsType'),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
label: null,
|
||||
name: 'dmsTypeFk',
|
||||
url: 'DmsTypes',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'reference',
|
||||
label: t('entry.preAccount.reference'),
|
||||
},
|
||||
{
|
||||
name: 'shipped',
|
||||
label: t('entry.preAccount.shipped'),
|
||||
format: ({ shipped }, dashIfEmpty) => dashIfEmpty(toDate(shipped)),
|
||||
columnFilter: {
|
||||
component: 'date',
|
||||
name: 'shipped',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'landed',
|
||||
label: t('entry.preAccount.landed'),
|
||||
format: ({ landed }, dashIfEmpty) => dashIfEmpty(toDate(landed)),
|
||||
columnFilter: {
|
||||
component: 'date',
|
||||
name: 'landed',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'invoiceInFk',
|
||||
label: t('entry.preAccount.invoiceInFk'),
|
||||
},
|
||||
{
|
||||
name: 'supplier',
|
||||
label: t('globals.supplier'),
|
||||
format: (row) => row.supplier,
|
||||
columnFilter: {
|
||||
component: markRaw(VnSelectSupplier),
|
||||
label: null,
|
||||
name: 'supplierFk',
|
||||
class: 'fit',
|
||||
event: 'update',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'country',
|
||||
label: t('globals.country'),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
name: 'countryFk',
|
||||
options: countries.value,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: t('entry.preAccount.entryType'),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
label: null,
|
||||
name: 'typeFk',
|
||||
options: entryTypes.value,
|
||||
optionLabel: 'description',
|
||||
optionValue: 'code',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'payDem',
|
||||
label: t('entry.preAccount.payDem'),
|
||||
columnFilter: {
|
||||
component: 'number',
|
||||
name: 'payDem',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'fiscalCode',
|
||||
label: t('entry.preAccount.fiscalCode'),
|
||||
format: ({ fiscalCode }) => t(fiscalCode),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
name: 'fiscalCode',
|
||||
options: supplierFiscalTypes.value,
|
||||
optionLabel: 'locale',
|
||||
optionValue: 'code',
|
||||
sortBy: 'code',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'amount',
|
||||
label: t('globals.amount'),
|
||||
format: ({ amount }) => toCurrency(amount),
|
||||
columnFilter: {
|
||||
component: 'number',
|
||||
name: 'amount',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'isAgricultural',
|
||||
label: t('entry.preAccount.isAgricultural'),
|
||||
component: 'checkbox',
|
||||
isEditable: false,
|
||||
},
|
||||
{
|
||||
name: 'isBooked',
|
||||
label: t('entry.preAccount.isBooked'),
|
||||
component: 'checkbox',
|
||||
},
|
||||
{
|
||||
name: 'isReceived',
|
||||
label: t('entry.preAccount.isReceived'),
|
||||
component: 'checkbox',
|
||||
isEditable: false,
|
||||
},
|
||||
]);
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const { data } = await axios.get('EntryConfigs/findOne', {
|
||||
params: { filter: JSON.stringify({ fields: ['maxDays', 'defaultDays'] }) },
|
||||
});
|
||||
maxDays = data.maxDays;
|
||||
defaultDays = data.defaultDays;
|
||||
daysAgo.value = arrayData.store.userParams.daysAgo || defaultDays;
|
||||
isBooked.value = arrayData.store.userParams.isBooked || false;
|
||||
stateStore.leftDrawer = false;
|
||||
});
|
||||
|
||||
watch(selectedRows, (nVal, oVal) => {
|
||||
const lastRow = nVal.at(-1);
|
||||
if (lastRow?.isBooked) selectedRows.value.pop();
|
||||
if (nVal.length > oVal.length && lastRow.invoiceInFk)
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: { title: t('entry.preAccount.hasInvoice') },
|
||||
});
|
||||
});
|
||||
|
||||
function filterByDaysAgo(val) {
|
||||
if (!val) val = defaultDays;
|
||||
else if (val > maxDays) val = maxDays;
|
||||
daysAgo.value = val;
|
||||
arrayData.store.userParams.daysAgo = daysAgo.value;
|
||||
table.value.reload();
|
||||
}
|
||||
|
||||
async function preAccount() {
|
||||
const entries = selectedRows.value;
|
||||
const { companyFk, isAgricultural, landed } = entries.at(0);
|
||||
try {
|
||||
dmsFk = entries.find(({ gestDocFk }) => gestDocFk)?.gestDocFk;
|
||||
if (isAgricultural) {
|
||||
const year = new Date(landed).getFullYear();
|
||||
supplierRef = (
|
||||
await axios.get('InvoiceIns/getMaxRef', { params: { companyFk, year } })
|
||||
).data;
|
||||
return createInvoice();
|
||||
} else if (dmsFk) {
|
||||
supplierRef = (
|
||||
await axios.get(`Dms/${dmsFk}`, {
|
||||
params: { filter: JSON.stringify({ fields: ['reference'] }) },
|
||||
})
|
||||
).data?.reference;
|
||||
updateDialog.value.show();
|
||||
} else {
|
||||
uploadFile();
|
||||
}
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
async function updateFile() {
|
||||
await axios.post(`Dms/${dmsFk}/updateFile`, { dmsTypeId: dmsTypeId.value });
|
||||
await createInvoice();
|
||||
}
|
||||
|
||||
async function uploadFile() {
|
||||
const firstSelectedEntry = selectedRows.value.at(0);
|
||||
const { supplier, companyFk, invoiceNumber } = firstSelectedEntry;
|
||||
dmsData.value = {
|
||||
dmsTypeFk: dmsTypeId.value,
|
||||
warehouseFk: user.value.warehouseFk,
|
||||
companyFk: companyFk,
|
||||
description: supplier + defaultDmsDescription.value + invoiceNumber,
|
||||
hasFile: false,
|
||||
};
|
||||
uploadDialog.value.show();
|
||||
}
|
||||
|
||||
async function afterUploadFile({ reference }, res) {
|
||||
supplierRef = reference;
|
||||
dmsFk = res.data[0].id;
|
||||
await createInvoice();
|
||||
}
|
||||
|
||||
async function createInvoice() {
|
||||
try {
|
||||
await axios.post(`Entries/addInvoiceIn`, {
|
||||
ids: selectedRows.value.map((entry) => entry.id),
|
||||
supplierRef,
|
||||
dmsFk,
|
||||
});
|
||||
notify(t('entry.preAccount.success'), 'positive');
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
supplierRef = null;
|
||||
dmsFk = undefined;
|
||||
selectedRows.value.length = 0;
|
||||
table.value.reload();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
url="Countries"
|
||||
:filter="{ fields: ['id', 'name'] }"
|
||||
@on-fetch="(data) => (countries = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="Companies"
|
||||
:filter="{ fields: ['id', 'code'] }"
|
||||
@on-fetch="(data) => (companies = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="Warehouses"
|
||||
:filter="{ fields: ['id', 'name'] }"
|
||||
@on-fetch="(data) => (warehouses = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="EntryTypes"
|
||||
:filter="{ fields: ['code', 'description'] }"
|
||||
@on-fetch="(data) => (entryTypes = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="supplierFiscalTypes"
|
||||
:filter="{ fields: ['code'] }"
|
||||
@on-fetch="
|
||||
(data) =>
|
||||
(supplierFiscalTypes = data.map((x) => ({ locale: t(x.code), ...x })))
|
||||
"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="InvoiceInConfigs/findOne"
|
||||
:filter="{ fields: ['defaultDmsDescription'] }"
|
||||
@on-fetch="(data) => (defaultDmsDescription = data?.defaultDmsDescription)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="DmsTypes/findOne"
|
||||
:filter="{ fields: ['id'] }"
|
||||
:where="{ code: 'invoiceIn' }"
|
||||
@on-fetch="(data) => (dmsTypeId = data?.id)"
|
||||
auto-load
|
||||
/>
|
||||
<VnSearchbar
|
||||
:data-key
|
||||
:url
|
||||
:label="t('entry.preAccount.search')"
|
||||
:info="t('entry.preAccount.searchInfo')"
|
||||
:search-remove-params="false"
|
||||
/>
|
||||
<VnTable
|
||||
v-model:selected="selectedRows"
|
||||
:data-key
|
||||
:columns
|
||||
:url
|
||||
:search-url="dataKey"
|
||||
ref="table"
|
||||
:disable-option="{ card: true }"
|
||||
redirect="Entry"
|
||||
:order="['landed DESC']"
|
||||
:right-search="false"
|
||||
:user-params="{ daysAgo, isBooked }"
|
||||
:row-click="false"
|
||||
:table="{ selection: 'multiple' }"
|
||||
:limit="0"
|
||||
:footer="true"
|
||||
@on-fetch="
|
||||
(data) => (totalAmount = data?.reduce((acc, entry) => acc + entry.amount, 0))
|
||||
"
|
||||
auto-load
|
||||
>
|
||||
<template #top-left>
|
||||
<QBtn
|
||||
data-cy="preAccount_btn"
|
||||
icon="account_balance"
|
||||
color="primary"
|
||||
class="q-mr-sm"
|
||||
:disable="!selectedRows.length"
|
||||
@click="preAccount"
|
||||
>
|
||||
<QTooltip>{{ t('entry.preAccount.btn') }}</QTooltip>
|
||||
</QBtn>
|
||||
<VnInputNumber
|
||||
v-model="daysAgo"
|
||||
:label="$t('globals.daysAgo')"
|
||||
dense
|
||||
:step="1"
|
||||
:decimal-places="0"
|
||||
@update:model-value="filterByDaysAgo"
|
||||
debounce="500"
|
||||
:title="t('entry.preAccount.daysAgo')"
|
||||
/>
|
||||
</template>
|
||||
<template #column-id="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.id }}
|
||||
<EntryDescriptorProxy :id="row.id" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-company="{ row }">
|
||||
<QBadge :color="row.color ?? 'transparent'" :label="row.company" />
|
||||
</template>
|
||||
<template #column-gestDocFk="{ row }">
|
||||
<span class="link" @click.stop="downloadFile(row.gestDocFk)">
|
||||
{{ row.gestDocFk }}
|
||||
</span>
|
||||
</template>
|
||||
<template #column-supplier="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.supplier }}
|
||||
<SupplierDescriptorProxy :id="row.supplierFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-invoiceInFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.invoiceInFk }}
|
||||
<InvoiceInDescriptorProxy :id="row.invoiceInFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-footer-amount>
|
||||
<div v-text="toCurrency(totalSelectedAmount)" />
|
||||
<div v-text="toCurrency(totalAmount)" />
|
||||
</template>
|
||||
</VnTable>
|
||||
<VnConfirm
|
||||
ref="updateDialog"
|
||||
:title="t('entry.preAccount.dialog.title')"
|
||||
:message="t('entry.preAccount.dialog.message')"
|
||||
>
|
||||
<template #actions>
|
||||
<QBtn
|
||||
data-cy="updateFileYes"
|
||||
:label="t('globals.yes')"
|
||||
color="primary"
|
||||
@click="updateFile"
|
||||
autofocus
|
||||
v-close-popup
|
||||
/>
|
||||
<QBtn
|
||||
data-cy="updateFileNo"
|
||||
:label="t('globals.no')"
|
||||
color="primary"
|
||||
flat
|
||||
@click="uploadFile"
|
||||
v-close-popup
|
||||
/>
|
||||
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
|
||||
</template>
|
||||
</VnConfirm>
|
||||
<QDialog ref="uploadDialog">
|
||||
<VnDms
|
||||
model="dms"
|
||||
:form-initial-data="dmsData"
|
||||
url="Dms/uploadFile"
|
||||
@on-data-saved="afterUploadFile"
|
||||
/>
|
||||
</QDialog>
|
||||
</template>
|
||||
<i18n>
|
||||
en:
|
||||
IntraCommunity: Intra-community
|
||||
NonCommunity: Non-community
|
||||
CanaryIslands: Canary Islands
|
||||
es:
|
||||
IntraCommunity: Intracomunitaria
|
||||
NonCommunity: Extracomunitaria
|
||||
CanaryIslands: Islas Canarias
|
||||
National: Nacional
|
||||
</i18n>
|
|
@ -0,0 +1,63 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import EntryPreAccount from '../EntryPreAccount.vue';
|
||||
import axios from 'axios';
|
||||
|
||||
describe('EntryPreAccount', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||
if (url == 'EntryConfigs/findOne')
|
||||
return { data: { maxDays: 90, defaultDays: 30 } };
|
||||
return { data: [] };
|
||||
});
|
||||
wrapper = createWrapper(EntryPreAccount);
|
||||
vm = wrapper.vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('filterByDaysAgo()', () => {
|
||||
it('should set daysAgo to defaultDays if no value is provided', () => {
|
||||
vm.filterByDaysAgo();
|
||||
expect(vm.daysAgo).toBe(vm.defaultDays);
|
||||
expect(vm.arrayData.store.userParams.daysAgo).toBe(vm.defaultDays);
|
||||
});
|
||||
|
||||
it('should set daysAgo to maxDays if the value exceeds maxDays', () => {
|
||||
vm.filterByDaysAgo(500);
|
||||
expect(vm.daysAgo).toBe(vm.maxDays);
|
||||
expect(vm.arrayData.store.userParams.daysAgo).toBe(vm.maxDays);
|
||||
});
|
||||
|
||||
it('should set daysAgo to the provided value if it is valid', () => {
|
||||
vm.filterByDaysAgo(30);
|
||||
expect(vm.daysAgo).toBe(30);
|
||||
expect(vm.arrayData.store.userParams.daysAgo).toBe(30);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dialog behavior when adding a new row', () => {
|
||||
it('should open the dialog if the new row has invoiceInFk', async () => {
|
||||
const dialogSpy = vi.spyOn(vm.quasar, 'dialog');
|
||||
const selectedRows = [{ id: 1, invoiceInFk: 123 }];
|
||||
vm.selectedRows = selectedRows;
|
||||
await vm.$nextTick();
|
||||
expect(dialogSpy).toHaveBeenCalledWith({
|
||||
component: vm.VnConfirm,
|
||||
componentProps: { title: vm.t('entry.preAccount.hasInvoice') },
|
||||
});
|
||||
});
|
||||
|
||||
it('should not open the dialog if the new row does not have invoiceInFk', async () => {
|
||||
const dialogSpy = vi.spyOn(vm.quasar, 'dialog');
|
||||
vm.selectedRows = [{ id: 1, invoiceInFk: null }];
|
||||
await vm.$nextTick();
|
||||
expect(dialogSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -118,6 +118,33 @@ entry:
|
|||
searchInfo: You can search by entry reference
|
||||
descriptorMenu:
|
||||
showEntryReport: Show entry report
|
||||
preAccount:
|
||||
gestDocFk: Gestdoc
|
||||
dmsType: Gestdoc type
|
||||
invoiceNumber: Entry ref.
|
||||
reference: Gestdoc ref.
|
||||
shipped: Shipped
|
||||
landed: Landed
|
||||
id: Entry
|
||||
invoiceInFk: Invoice in
|
||||
supplierFk: Supplier
|
||||
country: Country
|
||||
description: Entry type
|
||||
payDem: Payment term
|
||||
isBooked: B
|
||||
isReceived: R
|
||||
entryType: Entry type
|
||||
isAgricultural: Agricultural
|
||||
fiscalCode: Account type
|
||||
daysAgo: Max 365 days
|
||||
search: Search
|
||||
searchInfo: You can search by supplier name or nickname
|
||||
btn: Pre-account
|
||||
hasInvoice: This entry has already an invoice in
|
||||
success: It has been successfully pre-accounted
|
||||
dialog:
|
||||
title: Pre-account entries
|
||||
message: Do you want the invoice to inherit the entry document?
|
||||
entryFilter:
|
||||
params:
|
||||
isExcludedFromAvailable: Excluded from available
|
||||
|
|
|
@ -69,6 +69,33 @@ entry:
|
|||
observationType: Tipo de observación
|
||||
search: Buscar entradas
|
||||
searchInfo: Puedes buscar por referencia de entrada
|
||||
preAccount:
|
||||
gestDocFk: Gestdoc
|
||||
dmsType: Tipo gestdoc
|
||||
invoiceNumber: Ref. Entrada
|
||||
reference: Ref. GestDoc
|
||||
shipped: F. envío
|
||||
landed: F. llegada
|
||||
id: Entrada
|
||||
invoiceInFk: Recibida
|
||||
supplierFk: Proveedor
|
||||
country: País
|
||||
description: Tipo de Entrada
|
||||
payDem: Plazo de pago
|
||||
isBooked: C
|
||||
isReceived: R
|
||||
entryType: Tipo de entrada
|
||||
isAgricultural: Agricultural
|
||||
fiscalCode: Tipo de cuenta
|
||||
daysAgo: Máximo 365 días
|
||||
search: Buscar
|
||||
searchInfo: Puedes buscar por nombre o alias de proveedor
|
||||
btn: Precontabilizar
|
||||
hasInvoice: Esta entrada ya tiene una f. recibida
|
||||
success: Se ha precontabilizado correctamente
|
||||
dialog:
|
||||
title: Precontabilizar entradas
|
||||
message: ¿Desea que la factura herede el documento de la entrada?
|
||||
params:
|
||||
entryFk: Entrada
|
||||
observationTypeFk: Tipo de observación
|
||||
|
|
|
@ -5,7 +5,7 @@ import InvoiceInSummary from './InvoiceInSummary.vue';
|
|||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -164,6 +164,7 @@ onMounted(async () => {
|
|||
unelevated
|
||||
filled
|
||||
dense
|
||||
data-cy="formSubmitBtn"
|
||||
/>
|
||||
<QBtn
|
||||
v-else
|
||||
|
@ -174,6 +175,7 @@ onMounted(async () => {
|
|||
filled
|
||||
dense
|
||||
@click="getStatus = 'stopping'"
|
||||
data-cy="formStopBtn"
|
||||
/>
|
||||
</QForm>
|
||||
</template>
|
||||
|
|
|
@ -89,7 +89,6 @@ const insertTag = (rows) => {
|
|||
:default-remove="false"
|
||||
:user-filter="{
|
||||
fields: ['id', 'itemFk', 'tagFk', 'value', 'priority'],
|
||||
where: { itemFk: route.params.id },
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
|
@ -97,6 +96,7 @@ const insertTag = (rows) => {
|
|||
},
|
||||
},
|
||||
}"
|
||||
:filter="{ where: { itemFk: route.params.id } }"
|
||||
order="priority"
|
||||
auto-load
|
||||
@on-fetch="onItemTagsFetched"
|
||||
|
|
|
@ -6,10 +6,12 @@ import { toCurrency } from 'filters/index';
|
|||
import VnStockValueDisplay from 'src/components/ui/VnStockValueDisplay.vue';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import axios from 'axios';
|
||||
import notifyResults from 'src/utils/notifyResults';
|
||||
import { displayResults } from 'src/pages/Ticket/Negative/composables/notifyResults';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
const MATCH = 'match';
|
||||
const { notifyResults } = displayResults();
|
||||
|
||||
const { t } = useI18n();
|
||||
const $props = defineProps({
|
||||
|
@ -18,14 +20,20 @@ const $props = defineProps({
|
|||
required: true,
|
||||
default: () => {},
|
||||
},
|
||||
filter: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => {},
|
||||
},
|
||||
replaceAction: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
required: true,
|
||||
default: false,
|
||||
},
|
||||
|
||||
sales: {
|
||||
type: Array,
|
||||
required: false,
|
||||
required: true,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
@ -36,6 +44,8 @@ const proposalTableRef = ref(null);
|
|||
const sale = computed(() => $props.sales[0]);
|
||||
const saleFk = computed(() => sale.value.saleFk);
|
||||
const filter = computed(() => ({
|
||||
where: $props.filter,
|
||||
|
||||
itemFk: $props.itemLack.itemFk,
|
||||
sales: saleFk.value,
|
||||
}));
|
||||
|
@ -228,11 +238,15 @@ async function handleTicketConfig(data) {
|
|||
url="TicketConfigs"
|
||||
:filter="{ fields: ['lackAlertPrice'] }"
|
||||
@on-fetch="handleTicketConfig"
|
||||
auto-load
|
||||
></FetchData>
|
||||
<QInnerLoading
|
||||
:showing="isLoading"
|
||||
:label="t && t('globals.pleaseWait')"
|
||||
color="primary"
|
||||
/>
|
||||
|
||||
<VnTable
|
||||
v-if="ticketConfig"
|
||||
v-if="!isLoading"
|
||||
auto-load
|
||||
data-cy="proposalTable"
|
||||
ref="proposalTableRef"
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
<script setup>
|
||||
import ItemProposal from './ItemProposal.vue';
|
||||
import { useDialogPluginComponent } from 'quasar';
|
||||
|
||||
const $props = defineProps({
|
||||
itemLack: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => {},
|
||||
},
|
||||
filter: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => {},
|
||||
},
|
||||
replaceAction: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
|
@ -31,7 +35,7 @@ defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.h
|
|||
<QDialog ref="dialogRef" transition-show="scale" transition-hide="scale">
|
||||
<QCard class="dialog-width">
|
||||
<QCardSection class="row items-center q-pb-none">
|
||||
<span class="text-h6 text-grey">{{ $t('Item proposal') }}</span>
|
||||
<span class="text-h6 text-grey">{{ $t('itemProposal') }}</span>
|
||||
<QSpace />
|
||||
<QBtn icon="close" flat round dense v-close-popup />
|
||||
</QCardSection>
|
||||
|
|
|
@ -11,26 +11,19 @@ export function cloneItem() {
|
|||
const router = useRouter();
|
||||
const cloneItem = async (entityId) => {
|
||||
const { id } = entityId;
|
||||
try {
|
||||
const { data } = await axios.post(`Items/${id ?? entityId}/clone`);
|
||||
router.push({ name: 'ItemTags', params: { id: data.id } });
|
||||
} catch (err) {
|
||||
console.error('Error cloning item');
|
||||
}
|
||||
const { data } = await axios.post(`Items/${id ?? entityId}/clone`);
|
||||
router.push({ name: 'ItemTags', params: { id: data.id } });
|
||||
};
|
||||
|
||||
const openCloneDialog = async (entityId) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('item.descriptor.clone.title'),
|
||||
message: t('item.descriptor.clone.subTitle'),
|
||||
},
|
||||
})
|
||||
.onOk(async () => {
|
||||
await cloneItem(entityId);
|
||||
});
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('item.descriptor.clone.title'),
|
||||
message: t('item.descriptor.clone.subTitle'),
|
||||
promise: () => cloneItem(entityId),
|
||||
},
|
||||
});
|
||||
};
|
||||
return { openCloneDialog };
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ import VnRow from 'src/components/ui/VnRow.vue';
|
|||
class="q-pa-md"
|
||||
:style="{ 'flex-direction': $q.screen.lt.lg ? 'column' : 'row', gap: '0px' }"
|
||||
>
|
||||
<div style="flex: 0.3">
|
||||
<div style="flex: 0.3" data-cy="clientsOnWebsite">
|
||||
<span
|
||||
class="q-ml-md text-body1"
|
||||
v-text="$t('salesMonitor.clientsOnWebsite')"
|
||||
/>
|
||||
<SalesClientTable />
|
||||
</div>
|
||||
<div style="flex: 0.7">
|
||||
<div style="flex: 0.7" data-cy="recentOrderActions">
|
||||
<span
|
||||
class="q-ml-md text-body1"
|
||||
v-text="$t('salesMonitor.recentOrderActions')"
|
||||
|
|
|
@ -9,6 +9,7 @@ import { toDateFormat, toDateTimeFormat } from 'src/filters/date.js';
|
|||
import { toCurrency } from 'src/filters';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import axios from 'axios';
|
||||
import VnDateBadge from 'src/components/common/VnDateBadge.vue';
|
||||
import useOpenURL from 'src/composables/useOpenURL';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -165,16 +166,7 @@ const openTab = (id) => useOpenURL(`#/order/${id}/summary`);
|
|||
</div>
|
||||
</template>
|
||||
<template #column-dateSend="{ row }">
|
||||
<QTd>
|
||||
<QBadge
|
||||
:color="getBadgeColor(row.date_send)"
|
||||
text-color="black"
|
||||
class="q-pa-sm"
|
||||
style="font-size: 14px"
|
||||
>
|
||||
{{ toDateFormat(row.date_send) }}
|
||||
</QBadge>
|
||||
</QTd>
|
||||
<VnDateBadge :date="row.date_send" />
|
||||
</template>
|
||||
|
||||
<template #column-clientFk="{ row }">
|
||||
|
|
|
@ -9,6 +9,7 @@ import VnInput from 'src/components/common/VnInput.vue';
|
|||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import { dateRange } from 'src/filters';
|
||||
import VnCheckbox from 'src/components/common/VnCheckbox.vue';
|
||||
|
||||
defineProps({ dataKey: { type: String, required: true } });
|
||||
const { t, te } = useI18n();
|
||||
|
@ -209,7 +210,7 @@ const getLocale = (label) => {
|
|||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
:label="t('params.myTeam')"
|
||||
v-model="params.myTeam"
|
||||
toggle-indeterminate
|
||||
|
@ -218,7 +219,7 @@ const getLocale = (label) => {
|
|||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
:label="t('params.problems')"
|
||||
v-model="params.problems"
|
||||
toggle-indeterminate
|
||||
|
@ -227,7 +228,7 @@ const getLocale = (label) => {
|
|||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
:label="t('params.pending')"
|
||||
v-model="params.pending"
|
||||
toggle-indeterminate
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import DepartmentDescriptorProxy from 'src/pages/Worker/Department/Card/DepartmentDescriptorProxy.vue';
|
||||
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
|
||||
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
|
@ -168,9 +167,11 @@ const columns = computed(() => [
|
|||
component: 'select',
|
||||
name: 'provinceFk',
|
||||
attrs: {
|
||||
options: provinceOpts.value,
|
||||
'option-value': 'id',
|
||||
'option-label': 'name',
|
||||
url: 'Provinces',
|
||||
fields: ['id', 'name'],
|
||||
sortBy: ['name ASC'],
|
||||
optionValue: 'id',
|
||||
optionLabel: 'name',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
|
@ -183,9 +184,11 @@ const columns = computed(() => [
|
|||
component: 'select',
|
||||
name: 'stateFk',
|
||||
attrs: {
|
||||
options: stateOpts.value,
|
||||
'option-value': 'id',
|
||||
'option-label': 'name',
|
||||
sortBy: ['name ASC'],
|
||||
url: 'States',
|
||||
fields: ['id', 'name'],
|
||||
optionValue: 'id',
|
||||
optionLabel: 'name',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
|
@ -212,9 +215,12 @@ const columns = computed(() => [
|
|||
component: 'select',
|
||||
name: 'zoneFk',
|
||||
attrs: {
|
||||
options: zoneOpts.value,
|
||||
'option-value': 'id',
|
||||
'option-label': 'name',
|
||||
url: 'Zones',
|
||||
fields: ['id', 'name'],
|
||||
sortBy: ['name ASC'],
|
||||
|
||||
optionValue: 'id',
|
||||
optionLabel: 'name',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
|
@ -225,11 +231,12 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
url: 'PayMethods',
|
||||
attrs: {
|
||||
options: PayMethodOpts.value,
|
||||
optionValue: 'id',
|
||||
url: 'PayMethods',
|
||||
fields: ['id', 'name'],
|
||||
sortBy: ['id ASC'],
|
||||
optionLabel: 'name',
|
||||
optionValue: 'id',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
|
@ -254,7 +261,9 @@ const columns = computed(() => [
|
|||
columnFilter: {
|
||||
component: 'select',
|
||||
attrs: {
|
||||
options: DepartmentOpts.value,
|
||||
url: 'Departments',
|
||||
fields: ['id', 'name'],
|
||||
sortBy: ['id ASC'],
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
|
@ -265,11 +274,12 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
url: 'ItemPackingTypes',
|
||||
attrs: {
|
||||
options: ItemPackingTypeOpts.value,
|
||||
'option-value': 'code',
|
||||
'option-label': 'code',
|
||||
url: 'ItemPackingTypes',
|
||||
fields: ['code'],
|
||||
sortBy: ['code ASC'],
|
||||
optionValue: 'code',
|
||||
optionCode: 'code',
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
|
@ -324,60 +334,6 @@ const totalPriceColor = (ticket) => {
|
|||
const openTab = (id) => useOpenURL(`#/ticket/${id}/sale`);
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
url="Provinces"
|
||||
:filter="{
|
||||
fields: ['id', 'name'],
|
||||
order: 'name ASC',
|
||||
}"
|
||||
auto-load
|
||||
@on-fetch="(data) => (provinceOpts = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="States"
|
||||
:filter="{
|
||||
fields: ['id', 'name'],
|
||||
order: 'name ASC',
|
||||
}"
|
||||
auto-load
|
||||
@on-fetch="(data) => (stateOpts = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="Zones"
|
||||
:filter="{
|
||||
fields: ['id', 'name'],
|
||||
order: 'name ASC',
|
||||
}"
|
||||
auto-load
|
||||
@on-fetch="(data) => (zoneOpts = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="ItemPackingTypes"
|
||||
:filter="{
|
||||
fields: ['code'],
|
||||
order: 'code ASC',
|
||||
}"
|
||||
auto-load
|
||||
@on-fetch="(data) => (ItemPackingTypeOpts = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="Departments"
|
||||
:filter="{
|
||||
fields: ['id', 'name'],
|
||||
order: 'id ASC',
|
||||
}"
|
||||
auto-load
|
||||
@on-fetch="(data) => (DepartmentOpts = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="PayMethods"
|
||||
:filter="{
|
||||
fields: ['id', 'name'],
|
||||
order: 'id ASC',
|
||||
}"
|
||||
auto-load
|
||||
@on-fetch="(data) => (PayMethodOpts = data)"
|
||||
/>
|
||||
<MonitorTicketSearchbar />
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
|
|
|
@ -120,7 +120,6 @@ watch(
|
|||
:data-key="dataKey"
|
||||
:tag-value="tagValue"
|
||||
:tags="tags"
|
||||
:initial-catalog-params="catalogParams"
|
||||
:arrayData
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -27,7 +27,7 @@ const getTotalRef = ref();
|
|||
const total = ref(0);
|
||||
|
||||
const entityId = computed(() => {
|
||||
return $props.id || route.params.id;
|
||||
return Number($props.id || route.params.id);
|
||||
});
|
||||
|
||||
const orderTotal = computed(() => state.get('orderTotal') ?? 0);
|
||||
|
|
|
@ -247,10 +247,10 @@ const ticketColumns = ref([
|
|||
</span>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-client="{ value, row }">
|
||||
<QTd auto-width>
|
||||
<template #body-cell-client="{ row }">
|
||||
<QTd>
|
||||
<span class="link">
|
||||
{{ value }}
|
||||
{{ row.clientFk }}
|
||||
<CustomerDescriptorProxy :id="row?.clientFk" />
|
||||
</span>
|
||||
</QTd>
|
||||
|
|
|
@ -6,13 +6,18 @@ import { useRoute } from 'vue-router';
|
|||
import { useSession } from 'src/composables/useSession';
|
||||
import { toDateHourMin } from 'filters/index';
|
||||
import { useStateStore } from 'src/stores/useStateStore';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
|
||||
import AgencyDescriptorProxy from '../Agency/Card/AgencyDescriptorProxy.vue';
|
||||
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
|
||||
import RouteDescriptorProxy from '../Card/RouteDescriptorProxy.vue';
|
||||
import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
|
||||
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
|
||||
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
@ -30,39 +35,117 @@ const userParams = {
|
|||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
align: 'right',
|
||||
name: 'cmrFk',
|
||||
label: t('route.cmr.params.cmrFk'),
|
||||
label: t('cmr.params.cmrFk'),
|
||||
chip: {
|
||||
condition: () => true,
|
||||
},
|
||||
isId: true,
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
name: 'hasCmrDms',
|
||||
label: t('route.cmr.params.hasCmrDms'),
|
||||
component: 'checkbox',
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('route.cmr.params.ticketFk'),
|
||||
align: 'right',
|
||||
label: t('cmr.params.ticketFk'),
|
||||
name: 'ticketFk',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('route.cmr.params.routeFk'),
|
||||
align: 'right',
|
||||
label: t('cmr.params.routeFk'),
|
||||
name: 'routeFk',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('route.cmr.params.clientFk'),
|
||||
label: t('cmr.params.client'),
|
||||
name: 'clientFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Clients',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
columnFilter: {
|
||||
name: 'clientFk',
|
||||
attrs: {
|
||||
url: 'Clients',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
label: t('route.cmr.params.countryFk'),
|
||||
label: t('cmr.params.agency'),
|
||||
name: 'agencyModeFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Agencies',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
columnFilter: {
|
||||
name: 'agencyModeFk',
|
||||
attrs: {
|
||||
url: 'Agencies',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
format: ({ agencyName }) => agencyName,
|
||||
},
|
||||
{
|
||||
label: t('cmr.params.supplier'),
|
||||
name: 'supplierFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'suppliers',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
columnFilter: {
|
||||
name: 'supplierFk',
|
||||
attrs: {
|
||||
url: 'suppliers',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('cmr.params.sender'),
|
||||
name: 'addressFromFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Addresses',
|
||||
fields: ['id', 'nickname'],
|
||||
optionValue: 'id',
|
||||
optionLabel: 'nickname',
|
||||
},
|
||||
columnFilter: {
|
||||
name: 'addressFromFk',
|
||||
attrs: {
|
||||
url: 'Addresses',
|
||||
fields: ['id', 'nickname'],
|
||||
optionValue: 'id',
|
||||
optionLabel: 'nickname',
|
||||
},
|
||||
},
|
||||
format: ({ origin }) => origin,
|
||||
},
|
||||
{
|
||||
label: t('cmr.params.destination'),
|
||||
name: 'addressToFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'addresses',
|
||||
fields: ['id', 'nickname'],
|
||||
optionValue: 'id',
|
||||
optionLabel: 'nickname',
|
||||
},
|
||||
columnFilter: {
|
||||
name: 'addressToFk',
|
||||
attrs: {
|
||||
url: 'addresses',
|
||||
fields: ['id', 'nickname'],
|
||||
optionValue: 'id',
|
||||
optionLabel: 'nickname',
|
||||
},
|
||||
},
|
||||
format: ({ destination }) => destination,
|
||||
},
|
||||
{
|
||||
label: t('cmr.params.country'),
|
||||
name: 'countryFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
|
@ -79,16 +162,61 @@ const columns = computed(() => [
|
|||
format: ({ countryName }) => countryName,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
label: t('route.cmr.params.shipped'),
|
||||
name: 'shipped',
|
||||
cardVisible: true,
|
||||
label: t('cmr.params.created'),
|
||||
name: 'created',
|
||||
component: 'date',
|
||||
format: ({ shipped }) => toDateHourMin(shipped),
|
||||
format: ({ created }) => dashIfEmpty(toDateHourMin(created)),
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
label: t('route.cmr.params.warehouseFk'),
|
||||
label: t('cmr.params.shipped'),
|
||||
name: 'shipped',
|
||||
component: 'date',
|
||||
format: ({ shipped }) => dashIfEmpty(toDateHourMin(shipped)),
|
||||
},
|
||||
{
|
||||
label: t('cmr.params.etd'),
|
||||
name: 'ead',
|
||||
component: 'date',
|
||||
format: ({ ead }) => dashIfEmpty(toDateHourMin(ead)),
|
||||
toolTip: t('cmr.params.etdTooltip'),
|
||||
},
|
||||
{
|
||||
label: t('globals.landed'),
|
||||
name: 'landed',
|
||||
component: 'date',
|
||||
format: ({ landed }) => dashIfEmpty(toDateHourMin(landed)),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('cmr.params.packageList'),
|
||||
name: 'packagesList',
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('cmr.params.observation'),
|
||||
name: 'observation',
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('cmr.params.senderInstructions'),
|
||||
name: 'senderInstruccions',
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('cmr.params.paymentInstructions'),
|
||||
name: 'paymentInstruccions',
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('cmr.params.vehiclePlate'),
|
||||
name: 'truckPlate',
|
||||
},
|
||||
{
|
||||
label: t('cmr.params.warehouse'),
|
||||
name: 'warehouseFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
|
@ -96,7 +224,6 @@ const columns = computed(() => [
|
|||
fields: ['id', 'name'],
|
||||
},
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
name: 'warehouseFk',
|
||||
attrs: {
|
||||
url: 'warehouses',
|
||||
|
@ -105,12 +232,23 @@ const columns = computed(() => [
|
|||
},
|
||||
format: ({ warehouseName }) => warehouseName,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'specialAgreements',
|
||||
label: t('cmr.params.specialAgreements'),
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
name: 'hasCmrDms',
|
||||
label: t('cmr.params.hasCmrDms'),
|
||||
component: 'checkbox',
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('route.cmr.params.viewCmr'),
|
||||
title: t('cmr.params.viewCmr'),
|
||||
icon: 'visibility',
|
||||
isPrimary: true,
|
||||
action: (row) => window.open(getCmrUrl(row?.cmrFk), '_blank'),
|
||||
|
@ -151,11 +289,7 @@ function downloadPdfs() {
|
|||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnSearchbar
|
||||
:data-key
|
||||
:label="t('route.cmr.search')"
|
||||
:info="t('route.cmr.searchInfo')"
|
||||
/>
|
||||
<VnSearchbar :data-key :label="t('cmr.search')" :info="t('cmr.searchInfo')" />
|
||||
<VnSubToolbar>
|
||||
<template #st-actions>
|
||||
<QBtn
|
||||
|
@ -165,7 +299,7 @@ function downloadPdfs() {
|
|||
:disable="!selectedRows?.length"
|
||||
@click="downloadPdfs"
|
||||
>
|
||||
<QTooltip>{{ t('route.cmr.params.downloadCmrs') }}</QTooltip>
|
||||
<QTooltip>{{ t('cmr.params.downloadCmrs') }}</QTooltip>
|
||||
</QBtn>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
|
@ -191,11 +325,72 @@ function downloadPdfs() {
|
|||
<TicketDescriptorProxy :id="row.ticketFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-routeFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.routeFk }}
|
||||
<RouteDescriptorProxy :id="row.routeFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-clientFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.clientFk }}
|
||||
{{ row.clientName }}
|
||||
<CustomerDescriptorProxy :id="row.clientFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-agencyModeFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.agencyName }}
|
||||
<AgencyDescriptorProxy :id="row.agencyModeFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-supplierFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.carrierName }}
|
||||
<SupplierDescriptorProxy :id="row.supplierFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-observation="{ row }">
|
||||
<VnInput
|
||||
v-if="row.observation"
|
||||
type="textarea"
|
||||
v-model="row.observation"
|
||||
readonly
|
||||
dense
|
||||
rows="2"
|
||||
style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap"
|
||||
/>
|
||||
</template>
|
||||
<template #column-packagesList="{ row }">
|
||||
<span>
|
||||
{{ row.packagesList }}
|
||||
<QTooltip v-if="row.packagesList" :label="row.packagesList">
|
||||
{{ row.packagesList }}
|
||||
</QTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<template #column-senderInstruccions="{ row }">
|
||||
<span>
|
||||
{{ row.senderInstruccions }}
|
||||
<QTooltip v-if="row.packagesList" :label="row.packagesList">
|
||||
{{ row.senderInstruccions }}
|
||||
</QTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<template #column-paymentInstruccions="{ row }">
|
||||
<span>
|
||||
{{ row.paymentInstruccions }}
|
||||
<QTooltip v-if="row.packagesList" :label="row.packagesList">
|
||||
{{ row.paymentInstruccions }}
|
||||
</QTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<template #column-specialAgreements="{ row }">
|
||||
<span>
|
||||
{{ row.specialAgreements }}
|
||||
<QTooltip v-if="row.packagesList" :label="row.packagesList">
|
||||
{{ row.specialAgreements }}
|
||||
</QTooltip>
|
||||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
</template>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
cmr:
|
||||
search: Search Cmr
|
||||
searchInfo: You can search Cmr by Id
|
||||
params:
|
||||
agency: Agency
|
||||
client: Client
|
||||
cmrFk: CMR id
|
||||
country: Country
|
||||
created: Created
|
||||
destination: Destination
|
||||
downloadCmrs: Download CMRs
|
||||
etd: ETD
|
||||
etdTooltip: Estimated Time Delivery
|
||||
hasCmrDms: Attached in gestdoc
|
||||
observation: Observation
|
||||
packageList: Package List
|
||||
paymentInstructions: Payment instructions
|
||||
routeFk: Route id
|
||||
results: results
|
||||
search: General search
|
||||
sender: Sender
|
||||
senderInstructions: Sender instructions
|
||||
shipped: Shipped
|
||||
specialAgreements: Special agreements
|
||||
supplier: Carrier
|
||||
ticketFk: Ticket id
|
||||
vehiclePlate: Vehicle plate
|
||||
viewCmr: View CMR
|
||||
warehouse: Warehouse
|
||||
'true': 'Yes'
|
||||
'false': 'No'
|
|
@ -0,0 +1,31 @@
|
|||
cmr:
|
||||
search: Buscar Cmr
|
||||
searchInfo: Puedes buscar cmr por id
|
||||
params:
|
||||
agency: Agencia
|
||||
client: Cliente
|
||||
cmrFk: Id cmr
|
||||
country: País
|
||||
created: Creado
|
||||
destination: Destinatario
|
||||
downloadCmrs: Descargar CMRs
|
||||
etd: ETD
|
||||
etdTooltip: Fecha estimada de entrega
|
||||
hasCmrDms: Adjunto en gestdoc
|
||||
observation: Observaciones
|
||||
packageList: Listado embalajes
|
||||
paymentInstructions: Instrucciones de pago
|
||||
routeFk: Id ruta
|
||||
results: Resultados
|
||||
search: Busqueda general
|
||||
sender: Remitente
|
||||
senderInstructions: Instrucciones de envío
|
||||
shipped: F. envío
|
||||
specialAgreements: Acuerdos especiales
|
||||
supplier: Transportista
|
||||
ticketFk: Id ticket
|
||||
vehiclePlate: Matrícula
|
||||
viewCmr: Ver CMR
|
||||
warehouse: Almacén
|
||||
'true': 'Si'
|
||||
'false': 'No'
|
|
@ -0,0 +1,65 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
const emit = defineEmits(['onDataSaved']);
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const route = useRoute();
|
||||
|
||||
const dmsOptions = ref([]);
|
||||
const dmsId = ref(null);
|
||||
|
||||
const importDms = async () => {
|
||||
try {
|
||||
if (!dmsId.value) throw new Error(t(`vehicle.errors.documentIdEmpty`));
|
||||
|
||||
const data = {
|
||||
vehicleFk: route.params.id,
|
||||
dmsFk: dmsId.value,
|
||||
};
|
||||
|
||||
await axios.post('vehicleDms', data);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
dmsId.value = null;
|
||||
emit('onDataSaved');
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
url="Dms"
|
||||
:filter="{ fields: ['id'], order: 'id ASC' }"
|
||||
auto-load
|
||||
@on-fetch="(data) => (dmsOptions = data)"
|
||||
/>
|
||||
<FormModelPopup
|
||||
model="DmsImport"
|
||||
:title="t('globals.selectDocumentId')"
|
||||
:form-initial-data="{}"
|
||||
:save-fn="importDms"
|
||||
>
|
||||
<template #form-inputs>
|
||||
<VnSelect
|
||||
:label="t('globals.document')"
|
||||
:options="dmsOptions"
|
||||
hide-selected
|
||||
option-label="id"
|
||||
option-value="id"
|
||||
v-model="dmsId"
|
||||
/>
|
||||
</template>
|
||||
</FormModelPopup>
|
||||
</template>
|
|
@ -0,0 +1,183 @@
|
|||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import FormPopup from 'components/FormPopup.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import axios from 'axios';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
const props = defineProps({
|
||||
event: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
isNewMode: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
eventType: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
firstDay: {
|
||||
type: Date,
|
||||
default: null,
|
||||
},
|
||||
lastDay: {
|
||||
type: Date,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['onSubmit', 'closeForm', 'refresh-events']);
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
|
||||
const isNew = computed(() => props.isNewMode);
|
||||
const vehicleFormData = ref({
|
||||
started: null,
|
||||
finished: null,
|
||||
vehicleStateFk: null,
|
||||
description: '',
|
||||
vehicleFk: null,
|
||||
userFk: null,
|
||||
});
|
||||
|
||||
const arrayData = useArrayData('VehicleEvents');
|
||||
|
||||
onMounted(() => {
|
||||
if (props.event) {
|
||||
vehicleFormData.value = props.event;
|
||||
}
|
||||
});
|
||||
|
||||
const createVehicleEvent = async () => {
|
||||
vehicleFormData.value.vehicleFk = route.params.id;
|
||||
vehicleFormData.value.userFk = user.value.id;
|
||||
|
||||
if (isNew.value) {
|
||||
await axios.post(`VehicleEvents`, vehicleFormData.value);
|
||||
} else {
|
||||
await axios.patch(
|
||||
`VehicleEvents/${props.event?.id}`,
|
||||
vehicleFormData.value,
|
||||
);
|
||||
}
|
||||
await refetchEvents();
|
||||
|
||||
};
|
||||
|
||||
const deleteVehicleEvent = async () => {
|
||||
if (!props.event) return;
|
||||
await axios.delete(`VehicleEvents/${props.event?.id}`);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
const refetchEvents = async () => {
|
||||
await arrayData.refresh({
|
||||
append: false,
|
||||
params: {
|
||||
filter: {
|
||||
where: {
|
||||
vehicleFk: route.params.id,
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{ started: { lte: props.lastDay?.toISOString() } },
|
||||
{ started: null }
|
||||
]
|
||||
},
|
||||
{
|
||||
or: [
|
||||
{ finished: { gte: props.firstDay?.toISOString() } },
|
||||
{ finished: null }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
emit('refresh-events');
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
emit('closeForm');
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FormPopup
|
||||
:title="isNew ? t('Add vehicle event') : t('Edit vehicle event')"
|
||||
:default-cancel-button="false"
|
||||
:default-submit-button="false"
|
||||
>
|
||||
<template #form-inputs>
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<VnInputDate :label="t('Started')" v-model="vehicleFormData.started" />
|
||||
<VnInputDate :label="t('Finished')" v-model="vehicleFormData.finished" />
|
||||
<VnSelect
|
||||
url="VehicleStates"
|
||||
v-model="vehicleFormData.vehicleStateFk"
|
||||
:label="t('globals.state')"
|
||||
option-label="state"
|
||||
data-cy="State_input"
|
||||
/>
|
||||
</VnRow>
|
||||
<VnInput
|
||||
v-model="vehicleFormData.description"
|
||||
:label="t('globals.description')"
|
||||
/>
|
||||
</template>
|
||||
<template #custom-buttons>
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
color="primary"
|
||||
flat
|
||||
class="q-mr-sm"
|
||||
v-close-popup
|
||||
/>
|
||||
<QBtn
|
||||
v-if="!isNew"
|
||||
:label="t('globals.delete')"
|
||||
color="primary"
|
||||
flat
|
||||
class="q-mr-sm"
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('vehicle.deleteTitle'),
|
||||
t('vehicle.deleteSubtitle'),
|
||||
() => deleteVehicleEvent(),
|
||||
)
|
||||
"
|
||||
/>
|
||||
<QBtn
|
||||
:label="isNew ? t('globals.save') : t('globals.add')"
|
||||
@click="createVehicleEvent"
|
||||
color="primary"
|
||||
/>
|
||||
</template>
|
||||
</FormPopup>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Started: Inicio
|
||||
Finished: Fin
|
||||
Add vehicle event: Agregar evento
|
||||
Edit vehicle event: Editar evento
|
||||
</i18n>
|
|
@ -0,0 +1,86 @@
|
|||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VehicleEventsPanel from './VehicleEventsPanel.vue';
|
||||
import VehicleCalendarGrid from '../VehicleCalendarGrid.vue';
|
||||
import VehicleEventInclusionForm from './VehicleEventInclusionForm.vue';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
|
||||
const firstDay = ref();
|
||||
const lastDay = ref();
|
||||
const events = ref([]);
|
||||
const vehicleEventsPanelRef = ref(null);
|
||||
const showVehicleEventForm = ref(false);
|
||||
const vehicleEventsFormProps = reactive({
|
||||
isNewMode: true,
|
||||
date: null,
|
||||
event: null,
|
||||
});
|
||||
|
||||
const refreshEvents = async () => {
|
||||
await vehicleEventsPanelRef.value.fetchData();
|
||||
};
|
||||
|
||||
const openForm = (data) => {
|
||||
const { date = null, isNewMode, event } = data;
|
||||
Object.assign(vehicleEventsFormProps, { date, isNewMode, event });
|
||||
|
||||
showVehicleEventForm.value = true;
|
||||
};
|
||||
|
||||
const onVehicleEventFormClose = () => {
|
||||
showVehicleEventForm.value = false;
|
||||
vehicleEventsFormProps.value = {};
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RightMenu>
|
||||
<template #right-panel v-if="stateStore.isHeaderMounted()">
|
||||
<VehicleEventsPanel
|
||||
ref="vehicleEventsPanelRef"
|
||||
:first-day="firstDay"
|
||||
:last-day="lastDay"
|
||||
:events="events"
|
||||
@update:events="events = $event"
|
||||
/>
|
||||
</template>
|
||||
</RightMenu>
|
||||
<QPage class="q-pa-md flex justify-center">
|
||||
<VehicleCalendarGrid
|
||||
v-model:events="events"
|
||||
v-model:firstDay="firstDay"
|
||||
v-model:lastDay="lastDay"
|
||||
data-key="VehicleEvents"
|
||||
@on-date-selected="openForm"
|
||||
/>
|
||||
<QDialog v-model="showVehicleEventForm" @hide="onVehicleEventFormClose()">
|
||||
<VehicleEventInclusionForm
|
||||
v-bind="vehicleEventsFormProps"
|
||||
:first-day="firstDay"
|
||||
:last-day="lastDay"
|
||||
@close-form="onVehicleEventFormClose()"
|
||||
@refresh-events="refreshEvents()"
|
||||
/>
|
||||
</QDialog>
|
||||
<QPageSticky :offset="[20, 20]">
|
||||
<QBtn
|
||||
@click="openForm({ isNewMode: true }, true)"
|
||||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
v-shortcut="'+'"
|
||||
/>
|
||||
<QTooltip class="text-no-wrap">
|
||||
{{ t('eventsInclusionForm.addEvent') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
</QPage>
|
||||
</template>
|
|
@ -0,0 +1,196 @@
|
|||
<script setup>
|
||||
import { onMounted, watch, computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import axios from 'axios';
|
||||
import { toDateFormat } from 'src/filters/date.js';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
const props = defineProps({
|
||||
firstDay: {
|
||||
type: Date,
|
||||
default: null,
|
||||
},
|
||||
lastDay: {
|
||||
type: Date,
|
||||
default: null,
|
||||
},
|
||||
events: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['openVehicleForm']);
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const { notify } = useNotify();
|
||||
const weekdayStore = useWeekdayStore();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const vehicleStates = ref({});
|
||||
const fetchVehicleState = async () => {
|
||||
const vehicles = await axios.get('VehicleStates');
|
||||
vehicleStates.value = vehicles.data;
|
||||
};
|
||||
|
||||
const getVehicleStateName = (id) => {
|
||||
return vehicleStates.value[id - 1] ?? dashIfEmpty(id - 1);
|
||||
};
|
||||
|
||||
const params = computed(() => ({
|
||||
vehicleFk: route.params.id,
|
||||
started: props.firstDay,
|
||||
finished: props.lastDay,
|
||||
}));
|
||||
|
||||
const arrayData = useArrayData('VehicleEvents', {
|
||||
params: params,
|
||||
url: `VehicleEvents`,
|
||||
});
|
||||
|
||||
const fetchData = async () => {
|
||||
if (!params.value.vehicleFk || !props.firstDay || !props.lastDay) return;
|
||||
|
||||
try {
|
||||
await arrayData.applyFilter({
|
||||
params: {
|
||||
filter: {
|
||||
where: {
|
||||
vehicleFk: route.params.id,
|
||||
and: [
|
||||
{ or: [
|
||||
{ started: { lte: props.lastDay } },
|
||||
{ started: null }
|
||||
]},
|
||||
{ or: [
|
||||
{ finished: { gte: props.firstDay } },
|
||||
{ finished: null }
|
||||
]}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
emit('update:events', arrayData.store.data || []);
|
||||
} catch (error) {
|
||||
console.error('Error fetching events:', error);
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
params,
|
||||
async () => {
|
||||
await fetchData();
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.events,
|
||||
(newEvents) => {
|
||||
emit('update:events', newEvents);
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
const deleteEvent = async (id) => {
|
||||
if (!id) return;
|
||||
await axios.delete(`VehicleEvents/${id}`);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
await fetchData();
|
||||
};
|
||||
|
||||
const openInclusionForm = (event) => {
|
||||
emit('openVehicleForm', {
|
||||
date: event.dated,
|
||||
event,
|
||||
isNewMode: false,
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
weekdayStore.initStore();
|
||||
await fetchVehicleState();
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
fetchData
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QForm @submit="onSubmit()">
|
||||
<div class="column q-pa-md q-gutter-y-sm"></div>
|
||||
<span class="color-vn-label text-subtitle1 q-px-md">{{
|
||||
t('eventsPanel.events')
|
||||
}}</span>
|
||||
<QList>
|
||||
<QItem v-for="(event, index) in events" :key="index" class="event-card">
|
||||
<QItemSection left @click="openInclusionForm(event)">
|
||||
<div class="q-mb-xs">
|
||||
<span
|
||||
>({{ toDateFormat(event.started) }} -
|
||||
{{ toDateFormat(event.finished) }})</span
|
||||
>
|
||||
</div>
|
||||
<span class="color-vn-label"
|
||||
>{{ t('globals.description') }}:
|
||||
<span class="color-vn-text q-ml-xs">{{
|
||||
dashIfEmpty(event.description)
|
||||
}}</span>
|
||||
</span>
|
||||
<span class="color-vn-label"
|
||||
>{{ t('globals.state') }}:
|
||||
<span class="color-vn-text">{{
|
||||
getVehicleStateName(event.vehicleStateFk).state
|
||||
}}</span>
|
||||
</span>
|
||||
</QItemSection>
|
||||
<QItemSection side @click="openInclusionForm(event)">
|
||||
<QBtn
|
||||
icon="delete"
|
||||
data-cy="delete_event"
|
||||
flat
|
||||
dense
|
||||
size="md"
|
||||
color="primary"
|
||||
@click.stop="
|
||||
openConfirmationModal(
|
||||
t('vehicle.deleteTitle'),
|
||||
t('vehicle.deleteSubtitle'),
|
||||
() => deleteEvent(event.id),
|
||||
)
|
||||
"
|
||||
>
|
||||
<QTooltip>{{ t('eventsPanel.delete') }}</QTooltip>
|
||||
</QBtn>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<span
|
||||
v-if="!events.length"
|
||||
class="flex justify-center text-h5 color-vn-label"
|
||||
>
|
||||
{{ t('globals.noResults') }}
|
||||
</span>
|
||||
</QList>
|
||||
</QForm>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.event-card {
|
||||
display: flex;
|
||||
border-bottom: $border-thin-light;
|
||||
margin: 0;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--vn-accent-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue