Merge branch 'dev' into 7323-fixe2e
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2025-02-20 08:54:35 +00:00
commit 3529af45d9
12 changed files with 375 additions and 216 deletions

View File

@ -247,6 +247,7 @@ async function saveAndGo() {
} }
function reset() { function reset() {
formData.value = JSON.parse(JSON.stringify(originalData.value));
updateAndEmit('onFetch', { val: originalData.value }); updateAndEmit('onFetch', { val: originalData.value });
if ($props.observeFormChanges) { if ($props.observeFormChanges) {
hasChanges.value = false; hasChanges.value = false;

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import { markRaw, computed } from 'vue'; import { markRaw, computed } from 'vue';
import { QIcon, QCheckbox, QToggle } from 'quasar'; import { QIcon, QToggle } from 'quasar';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';

View File

@ -10,14 +10,15 @@ import {
render, render,
inject, inject,
useAttrs, useAttrs,
nextTick,
} from 'vue'; } from 'vue';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar'; import { useQuasar, date } from 'quasar';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useFilterParams } from 'src/composables/useFilterParams'; import { useFilterParams } from 'src/composables/useFilterParams';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty, toDate } from 'src/filters';
import CrudModel from 'src/components/CrudModel.vue'; import CrudModel from 'src/components/CrudModel.vue';
import FormModelPopup from 'components/FormModelPopup.vue'; import FormModelPopup from 'components/FormModelPopup.vue';
@ -344,7 +345,7 @@ const clickHandler = async (event) => {
if (isDateElement || isTimeElement || isQselectDropDown) return; if (isDateElement || isTimeElement || isQselectDropDown) return;
if (clickedElement === null) { if (clickedElement === null) {
destroyInput(editingRow.value, editingField.value); await destroyInput(editingRow.value, editingField.value);
return; return;
} }
const rowIndex = clickedElement.getAttribute('data-row-index'); const rowIndex = clickedElement.getAttribute('data-row-index');
@ -354,7 +355,7 @@ const clickHandler = async (event) => {
if (editingRow.value !== null && editingField.value !== null) { if (editingRow.value !== null && editingField.value !== null) {
if (editingRow.value == rowIndex && editingField.value == colField) return; if (editingRow.value == rowIndex && editingField.value == colField) return;
destroyInput(editingRow.value, editingField.value); await destroyInput(editingRow.value, editingField.value);
} }
if (isEditableColumn(column)) { if (isEditableColumn(column)) {
@ -364,7 +365,7 @@ const clickHandler = async (event) => {
async function handleTabKey(event, rowIndex, colField) { async function handleTabKey(event, rowIndex, colField) {
if (editingRow.value == rowIndex && editingField.value == colField) if (editingRow.value == rowIndex && editingField.value == colField)
destroyInput(editingRow.value, editingField.value); await destroyInput(editingRow.value, editingField.value);
const direction = event.shiftKey ? -1 : 1; const direction = event.shiftKey ? -1 : 1;
const { nextRowIndex, nextColumnName } = await handleTabNavigation( const { nextRowIndex, nextColumnName } = await handleTabNavigation(
@ -424,7 +425,8 @@ async function renderInput(rowId, field, clickedElement) {
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row); await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
}, },
keyup: async (event) => { keyup: async (event) => {
if (event.key === 'Enter') handleBlur(rowId, field, clickedElement); if (event.key === 'Enter')
await destroyInput(rowIndex, field, clickedElement);
}, },
keydown: async (event) => { keydown: async (event) => {
switch (event.key) { switch (event.key) {
@ -433,7 +435,7 @@ async function renderInput(rowId, field, clickedElement) {
event.stopPropagation(); event.stopPropagation();
break; break;
case 'Escape': case 'Escape':
destroyInput(rowId, field, clickedElement); await destroyInput(rowId, field, clickedElement);
break; break;
default: default:
break; break;
@ -455,12 +457,13 @@ async function renderInput(rowId, field, clickedElement) {
node.el?.querySelector('span > div > div').focus(); node.el?.querySelector('span > div > div').focus();
} }
function destroyInput(rowIndex, field, clickedElement) { async function destroyInput(rowIndex, field, clickedElement) {
if (!clickedElement) if (!clickedElement)
clickedElement = document.querySelector( clickedElement = document.querySelector(
`[data-row-index="${rowIndex}"][data-col-field="${field}"]`, `[data-row-index="${rowIndex}"][data-col-field="${field}"]`,
); );
if (clickedElement) { if (clickedElement) {
await nextTick();
render(null, clickedElement); render(null, clickedElement);
Array.from(clickedElement.childNodes).forEach((child) => { Array.from(clickedElement.childNodes).forEach((child) => {
child.style.visibility = 'visible'; child.style.visibility = 'visible';
@ -472,10 +475,6 @@ function destroyInput(rowIndex, field, clickedElement) {
editingField.value = null; editingField.value = null;
} }
function handleBlur(rowIndex, field, clickedElement) {
destroyInput(rowIndex, field, clickedElement);
}
async function handleTabNavigation(rowIndex, colName, direction) { async function handleTabNavigation(rowIndex, colName, direction) {
const columns = $props.columns; const columns = $props.columns;
const totalColumns = columns.length; const totalColumns = columns.length;
@ -526,11 +525,36 @@ function formatColumnValue(col, row, dashIfEmpty) {
} else { } else {
return col.format(row, dashIfEmpty); return col.format(row, dashIfEmpty);
} }
}
if (col?.component === 'date') return dashIfEmpty(toDate(row[col?.name]));
if (col?.component === 'time')
return row[col?.name] >= 5
? dashIfEmpty(date.formatDate(new Date(row[col?.name]), 'HH:mm'))
: row[col?.name];
if (selectRegex.test(col?.component) && $props.isEditable) {
const { find, url } = col.attrs;
const urlRelation = url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
if (col?.attrs.options) {
const find = col?.attrs.options.find((option) => option.id === row[col.name]);
if (!col.attrs?.optionLabel || !find) return dashIfEmpty(row[col?.name]);
return dashIfEmpty(find[col.attrs?.optionLabel ?? 'name']);
}
if (typeof row[urlRelation] == 'object') {
if (typeof find == 'object')
return dashIfEmpty(row[urlRelation][find?.label ?? 'name']);
return dashIfEmpty(row[urlRelation][col?.attrs.optionLabel ?? 'name']);
}
if (typeof row[urlRelation] == 'string') return dashIfEmpty(row[urlRelation]);
} else { } else {
return dashIfEmpty(row[col?.name]); return dashIfEmpty(row[col?.name]);
} }
} }
const checkbox = ref(null);
function cardClick(_, row) { function cardClick(_, row) {
if ($props.redirect) router.push({ path: `/${$props.redirect}/${row.id}` }); if ($props.redirect) router.push({ path: `/${$props.redirect}/${row.id}` });
} }
@ -721,7 +745,11 @@ function cardClick(_, row) {
<span <span
v-else v-else
:class="hasEditableFormat(col)" :class="hasEditableFormat(col)"
:style="col?.style ? col.style(row) : null" :style="
typeof col?.style == 'function'
? col.style(row)
: col?.style
"
style="bottom: 0" style="bottom: 0"
> >
{{ formatColumnValue(col, row, dashIfEmpty) }} {{ formatColumnValue(col, row, dashIfEmpty) }}

View File

@ -7,6 +7,7 @@ export function getColAlign(col) {
case 'number': case 'number':
align = 'right'; align = 'right';
break; break;
case 'time':
case 'date': case 'date':
case 'checkbox': case 'checkbox':
align = 'center'; align = 'center';

View File

@ -49,6 +49,7 @@ globals:
rowRemoved: Row removed rowRemoved: Row removed
pleaseWait: Please wait... pleaseWait: Please wait...
noPinnedModules: You don't have any pinned modules noPinnedModules: You don't have any pinned modules
enterToConfirm: Press Enter to confirm
summary: summary:
basicData: Basic data basicData: Basic data
daysOnward: Days onward daysOnward: Days onward

View File

@ -51,6 +51,7 @@ globals:
pleaseWait: Por favor espera... pleaseWait: Por favor espera...
noPinnedModules: No has fijado ningún módulo noPinnedModules: No has fijado ningún módulo
split: Split split: Split
enterToConfirm: Pulsa Enter para confirmar
summary: summary:
basicData: Datos básicos basicData: Datos básicos
daysOnward: Días adelante daysOnward: Días adelante

View File

@ -21,6 +21,10 @@ const $props = defineProps({
type: String, type: String,
default: 'mana', default: 'mana',
}, },
sale: {
type: Object,
default: null,
},
}); });
const emit = defineEmits(['save', 'cancel']); const emit = defineEmits(['save', 'cancel']);
@ -29,8 +33,8 @@ const { t } = useI18n();
const QPopupProxyRef = ref(null); const QPopupProxyRef = ref(null);
const manaCode = ref($props.manaCode); const manaCode = ref($props.manaCode);
const save = () => { const save = (sale = $props.sale) => {
emit('save'); emit('save', sale);
QPopupProxyRef.value.hide(); QPopupProxyRef.value.hide();
}; };
@ -38,10 +42,11 @@ const cancel = () => {
emit('cancel'); emit('cancel');
QPopupProxyRef.value.hide(); QPopupProxyRef.value.hide();
}; };
defineExpose({ save });
</script> </script>
<template> <template>
<QPopupProxy ref="QPopupProxyRef"> <QPopupProxy ref="QPopupProxyRef" data-cy="ticketEditManaProxy">
<div class="container"> <div class="container">
<QSpinner v-if="!mana" color="primary" size="md" /> <QSpinner v-if="!mana" color="primary" size="md" />
<div v-else> <div v-else>

View File

@ -22,7 +22,6 @@ import { useVnConfirm } from 'composables/useVnConfirm';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import VnUsesMana from 'src/components/ui/VnUsesMana.vue';
import VnConfirm from 'src/components/ui/VnConfirm.vue'; import VnConfirm from 'src/components/ui/VnConfirm.vue';
import TicketProblems from 'src/components/TicketProblems.vue'; import TicketProblems from 'src/components/TicketProblems.vue';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
@ -33,6 +32,7 @@ const { t } = useI18n();
const { notify } = useNotify(); const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const editPriceProxyRef = ref(null); const editPriceProxyRef = ref(null);
const editManaProxyRef = ref(null);
const stateBtnDropdownRef = ref(null); const stateBtnDropdownRef = ref(null);
const quasar = useQuasar(); const quasar = useQuasar();
const arrayData = useArrayData('Ticket'); const arrayData = useArrayData('Ticket');
@ -53,7 +53,6 @@ const transfer = ref({
sales: [], sales: [],
}); });
const tableRef = ref([]); const tableRef = ref([]);
const canProceed = ref();
watch( watch(
() => route.params.id, () => route.params.id,
@ -133,7 +132,6 @@ const columns = computed(() => [
align: 'left', align: 'left',
label: t('globals.amount'), label: t('globals.amount'),
name: 'amount', name: 'amount',
format: (row) => toCurrency(getSaleTotal(row)),
}, },
{ {
align: 'left', align: 'left',
@ -183,8 +181,6 @@ const resetChanges = async () => {
}; };
const rowToUpdate = ref(null); const rowToUpdate = ref(null);
const changeQuantity = async (sale) => { const changeQuantity = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
if ( if (
!sale.itemFk || !sale.itemFk ||
sale.quantity == null || sale.quantity == null ||
@ -193,11 +189,21 @@ const changeQuantity = async (sale) => {
return; return;
if (!sale.id) return addSale(sale); if (!sale.id) return addSale(sale);
if (await isSalePrepared(sale)) {
await confirmUpdate(() => updateQuantity(sale));
} else await updateQuantity(sale);
};
const updateQuantity = async (sale) => {
try { try {
let { quantity, id } = sale;
if (!rowToUpdate.value) return; if (!rowToUpdate.value) return;
rowToUpdate.value = null; rowToUpdate.value = null;
sale.isNew = false; sale.isNew = false;
await updateQuantity(sale); const params = { quantity: quantity };
await axios.post(`Sales/${id}/updateQuantity`, params);
notify('globals.dataSaved', 'positive');
tableRef.value.reload();
} catch (e) { } catch (e) {
const { quantity } = tableRef.value.CrudModelRef.originalData.find( const { quantity } = tableRef.value.CrudModelRef.originalData.find(
(s) => s.id === sale.id, (s) => s.id === sale.id,
@ -207,12 +213,6 @@ const changeQuantity = async (sale) => {
} }
}; };
const updateQuantity = async ({ quantity, id }) => {
const params = { quantity: quantity };
await axios.post(`Sales/${id}/updateQuantity`, params);
notify('globals.dataSaved', 'positive');
};
const addSale = async (sale) => { const addSale = async (sale) => {
const params = { const params = {
barcode: sale.itemFk, barcode: sale.itemFk,
@ -237,13 +237,17 @@ const addSale = async (sale) => {
sale.isNew = false; sale.isNew = false;
arrayData.fetch({}); arrayData.fetch({});
}; };
const changeConcept = async (sale) => {
if (await isSalePrepared(sale)) {
await confirmUpdate(() => updateConcept(sale));
} else await updateConcept(sale);
};
const updateConcept = async (sale) => { const updateConcept = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
const data = { newConcept: sale.concept }; const data = { newConcept: sale.concept };
await axios.post(`Sales/${sale.id}/updateConcept`, data); await axios.post(`Sales/${sale.id}/updateConcept`, data);
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
tableRef.value.reload();
}; };
const DEFAULT_EDIT = { const DEFAULT_EDIT = {
@ -295,33 +299,43 @@ const onOpenEditDiscountPopover = async (sale) => {
}; };
} }
}; };
const changePrice = async (sale) => {
const updatePrice = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
const newPrice = edit.value.price; const newPrice = edit.value.price;
if (newPrice != null && newPrice != sale.price) { if (newPrice != null && newPrice != sale.price) {
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice }); if (await isSalePrepared(sale)) {
sale.price = newPrice; await confirmUpdate(() => updatePrice(sale, newPrice));
edit.value = { ...DEFAULT_EDIT }; } else updatePrice(sale, newPrice);
notify('globals.dataSaved', 'positive');
} }
await getMana(); await getMana();
}; };
const updatePrice = async (sale, newPrice) => {
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
sale.price = newPrice;
edit.value = { ...DEFAULT_EDIT };
notify('globals.dataSaved', 'positive');
tableRef.value.reload();
};
const changeDiscount = async (sale) => { const changeDiscount = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
const newDiscount = edit.value.discount; const newDiscount = edit.value.discount;
if (newDiscount != null && newDiscount != sale.discount) updateDiscount([sale]); if (newDiscount != null && newDiscount != sale.discount) {
if (await isSalePrepared(sale))
await confirmUpdate(() => updateDiscount([sale], newDiscount));
else await updateDiscount([sale], newDiscount);
}
};
const updateDiscounts = async (sales, newDiscount = null) => {
const salesTracking = await fetchSalesTracking();
const someSaleIsPrepared = salesTracking.some((sale) =>
matchSale(salesTracking, sale),
);
if (someSaleIsPrepared) await confirmUpdate(() => updateDiscount(sales, newDiscount));
else updateDiscount(sales, newDiscount);
}; };
const updateDiscount = async (sales, newDiscount = null) => { const updateDiscount = async (sales, newDiscount = null) => {
for (const sale of sales) {
const canProceed = await isSalePrepared(sale);
if (!canProceed) return;
}
const saleIds = sales.map((sale) => sale.id); const saleIds = sales.map((sale) => sale.id);
const _newDiscount = newDiscount || edit.value.discount; const _newDiscount = newDiscount || edit.value.discount;
const params = { const params = {
@ -424,9 +438,13 @@ onMounted(async () => {
const items = ref([]); const items = ref([]);
const newRow = ref({}); const newRow = ref({});
const changeItem = async (sale) => {
if (await isSalePrepared(sale)) {
await confirmUpdate(() => updateItem(sale));
} else await updateItem(sale);
};
const updateItem = async (row) => { const updateItem = async (row) => {
canProceed.value = await isSalePrepared(row);
if (!canProceed.value) return;
const selectedItem = items.value.find((item) => item.id === row.itemFk); const selectedItem = items.value.find((item) => item.id === row.itemFk);
if (selectedItem) { if (selectedItem) {
row.item = selectedItem; row.item = selectedItem;
@ -470,7 +488,18 @@ const endNewRow = (row) => {
} }
}; };
async function isSalePrepared(item) { async function confirmUpdate(cb) {
await quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('Item prepared'),
message: t('This item is already prepared. Do you want to continue?'),
},
})
.onOk(cb);
}
async function fetchSalesTracking() {
const filter = { const filter = {
params: { params: {
where: { ticketFk: route.params.id }, where: { ticketFk: route.params.id },
@ -482,48 +511,37 @@ async function isSalePrepared(item) {
filter: JSON.stringify(filter), filter: JSON.stringify(filter),
}, },
}); });
return data;
const matchingSale = data.find((sale) => sale.itemFk === item.itemFk);
if (!matchingSale) {
return true;
}
if (
matchingSale.hasSaleGroupDetail ||
matchingSale.isControled ||
matchingSale.isPrepared ||
matchingSale.isPrevious ||
matchingSale.isPreviousSelected
) {
try {
await new Promise((resolve, reject) => {
quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('Item prepared'),
message: t(
'This item is already prepared. Do you want to continue?',
),
data: item,
},
})
.onOk(() => resolve(true))
.onCancel(() => reject(new Error('cancelled')));
});
} catch (error) {
tableRef.value.reload();
return false;
}
}
return true;
} }
async function isSalePrepared(sale) {
const data = await fetchSalesTracking();
return matchSale(data, sale);
}
function matchSale(data, sale) {
const matchingSale = data.find(({ itemFk }) => itemFk === sale.itemFk);
if (!matchingSale) {
return false;
}
return isPrepared(matchingSale);
}
function isPrepared(sale) {
const flagsToCheck = [
'hasSaleGroupDetail',
'isControled',
'isPrepared',
'isPrevious',
'isPreviousSelected',
];
return flagsToCheck.some((flag) => sale[flag] === 1);
}
watch( watch(
() => newRow.value.itemFk, () => newRow.value.itemFk,
(newItemFk) => { (newItemFk) => {
if (newItemFk) { if (newItemFk) {
updateItem(newRow.value); changeItem(newRow.value);
} }
}, },
); );
@ -584,7 +602,7 @@ watch(
:mana="mana" :mana="mana"
:ticket-config="ticketConfig" :ticket-config="ticketConfig"
@get-mana="getMana()" @get-mana="getMana()"
@update-discounts="updateDiscount" @update-discounts="updateDiscounts"
@refresh-table="resetChanges" @refresh-table="resetChanges"
/> />
<QBtn <QBtn
@ -715,7 +733,7 @@ watch(
option-value="id" option-value="id"
v-model="row.itemFk" v-model="row.itemFk"
:use-like="false" :use-like="false"
@update:model-value="updateItem(row)" @update:model-value="changeItem(row)"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
@ -741,16 +759,21 @@ watch(
</div> </div>
<FetchedTags :item="row" :max-length="6" /> <FetchedTags :item="row" :max-length="6" />
<QPopupProxy v-if="row.id && isTicketEditable"> <QPopupProxy v-if="row.id && isTicketEditable">
<VnInput v-model="row.concept" @change="updateConcept(row)" /> <VnInput
v-model="row.concept"
@keyup.enter.stop="changeConcept(row)"
:hint="t('globals.enterToConfirm')"
/>
</QPopupProxy> </QPopupProxy>
</template> </template>
<template #column-quantity="{ row }"> <template #column-quantity="{ row }">
<VnInput <VnInput
data-cy="ticketSaleQuantityInput"
v-if="row.isNew || isTicketEditable" v-if="row.isNew || isTicketEditable"
type="number" type="number"
v-model.number="row.quantity" v-model.number="row.quantity"
@blur="changeQuantity(row)" @blur="changeQuantity(row)"
@keyup.enter="changeQuantity(row)" @keyup.enter.stop="changeQuantity(row)"
@update:model-value="() => (rowToUpdate = row)" @update:model-value="() => (rowToUpdate = row)"
@focus="edit.oldQuantity = row.quantity" @focus="edit.oldQuantity = row.quantity"
/> />
@ -764,10 +787,12 @@ watch(
<TicketEditManaProxy <TicketEditManaProxy
ref="editPriceProxyRef" ref="editPriceProxyRef"
:mana="mana" :mana="mana"
:sale="row"
:new-price="getNewPrice" :new-price="getNewPrice"
@save="updatePrice(row)" @save="changePrice"
> >
<VnInput <VnInput
@keyup.enter.stop="() => editManaProxyRef.save(row)"
v-model.number="edit.price" v-model.number="edit.price"
:label="t('basicData.price')" :label="t('basicData.price')"
type="number" type="number"
@ -781,31 +806,30 @@ watch(
<QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)"> <QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)">
{{ toPercentage(row.discount / 100) }} {{ toPercentage(row.discount / 100) }}
</QBtn> </QBtn>
<TicketEditManaProxy <TicketEditManaProxy
ref="editManaProxyRef"
:mana="mana" :mana="mana"
:sale="row"
:new-price="getNewPrice" :new-price="getNewPrice"
:uses-mana="usesMana" :uses-mana="usesMana"
:mana-code="manaCode" :mana-code="manaCode"
@save="changeDiscount(row)" @save="changeDiscount"
> >
<template #default="{ popup }"> <VnInput
<VnInput autofocus
autofocus @keyup.enter.stop="() => editManaProxyRef.save(row)"
@keyup.enter=" v-model.number="edit.discount"
() => { :label="t('ticketSale.discount')"
changeDiscount(row); type="number"
popup.hide(); />
}
"
v-model.number="edit.discount"
:label="t('ticketSale.discount')"
type="number"
/>
</template>
</TicketEditManaProxy> </TicketEditManaProxy>
</template> </template>
<span v-else>{{ toPercentage(row.discount / 100) }}</span> <span v-else>{{ toPercentage(row.discount / 100) }}</span>
</template> </template>
<template #column-amount="{ row }">
{{ toCurrency(getSaleTotal(row)) }}
</template>
</VnTable> </VnTable>
<QPageSticky :offset="[20, 20]" style="z-index: 2"> <QPageSticky :offset="[20, 20]" style="z-index: 2">

View File

@ -209,7 +209,7 @@ const onThermographCreated = async (data) => {
}" }"
sort-by="thermographFk ASC" sort-by="thermographFk ASC"
option-label="thermographFk" option-label="thermographFk"
option-filter-value="id" option-filter-value="thermographFk"
:disable="viewAction === 'edit'" :disable="viewAction === 'edit'"
:tooltip="t('New thermograph')" :tooltip="t('New thermograph')"
:roles-allowed-to-create="['logistic']" :roles-allowed-to-create="['logistic']"

View File

@ -119,7 +119,7 @@ const columns = computed(() => [
:url="`Workers/${entityId}/trainingCourse`" :url="`Workers/${entityId}/trainingCourse`"
:url-create="`Workers/${entityId}/trainingCourse`" :url-create="`Workers/${entityId}/trainingCourse`"
save-url="TrainingCourses/crud" save-url="TrainingCourses/crud"
:filter="courseFilter" :user-filter="courseFilter"
:create="{ :create="{
urlCreate: 'trainingCourses', urlCreate: 'trainingCourses',
title: t('Create training course'), title: t('Create training course'),

View File

@ -8,6 +8,17 @@ const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const entityId = computed(() => route.params.id); const entityId = computed(() => route.params.id);
const centerFilter = {
include: [
{
relation: 'center',
scope: {
fields: ['id', 'name'],
},
},
],
};
const columns = [ const columns = [
{ {
align: 'left', align: 'left',
@ -33,7 +44,7 @@ const columns = [
create: true, create: true,
component: 'select', component: 'select',
attrs: { attrs: {
url: 'medicalCenters', url: 'centers',
fields: ['id', 'name'], fields: ['id', 'name'],
}, },
}, },
@ -84,6 +95,7 @@ const columns = [
ref="tableRef" ref="tableRef"
data-key="WorkerMedical" data-key="WorkerMedical"
:url="`Workers/${entityId}/medicalReview`" :url="`Workers/${entityId}/medicalReview`"
:user-filter="centerFilter"
save-url="MedicalReviews/crud" save-url="MedicalReviews/crud"
:create="{ :create="{
urlCreate: 'medicalReviews', urlCreate: 'medicalReviews',

View File

@ -1,122 +1,208 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('TicketSale', () => { describe('TicketSale', () => {
beforeEach(() => { describe('Free ticket #31', () => {
cy.login('developer'); beforeEach(() => {
cy.viewport(1920, 1080); cy.login('developer');
cy.visit('/#/ticket/31/sale'); cy.viewport(1920, 1080);
}); cy.visit('/#/ticket/31/sale');
const firstRow = 'tbody > :nth-child(1)';
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('it should add item to basket', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
}); });
cy.dataCy('ticketSaleAddToBasketBtn').should('exist');
cy.dataCy('ticketSaleAddToBasketBtn').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/);
});
it('should send SMS', () => { const firstRow = 'tbody > :nth-child(1)';
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="sendShortageSMSItem"]');
cy.dataCy('sendShortageSMSItem').should('exist');
cy.dataCy('sendShortageSMSItem').click();
cy.dataCy('vnSmsDialog').should('exist');
cy.dataCy('sendSmsBtn').click();
cy.checkNotification('SMS sent');
});
it('should recalculate price when "Recalculate price" is clicked', () => { const selectFirstRow = () => {
cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice'); cy.waitForElement(firstRow);
selectFirstRow(); cy.get(firstRow).find('.q-checkbox__inner').click();
cy.dataCy('ticketSaleMoreActionsDropdown').click(); };
cy.waitForElement('[data-cy="recalculatePriceItem"]');
cy.dataCy('recalculatePriceItem').should('exist');
cy.dataCy('recalculatePriceItem').click();
cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
});
it('should update discount when "Update discount" is clicked', () => { it('it should add item to basket', () => {
selectFirstRow(); cy.window().then((win) => {
cy.dataCy('ticketSaleMoreActionsDropdown').click(); cy.stub(win, 'open').as('windowOpen');
cy.waitForElement('[data-cy="updateDiscountItem"]'); });
cy.dataCy('updateDiscountItem').should('exist'); cy.dataCy('ticketSaleAddToBasketBtn').should('exist');
cy.dataCy('updateDiscountItem').click(); cy.dataCy('ticketSaleAddToBasketBtn').click();
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]'); cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/);
cy.dataCy('ticketSaleDiscountInput').find('input').focus(); });
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.checkNotification('Data saved');
});
it('adds claim', () => { it('should send SMS', () => {
selectFirstRow(); selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click(); cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click(); cy.waitForElement('[data-cy="sendShortageSMSItem"]');
cy.dataCy('VnConfirm_confirm').click(); cy.dataCy('sendShortageSMSItem').should('exist');
cy.url().should('contain', 'claim/'); cy.dataCy('sendShortageSMSItem').click();
// Delete created claim to avoid cluttering the database cy.dataCy('vnSmsDialog').should('exist');
cy.dataCy('descriptor-more-opts').click(); cy.dataCy('sendSmsBtn').click();
cy.dataCy('deleteClaim').click(); cy.checkNotification('SMS sent');
cy.dataCy('VnConfirm_confirm').click(); });
cy.checkNotification('Data deleted');
});
it('marks row as reserved', () => { it('should recalculate price when "Recalculate price" is clicked', () => {
selectFirstRow(); cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice');
cy.dataCy('ticketSaleMoreActionsDropdown').click(); selectFirstRow();
cy.waitForElement('[data-cy="markAsReservedItem"]'); cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('markAsReservedItem').click(); cy.waitForElement('[data-cy="recalculatePriceItem"]');
cy.dataCy('ticketSaleReservedIcon').should('exist'); cy.dataCy('recalculatePriceItem').should('exist');
}); cy.dataCy('recalculatePriceItem').click();
cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
});
it('unmarks row as reserved', () => { it('should update discount when "Update discount" is clicked', () => {
selectFirstRow(); selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click(); cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="unmarkAsReservedItem"]'); cy.waitForElement('[data-cy="updateDiscountItem"]');
cy.dataCy('unmarkAsReservedItem').click(); cy.dataCy('updateDiscountItem').should('exist');
cy.dataCy('ticketSaleReservedIcon').should('not.exist'); cy.dataCy('updateDiscountItem').click();
}); cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.checkNotification('Data saved');
});
it('refunds row with warehouse', () => { it('adds claim', () => {
selectFirstRow(); selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click(); cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click(); cy.dataCy('createClaimItem').click();
cy.dataCy('ticketSaleRefundWithWarehouse').click(); cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('The following refund ticket have been created'); cy.url().should('contain', 'claim/');
}); // Delete created claim to avoid cluttering the database
cy.dataCy('descriptor-more-opts').click();
cy.dataCy('deleteClaim').click();
cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('Data deleted');
});
it('refunds row without warehouse', () => { it('marks row as reserved', () => {
selectFirstRow(); selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click(); cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click(); cy.waitForElement('[data-cy="markAsReservedItem"]');
cy.dataCy('ticketSaleRefundWithoutWarehouse').click(); cy.dataCy('markAsReservedItem').click();
cy.checkNotification('The following refund ticket have been created'); cy.dataCy('ticketSaleReservedIcon').should('exist');
}); });
it('transfer sale to a new ticket', () => { it('unmarks row as reserved', () => {
cy.visit('/#/ticket/32/sale'); selectFirstRow();
cy.get('.q-item > .q-item__label').should('have.text', ' #32'); cy.dataCy('ticketSaleMoreActionsDropdown').click();
selectFirstRow(); cy.waitForElement('[data-cy="unmarkAsReservedItem"]');
cy.dataCy('ticketSaleTransferBtn').click(); cy.dataCy('unmarkAsReservedItem').click();
cy.dataCy('ticketTransferPopup').should('exist'); cy.dataCy('ticketSaleReservedIcon').should('not.exist');
cy.dataCy('ticketTransferNewTicketBtn').click(); });
//check the new ticket has been created succesfully
cy.get('.q-item > .q-item__label').should('not.have.text', ' #32');
});
it('should redirect to ticket logs', () => { it('refunds row with warehouse', () => {
cy.get(firstRow).find('.q-btn:last').click(); selectFirstRow();
cy.url().should('match', /\/ticket\/31\/log/); cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('refunds row without warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithoutWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('transfer sale to a new ticket', () => {
cy.visit('/#/ticket/32/sale');
cy.get('.q-item > .q-item__label').should('have.text', ' #32');
selectFirstRow();
cy.dataCy('ticketSaleTransferBtn').click();
cy.dataCy('ticketTransferPopup').should('exist');
cy.dataCy('ticketTransferNewTicketBtn').click();
//check the new ticket has been created succesfully
cy.get('.q-item > .q-item__label').should('not.have.text', ' #32');
});
it('should redirect to ticket logs', () => {
cy.get(firstRow).find('.q-btn:last').click();
cy.url().should('match', /\/ticket\/31\/log/);
});
});
describe('Ticket prepared #23', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/23/sale');
});
const firstRow = 'tbody > :nth-child(1)';
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('update price', () => {
const price = Number((Math.random() * 99 + 1).toFixed(2));
cy.waitForElement(firstRow);
cy.get(':nth-child(10) > .q-btn').click();
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
cy.dataCy('ticketEditManaProxy').should('exist');
cy.waitForElement('[data-cy="Price_input"]');
cy.dataCy('Price_input').clear();
cy.dataCy('Price_input').type(price);
cy.dataCy('saveManaBtn').click();
handleVnConfirm();
cy.get(':nth-child(10) > .q-btn > .q-btn__content').should(
'have.text',
`${price}`,
);
});
it('update dicount', () => {
const discount = Math.floor(Math.random() * 100) + 1;
selectFirstRow();
cy.get(':nth-child(11) > .q-btn').click();
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
cy.dataCy('ticketEditManaProxy').should('exist');
cy.waitForElement('[data-cy="Disc_input"]');
cy.dataCy('Disc_input').clear();
cy.dataCy('Disc_input').type(discount);
cy.dataCy('saveManaBtn').click();
handleVnConfirm();
cy.get(':nth-child(11) > .q-btn > .q-btn__content').should(
'have.text',
`${discount}.00%`,
);
});
it('change concept', () => {
const quantity = Math.floor(Math.random() * 100) + 1;
cy.waitForElement(firstRow);
cy.get(':nth-child(8) > .row').click();
cy.get(
'.q-menu > [data-v-ca3f07a4=""] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="undefined_input"]',
)
.type(quantity)
.type('{enter}');
handleVnConfirm();
cy.get(':nth-child(8) >.row').should('contain.text', `${quantity}`);
});
it('changequantity ', () => {
const quantity = Math.floor(Math.random() * 100) + 1;
cy.waitForElement(firstRow);
cy.dataCy('ticketSaleQuantityInput').clear();
cy.dataCy('ticketSaleQuantityInput').type(quantity).trigger('tab');
cy.get('.q-page > :nth-child(6)').click();
handleVnConfirm();
cy.get('[data-cy="ticketSaleQuantityInput"]')
.find('[data-cy="undefined_input"]')
.should('have.value', `${quantity}`);
});
}); });
}); });
function handleVnConfirm() {
cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click();
cy.waitForElement('.q-notification__message');
cy.get('.q-notification__message').should('be.visible');
cy.checkNotification('Data saved');
}