Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 7524-addTests
This commit is contained in:
commit
a73a451cd8
|
@ -30,10 +30,10 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
|
||||
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
|
||||
const emit = defineEmits(['confirm', 'cancel', ...useDialogPluginComponent.emits]);
|
||||
|
||||
const { dialogRef, onDialogOK } = useDialogPluginComponent();
|
||||
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
|
||||
useDialogPluginComponent();
|
||||
|
||||
const title = props.title || t('Confirm');
|
||||
const message =
|
||||
|
@ -53,9 +53,14 @@ async function confirm() {
|
|||
}
|
||||
onDialogOK(props.data);
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
emit('cancel');
|
||||
onDialogCancel();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<QDialog ref="dialogRef">
|
||||
<QDialog ref="dialogRef" @hide="onDialogHide">
|
||||
<QCard class="q-pa-sm">
|
||||
<QCardSection class="row items-center q-pb-none">
|
||||
<QAvatar
|
||||
|
@ -67,7 +72,14 @@ async function confirm() {
|
|||
/>
|
||||
<span class="text-h6">{{ title }}</span>
|
||||
<QSpace />
|
||||
<QBtn icon="close" :disable="isLoading" flat round dense v-close-popup />
|
||||
<QBtn
|
||||
icon="close"
|
||||
:disable="isLoading"
|
||||
flat
|
||||
round
|
||||
dense
|
||||
@click="cancel()"
|
||||
/>
|
||||
</QCardSection>
|
||||
<QCardSection class="q-pb-none">
|
||||
<span v-if="message !== false" v-html="message" />
|
||||
|
@ -81,7 +93,7 @@ async function confirm() {
|
|||
color="primary"
|
||||
:disable="isLoading"
|
||||
flat
|
||||
v-close-popup
|
||||
@click="cancel()"
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.confirm')"
|
||||
|
|
|
@ -278,6 +278,7 @@ globals:
|
|||
RouteExtendedList: Router
|
||||
wasteRecalc: Waste recaclulate
|
||||
operator: Operator
|
||||
parking: Parking
|
||||
supplier: Supplier
|
||||
created: Created
|
||||
worker: Worker
|
||||
|
@ -663,8 +664,6 @@ parking:
|
|||
sector: Sector
|
||||
row: Row
|
||||
column: Column
|
||||
pageTitles:
|
||||
parking: Parking
|
||||
searchBar:
|
||||
info: You can search by parking code
|
||||
label: Search parking...
|
||||
|
|
|
@ -282,6 +282,7 @@ globals:
|
|||
medical: Mutua
|
||||
wasteRecalc: Recalcular mermas
|
||||
operator: Operario
|
||||
parking: Parking
|
||||
supplier: Proveedor
|
||||
created: Fecha creación
|
||||
worker: Trabajador
|
||||
|
@ -710,8 +711,6 @@ parking:
|
|||
pickingOrder: Orden de recogida
|
||||
row: Fila
|
||||
column: Columna
|
||||
pageTitles:
|
||||
parking: Parking
|
||||
searchBar:
|
||||
info: Puedes buscar por código de parking
|
||||
label: Buscar parking...
|
||||
|
|
|
@ -40,6 +40,12 @@ const itemFilter = {
|
|||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'production',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
const columns = computed(() => [
|
||||
|
@ -161,19 +167,13 @@ const columns = computed(() => [
|
|||
name: 'intrastat',
|
||||
align: 'left',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Intrastats',
|
||||
optionValue: 'description',
|
||||
optionLabel: 'description',
|
||||
},
|
||||
columnFilter: {
|
||||
name: 'description',
|
||||
name: 'intrastat',
|
||||
attrs: {
|
||||
url: 'Intrastats',
|
||||
optionValue: 'description',
|
||||
optionLabel: 'description',
|
||||
},
|
||||
alias: 'intr',
|
||||
},
|
||||
columnField: {
|
||||
component: null,
|
||||
|
@ -211,14 +211,19 @@ const columns = computed(() => [
|
|||
label: t('item.list.userName'),
|
||||
name: 'userName',
|
||||
align: 'left',
|
||||
component: 'select',
|
||||
columnFilter: {
|
||||
name: 'workerFk',
|
||||
attrs: {
|
||||
url: 'Users',
|
||||
url: 'VnUsers/preview',
|
||||
optionValue: 'id',
|
||||
optionLabel: 'userName',
|
||||
optionLabel: 'nickname',
|
||||
},
|
||||
},
|
||||
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('item.list.weightByPiece'),
|
||||
|
@ -255,9 +260,13 @@ const columns = computed(() => [
|
|||
name: 'producer',
|
||||
align: 'left',
|
||||
component: 'select',
|
||||
columnFilter: {
|
||||
name: 'producerFk',
|
||||
attrs: {
|
||||
url: 'Producers',
|
||||
fields: ['id', 'name'],
|
||||
optionValue: 'id',
|
||||
optionLabel: 'name',
|
||||
},
|
||||
},
|
||||
columnField: {
|
||||
component: null,
|
||||
|
@ -331,7 +340,7 @@ const columns = computed(() => [
|
|||
<template #column-userName="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.userName }}
|
||||
<WorkerDescriptorProxy :id="row.buyerFk" />
|
||||
<WorkerDescriptorProxy :id="row.workerFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-description="{ row }">
|
||||
|
|
|
@ -70,6 +70,18 @@ const columns = computed(() => [
|
|||
{
|
||||
label: t('item.buyRequest.requester'),
|
||||
name: 'requesterName',
|
||||
component: 'select',
|
||||
columnFilter: {
|
||||
name: 'requesterFk',
|
||||
attrs: {
|
||||
url: 'VnUsers/preview',
|
||||
optionValue: 'id',
|
||||
optionLabel: 'nickname',
|
||||
},
|
||||
},
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
columnClass: 'shrink',
|
||||
},
|
||||
{
|
||||
|
@ -88,6 +100,18 @@ const columns = computed(() => [
|
|||
label: t('item.buyRequest.attender'),
|
||||
name: 'attenderName',
|
||||
align: 'left',
|
||||
component: 'select',
|
||||
columnFilter: {
|
||||
name: 'attenderFk',
|
||||
attrs: {
|
||||
url: 'VnUsers/preview',
|
||||
optionValue: 'id',
|
||||
optionLabel: 'nickname',
|
||||
},
|
||||
},
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
columnClass: 'shrink',
|
||||
},
|
||||
{
|
||||
|
|
|
@ -2,17 +2,11 @@
|
|||
import VnCard from 'components/common/VnCard.vue';
|
||||
import ParkingDescriptor from 'pages/Parking/Card/ParkingDescriptor.vue';
|
||||
import ParkingFilter from 'pages/Parking/ParkingFilter.vue';
|
||||
|
||||
const filter = {
|
||||
fields: ['id', 'sectorFk', 'code', 'pickingOrder', 'row', 'column'],
|
||||
include: [{ relation: 'sector', scope: { fields: ['id', 'description'] } }],
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnCard
|
||||
data-key="Parking"
|
||||
base-url="Parkings"
|
||||
:filter="filter"
|
||||
:descriptor="ParkingDescriptor"
|
||||
:filter-panel="ParkingFilter"
|
||||
search-data-key="ParkingList"
|
||||
|
|
|
@ -29,6 +29,7 @@ const filter = {
|
|||
:url="`Parkings/${entityId}`"
|
||||
title="code"
|
||||
:filter="filter"
|
||||
:to-module="{ name: 'ParkingList' }"
|
||||
>
|
||||
<template #body="{ entity }">
|
||||
<VnLv :label="t('globals.code')" :value="entity.code" />
|
||||
|
|
|
@ -22,7 +22,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
|
||||
const filter = {
|
||||
fields: ['id', 'sectorFk', 'code', 'pickingOrder'],
|
||||
include: [{ relation: 'sector', scope: { fields: ['id', 'description'] } }],
|
||||
};
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
|
@ -55,10 +54,9 @@ function exprBuilder(param, value) {
|
|||
<VnPaginate
|
||||
data-key="ParkingList"
|
||||
url="Parkings"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:expr-builder="exprBuilder"
|
||||
:limit="20"
|
||||
auto-load
|
||||
order="code"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { onMounted, ref, computed, onUnmounted, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||
|
@ -23,6 +24,7 @@ import useNotify from 'src/composables/useNotify.js';
|
|||
import axios from 'axios';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import VnUsesMana from 'src/components/ui/VnUsesMana.vue';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
@ -32,7 +34,7 @@ const { notify } = useNotify();
|
|||
const { openConfirmationModal } = useVnConfirm();
|
||||
const editPriceProxyRef = ref(null);
|
||||
const stateBtnDropdownRef = ref(null);
|
||||
|
||||
const quasar = useQuasar();
|
||||
const arrayData = useArrayData('ticketData');
|
||||
const { store } = arrayData;
|
||||
const selectedRows = ref([]);
|
||||
|
@ -51,6 +53,7 @@ const transfer = ref({
|
|||
sales: [],
|
||||
});
|
||||
const tableRef = ref([]);
|
||||
const canProceed = ref();
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
|
@ -214,7 +217,9 @@ const addSale = async (sale) => {
|
|||
}
|
||||
};
|
||||
|
||||
const changeQuantity = (sale) => {
|
||||
const changeQuantity = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
if (
|
||||
!sale.itemFk ||
|
||||
sale.quantity == null ||
|
||||
|
@ -226,6 +231,8 @@ const changeQuantity = (sale) => {
|
|||
};
|
||||
|
||||
const updateConcept = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
try {
|
||||
const data = { newConcept: sale.concept };
|
||||
await axios.post(`Sales/${sale.id}/updateConcept`, data);
|
||||
|
@ -286,6 +293,8 @@ const onOpenEditDiscountPopover = async (sale) => {
|
|||
};
|
||||
|
||||
const updatePrice = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
try {
|
||||
const newPrice = edit.value.price;
|
||||
if (newPrice != null && newPrice != sale.price) {
|
||||
|
@ -300,12 +309,18 @@ const updatePrice = async (sale) => {
|
|||
}
|
||||
};
|
||||
|
||||
const changeDiscount = (sale) => {
|
||||
const changeDiscount = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
const newDiscount = edit.value.discount;
|
||||
if (newDiscount != null && newDiscount != sale.discount) updateDiscount([sale]);
|
||||
};
|
||||
|
||||
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 _newDiscount = newDiscount || edit.value.discount;
|
||||
const params = {
|
||||
|
@ -433,7 +448,9 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
const items = ref([]);
|
||||
const newRow = ref({});
|
||||
|
||||
const updateItem = (row) => {
|
||||
const updateItem = async (row) => {
|
||||
canProceed.value = await isSalePrepared(row);
|
||||
if (!canProceed.value) return;
|
||||
const selectedItem = items.value.find((item) => item.id === row.itemFk);
|
||||
if (selectedItem) {
|
||||
row.item = selectedItem;
|
||||
|
@ -476,6 +493,55 @@ const endNewRow = (row) => {
|
|||
}
|
||||
};
|
||||
|
||||
async function isSalePrepared(item) {
|
||||
const filter = {
|
||||
params: {
|
||||
where: { ticketFk: route.params.id },
|
||||
order: ['concept ASC', 'quantity DESC'],
|
||||
},
|
||||
};
|
||||
const { data } = await axios.get(`SaleTrackings/${route.params.id}/filter`, {
|
||||
params: {
|
||||
filter: JSON.stringify(filter),
|
||||
},
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => newRow.value.itemFk,
|
||||
(newItemFk) => {
|
||||
|
@ -821,4 +887,6 @@ es:
|
|||
You are going to delete lines of the ticket: Vas a eliminar lineas del ticket
|
||||
Add item: Añadir artículo
|
||||
Transfer lines: Transferir líneas
|
||||
Item prepared: Artículo preparado
|
||||
This item is already prepared. Do you want to continue?: Este artículo ya esta preparado. Desea continuar?
|
||||
</i18n>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('ParkingList', () => {
|
||||
const searchbar = '#searchbar input';
|
||||
const firstCard = '.q-card:nth-child(1)';
|
||||
const firstChipId =
|
||||
':nth-child(1) > :nth-child(1) > .justify-between > .flex > .q-chip > .q-chip__content';
|
||||
|
@ -14,6 +15,7 @@ describe('ParkingList', () => {
|
|||
});
|
||||
|
||||
it('should redirect on clicking a parking', () => {
|
||||
cy.get(searchbar).type('{enter}');
|
||||
cy.get(firstChipId)
|
||||
.invoke('text')
|
||||
.then((content) => {
|
||||
|
@ -24,6 +26,7 @@ describe('ParkingList', () => {
|
|||
});
|
||||
|
||||
it('should open the details', () => {
|
||||
cy.get(searchbar).type('{enter}');
|
||||
cy.get(firstDetailBtn).click();
|
||||
cy.get(summaryHeader).contains('Basic data');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue