0
0
Fork 0

Merge branch 'dev' into fix_customer_issues

This commit is contained in:
Javier Segarra 2024-11-07 12:54:19 +01:00
commit 489df51d64
38 changed files with 408 additions and 462 deletions

View File

@ -272,6 +272,7 @@ defineExpose({
hasChanges, hasChanges,
reset, reset,
fetch, fetch,
formData,
}); });
</script> </script>
<template> <template>

View File

@ -331,6 +331,20 @@ function handleScroll() {
const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40; const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40;
if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate(); if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
} }
function handleSelection({ evt, added, rows: selectedRows }, rows) {
if (evt?.shiftKey && added) {
const rowIndex = selectedRows[0].$index;
const selectedIndexes = new Set(selected.value.map((row) => row.$index));
for (const row of rows) {
if (row.$index == rowIndex) break;
if (!selectedIndexes.has(row.$index)) {
selected.value.push(row);
selectedIndexes.add(row.$index);
}
}
}
}
</script> </script>
<template> <template>
<QDrawer <QDrawer
@ -431,6 +445,7 @@ function handleScroll() {
@virtual-scroll="handleScroll" @virtual-scroll="handleScroll"
@row-click="(_, row) => rowClickFunction && rowClickFunction(row)" @row-click="(_, row) => rowClickFunction && rowClickFunction(row)"
@update:selected="emit('update:selected', $event)" @update:selected="emit('update:selected', $event)"
@selection="(details) => handleSelection(details, rows)"
> >
<template #top-left v-if="!$props.withoutHeader"> <template #top-left v-if="!$props.withoutHeader">
<slot name="top-left"></slot> <slot name="top-left"></slot>

View File

@ -31,6 +31,10 @@ const $props = defineProps({
type: String, type: String,
default: null, default: null,
}, },
description: {
type: String,
default: null,
},
}); });
const warehouses = ref(); const warehouses = ref();
@ -43,7 +47,8 @@ const dms = ref({});
onMounted(() => { onMounted(() => {
defaultData(); defaultData();
if (!$props.formInitialData) if (!$props.formInitialData)
dms.value.description = t($props.model + 'Description', dms.value); dms.value.description =
$props.description ?? t($props.model + 'Description', dms.value);
}); });
function onFileChange(files) { function onFileChange(files) {
dms.value.hasFileAttached = !!files; dms.value.hasFileAttached = !!files;
@ -54,7 +59,6 @@ function mapperDms(data) {
const formData = new FormData(); const formData = new FormData();
const { files } = data; const { files } = data;
if (files) formData.append(files?.name, files); if (files) formData.append(files?.name, files);
delete data.files;
const dms = { const dms = {
hasFile: !!data.hasFile, hasFile: !!data.hasFile,
@ -78,6 +82,7 @@ async function save() {
const body = mapperDms(dms.value); const body = mapperDms(dms.value);
const response = await axios.post(getUrl(), body[0], body[1]); const response = await axios.post(getUrl(), body[0], body[1]);
emit('onDataSaved', body[1].params, response); emit('onDataSaved', body[1].params, response);
delete dms.value.files;
return response; return response;
} }
@ -165,6 +170,7 @@ function addDefaultData(data) {
@update:model-value="onFileChange(dms.files)" @update:model-value="onFileChange(dms.files)"
class="required" class="required"
:display-value="dms.file" :display-value="dms.file"
data-cy="VnDms_inputFile"
> >
<template #append> <template #append>
<QIcon <QIcon

View File

@ -27,6 +27,10 @@ const $props = defineProps({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
emptyToNull: {
type: Boolean,
default: true,
},
}); });
const { validations } = useValidator(); const { validations } = useValidator();
@ -39,6 +43,7 @@ const value = computed({
return $props.modelValue; return $props.modelValue;
}, },
set(value) { set(value) {
if ($props.emptyToNull && value === '') value = null;
emit('update:modelValue', value); emit('update:modelValue', value);
}, },
}); });

View File

@ -167,6 +167,7 @@ const toModule = computed(() =>
icon="more_vert" icon="more_vert"
round round
size="md" size="md"
data-cy="descriptor-more-opts"
> >
<QTooltip> <QTooltip>
{{ t('components.cardDescriptor.moreOptions') }} {{ t('components.cardDescriptor.moreOptions') }}

View File

@ -31,6 +31,7 @@ const props = defineProps({
}); });
const emit = defineEmits(['confirm', 'cancel', ...useDialogPluginComponent.emits]); const emit = defineEmits(['confirm', 'cancel', ...useDialogPluginComponent.emits]);
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
useDialogPluginComponent(); useDialogPluginComponent();
@ -102,6 +103,7 @@ function cancel() {
@click="confirm()" @click="confirm()"
unelevated unelevated
autofocus autofocus
data-cy="VnConfirm_confirm"
/> />
</QCardActions> </QCardActions>
</QCard> </QCard>

View File

@ -705,6 +705,8 @@ order:
quantity: Quantity quantity: Quantity
price: Price price: Price
amount: Amount amount: Amount
confirm: Confirm
confirmLines: Confirm lines
department: department:
pageTitles: pageTitles:
basicData: Basic data basicData: Basic data

View File

@ -681,13 +681,15 @@ order:
vat: IVA vat: IVA
state: Estado state: Estado
alias: Alias alias: Alias
items: Items items: Artículos
orderTicketList: Tickets del pedido orderTicketList: Tickets del pedido
details: Detalles details: Detalles
item: Item item: Item
quantity: Cantidad quantity: Cantidad
price: Precio price: Precio
amount: Monto amount: Monto
confirm: Confirmar
confirmLines: Confirmar lineas
shelving: shelving:
list: list:
parking: Parking parking: Parking

View File

@ -63,7 +63,11 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
<<<<<<< HEAD
format: (row) => dashIfEmpty(row.agencyMode?.name), format: (row) => dashIfEmpty(row.agencyMode?.name),
=======
format: (row, dashIfEmpty) => dashIfEmpty(row.agencyMode?.name),
>>>>>>> dev
columnClass: 'expand', columnClass: 'expand',
label: t('Agency'), label: t('Agency'),
}, },

View File

@ -121,7 +121,7 @@ const entriesTableColumns = computed(() => [
:loading="isLoading" :loading="isLoading"
@click=" @click="
openReport( openReport(
`Entries/${props.row.id}/buy-label` `Entries/${props.row.id}/buy-label-supplier`
) )
" "
unelevated unelevated

View File

@ -3,8 +3,6 @@ import { ref, computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import axios from 'axios';
import { useArrayData } from 'src/composables/useArrayData';
import { downloadFile } from 'src/composables/downloadFile'; import { downloadFile } from 'src/composables/downloadFile';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
@ -12,15 +10,15 @@ import FetchData from 'src/components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnDms from 'src/components/common/VnDms.vue';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
import axios from 'axios';
const quasar = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const dms = ref({});
const route = useRoute(); const route = useRoute();
const quasar = useQuasar();
const editDownloadDisabled = ref(false); const editDownloadDisabled = ref(false);
const arrayData = useArrayData();
const invoiceIn = computed(() => arrayData.store.data);
const userConfig = ref(null); const userConfig = ref(null);
const invoiceId = computed(() => +route.params.id); const invoiceId = computed(() => +route.params.id);
@ -36,98 +34,25 @@ const warehousesRef = ref();
const allowTypesRef = ref(); const allowTypesRef = ref();
const allowedContentTypes = ref([]); const allowedContentTypes = ref([]);
const sageWithholdings = ref([]); const sageWithholdings = ref([]);
const inputFileRef = ref(); const documentDialogRef = ref({});
const editDmsRef = ref(); const invoiceInRef = ref({});
const createDmsRef = ref();
async function checkFileExists(dmsId) { function deleteFile(dmsFk) {
if (!dmsId) return; quasar
try { .dialog({
await axios.get(`Dms/${dmsId}`, { fields: ['id'] }); component: VnConfirm,
editDownloadDisabled.value = false; componentProps: {
} catch (e) { title: t('globals.confirmDeletion'),
editDownloadDisabled.value = true; message: t('globals.confirmDeletionMessage'),
} },
} })
.onOk(async () => {
async function setEditDms(dmsId) { await axios.post(`dms/${dmsFk}/removeFile`);
const { data } = await axios.get(`Dms/${dmsId}`); invoiceInRef.value.formData.dmsFk = null;
dms.value = { invoiceInRef.value.formData.dms = undefined;
warehouseId: data.warehouseFk, invoiceInRef.value.hasChanges = true;
companyId: data.companyFk, invoiceInRef.value.save();
dmsTypeId: data.dmsTypeFk,
...data,
};
if (!allowedContentTypes.value.length) await allowTypesRef.value.fetch();
editDmsRef.value.show();
}
async function setCreateDms() {
const { data } = await axios.get('DmsTypes/findOne', {
where: { code: 'invoiceIn' },
});
dms.value = {
reference: invoiceIn.value.supplierRef,
warehouseId: userConfig.value.warehouseFk,
companyId: userConfig.value.companyFk,
dmsTypeId: data.id,
description: invoiceIn.value.supplier.name,
hasFile: true,
hasFileAttached: true,
files: null,
};
createDmsRef.value.show();
}
async function onSubmit() {
try {
const isEdit = !!dms.value.id;
const errors = {
companyId: `The company can't be empty`,
warehouseId: `The warehouse can't be empty`,
dmsTypeId: `The DMS Type can't be empty`,
description: `The description can't be empty`,
};
Object.keys(errors).forEach((key) => {
if (!dms.value[key]) throw Error(t(errors[key]));
}); });
if (!isEdit && !dms.value.files) throw Error(t(`The files can't be empty`));
const formData = new FormData();
if (dms.value.files) {
for (let i = 0; i < dms.value.files.length; i++)
formData.append(dms.value.files[i].name, dms.value.files[i]);
dms.value.hasFileAttached = true;
}
const url = isEdit ? `dms/${dms.value.id}/updateFile` : 'Dms/uploadFile';
const { data } = await axios.post(url, formData, {
params: dms.value,
});
if (data.length) invoiceIn.value.dmsFk = data[0].id;
if (!isEdit) {
createDmsRef.value.hide();
} else {
editDmsRef.value.hide();
}
quasar.notify({
message: t('globals.dataSaved'),
type: 'positive',
});
} catch (error) {
quasar.notify({
message: t(`${error.message}`),
type: 'negative',
});
}
} }
</script> </script>
<template> <template>
@ -181,10 +106,12 @@ async function onSubmit() {
@on-fetch="(data) => (sageWithholdings = data)" @on-fetch="(data) => (sageWithholdings = data)"
/> />
<FormModel <FormModel
ref="invoiceInRef"
model="InvoiceIn" model="InvoiceIn"
:go-to="`/invoice-in/${invoiceId}/vat`" :go-to="`/invoice-in/${invoiceId}/vat`"
auto-load
:url-update="`InvoiceIns/${invoiceId}/updateInvoiceIn`" :url-update="`InvoiceIns/${invoiceId}/updateInvoiceIn`"
@on-fetch="(data) => (documentDialogRef.supplierName = data.supplier.nickname)"
auto-load
> >
<template #form="{ data }"> <template #form="{ data }">
<VnRow> <VnRow>
@ -242,16 +169,22 @@ async function onSubmit() {
</QItem> </QItem>
</template> </template>
</VnSelect> </VnSelect>
<VnInput
:label="t('Document')" <div class="row no-wrap">
v-model="data.dmsFk" <VnInput
clearable :label="t('Document')"
clear-icon="close" v-model="data.dmsFk"
@update:model-value="checkFileExists(data.dmsFk)" clearable
> clear-icon="close"
<template #prepend> class="full-width"
:disable="true"
/>
<div
v-if="data.dmsFk"
class="row no-wrap q-pa-xs q-gutter-x-xs"
data-cy="dms-buttons"
>
<QBtn <QBtn
v-if="data.dmsFk"
:class="{ :class="{
'no-pointer-events': editDownloadDisabled, 'no-pointer-events': editDownloadDisabled,
}" }"
@ -262,33 +195,52 @@ async function onSubmit() {
round round
@click="downloadFile(data.dmsFk)" @click="downloadFile(data.dmsFk)"
/> />
</template>
<template #append>
<QBtn <QBtn
:class="{ :class="{
'no-pointer-events': editDownloadDisabled, 'no-pointer-events': editDownloadDisabled,
}" }"
:disable="editDownloadDisabled" :disable="editDownloadDisabled"
v-if="data.dmsFk"
icon="edit" icon="edit"
round round
padding="xs" padding="xs"
@click="setEditDms(data.dmsFk)" @click="
() => {
documentDialogRef.show = true;
documentDialogRef.dms = data.dms;
}
"
> >
<QTooltip>{{ t('Edit document') }}</QTooltip> <QTooltip>{{ t('Edit document') }}</QTooltip>
</QBtn> </QBtn>
<QBtn <QBtn
v-else :class="{
icon="add_circle" 'no-pointer-events': editDownloadDisabled,
round }"
shortcut="+" :disable="editDownloadDisabled"
icon="delete"
:title="t('Delete file')"
padding="xs" padding="xs"
@click="setCreateDms()" round
> @click="deleteFile(data.dmsFk)"
<QTooltip>{{ t('Create document') }}</QTooltip> />
</QBtn> </div>
</template> <QBtn
</VnInput> v-else
icon="add_circle"
round
shortcut="+"
padding="xs"
@click="
() => {
documentDialogRef.show = true;
delete documentDialogRef.dms;
}
"
data-cy="dms-create"
>
<QTooltip>{{ t('Create document') }}</QTooltip>
</QBtn>
</div>
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
@ -319,237 +271,28 @@ async function onSubmit() {
</VnRow> </VnRow>
</template> </template>
</FormModel> </FormModel>
<QDialog ref="editDmsRef"> <QDialog v-model="documentDialogRef.show">
<QForm @submit="onSubmit()" class="all-pointer-events"> <VnDms
<QCard class="q-pa-sm"> model="dms"
<QCardSection class="row items-center q-pb-none"> default-dms-code="invoiceIn"
<span class="text-primary text-h6"> :form-initial-data="documentDialogRef.dms"
<QIcon name="edit" class="q-mr-xs" /> :url="
{{ t('Edit document') }} documentDialogRef.dms
</span> ? `Dms/${documentDialogRef.dms.id}/updateFile`
<QSpace /> : 'Dms/uploadFile'
<QBtn icon="close" flat round dense v-close-popup /> "
</QCardSection> :description="documentDialogRef.supplierName"
<QCardSection class="q-py-none"> @on-data-saved="
<QItem> (_, { data }) => {
<VnInput let dmsData = data;
class="full-width q-pa-xs" if (Array.isArray(data)) dmsData = data[0];
:label="t('Reference')" invoiceInRef.formData.dmsFk = dmsData.id;
v-model="dms.reference" invoiceInRef.formData.dms = dmsData;
clearable invoiceInRef.hasChanges = true;
clear-icon="close" invoiceInRef.save();
/> }
<VnSelect "
class="full-width q-pa-xs" />
:label="t('Company')"
v-model="dms.companyId"
:options="companies"
option-value="id"
option-label="code"
:required="true"
/>
</QItem>
<QItem>
<VnSelect
class="full-width q-pa-xs"
:label="t('Warehouse')"
v-model="dms.warehouseId"
:options="warehouses"
option-value="id"
option-label="name"
:required="true"
/>
<VnSelect
class="full-width q-pa-xs"
:label="t('Type')"
v-model="dms.dmsTypeId"
:options="dmsTypes"
option-value="id"
option-label="name"
:required="true"
/>
</QItem>
<QItem>
<VnInput
:label="t('Description')"
v-model="dms.description"
:required="true"
type="textarea"
class="full-width q-pa-xs"
size="lg"
autogrow
clearable
clear-icon="close"
/>
</QItem>
<QItem>
<QFile
ref="inputFileRef"
class="full-width q-pa-xs"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="attach_file_add"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('globals.selectFile') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</QItem>
<QItem>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
/>
</QItem>
</QCardSection>
<QCardActions class="justify-end">
<QBtn
flat
:label="t('globals.close')"
color="primary"
v-close-popup
/>
<QBtn :label="t('globals.save')" color="primary" @click="onSubmit" />
</QCardActions>
</QCard>
</QForm>
</QDialog>
<QDialog ref="createDmsRef">
<QForm @submit="onSubmit()" class="all-pointer-events">
<QCard class="q-pa-sm">
<QCardSection class="row items-center q-pb-none">
<span class="text-primary text-h6">
<QIcon name="edit" class="q-mr-xs" />
{{ t('Create document') }}
</span>
<QSpace />
<QBtn icon="close" flat round dense v-close-popup />
</QCardSection>
<QCardSection class="q-pb-none">
<QItem>
<VnInput
class="full-width q-pa-xs"
:label="t('Reference')"
v-model="dms.reference"
/>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Company')}*`"
v-model="dms.companyId"
:options="companies"
option-value="id"
option-label="code"
:required="true"
/>
</QItem>
<QItem>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Warehouse')}*`"
v-model="dms.warehouseId"
:options="warehouses"
option-value="id"
option-label="name"
:required="true"
/>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Type')}*`"
v-model="dms.dmsTypeId"
:options="dmsTypes"
option-value="id"
option-label="name"
:required="true"
/>
</QItem>
<QItem>
<VnInput
class="full-width q-pa-xs"
type="textarea"
size="lg"
autogrow
:label="`${t('Description')}*`"
v-model="dms.description"
clearable
clear-icon="close"
:rules="[(val) => val.length || t('Required field')]"
/>
</QItem>
<QItem>
<QFile
ref="inputFileRef"
class="full-width q-pa-xs"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="attach_file_add"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('globals.selectFile') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</QItem>
<QItem>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
/>
</QItem>
</QCardSection>
<QCardActions align="right">
<QBtn
flat
:label="t('globals.close')"
color="primary"
v-close-popup
/>
<QBtn :label="t('globals.save')" color="primary" @click="onSubmit" />
</QCardActions>
</QCard>
</QForm>
</QDialog> </QDialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -20,6 +20,23 @@ const filter = {
{ relation: 'invoiceInDueDay' }, { relation: 'invoiceInDueDay' },
{ relation: 'company' }, { relation: 'company' },
{ relation: 'currency' }, { relation: 'currency' },
{
relation: 'dms',
scope: {
fields: [
'dmsTypeFk',
'reference',
'hardCopyNumber',
'workerFk',
'description',
'hasFile',
'file',
'created',
'companyFk',
'warehouseFk',
],
},
},
], ],
}; };

View File

@ -13,7 +13,7 @@ const { t } = useI18n();
const invoiceOutGlobalStore = useInvoiceOutGlobalStore(); const invoiceOutGlobalStore = useInvoiceOutGlobalStore();
// invoiceOutGlobalStore state and getters // invoiceOutGlobalStore state and getters
const { initialDataLoading, formInitialData, invoicing, status } = const { initialDataLoading, formInitialData, status } =
storeToRefs(invoiceOutGlobalStore); storeToRefs(invoiceOutGlobalStore);
// invoiceOutGlobalStore actions // invoiceOutGlobalStore actions
@ -151,9 +151,8 @@ onMounted(async () => {
rounded rounded
/> />
</div> </div>
<QBtn <QBtn
v-if="!invoicing" v-if="!getStatus || getStatus === 'stopping'"
:label="t('invoiceOut')" :label="t('invoiceOut')"
type="submit" type="submit"
color="primary" color="primary"
@ -163,7 +162,7 @@ onMounted(async () => {
dense dense
/> />
<QBtn <QBtn
v-if="invoicing" v-else
:label="t('stop')" :label="t('stop')"
color="primary" color="primary"
class="q-mt-md full-width" class="q-mt-md full-width"

View File

@ -109,7 +109,11 @@ const insertTag = (rows) => {
> >
<template #body="{ rows, validate }"> <template #body="{ rows, validate }">
<QCard class="q-px-lg q-pt-md q-pb-sm"> <QCard class="q-px-lg q-pt-md q-pb-sm">
<VnRow v-for="(row, index) in rows" :key="index"> <VnRow
v-for="(row, index) in rows"
:key="index"
class="items-center"
>
<VnSelect <VnSelect
:label="t('itemTags.tag')" :label="t('itemTags.tag')"
:options="tagOptions" :options="tagOptions"
@ -153,13 +157,14 @@ const insertTag = (rows) => {
:required="true" :required="true"
:rules="validate('itemTag.priority')" :rules="validate('itemTag.priority')"
/> />
<div class="row justify-center items-center" style="flex: 0"> <div class="row justify-center" style="flex: 0">
<QIcon <QIcon
@click="itemTagsRef.remove([row])" @click="itemTagsRef.remove([row])"
class="fill-icon-on-hover" class="fill-icon-on-hover"
color="primary" color="primary"
name="delete" name="delete"
size="sm" size="sm"
dense
> >
<QTooltip> <QTooltip>
{{ t('itemTags.removeTag') }} {{ t('itemTags.removeTag') }}
@ -167,22 +172,20 @@ const insertTag = (rows) => {
</QIcon> </QIcon>
</div> </div>
</VnRow> </VnRow>
<VnRow class="justify-center items-center">
<QBtn
@click="insertTag(rows)"
class="cursor-pointer"
color="primary"
flat
icon="add"
shortcut="+"
style="flex: 0"
>
<QTooltip>
{{ t('itemTags.addTag') }}
</QTooltip>
</QBtn>
</VnRow>
</QCard> </QCard>
<QPageSticky position="bottom-right" :offset="[25, 25]">
<QBtn
@click="insertTag(rows)"
color="primary"
icon="add"
shortcut="+"
fab
>
<QTooltip>
{{ t('itemTags.addTag') }}
</QTooltip>
</QBtn>
</QPageSticky>
</template> </template>
</CrudModel> </CrudModel>
</QPage> </QPage>

View File

@ -12,6 +12,8 @@ import ItemSummary from '../Item/Card/ItemSummary.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
import { cloneItem } from 'src/pages/Item/composables/cloneItem'; import { cloneItem } from 'src/pages/Item/composables/cloneItem';
import RightMenu from 'src/components/common/RightMenu.vue';
import ItemListFilter from './ItemListFilter.vue';
const entityId = computed(() => route.params.id); const entityId = computed(() => route.params.id);
const { openCloneDialog } = cloneItem(); const { openCloneDialog } = cloneItem();
@ -215,7 +217,7 @@ const columns = computed(() => [
columnFilter: { columnFilter: {
name: 'workerFk', name: 'workerFk',
attrs: { attrs: {
url: 'VnUsers/preview', url: 'TicketRequests/getItemTypeWorker',
optionValue: 'id', optionValue: 'id',
optionLabel: 'nickname', optionLabel: 'nickname',
}, },
@ -311,6 +313,11 @@ const columns = computed(() => [
:label="t('item.searchbar.label')" :label="t('item.searchbar.label')"
:info="t('You can search by id')" :info="t('You can search by id')"
/> />
<RightMenu>
<template #right-panel>
<ItemListFilter data-key="ItemList" />
</template>
</RightMenu>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="ItemList" data-key="ItemList"
@ -329,6 +336,7 @@ const columns = computed(() => [
auto-load auto-load
redirect="Item" redirect="Item"
:is-editable="false" :is-editable="false"
:right-search="false"
:filer="itemFilter" :filer="itemFilter"
> >
<template #column-id="{ row }"> <template #column-id="{ row }">

View File

@ -104,7 +104,7 @@ const columns = computed(() => [
columnFilter: { columnFilter: {
name: 'attenderFk', name: 'attenderFk',
attrs: { attrs: {
url: 'VnUsers/preview', url: 'TicketRequests/getItemTypeWorker',
optionValue: 'id', optionValue: 'id',
optionLabel: 'nickname', optionLabel: 'nickname',
}, },

View File

@ -102,6 +102,7 @@ function extractValueTags(items) {
:key="row.id" :key="row.id"
:item="row" :item="row"
is-catalog is-catalog
class="fill-icon"
/> />
</div> </div>
</template> </template>

View File

@ -10,7 +10,6 @@ import VnSelect from 'components/common/VnSelect.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import { useDialogPluginComponent } from 'quasar'; import { useDialogPluginComponent } from 'quasar';
import { reactive } from 'vue'; import { reactive } from 'vue';
import FetchData from 'components/FetchData.vue';
const { t } = useI18n(); const { t } = useI18n();
const state = useState(); const state = useState();

View File

@ -71,10 +71,6 @@ const getConfirmationValue = (isConfirmed) => {
}; };
const total = ref(null); const total = ref(null);
function ticketFilter(order) {
return JSON.stringify({ id: order.id });
}
</script> </script>
<template> <template>
@ -126,7 +122,11 @@ function ticketFilter(order) {
color="primary" color="primary"
:to="{ :to="{
name: 'TicketList', name: 'TicketList',
query: { table: ticketFilter(entity) }, query: {
table: JSON.stringify({
orderFk: entity.id,
}),
},
}" }"
> >
<QTooltip>{{ t('order.summary.orderTicketList') }}</QTooltip> <QTooltip>{{ t('order.summary.orderTicketList') }}</QTooltip>

View File

@ -23,8 +23,8 @@ function confirmRemove() {
.dialog({ .dialog({
component: VnConfirm, component: VnConfirm,
componentProps: { componentProps: {
title: t('globals.confirmDeletion'), title: t('You are going to delete this order'),
message: t('confirmDeletionMessage'), message: t('Continue anyway?'),
promise: remove, promise: remove,
}, },
}) })
@ -57,5 +57,6 @@ en:
es: es:
deleteOrder: Eliminar pedido deleteOrder: Eliminar pedido
confirmDeletionMessage: Seguro que quieres eliminar este pedido? confirmDeletionMessage: Seguro que quieres eliminar este pedido?
You are going to delete this order: El pedido se eliminará
Continue anyway?: ¿Continuar de todos modos?
</i18n> </i18n>

View File

@ -6,6 +6,7 @@ import { useQuasar } from 'quasar';
import axios from 'axios'; import axios from 'axios';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import { confirm } from 'src/pages/Order/composables/confirmOrder';
import { toCurrency, toDate } from 'src/filters'; import { toCurrency, toDate } from 'src/filters';
import VnConfirm from 'components/ui/VnConfirm.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
@ -31,7 +32,6 @@ const orderSummary = ref({
}); });
const getTotalRef = ref(); const getTotalRef = ref();
const getVATRef = ref(); const getVATRef = ref();
const lineFilter = ref({ const lineFilter = ref({
include: [ include: [
{ {
@ -168,7 +168,7 @@ const columns = computed(() => [
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
title: t('Delete'), title: t('Remove item'),
icon: 'delete', icon: 'delete',
show: (row) => !row.order.isConfirmed, show: (row) => !row.order.isConfirmed,
action: (row) => confirmRemove(row), action: (row) => confirmRemove(row),
@ -204,20 +204,21 @@ async function remove(item) {
getVATRef.value.fetch(); getVATRef.value.fetch();
} }
async function confirmOrder() { async function handleConfirm() {
await axios.post(`Orders/${route.params.id}/confirm`); const result = await confirm(route.params.id);
quasar.notify({ if (result) {
message: t('globals.confirm'), quasar.notify({
type: 'positive', message: t('globals.dataSaved'),
}); type: 'positive',
router.push({ });
name: 'TicketList', router.push({
query: { name: 'TicketList',
table: JSON.stringify({ clientFk: descriptorData.store.data.clientFk }), query: {
}, table: JSON.stringify({ clientFk: descriptorData.store.data.clientFk }),
}); },
});
}
} }
watch( watch(
() => router.currentRoute.value.params.id, () => router.currentRoute.value.params.id,
() => { () => {
@ -314,7 +315,7 @@ watch(
</template> </template>
</VnTable> </VnTable>
<QPageSticky :offset="[20, 20]" v-if="!order?.isConfirmed" style="z-index: 2"> <QPageSticky :offset="[20, 20]" v-if="!order?.isConfirmed" style="z-index: 2">
<QBtn fab icon="check" color="primary" @click="confirmOrder()" /> <QBtn fab icon="check" color="primary" @click="handleConfirm()" />
<QTooltip> <QTooltip>
{{ t('confirm') }} {{ t('confirm') }}
</QTooltip> </QTooltip>
@ -401,4 +402,5 @@ es:
confirmDeletion: Confirmar eliminación, confirmDeletion: Confirmar eliminación,
confirmDeletionMessage: Seguro que quieres eliminar este artículo? confirmDeletionMessage: Seguro que quieres eliminar este artículo?
confirm: Confirmar confirm: Confirmar
Remove item: Eliminar artículo
</i18n> </i18n>

View File

@ -2,7 +2,10 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import { dashIfEmpty, toCurrency, toDateHourMinSec } from 'src/filters'; import { dashIfEmpty, toCurrency, toDateHourMinSec } from 'src/filters';
import { useArrayData } from 'composables/useArrayData';
import { confirm } from 'src/pages/Order/composables/confirmOrder';
import VnLv from 'components/ui/VnLv.vue'; import VnLv from 'components/ui/VnLv.vue';
import CardSummary from 'components/ui/CardSummary.vue'; import CardSummary from 'components/ui/CardSummary.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue'; import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
@ -21,6 +24,9 @@ const $props = defineProps({
}); });
const entityId = computed(() => $props.id || route.params.id); const entityId = computed(() => $props.id || route.params.id);
const summary = ref();
const quasar = useQuasar();
const descriptorData = useArrayData('orderData');
const detailsColumns = ref([ const detailsColumns = ref([
{ {
name: 'item', name: 'item',
@ -49,6 +55,18 @@ const detailsColumns = ref([
field: (row) => toCurrency(row?.quantity * row?.price), field: (row) => toCurrency(row?.quantity * row?.price),
}, },
]); ]);
async function handleConfirm() {
const result = await confirm(route.params.id);
if (result) {
quasar.notify({
message: t('globals.dataSaved'),
type: 'positive',
});
summary.value.fetch({});
descriptorData.fetch({});
}
}
</script> </script>
<template> <template>
@ -62,6 +80,17 @@ const detailsColumns = ref([
{{ t('order.summary.basket') }} #{{ entity?.id }} - {{ t('order.summary.basket') }} #{{ entity?.id }} -
{{ entity?.client?.name }} ({{ entity?.clientFk }}) {{ entity?.client?.name }} ({{ entity?.clientFk }})
</template> </template>
<template #header-right>
<QBtn
flat
text-color="white"
:disabled="isConfirmed"
:label="t('order.summary.confirm')"
@click="handleConfirm()"
>
<QTooltip>{{ t('order.summary.confirmLines') }}</QTooltip>
</QBtn>
</template>
<template #body="{ entity }"> <template #body="{ entity }">
<QCard class="vn-one"> <QCard class="vn-one">
<VnTitle <VnTitle

View File

@ -233,7 +233,20 @@ onMounted(() => {
v-model="data.clientFk" v-model="data.clientFk"
:label="t('module.customer')" :label="t('module.customer')"
@update:model-value="(id) => fetchClientAddress(id, data)" @update:model-value="(id) => fetchClientAddress(id, data)"
/> >
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt.name }}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt.id}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect <VnSelect
v-model="data.addressId" v-model="data.addressId"
:options="addressesList" :options="addressesList"
@ -245,10 +258,21 @@ onMounted(() => {
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
<QItemSection> <QItemSection>
<QItemLabel> <QItemLabel
{{ scope.opt?.nickname }}: {{ scope.opt?.street }}, :class="{
{{ scope.opt?.city }}</QItemLabel 'color-vn-label': !scope.opt?.isActive,
}"
> >
{{
`${
!scope.opt?.isActive
? t('basicData.inactive')
: ''
} `
}}
{{ scope.opt?.nickname }}: {{ scope.opt?.street }},
{{ scope.opt?.city }}
</QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>
</template> </template>

View File

@ -0,0 +1,5 @@
import axios from 'axios';
export async function confirm(routeId) {
return await axios.post(`Orders/${routeId}/confirm`);
}

View File

@ -56,6 +56,7 @@ const attendersOptions = ref([]);
v-model="data.price" v-model="data.price"
:label="t('purchaseRequest.price')" :label="t('purchaseRequest.price')"
type="number" type="number"
step="0.01"
min="0" min="0"
/> />
</VnRow> </VnRow>

View File

@ -19,7 +19,6 @@ import VnTitle from 'src/components/common/VnTitle.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue'; import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue'; import VnToSummary from 'src/components/ui/VnToSummary.vue';
const route = useRoute(); const route = useRoute();
@ -87,10 +86,6 @@ async function changeState(value) {
function toTicketUrl(section) { function toTicketUrl(section) {
return '#/ticket/' + entityId.value + '/' + section; return '#/ticket/' + entityId.value + '/' + section;
} }
function isOnTicketCard() {
const currentPath = route.path;
return currentPath.startsWith('/ticket');
}
</script> </script>
<template> <template>

View File

@ -268,8 +268,7 @@ const fetchAddresses = async (formData) => {
if (!formData.clientId) return; if (!formData.clientId) return;
const filter = { const filter = {
fields: ['nickname', 'street', 'city', 'id'], fields: ['nickname', 'street', 'city', 'id', 'isActive'],
where: { isActive: true },
order: 'nickname ASC', order: 'nickname ASC',
}; };
const params = { filter: JSON.stringify(filter) }; const params = { filter: JSON.stringify(filter) };
@ -635,24 +634,36 @@ function setReference(data) {
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
url="Addresses" :label="t('basicData.address')"
:label="t('ticket.create.address')"
v-model="data.addressId" v-model="data.addressId"
:options="addressesOptions" :options="addressesOptions"
option-value="id" option-value="id"
option-label="nickname" option-label="nickname"
hide-selected hide-selected
map-options
:disable="!data.clientId" :disable="!data.clientId"
:sort-by="'isActive DESC'"
@update:model-value="() => fetchAvailableAgencies(data)" @update:model-value="() => fetchAvailableAgencies(data)"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
<QItemSection> <QItemSection>
<QItemLabel> <QItemLabel
{{ scope.opt.nickname }} :class="{
</QItemLabel> 'color-vn-label': !scope.opt?.isActive,
<QItemLabel caption> }"
{{ `${scope.opt.street}, ${scope.opt.city}` }} >
{{
`${
!scope.opt?.isActive
? t('basicData.inactive')
: ''
} `
}}
<span>
{{ scope.opt?.nickname }}:
{{ scope.opt?.street }}, {{ scope.opt?.city }}
</span>
</QItemLabel> </QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>

View File

@ -3,11 +3,12 @@ import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import FetchData from 'src/components/FetchData.vue';
const tableRef = ref(); const tableRef = ref();
const payrollComponents = ref([]);
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const entityId = computed(() => route.params.id); const entityId = computed(() => route.params.id);
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -25,8 +26,9 @@ const columns = computed(() => [
create: true, create: true,
component: 'select', component: 'select',
attrs: { attrs: {
url: 'payrollComponents', options: payrollComponents,
fields: ['id', 'name'], optionLabel: 'name',
optionValue: 'id',
}, },
cardVisible: true, cardVisible: true,
}, },
@ -73,6 +75,16 @@ const columns = computed(() => [
]); ]);
</script> </script>
<template> <template>
<FetchData
url="PayrollComponents"
:filter="{
fields: ['id', 'name'],
where: { name: { neq: '' } },
order: 'name ASC',
}"
@on-fetch="(data) => (payrollComponents = data)"
auto-load
/>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="WorkerBalance" data-key="WorkerBalance"
@ -94,6 +106,7 @@ const columns = computed(() => [
:is-editable="true" :is-editable="true"
:use-model="true" :use-model="true"
:default-remove="false" :default-remove="false"
search-url="balance"
/> />
</template> </template>
<i18n> <i18n>

View File

@ -134,6 +134,7 @@ const columns = computed(() => [
:is-editable="true" :is-editable="true"
:use-model="true" :use-model="true"
:default-remove="false" :default-remove="false"
search-url="formation"
/> />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -100,5 +100,6 @@ const columns = [
:is-editable="true" :is-editable="true"
:use-model="true" :use-model="true"
:default-remove="false" :default-remove="false"
search-url="medical"
/> />
</template> </template>

View File

@ -71,6 +71,7 @@ function setNotifications(data) {
:default-remove="false" :default-remove="false"
:default-save="false" :default-save="false"
@on-fetch="setNotifications" @on-fetch="setNotifications"
search-url="notifications"
> >
<template #body> <template #body>
<div <div

View File

@ -63,6 +63,7 @@ function reloadData() {
url="DeviceProductionUsers" url="DeviceProductionUsers"
:filter="{ where: { userFk: routeId } }" :filter="{ where: { userFk: routeId } }"
order="id" order="id"
search-url="pda"
auto-load auto-load
> >
<template #body="{ rows }"> <template #body="{ rows }">

View File

@ -93,7 +93,7 @@ export const useInvoiceOutGlobalStore = defineStore({
async makeInvoice(formData, clientsToInvoice) { async makeInvoice(formData, clientsToInvoice) {
this.invoicing = true; this.invoicing = true;
this.status = 'packageInvoicing'; const promises = [];
try { try {
this.printer = formData.printer; this.printer = formData.printer;
const params = { const params = {
@ -118,10 +118,11 @@ export const useInvoiceOutGlobalStore = defineStore({
); );
throw new Error("There aren't addresses to invoice"); throw new Error("There aren't addresses to invoice");
} }
this.status = 'invoicing';
for (const address of this.addresses) { for (let index = 0; index < this.parallelism; index++) {
await this.invoiceClient(address, formData); promises.push(this.invoiceClient(formData, index));
} }
await Promise.all(promises);
} catch (err) { } catch (err) {
this.handleError(err); this.handleError(err);
} }
@ -171,17 +172,14 @@ export const useInvoiceOutGlobalStore = defineStore({
} }
}, },
async invoiceClient(address, formData) { async invoiceClient(formData, index) {
const address = this.addresses[index];
if (!address || !this.status || this.status == 'stopping') {
this.status = 'stopping';
this.invoicing = false;
return;
}
try { try {
if (this.nRequests === this.parallelism || this.isInvoicing) return;
if (this.status === 'stopping') {
if (this.nRequests) return;
this.invoicing = false;
this.status = 'done';
return;
}
const params = { const params = {
clientId: address.clientId, clientId: address.clientId,
addressId: address.id, addressId: address.id,
@ -191,13 +189,11 @@ export const useInvoiceOutGlobalStore = defineStore({
serialType: formData.serialType, serialType: formData.serialType,
}; };
this.status = 'invoicing';
this.invoicing = true; this.invoicing = true;
const { data } = await axios.post('InvoiceOuts/invoiceClient', params); const { data } = await axios.post('InvoiceOuts/invoiceClient', params);
if (data) await this.makePdfAndNotify(data, address); if (data) await this.makePdfAndNotify(data, address);
this.addressIndex++;
this.isInvoicing = false; this.isInvoicing = false;
} catch (err) { } catch (err) {
if (err?.response?.status >= 400 && err?.response?.status < 500) { if (err?.response?.status >= 400 && err?.response?.status < 500) {
@ -205,13 +201,16 @@ export const useInvoiceOutGlobalStore = defineStore({
return; return;
} else { } else {
this.invoicing = false; this.invoicing = false;
this.status = 'done';
notify( notify(
'invoiceOut.globalInvoices.errors.criticalInvoiceError', 'invoiceOut.globalInvoices.errors.criticalInvoiceError',
'negative' 'negative'
); );
throw new Error('Critical invoicing error, process stopped'); throw new Error('Critical invoicing error, process stopped');
} }
} finally {
this.addressIndex++;
if (this.status != 'stopping')
await this.invoiceClient(formData, this.addressIndex);
} }
}, },
@ -234,7 +233,6 @@ export const useInvoiceOutGlobalStore = defineStore({
handleError(err) { handleError(err) {
this.invoicing = false; this.invoicing = false;
this.status = null;
throw err; throw err;
}, },
@ -279,7 +277,7 @@ export const useInvoiceOutGlobalStore = defineStore({
return 0; return 0;
} }
let porcentaje = (state.addressIndex / this.getNAddresses) * 100; let porcentaje = (state.addressIndex / this.getNAddresses) * 100;
return porcentaje; return porcentaje?.toFixed(2);
}, },
getAddressNumber(state) { getAddressNumber(state) {
return state.addressIndex; return state.addressIndex;

View File

@ -2,9 +2,8 @@
describe('InvoiceInBasicData', () => { describe('InvoiceInBasicData', () => {
const formInputs = '.q-form > .q-card input'; const formInputs = '.q-form > .q-card input';
const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select'; const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select';
const documentBtns = '.q-form .q-field button'; const documentBtns = '[data-cy="dms-buttons"] button';
const dialogInputs = '.q-dialog input'; const dialogInputs = '.q-dialog input';
const dialogActionBtns = '.q-card__actions button';
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
@ -21,27 +20,35 @@ describe('InvoiceInBasicData', () => {
cy.get(formInputs).eq(1).invoke('val').should('eq', '4739'); cy.get(formInputs).eq(1).invoke('val').should('eq', '4739');
}); });
it('should edit the dms data', () => { it('should edit, remove and create the dms data', () => {
const firtsInput = 'Ticket:65'; const firtsInput = 'Ticket:65';
const secondInput = "I don't know what posting here!"; const secondInput = "I don't know what posting here!";
//edit
cy.get(documentBtns).eq(1).click(); cy.get(documentBtns).eq(1).click();
cy.get(dialogInputs).eq(0).type(`{selectall}${firtsInput}`); cy.get(dialogInputs).eq(0).type(`{selectall}${firtsInput}`);
cy.get('textarea').type(`{selectall}${secondInput}`); cy.get('textarea').type(`{selectall}${secondInput}`);
cy.get(dialogActionBtns).eq(1).click(); cy.get('[data-cy="FormModelPopup_save"]').click();
cy.get(documentBtns).eq(1).click(); cy.get(documentBtns).eq(1).click();
cy.get(dialogInputs).eq(0).invoke('val').should('eq', firtsInput); cy.get(dialogInputs).eq(0).invoke('val').should('eq', firtsInput);
cy.get('textarea').invoke('val').should('eq', secondInput); cy.get('textarea').invoke('val').should('eq', secondInput);
}); cy.get('[data-cy="FormModelPopup_save"]').click();
cy.checkNotification('Data saved');
it('should throw an error creating a new dms if a file is not attached', () => { //remove
cy.get(formInputs).eq(7).type('{selectall}{backspace}'); cy.get(documentBtns).eq(2).click();
cy.get(documentBtns).eq(0).click(); cy.get('[data-cy="VnConfirm_confirm"]').click();
cy.get(dialogActionBtns).eq(1).click(); cy.checkNotification('Data saved');
cy.get('.q-notification__message').should(
'have.text', //create
"The files can't be empty" cy.get('[data-cy="dms-create"]').eq(0).click();
cy.get('[data-cy="VnDms_inputFile"').selectFile(
'test/cypress/fixtures/image.jpg',
{
force: true,
}
); );
cy.get('[data-cy="FormModelPopup_save"]').click();
cy.checkNotification('Data saved');
}); });
}); });

View File

@ -13,7 +13,7 @@ describe('Logout', () => {
}); });
describe('not user', () => { describe('not user', () => {
beforeEach(() => { beforeEach(() => {
cy.intercept('GET', '**DefaultViewConfigs**', { cy.intercept('GET', '**StarredModules**', {
statusCode: 401, statusCode: 401,
body: { body: {
error: { error: {
@ -29,10 +29,7 @@ describe('Logout', () => {
it('when token not exists', () => { it('when token not exists', () => {
cy.get('.q-list > [href="#/item"]').click(); cy.get('.q-list > [href="#/item"]').click();
cy.get('.q-notification__message').should( cy.checkNotification('Authorization Required');
'have.text',
'Authorization Required'
);
}); });
}); });
}); });

View File

@ -14,6 +14,8 @@ describe('Ticket descriptor', () => {
it('should clone the ticket without warehouse', () => { it('should clone the ticket without warehouse', () => {
cy.visit('/#/ticket/1/summary'); cy.visit('/#/ticket/1/summary');
cy.intercept('GET', /\/api\/Tickets\/\d/).as('ticket');
cy.wait('@ticket');
cy.openActionsDescriptor(); cy.openActionsDescriptor();
cy.contains(listItem, toCloneOpt).click(); cy.contains(listItem, toCloneOpt).click();
cy.clickConfirm(); cy.clickConfirm();
@ -28,6 +30,8 @@ describe('Ticket descriptor', () => {
it('should set the weight of the ticket', () => { it('should set the weight of the ticket', () => {
cy.visit('/#/ticket/10/summary'); cy.visit('/#/ticket/10/summary');
cy.intercept('GET', /\/api\/Tickets\/\d/).as('ticket');
cy.wait('@ticket');
cy.openActionsDescriptor(); cy.openActionsDescriptor();
cy.contains(listItem, setWeightOpt).click(); cy.contains(listItem, setWeightOpt).click();
cy.intercept('POST', /\/api\/Tickets\/\d+\/setWeight/).as('weight'); cy.intercept('POST', /\/api\/Tickets\/\d+\/setWeight/).as('weight');

View File

@ -261,7 +261,7 @@ Cypress.Commands.add('openActionDescriptor', (opt) => {
}); });
Cypress.Commands.add('openActionsDescriptor', () => { Cypress.Commands.add('openActionsDescriptor', () => {
cy.get('.header > :nth-child(3) > .q-btn__content > .q-icon').click(); cy.get('[data-cy="descriptor-more-opts"]').click();
}); });
Cypress.Commands.add('clickButtonsDescriptor', (id) => { Cypress.Commands.add('clickButtonsDescriptor', (id) => {

View File

@ -0,0 +1,47 @@
import { describe, expect, it, beforeAll, beforeEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import VnTable from 'src/components/VnTable/VnTable.vue';
describe('VnTable', () => {
let wrapper;
let vm;
beforeAll(() => {
wrapper = createWrapper(VnTable, {
propsData: {
columns: [],
},
});
vm = wrapper.vm;
});
beforeEach(() => (vm.selected = []));
describe('handleSelection()', () => {
const rows = [{ $index: 0 }, { $index: 1 }, { $index: 2 }];
const selectedRows = [{ $index: 1 }];
it('should add rows to selected when shift key is pressed and rows are added except last one', () => {
vm.handleSelection(
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
rows
);
expect(vm.selected).toEqual([{ $index: 0 }]);
});
it('should not add rows to selected when shift key is not pressed', () => {
vm.handleSelection(
{ evt: { shiftKey: false }, added: true, rows: selectedRows },
rows
);
expect(vm.selected).toEqual([]);
});
it('should not add rows to selected when rows are not added', () => {
vm.handleSelection(
{ evt: { shiftKey: true }, added: false, rows: selectedRows },
rows
);
expect(vm.selected).toEqual([]);
});
});
});