refactor(customerAddress): refs #7527 is popup remove /create /edit #1695

Closed
alexm wants to merge 13 commits from 7527-notCreatePaths into dev
25 changed files with 482 additions and 1742 deletions

View File

@ -48,6 +48,10 @@ const $props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
description: {
type: String,
deafult: undefined,
},
}); });
const dmsFilter = { const dmsFilter = {
@ -88,7 +92,6 @@ const dmsFilter = {
], ],
}, },
}, },
where: { [$props.filter]: route.params.id },
}; };
const columns = computed(() => [ const columns = computed(() => [
@ -298,6 +301,7 @@ defineExpose({
:data-key="$props.model" :data-key="$props.model"
:url="$props.model" :url="$props.model"
:user-filter="dmsFilter" :user-filter="dmsFilter"
:filter="{ where: { [filter]: route.params.id } }"
:order="['dmsFk DESC']" :order="['dmsFk DESC']"
auto-load auto-load
@on-fetch="setData" @on-fetch="setData"

View File

@ -211,12 +211,10 @@ globals:
mandates: Mandates mandates: Mandates
contacts: Contacts contacts: Contacts
webPayment: Web payment webPayment: Web payment
fileManagement: File management
unpaid: Unpaid unpaid: Unpaid
entries: Entries entries: Entries
buys: Buys buys: Buys
dms: File management dms: File management
entryCreate: New entry
latestBuys: Latest buys latestBuys: Latest buys
reserves: Reserves reserves: Reserves
tickets: Tickets tickets: Tickets

View File

@ -214,12 +214,10 @@ globals:
mandates: Mandatos mandates: Mandatos
contacts: Contactos contacts: Contactos
webPayment: Pago web webPayment: Pago web
fileManagement: Gestión documental
unpaid: Impago unpaid: Impago
entries: Entradas entries: Entradas
buys: Compras buys: Compras
dms: Gestión documental dms: Gestión documental
entryCreate: Nueva entrada
latestBuys: Últimas compras latestBuys: Últimas compras
reserves: Reservas reserves: Reservas
tickets: Tickets tickets: Tickets

View File

@ -1,18 +1,22 @@
<script setup> <script setup>
import { onBeforeMount, ref, watch } from 'vue'; import { ref, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute } from 'vue-router';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import axios from 'axios'; import axios from 'axios';
import CustomerAddressForm from '../components/CustomerAddressForm.vue';
import CustomerAddressEdit from '../components/CustomerAddressEdit.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter();
const addresses = ref([]); const addresses = ref([]);
const client = ref(null); const client = ref(null);
const showFormCreate = ref();
const showFormEdit = ref();
const showFormEditModel = ref();
const vnPaginateRef = ref();
const addressFilter = { const addressFilter = {
fields: [ fields: [
'id', 'id',
@ -27,6 +31,11 @@ const addressFilter = {
'isEqualizated', 'isEqualizated',
'isLogifloraAllowed', 'isLogifloraAllowed',
'postalCode', 'postalCode',
'agencyModeFk',
'longitude',
'latitude',
'incotermsFk',
'customsAgentFk',
], ],
order: ['isDefaultAddress DESC', 'isActive DESC', 'id DESC', 'nickname ASC'], order: ['isDefaultAddress DESC', 'isActive DESC', 'id DESC', 'nickname ASC'],
include: [ include: [
@ -48,14 +57,15 @@ const addressFilter = {
], ],
}, },
}, },
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name'],
},
},
], ],
}; };
onBeforeMount(() => {
const { id } = route.params;
getClientData(id);
});
watch( watch(
() => route.params.id, () => route.params.id,
(newValue) => { (newValue) => {
@ -65,16 +75,13 @@ watch(
); );
const getClientData = async (id) => { const getClientData = async (id) => {
try { const { data } = await axios.get(`Clients/${id}`);
const { data } = await axios.get(`Clients/${id}`); client.value = data;
client.value = data;
} catch (error) {
return error;
}
}; };
const isDefaultAddress = (address) => { const isDefaultAddress = (address) => {
return client?.value?.defaultAddressFk === address.id ? 1 : 0; address.isDefaultAddress = client?.value?.defaultAddressFk === address.id ? 1 : 0;
return address.isDefaultAddress;
}; };
const setDefault = (address) => { const setDefault = (address) => {
@ -88,35 +95,35 @@ const setDefault = (address) => {
}); });
}; };
const sortAddresses = (data) => { const sortAddresses = async (data) => {
await getClientData(route.params.id);
if (!client.value || !data) return; if (!client.value || !data) return;
addresses.value = data.sort((a, b) => { addresses.value = data.sort((a, b) => {
return isDefaultAddress(b) - isDefaultAddress(a); return isDefaultAddress(b) - isDefaultAddress(a);
}); });
openAddressForm();
}; };
const toCustomerAddressCreate = () => { function openAddressForm() {
router.push({ name: 'CustomerAddressCreate' }); if (route.query.addressId) {
}; const address = addresses.value.find(
(address) => address.id == +route.query.addressId,
const toCustomerAddressEdit = (addressId) => { );
router.push({ if (address) {
name: 'CustomerAddressEdit', showFormEdit.value = true;
params: { showFormEditModel.value = address;
id: route.params.id, }
addressId, }
}, }
});
};
</script> </script>
<template> <template>
<FetchData <FetchData
ref="vnPaginateRef"
@on-fetch="sortAddresses" @on-fetch="sortAddresses"
auto-load auto-load
data-key="CustomerAddresses" data-key="CustomerAddresses"
order="id DESC" order="id DESC"
ref="vnPaginateRef"
:filter="addressFilter" :filter="addressFilter"
:url="`Clients/${route.params.id}/addresses`" :url="`Clients/${route.params.id}/addresses`"
/> />
@ -131,7 +138,7 @@ const toCustomerAddressEdit = (addressId) => {
'q-mb-md': index < addresses.length - 1, 'q-mb-md': index < addresses.length - 1,
'item-disabled': !item.isActive, 'item-disabled': !item.isActive,
}" }"
@click="toCustomerAddressEdit(item.id)" @click="(showFormEdit = !showFormEdit) && (showFormEditModel = item)"
> >
<div class="q-ml-xs q-mr-md flex items-center"> <div class="q-ml-xs q-mr-md flex items-center">
<QIcon <QIcon
@ -200,19 +207,18 @@ const toCustomerAddressEdit = (addressId) => {
v-for="(observation, obIndex) in item.observations" v-for="(observation, obIndex) in item.observations"
> >
<div class="text-weight-bold q-mr-sm"> <div class="text-weight-bold q-mr-sm">
{{ observation.observationType.description }}: {{ observation?.observationType?.description }}:
</div> </div>
<div>{{ observation.description }}</div> <div>{{ observation?.description }}</div>
</div> </div>
</div> </div>
</div> </div>
</QCardSection> </QCardSection>
</QCard> </QCard>
</div> </div>
<QPageSticky :offset="[18, 18]"> <QPageSticky :offset="[18, 18]">
<QBtn <QBtn
@click.stop="toCustomerAddressCreate()" @click.stop="showFormCreate = !showFormCreate"
color="primary" color="primary"
fab fab
icon="add" icon="add"
@ -222,6 +228,28 @@ const toCustomerAddressEdit = (addressId) => {
{{ t('New consignee') }} {{ t('New consignee') }}
</QTooltip> </QTooltip>
</QPageSticky> </QPageSticky>
<QDialog v-model="showFormEdit" :full-width="true">
<CustomerAddressEdit
:id="showFormEditModel.id"
v-model="showFormEditModel"
@on-data-saved="() => vnPaginateRef.fetch()"
/>
</QDialog>
<QDialog v-model="showFormCreate" :full-width="true">
<CustomerAddressForm
:is-create="true"
:form-initial-data="{
isDefaultAddress: false,
isActive: true,
isEqualizated: false,
isLogifloraAllowed: false,
}"
:observe-form-changes="false"
:url-create="`Clients/${route.params.id}/createAddress`"
model="client"
@on-data-saved="() => vnPaginateRef.fetch()"
/>
</QDialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -2,12 +2,13 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
import ModalCloseContract from 'src/pages/Customer/components/ModalCloseContract.vue'; import ModalCloseContract from 'src/pages/Customer/components/ModalCloseContract.vue';
import { toDate } from 'src/filters'; import CustomerCreditContractsCreate from '../components/CustomerCreditContractsCreate.vue';
import VnLv from 'src/components/ui/VnLv.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
@ -16,6 +17,7 @@ const quasar = useQuasar();
const vnPaginateRef = ref(null); const vnPaginateRef = ref(null);
const showQPageSticky = ref(true); const showQPageSticky = ref(true);
const showForm = ref();
const filter = { const filter = {
order: 'finished ASC, started DESC', order: 'finished ASC, started DESC',
@ -36,25 +38,21 @@ const fetch = (data) => {
data.forEach((element) => { data.forEach((element) => {
if (!element.finished) { if (!element.finished) {
showQPageSticky.value = false; showQPageSticky.value = false;
return;
} }
}); });
}; };
const toCustomerCreditContractsCreate = () => {
router.push({ name: 'CustomerCreditContractsCreate' });
};
const openDialog = (item) => { const openDialog = (item) => {
quasar.dialog({ quasar.dialog({
component: ModalCloseContract, component: ModalCloseContract,
componentProps: { componentProps: {
id: item.id, id: item.id,
promise: updateData, promise: async () => {
await updateData();
showQPageSticky.value = true;
},
}, },
}); });
updateData();
showQPageSticky.value = true;
}; };
const openViewCredit = (credit) => { const openViewCredit = (credit) => {
@ -66,14 +64,14 @@ const openViewCredit = (credit) => {
}); });
}; };
const updateData = () => { const updateData = async () => {
vnPaginateRef.value?.fetch(); await vnPaginateRef.value?.fetch();
}; };
</script> </script>
<template> <template>
<div class="full-width flex justify-center"> <section class="row justify-center">
<QCard class="card-width q-pa-lg"> <QCard class="q-pa-lg" style="width: 70%">
<VnPaginate <VnPaginate
:user-filter="filter" :user-filter="filter"
@on-fetch="fetch" @on-fetch="fetch"
@ -84,100 +82,82 @@ const updateData = () => {
url="CreditClassifications" url="CreditClassifications"
> >
<template #body="{ rows }"> <template #body="{ rows }">
<div v-if="rows.length"> <div v-if="rows.length" class="q-gutter-y-md">
<QCard <QCard
v-for="(item, index) in rows" v-for="(item, index) in rows"
:key="index" :key="index"
:class="{ :class="{ disabled: item.finished }"
'customer-card': true,
'q-mb-md': index < rows.length - 1,
'is-active': !item.finished,
}"
> >
<QCardSection <QCardSection
class="full-width flex justify-between q-py-none" class="full-width"
:class="{ 'row justify-between': $q.screen.gt.md }"
> >
<div class="width-state flex"> <div class="width-state row no-wrap">
<div <QIcon
class="flex items-center cursor-pointer q-mr-md" :style="{
v-if="!item.finished" visibility: item.finished
? 'hidden'
: 'visible',
}"
@click.stop="openDialog(item)"
color="primary"
name="lock"
size="md"
class="fill-icon q-px-md"
> >
<QIcon <QTooltip>{{ t('Close contract') }}</QTooltip>
@click.stop="openDialog(item)" </QIcon>
color="primary"
name="lock"
size="md"
class="fill-icon"
>
<QTooltip>{{ t('Close contract') }}</QTooltip>
</QIcon>
</div>
<div> <div class="column">
<div class="flex q-mb-xs"> <VnLv
<div class="q-mr-sm color-vn-label"> :label="t('Since')"
{{ t('Since') }}: :value="toDate(item.started)"
</div> />
<div class="text-weight-bold"> <VnLv
{{ toDate(item.started) }} :label="t('To')"
</div> :value="toDate(item.finished)"
</div> />
<div class="flex">
<div class="q-mr-sm color-vn-label">
{{ t('To') }}:
</div>
<div class="text-weight-bold">
{{ toDate(item.finished) }}
</div>
</div>
</div> </div>
</div> </div>
<QSeparator vertical /> <QSeparator vertical />
<div class="width-data flex"> <div class="column width-data">
<div <div
class="full-width flex justify-between items-center" class="column"
v-if="item?.insurances.length" v-if="item?.insurances.length"
v-for="insurance in item.insurances"
:key="insurance.id"
> >
<div class="flex"> <div
<div class="color-vn-label q-mr-xs"> :class="{
{{ t('Credit') }}: 'row q-gutter-x-md': $q.screen.gt.sm,
</div> }"
<div class="text-weight-bold"> class="q-mb-sm"
{{ item.insurances[0].credit }} >
</div> <VnLv
</div> :label="t('Credit')"
<div class="flex"> :value="toCurrency(insurance.credit)"
<div class="color-vn-label q-mr-xs"> />
{{ t('Grade') }}: <VnLv
</div> :label="t('Grade')"
<div class="text-weight-bold"> :value="dashIfEmpty(insurance.grade)"
{{ item.insurances[0].grade || '-' }} />
</div> <VnLv
</div> :label="t('Date')"
<div class="flex"> :value="toDate(insurance.created)"
<div class="color-vn-label q-mr-xs"> />
{{ t('Date') }}:
</div>
<div class="text-weight-bold">
{{ toDate(item.insurances[0].created) }}
</div>
</div>
<div class="flex items-center cursor-pointer">
<QIcon
@click.stop="openViewCredit(item)"
color="primary"
name="preview"
size="md"
>
<QTooltip>{{
t('View credits')
}}</QTooltip>
</QIcon>
</div> </div>
</div> </div>
</div> </div>
<QBtn
@click.stop="openViewCredit(item)"
icon="preview"
size="md"
:title="t('View credits')"
color="primary"
flat
/>
</QCardSection> </QCardSection>
</QCard> </QCard>
</div> </div>
@ -187,11 +167,11 @@ const updateData = () => {
</template> </template>
</VnPaginate> </VnPaginate>
</QCard> </QCard>
</div> </section>
<QPageSticky :offset="[18, 18]" v-if="showQPageSticky"> <QPageSticky :offset="[18, 18]" v-if="showQPageSticky">
<QBtn <QBtn
@click.stop="toCustomerCreditContractsCreate()" @click.stop="showForm = !showForm"
color="primary" color="primary"
fab fab
icon="add" icon="add"
@ -201,24 +181,25 @@ const updateData = () => {
{{ t('New contract') }} {{ t('New contract') }}
</QTooltip> </QTooltip>
</QPageSticky> </QPageSticky>
<QDialog v-model="showForm">
<CustomerCreditContractsCreate @on-data-saved="updateData()" />
</QDialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.customer-card {
border: 2px solid var(--vn-light-gray);
border-radius: 10px;
padding: 10px;
display: flex;
justify-content: space-between;
}
.is-active {
background-color: var(--vn-light-gray);
}
.width-state { .width-state {
width: 30%; width: 30%;
} }
.width-data { .width-data {
width: 65%; width: 50%;
}
::v-deep(.label) {
margin-right: 5px;
}
::v-deep(.label)::after {
content: ':';
color: var(--vn-label-color);
} }
</style> </style>

View File

@ -0,0 +1,93 @@
<script setup>
import { computed, onBeforeMount, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { toCurrency, toDate } from 'src/filters';
import VnTable from 'src/components/VnTable/VnTable.vue';
import axios from 'axios';
const { t } = useI18n();
const route = useRoute();
const create = ref(null);
const tableRef = ref();
const columns = computed(() => [
{
align: 'left',
field: 'created',
format: ({ created }) => toDate(created),
label: t('Created'),
name: 'created',
create: true,
columnCreate: {
component: 'date',
},
},
{
align: 'left',
field: 'grade',
label: t('Grade'),
name: 'grade',
create: true,
},
{
align: 'left',
format: ({ credit }) => toCurrency(credit),
label: t('Credit'),
name: 'credit',
create: true,
},
]);
onBeforeMount(async () => {
const query = `CreditClassifications/findOne?filter=${encodeURIComponent(
JSON.stringify({
fields: ['finished'],
where: { id: route.params.creditId },
}),
)}`;
const { data } = await axios(query);
create.value = data.finished
? false
: {
urlCreate: 'CreditInsurances',
title: t('Create Insurance'),
onDataSaved: () => tableRef.value.reload(),
formInitialData: {
created: Date.vnNew(),
creditClassificationFk: route.params.creditId,
},
};
});
</script>
<template>
<VnTable
v-if="create != null"
url="CreditInsurances"
ref="tableRef"
data-key="creditInsurances"
:filter="{
where: {
creditClassificationFk: `${route.params.creditId}`,
},
order: 'created DESC',
}"
:columns="columns"
:right-search="false"
:is-editable="false"
:use-model="true"
:column-search="false"
:disable-option="{ card: true }"
:create
auto-load
/>
</template>
<i18n>
es:
Created: Fecha creación
Grade: Grade
Credit: Crédito
</i18n>

View File

@ -0,0 +1,28 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnDmsList from 'src/components/common/VnDmsList.vue';
import { useArrayData } from 'src/composables/useArrayData';
const arrayData = useArrayData('Customer');
const { t } = useI18n();
</script>
<template>
<VnDmsList
v-if="arrayData?.store?.data"
model="ClientDms"
update-model="Clients"
default-dms-code="paymentsLaw"
filter="clientFk"
:description="
t('ClientFileDescription', {
clientId: $route.params.id,
clientName: arrayData.store.data.socialName,
})
"
/>
</template>
<i18n>
en:
ClientFileDescription: Payment law from client {clientName} ID {clientId}
es:
ClientFileDescription: Ley de pagos del cliente {clientName} ID {clientId}
</i18n>

View File

@ -1,269 +0,0 @@
<script setup>
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { QBadge, QBtn, QCheckbox } from 'quasar';
import { downloadFile } from 'src/composables/downloadFile';
import { toDateTimeFormat } from 'src/filters/date';
import FetchData from 'components/FetchData.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import CustomerFileManagementActions from 'src/pages/Customer/components/CustomerFileManagementActions.vue';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const ClientDmsRef = ref(null);
const rows = ref([]);
const filter = {
include: {
relation: 'dms',
scope: {
fields: [
'dmsTypeFk',
'reference',
'hardCopyNumber',
'workerFk',
'description',
'hasFile',
'file',
'created',
],
include: [
{ relation: 'dmsType', scope: { fields: ['name'] } },
{
relation: 'worker',
scope: {
fields: ['id'],
include: { relation: 'user', scope: { fields: ['name'] } },
},
},
],
},
},
where: { clientFk: route.params.id },
order: ['dmsFk DESC'],
limit: 20,
};
const tableColumnComponents = {
id: {
component: 'span',
props: () => {},
event: () => {},
},
type: {
component: 'span',
props: () => {},
event: () => {},
},
order: {
component: QBadge,
props: () => {},
event: () => {},
},
reference: {
component: 'span',
props: () => {},
event: () => {},
},
description: {
component: 'span',
props: () => {},
event: () => {},
},
original: {
component: QCheckbox,
props: (prop) => ({
disable: true,
'model-value': Boolean(prop.value),
}),
event: () => {},
},
file: {
component: QBtn,
props: () => ({ flat: true }),
event: ({ row }) => downloadFile(row.dmsFk),
},
employee: {
component: QBtn,
props: () => ({ flat: true }),
event: () => {},
},
created: {
component: 'span',
props: () => {},
event: () => {},
},
actions: {
component: CustomerFileManagementActions,
props: (prop) => ({
id: prop.row.dmsFk,
promise: setData,
}),
event: () => {},
},
};
const columns = computed(() => [
{
align: 'left',
field: ({ dms }) => dms.id,
label: t('Id'),
name: 'id',
},
{
align: 'left',
field: ({ dms }) => dms.dmsType.name,
label: t('Type'),
name: 'type',
},
{
align: 'left',
field: ({ dms }) => dms.hardCopyNumber,
label: t('Order'),
name: 'order',
},
{
align: 'left',
field: ({ dms }) => dms.reference,
label: t('Reference'),
name: 'reference',
},
{
align: 'left',
field: ({ dms }) => dms.description,
label: t('Description'),
name: 'description',
},
{
align: 'left',
field: ({ dms }) => dms.hasFile,
label: t('Original'),
name: 'original',
},
{
align: 'left',
field: ({ dms }) => dms.file,
label: t('File'),
name: 'file',
},
{
align: 'left',
field: ({ dms }) => dms.worker.user.name,
label: t('Employee'),
name: 'employee',
},
{
align: 'left',
field: (value) => value.dms.created,
label: t('Created'),
name: 'created',
format: (value) => toDateTimeFormat(value),
},
{
align: 'right',
field: 'actions',
label: '',
name: 'actions',
},
]);
const setData = () => {
ClientDmsRef.value.fetch();
};
const toCustomerFileManagementCreate = () => {
router.push({ name: 'CustomerFileManagementCreate' });
};
</script>
<template>
<FetchData
ref="ClientDmsRef"
:filter="filter"
@on-fetch="(data) => (rows = data)"
auto-load
url="ClientDms"
/>
<QPage class="column items-center q-pa-md">
<QTable
:columns="columns"
:pagination="{ rowsPerPage: 12 }"
:rows="rows"
class="full-width q-mt-md"
row-key="id"
v-if="rows?.length"
>
<template #body-cell="props">
<QTd :props="props">
<QTr :props="props" class="cursor-pointer">
<component
:is="
props.col.name === 'order' && !props.value
? 'span'
: tableColumnComponents[props.col.name].component
"
@click="tableColumnComponents[props.col.name].event(props)"
class="col-content"
v-bind="tableColumnComponents[props.col.name].props(props)"
>
<template v-if="props.col.name !== 'original'">
<span
:class="{
link:
props.col.name === 'employee' ||
props.col.name === 'file',
}"
>
{{ props.value }}
</span>
</template>
<WorkerDescriptorProxy
:id="props.row.dms.workerFk"
v-if="props.col.name === 'employee'"
/>
</component>
</QTr>
</QTd>
</template>
</QTable>
<h5 class="flex justify-center color-vn-label" v-else>
{{ t('globals.noResults') }}
</h5>
</QPage>
<QPageSticky :offset="[18, 18]">
<QBtn
@click.stop="toCustomerFileManagementCreate()"
color="primary"
fab
v-shortcut="'+'"
icon="add"
/>
<QTooltip>
{{ t('Upload file') }}
</QTooltip>
</QPageSticky>
</template>
<i18n>
es:
Id: Id
Type: Tipo
Order: Orden
Reference: Referencia
Description: Descripción
Original: Original
File: Fichero
Employee: Empleado
Created: Fecha creación
Upload file: Subir fichero
</i18n>

View File

@ -20,9 +20,7 @@ const filter = {
{ relation: 'user', scope: { fields: ['id', 'name'] } }, { relation: 'user', scope: { fields: ['id', 'name'] } },
{ relation: 'company', scope: { fields: ['code'] } }, { relation: 'company', scope: { fields: ['code'] } },
], ],
where: { clientFk: route.params.id },
order: ['created DESC'], order: ['created DESC'],
limit: 20,
}; };
const columns = computed(() => [ const columns = computed(() => [
@ -76,7 +74,8 @@ const tableRef = ref();
ref="tableRef" ref="tableRef"
data-key="ClientSamples" data-key="ClientSamples"
auto-load auto-load
:filter="filter" :user-filter="filter"
:filter="{ where: { clientFk: route.params.id } }"
url="ClientSamples" url="ClientSamples"
:columns="columns" :columns="columns"
:pagination="{ rowsPerPage: 12 }" :pagination="{ rowsPerPage: 12 }"

View File

@ -4,16 +4,14 @@ import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import axios from 'axios'; import axios from 'axios';
import VnLocation from 'src/components/common/VnLocation.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
import VnRow from 'components/ui/VnRow.vue'; import CustomerAddressForm from './CustomerAddressForm.vue';
import VnRow from 'src/components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue'; const emit = defineEmits(['onDataSaved']);
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
@ -22,31 +20,31 @@ const quasar = useQuasar();
const urlUpdate = ref(''); const urlUpdate = ref('');
const agencyModes = ref([]); const agencyModes = ref([]);
const incoterms = ref([]); const incoterms = ref([]);
const customsAgents = ref([]);
const observationTypes = ref([]); const observationTypes = ref([]);
const notes = ref([]); const customsAgents = ref([]);
let originalNotes = []; let originalNotes = [];
const deletes = ref([]); const deletes = ref([]);
const model = defineModel({ type: Object });
const notes = ref(model.value.observations || []);
const $props = defineProps({
id: {
type: Number,
required: true,
},
});
onBeforeMount(() => { onBeforeMount(() => {
urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}`; urlUpdate.value = `Clients/${route.params.id}/updateAddress/${$props.id}`;
}); });
const getData = async (observations) => { const getData = async (observations) => {
observationTypes.value = observations; observationTypes.value = observations;
if (observationTypes.value.length) { if (observationTypes.value.length) {
const filter = { if (notes.value.length) {
fields: ['id', 'addressFk', 'observationTypeFk', 'description'], originalNotes = JSON.parse(JSON.stringify(notes.value));
where: { addressFk: `${route.params.addressId}` }, notes.value = notes.value
};
const { data } = await axios.get('AddressObservations', {
params: { filter: JSON.stringify(filter) },
});
if (data.length) {
originalNotes = data;
notes.value = originalNotes
.map((observation) => { .map((observation) => {
const type = observationTypes.value.find( const type = observationTypes.value.find(
(type) => type.id === observation.observationTypeFk, (type) => type.id === observation.observationTypeFk,
@ -56,7 +54,7 @@ const getData = async (observations) => {
$isNew: false, $isNew: false,
$oldData: null, $oldData: null,
$orgIndex: null, $orgIndex: null,
addressFk: `${route.params.addressId}`, addressFk: `${$props.id}`,
description: observation.description, description: observation.description,
id: observation.id, id: observation.id,
observationTypeFk: type.id, observationTypeFk: type.id,
@ -68,22 +66,6 @@ const getData = async (observations) => {
} }
}; };
const addNote = () => {
notes.value.push({
$isNew: true,
$oldData: null,
$orgIndex: null,
addressFk: `${route.params.addressId}`,
description: '',
observationTypeFk: '',
});
};
const deleteNote = (id, index) => {
deletes.value.push(id);
notes.value.splice(index, 1);
};
const updateAddress = async (data) => { const updateAddress = async (data) => {
await axios.patch(urlUpdate.value, data); await axios.patch(urlUpdate.value, data);
}; };
@ -116,8 +98,9 @@ function cleanPayload(payload) {
async function updateAll({ data, payload }) { async function updateAll({ data, payload }) {
await updateObservations(payload); await updateObservations(payload);
await updateAddress(data); await updateAddress(data);
toCustomerAddress(); emit('onDataSaved');
} }
function getPayload() { function getPayload() {
return { return {
creates: notes.value.filter((note) => note.$isNew), creates: notes.value.filter((note) => note.$isNew),
@ -162,23 +145,21 @@ async function handleDialog(data) {
} }
} }
const toCustomerAddress = () => { const addNote = () => {
notes.value = []; notes.value.push({
deletes.value = []; $isNew: true,
router.push({ $oldData: null,
name: 'CustomerAddress', $orgIndex: null,
params: { addressFk: `${$props.id}`,
id: route.params.id, description: '',
}, observationTypeFk: '',
}); });
}; };
function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {}; const deleteNote = (id, index) => {
data.postalCode = code; deletes.value.push(id);
data.city = town; notes.value.splice(index, 1);
data.provinceFk = provinceFk; };
data.countryFk = countryFk;
}
</script> </script>
<template> <template>
@ -194,207 +175,76 @@ function handleLocation(data, location) {
url="CustomsAgents" url="CustomsAgents"
/> />
<FetchData @on-fetch="getData" auto-load url="ObservationTypes" /> <FetchData @on-fetch="getData" auto-load url="ObservationTypes" />
<CustomerAddressForm
<FormModel
:observe-form-changes="false"
:url-update="urlUpdate" :url-update="urlUpdate"
:url="`Addresses/${route.params.addressId}`" :form-initial-data="model"
:save-fn="handleDialog" :save-fn="handleDialog"
auto-load auto-load
> >
<template #moreActions> <template #more-form="{ validate }">
<QBtn <div class="column">
:label="t('globals.cancel')" <h4 class="q-mb-xs">{{ t('Notes') }}</h4>
@click="toCustomerAddress" <VnRow
color="primary" v-if="!isPopup"
flat :key="index"
icon="close" class="row q-gutter-md q-mb-md"
/> v-for="(note, index) in notes"
</template>
<template #form="{ data, validate }">
<VnRow>
<div class="col">
<QCheckbox :label="t('Enabled')" v-model="data.isActive" />
</div>
<div class="col">
<QCheckbox
:label="t('Is equalizated')"
v-model="data.isEqualizated"
/>
</div>
<div class="col">
<QCheckbox
:label="t('Is Loginflora allowed')"
v-model="data.isLogifloraAllowed"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnInput :label="t('Consignee')" clearable v-model="data.nickname" />
</div>
<div class="col">
<VnInput :label="t('Street')" clearable v-model="data.street" />
</div>
</VnRow>
<VnRow>
<div class="col">
<VnLocation
:rules="validate('Worker.postcode')"
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
:location="{
postcode: data.postalCode,
city: data.city,
province: data.province,
country: data.province?.country,
}"
@update:model-value="(location) => handleLocation(data, location)"
></VnLocation>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnSelect
:label="t('Agency')"
:options="agencyModes"
:rules="validate('route.agencyFk')"
hide-selected
option-label="name"
option-value="id"
v-model="data.agencyModeFk"
/>
</div>
<div class="col">
<VnInput :label="t('Phone')" clearable v-model="data.phone" />
</div>
<div class="col">
<VnInput :label="t('Mobile')" clearable v-model="data.mobile" />
</div>
</VnRow>
<VnRow>
<VnSelect
:label="t('Incoterms')"
:options="incoterms"
hide-selected
option-label="name"
option-value="code"
v-model="data.incotermsFk"
/>
<VnSelectDialog
:label="t('Customs agent')"
:options="customsAgents"
hide-selected
option-label="fiscalName"
option-value="id"
v-model="data.customsAgentFk"
:tooltip="t('New customs agent')"
> >
<template #form> <VnSelect
<CustomerNewCustomsAgent /> :label="t('Observation type')"
</template> :options="observationTypes"
</VnSelectDialog> hide-selected
</VnRow> option-label="description"
<VnRow> option-value="id"
<VnInputNumber v-model="note.observationTypeFk"
:label="t('Longitude')" />
clearable <VnInput
v-model="data.longitude" :label="t('Description')"
:decimal-places="7" :rules="validate('route.description')"
:positive="false" clearable
/> v-model="note.description"
<VnInputNumber />
:label="t('Latitude')" <QIcon
clearable :style="{
v-model="data.latitude" flex: 0,
:decimal-places="7" 'align-self': $q.screen.gt.xs ? 'end' : 'center',
:positive="false" }"
/> @click.stop="deleteNote(note.id, index)"
</VnRow> class="cursor-pointer"
<h4 class="q-mb-xs">{{ t('Notes') }}</h4> color="primary"
<VnRow name="delete"
:key="index" size="sm"
class="row q-gutter-md q-mb-md" >
v-for="(note, index) in notes" <QTooltip>
> {{ t('Remove note') }}
<VnSelect </QTooltip>
:label="t('Observation type')" </QIcon>
:options="observationTypes" </VnRow>
hide-selected <QBtn
option-label="description" @click.stop="addNote()"
option-value="id" icon="add"
v-model="note.observationTypeFk" v-shortcut="'+'"
/>
<VnInput
:label="t('Description')"
:rules="validate('route.description')"
clearable
v-model="note.description"
/>
<QIcon
:style="{ flex: 0, 'align-self': $q.screen.gt.xs ? 'end' : 'center' }"
@click.stop="deleteNote(note.id, index)"
class="cursor-pointer"
color="primary" color="primary"
name="delete" style="width: 10%"
size="sm"
> >
<QTooltip> <QTooltip>
{{ t('Remove note') }} {{ t('Add note') }}
</QTooltip> </QTooltip>
</QIcon> </QBtn>
</VnRow> </div>
<QBtn
@click.stop="addNote()"
class="cursor-pointer add-icon q-mt-md"
flat
icon="add"
v-shortcut="'+'"
>
<QTooltip>
{{ t('Add note') }}
</QTooltip>
</QBtn>
</template> </template>
</FormModel> </CustomerAddressForm>
</template> </template>
<style lang="scss" scoped>
.add-icon {
background-color: $primary;
border-radius: 50px;
}
</style>
<i18n> <i18n>
es: es:
Enabled: Activo Notes: Notas
Is equalizated: Recargo de equivalencia Observation type: Tipo de observación
Is Loginflora allowed: Compra directa en Holanda Description: Descripción
Consignee: Consignatario Add note: Añadir nota
Street: Dirección fiscal Remove note: Eliminar nota
Postcode: Código postal confirmTicket: ¿Desea modificar también los estados de todos los tickets que están a punto de ser servidos?
City: Población confirmDeletionMessage: Si le das a aceptar, se modificaran todas las notas de los ticket a futuro
Province: Provincia en:
Agency: Agencia confirmTicket: Do you also want to modify the states of all the tickets that are about to be served?
Phone: Teléfono confirmDeletionMessage: If you click accept, all the notes of the future tickets will be modified
Mobile: Movíl
Incoterms: Incoterms
Customs agent: Agente de aduanas
New customs agent: Nuevo agente de aduanas
Notes: Notas
Observation type: Tipo de observación
Description: Descripción
Add note: Añadir nota
Remove note: Eliminar nota
Longitude: Longitud
Latitude: Latitud
confirmTicket: ¿Desea modificar también los estados de todos los tickets que están a punto de ser servidos?
confirmDeletionMessage: Si le das a aceptar, se modificaran todas las notas de los ticket a futuro
en:
confirmTicket: Do you also want to modify the states of all the tickets that are about to be served?
confirmDeletionMessage: If you click accept, all the notes of the future tickets will be modified
</i18n> </i18n>

View File

@ -1,36 +1,35 @@
<script setup> <script setup>
import { reactive, ref } from 'vue'; import { onBeforeMount, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute } from 'vue-router';
import VnLocation from 'src/components/common/VnLocation.vue'; import VnLocation from 'src/components/common/VnLocation.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue'; import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import FormModelPopup from 'src/components/FormModelPopup.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const urlUpdate = ref('');
const formInitialData = reactive({ isDefaultAddress: false });
const agencyModes = ref([]); const agencyModes = ref([]);
const incoterms = ref([]); const incoterms = ref([]);
const customsAgents = ref([]); const customsAgents = ref([]);
const toCustomerAddress = () => { const $props = defineProps({
router.push({ isCreate: {
name: 'CustomerAddress', type: Boolean,
params: { default: false,
id: route.params.id, },
}, });
});
}; onBeforeMount(() => {
urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}`;
});
function handleLocation(data, location) { function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {}; const { town, code, provinceFk, countryFk } = location ?? {};
data.postalCode = code; data.postalCode = code;
@ -38,33 +37,21 @@ function handleLocation(data, location) {
data.provinceFk = provinceFk; data.provinceFk = provinceFk;
data.countryFk = countryFk; data.countryFk = countryFk;
} }
function onAgentCreated({ id, fiscalName }, data) {
customsAgents.value.push({ id, fiscalName });
data.customsAgentFk = id;
}
</script> </script>
<template> <template>
<FetchData
@on-fetch="(data) => (customsAgents = data)"
auto-load
url="CustomsAgents"
/>
<FetchData <FetchData
@on-fetch="(data) => (agencyModes = data)" @on-fetch="(data) => (agencyModes = data)"
auto-load auto-load
url="AgencyModes/isActive" url="AgencyModes/isActive"
/> />
<FetchData @on-fetch="(data) => (incoterms = data)" auto-load url="Incoterms" /> <FetchData @on-fetch="(data) => (incoterms = data)" auto-load url="Incoterms" />
<FetchData
<FormModel @on-fetch="(data) => (customsAgents = data)"
:form-initial-data="formInitialData" auto-load
:observe-form-changes="false" url="CustomsAgents"
:url-create="`Clients/${route.params.id}/createAddress`" />
@on-data-saved="toCustomerAddress()" <FormModelPopup v-bind="$attrs" v-on="$attrs" :reload="false">
model="client"
>
<template #moreActions> <template #moreActions>
<QBtn <QBtn
:label="t('globals.cancel')" :label="t('globals.cancel')"
@ -74,34 +61,47 @@ function onAgentCreated({ id, fiscalName }, data) {
icon="close" icon="close"
/> />
</template> </template>
<template #form-inputs="{ data, validate }">
<template #form="{ data, validate }">
<QCheckbox :label="t('Default')" v-model="data.isDefaultAddress" />
<VnRow> <VnRow>
<VnInput <QCheckbox
:label="t('Consignee')" :label="t('Default')"
required v-model="data.isDefaultAddress"
clearable checked-icon="star"
v-model="data.nickname" unchecked-icon="star"
indeterminate-icon="star"
size="lg"
color="primary"
:class="{ 'fill-icon': !!data.isDefaultAddress }"
/> />
<QCheckbox :label="t('Enabled')" v-model="data.isActive" />
<VnInput <QCheckbox
:label="t('Street address')" :label="t('Is equalizated')"
clearable v-model="data.isEqualizated"
v-model="data.street" data-cy="isEqualizated_form"
required />
<QCheckbox
:label="t('Is Loginflora allowed')"
v-model="data.isLogifloraAllowed"
/> />
</VnRow> </VnRow>
<VnRow>
<VnLocation <VnInput :label="t('Consignee')" clearable v-model="data.nickname" />
:rules="validate('Worker.postcode')" <VnInput :label="t('Street')" clearable v-model="data.street" />
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]" </VnRow>
v-model="data.location" <VnRow>
@update:model-value="(location) => handleLocation(data, location)" <VnLocation
/> :rules="validate('Worker.postcode')"
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
<div class="row justify-between q-gutter-md q-mb-md"> :location="{
postcode: data.postalCode,
city: data.city,
province: data.province,
country: data.province?.country,
}"
@update:model-value="(location) => handleLocation(data, location)"
></VnLocation>
</VnRow>
<VnRow>
<VnSelect <VnSelect
:label="t('Agency')" :label="t('Agency')"
:options="agencyModes" :options="agencyModes"
@ -110,17 +110,10 @@ function onAgentCreated({ id, fiscalName }, data) {
option-label="name" option-label="name"
option-value="id" option-value="id"
v-model="data.agencyModeFk" v-model="data.agencyModeFk"
class="col"
/> />
<VnInput class="col" :label="t('Phone')" clearable v-model="data.phone" /> <VnInput :label="t('Phone')" clearable v-model="data.phone" />
<VnInput <VnInput :label="t('Mobile')" clearable v-model="data.mobile" />
class="col" </VnRow>
:label="t('Mobile')"
clearable
v-model="data.mobile"
/>
</div>
<VnRow> <VnRow>
<VnSelect <VnSelect
:label="t('Incoterms')" :label="t('Incoterms')"
@ -130,23 +123,17 @@ function onAgentCreated({ id, fiscalName }, data) {
option-value="code" option-value="code"
v-model="data.incotermsFk" v-model="data.incotermsFk"
/> />
<VnSelectDialog <VnSelectDialog
url="CustomsAgents"
:label="t('Customs agent')" :label="t('Customs agent')"
:options="customsAgents" :options="customsAgents"
hide-selected hide-selected
option-label="fiscalName" option-label="fiscalName"
option-value="id" option-value="id"
v-model="data.customsAgentFk" v-model="data.customsAgentFk"
:tooltip="t('Create a new expense')" :tooltip="t('New customs agent')"
> >
<template #form> <template #form>
<CustomerNewCustomsAgent <CustomerNewCustomsAgent />
@on-data-saved="
(requestResponse) => onAgentCreated(requestResponse, data)
"
/>
</template> </template>
</VnSelectDialog> </VnSelectDialog>
</VnRow> </VnRow>
@ -166,13 +153,13 @@ function onAgentCreated({ id, fiscalName }, data) {
:positive="false" :positive="false"
/> />
</VnRow> </VnRow>
<slot name="more-form" :validate />
</template> </template>
</FormModel> </FormModelPopup>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.add-icon { .add-icon {
cursor: pointer;
background-color: $primary; background-color: $primary;
border-radius: 50px; border-radius: 50px;
} }
@ -180,9 +167,11 @@ function onAgentCreated({ id, fiscalName }, data) {
<i18n> <i18n>
es: es:
Default: Predeterminado Enabled: Activo
Is equalizated: Recargo de equivalencia
Is Loginflora allowed: Compra directa en Holanda
Consignee: Consignatario Consignee: Consignatario
Street address: Dirección postal Street: Dirección fiscal
Postcode: Código postal Postcode: Código postal
City: Población City: Población
Province: Provincia Province: Provincia
@ -191,6 +180,17 @@ es:
Mobile: Movíl Mobile: Movíl
Incoterms: Incoterms Incoterms: Incoterms
Customs agent: Agente de aduanas Customs agent: Agente de aduanas
New customs agent: Nuevo agente de aduanas
Notes: Notas
Observation type: Tipo de observación
Description: Descripción
Add note: Añadir nota
Remove note: Eliminar nota
Longitude: Longitud Longitude: Longitud
Latitude: Latitud Latitude: Latitud
confirmTicket: ¿Desea modificar también los estados de todos los tickets que están a punto de ser servidos?
confirmDeletionMessage: Si le das a aceptar, se modificaran todas las notas de los ticket a futuro
en:
confirmTicket: Do you also want to modify the states of all the tickets that are about to be served?
confirmDeletionMessage: If you click accept, all the notes of the future tickets will be modified
</i18n> </i18n>

View File

@ -3,44 +3,29 @@ import { reactive, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
import FormModelPopup from 'src/components/FormModelPopup.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const routeId = computed(() => route.params.id); const routeId = computed(() => route.params.id);
const router = useRouter();
const initialData = reactive({ const initialData = reactive({
started: Date.vnNew(), started: Date.vnNew(),
clientFk: routeId.value, clientFk: routeId.value,
}); });
const toCustomerCreditContracts = () => {
router.push({ name: 'CustomerCreditContracts' });
};
</script> </script>
<template> <template>
<FormModel <FormModelPopup
v-on="$attrs"
:form-initial-data="initialData" :form-initial-data="initialData"
:observe-form-changes="false" :observe-form-changes="false"
url-create="creditClassifications/createWithInsurance" url-create="creditClassifications/createWithInsurance"
@on-data-saved="toCustomerCreditContracts()"
> >
<template #moreActions> <template #form-inputs="{ data }">
<QBtn
:label="t('globals.cancel')"
@click="toCustomerCreditContracts"
color="primary"
flat
icon="close"
/>
</template>
<template #form="{ data }">
<VnRow> <VnRow>
<div class="col"> <div class="col">
<VnInput <VnInput
@ -63,7 +48,7 @@ const toCustomerCreditContracts = () => {
</div> </div>
</VnRow> </VnRow>
</template> </template>
</FormModel> </FormModelPopup>
</template> </template>
<i18n> <i18n>

View File

@ -1,63 +0,0 @@
<script setup>
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { toCurrency, toDate } from 'src/filters';
import VnTable from 'src/components/VnTable/VnTable.vue';
const { t } = useI18n();
const route = useRoute();
const filter = {
where: {
creditClassificationFk: `${route.params.creditId}`,
},
limit: 20,
};
const columns = computed(() => [
{
align: 'left',
field: 'created',
format: ({ created }) => toDate(created),
label: t('Created'),
name: 'created',
},
{
align: 'left',
field: 'grade',
label: t('Grade'),
name: 'grade',
},
{
align: 'left',
format: ({ credit }) => toCurrency(credit),
label: t('Credit'),
name: 'credit',
},
]);
</script>
<template>
<VnTable
url="CreditInsurances"
ref="tableRef"
data-key="creditInsurances"
:filter="filter"
:columns="columns"
:right-search="false"
:is-editable="false"
:use-model="true"
:column-search="false"
:disable-option="{ card: true }"
auto-load
></VnTable>
</template>
<i18n>
es:
Created: Fecha creación
Grade: Grade
Credit: Crédito
</i18n>

View File

@ -1,96 +0,0 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import { downloadFile } from 'src/composables/downloadFile';
import CustomerFileManagementDelete from 'src/pages/Customer/components/CustomerFileManagementDelete.vue';
const { t } = useI18n();
const quasar = useQuasar();
const route = useRoute();
const router = useRouter();
const $props = defineProps({
id: {
type: Number,
required: true,
},
promise: {
type: Function,
required: true,
},
});
const setDownloadFile = () => downloadFile($props.id);
const toCustomerFileManagementEdit = () => {
router.push({
name: 'CustomerFileManagementEdit',
params: {
id: route.params.id,
dmsId: $props.id,
},
});
};
const showCustomerFileManagementDeleteDialog = () => {
quasar.dialog({
component: CustomerFileManagementDelete,
componentProps: {
id: $props.id,
promise: setData,
},
});
};
const setData = () => {
$props.promise();
};
</script>
<template>
<div>
<QIcon
@click.stop="setDownloadFile"
color="primary"
name="cloud_download"
size="sm"
>
<QTooltip>
{{ t('actionFile', { action: t('globals.download') }) }}
</QTooltip>
</QIcon>
<QIcon
@click.stop="toCustomerFileManagementEdit"
class="q-ml-md"
color="primary"
name="edit"
size="sm"
>
<QTooltip>
{{ t('actionFile', { action: t('globals.edit') }) }}
</QTooltip>
</QIcon>
<QIcon
@click.stop="showCustomerFileManagementDeleteDialog"
class="q-ml-md"
color="primary"
name="delete"
size="sm"
>
<QTooltip>
{{ t('actionFile', { action: t('globals.remove') }) }}
</QTooltip>
</QIcon>
</div>
</template>
<i18n>
en:
actionFile: '{action} file'
es:
actionFile: '{action} fichero'
</i18n>

View File

@ -1,260 +0,0 @@
<script setup>
import { onBeforeMount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
import { useState } from 'src/composables/useState';
import { useValidator } from 'src/composables/useValidator';
import useNotify from 'src/composables/useNotify';
import FetchData from 'components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { notify } = useNotify();
const { t } = useI18n();
const { validate } = useValidator();
const route = useRoute();
const router = useRouter();
const state = useState();
const user = state.getUser();
const filterFindOne = { where: { code: 'paymentsLaw' } };
const filterCompanies = { order: ['code'] };
const filterWarehouses = { order: ['name'] };
const inputFileRef = ref();
const client = ref({});
const findOne = ref([]);
const allowedContentTypes = ref([]);
const optionsCompanies = ref([]);
const optionsWarehouses = ref([]);
const optionsDmsTypes = ref([]);
const isLoading = ref(false);
const dms = ref({
hasFile: false,
});
onBeforeMount(() => {
const { companyFk, warehouseFk } = user.value;
dms.value.reference = route.params.id;
dms.value.companyId = companyFk;
dms.value.warehouseId = warehouseFk;
});
watch([client, findOne], ([newClient, newFindOne]) => {
dms.value.description = t('clientFileDescription', {
dmsTypeName: newFindOne.name?.toUpperCase(),
clientName: newClient.name?.toUpperCase(),
clientId: newClient.id,
});
dms.value.dmsTypeId = newFindOne.id;
});
const saveData = async () => {
try {
const formData = new FormData();
const files = dms.value.files;
if (files && files.length > 0) {
for (let file of files) {
formData.append(file.name, file);
}
dms.value.hasFileAttached = true;
const url = `clients/${route.params.id}/uploadFile`;
await axios.post(url, formData, {
params: dms.value,
});
notify('globals.dataSaved', 'positive');
toCustomerFileManagement();
}
} catch (error) {
notify(error.message, 'negative');
}
};
const toCustomerFileManagement = () => {
router.push({ name: 'CustomerFileManagement' });
};
</script>
<template>
<FetchData
@on-fetch="(data) => (client = data)"
auto-load
:url="`Clients/${route.params.id}/getCard`"
/>
<FetchData
:filter="filterFindOne"
@on-fetch="(data) => (findOne = data)"
auto-load
url="DmsTypes/findOne"
/>
<FetchData
@on-fetch="(data) => (allowedContentTypes = data)"
auto-load
url="DmsContainers/allowedContentTypes"
/>
<FetchData
:filter="filterCompanies"
@on-fetch="(data) => (optionsCompanies = data)"
auto-load
url="Companies"
/>
<FetchData
:filter="filterWarehouses"
@on-fetch="(data) => (optionsWarehouses = data)"
auto-load
url="Warehouses"
/>
<FetchData
:filter="filterWarehouses"
@on-fetch="(data) => (optionsDmsTypes = data)"
auto-load
url="DmsTypes"
/>
<Teleport to="#st-actions">
<QBtnGroup push class="q-gutter-x-sm">
<QBtn
:disabled="isLoading"
:label="t('globals.cancel')"
:loading="isLoading"
@click="toCustomerFileManagement"
color="primary"
flat
icon="close"
/>
<QBtn
:disabled="isLoading"
:label="t('globals.save')"
:loading="isLoading"
@click.stop="saveData"
color="primary"
icon="save"
/>
</QBtnGroup>
</Teleport>
<QCard class="q-pa-lg">
<QCardSection>
<QForm>
<VnRow>
<div class="col">
<VnInput
:label="t('Reference')"
clearable
v-model="dms.reference"
/>
</div>
<div class="col">
<VnSelect
:label="t('Company')"
:options="optionsCompanies"
:rules="validate('entry.companyFk')"
option-label="code"
option-value="id"
v-model="dms.companyId"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnSelect
:label="t('Warehouse')"
:options="optionsWarehouses"
option-label="name"
option-value="id"
v-model="dms.warehouseId"
/>
</div>
<div class="col">
<VnSelect
:label="t('Type')"
:options="optionsDmsTypes"
option-label="name"
option-value="id"
v-model="dms.dmsTypeId"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnInput
:label="t('Description')"
:rules="validate('route.description')"
clearable
type="textarea"
v-model="dms.description"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<QFile
ref="inputFileRef"
class="required"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="vn:attach"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('Select a file') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</div>
</VnRow>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
/>
</QForm>
</QCardSection>
</QCard>
</template>
<i18n>
en:
clientFileDescription: '{dmsTypeName} FROM CLIENT {clientName} ID {clientId}'
es:
Reference: Referencia
Company: Empresa
Warehouse: Almacén
Type: Tipo
Description: Descripción
clientFileDescription: '{dmsTypeName} DEL CLIENTE {clientName} ID {clientId}'
File: Fichero
Select a file: Selecciona un fichero
Allowed content types: Tipos de archivo permitidos
Generate identifier for original file: Generar identificador para archivo original
</i18n>

View File

@ -1,82 +0,0 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useDialogPluginComponent } from 'quasar';
import axios from 'axios';
import useNotify from 'src/composables/useNotify';
const $props = defineProps({
id: {
type: Number,
required: true,
},
promise: {
type: Function,
required: true,
},
});
const { dialogRef } = useDialogPluginComponent();
const { notify } = useNotify();
const { t } = useI18n();
const closeButton = ref(null);
const isLoading = ref(false);
const deleteDms = async () => {
isLoading.value = true;
try {
await axios.post(`ClientDms/${$props.id}/removeFile`);
if ($props.promise) await $props.promise();
notify('globals.dataDeleted', 'positive');
} catch (error) {
notify(error.message, 'negative');
} finally {
closeButton.value.click();
isLoading.value = false;
}
};
</script>
<template>
<QDialog ref="dialogRef">
<QCard class="q-pa-md q-mb-md">
<span ref="closeButton" class="row justify-end close-icon" v-close-popup>
<QIcon name="close" size="sm" />
</span>
<QCardSection>
<div class="mt-1 text-h6">{{ t('This file will be deleted') }}</div>
<div>{{ t('Are you sure you want to continue?') }}</div>
</QCardSection>
<QCardActions class="flex justify-end">
<QBtn
:disabled="isLoading"
:label="t('globals.cancel')"
:loading="isLoading"
class="q-mr-xl"
color="primary"
flat
v-close-popup
/>
<QBtn
:disabled="isLoading"
:label="t('globals.save')"
:loading="isLoading"
@click.stop="deleteDms"
color="primary"
/>
</QCardActions>
</QCard>
</QDialog>
</template>
<i18n>
es:
This file will be deleted: Este fichero va a ser borrado
Are you sure you want to continue?: ¿Seguro que quieres continuar?
</i18n>

View File

@ -1,237 +0,0 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
import { useValidator } from 'src/composables/useValidator';
import useNotify from 'src/composables/useNotify';
import FetchData from 'components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { notify } = useNotify();
const { t } = useI18n();
const { validate } = useValidator();
const route = useRoute();
const router = useRouter();
const filterCompanies = { order: ['code'] };
const filterWarehouses = { order: ['name'] };
const inputFileRef = ref();
const allowedContentTypes = ref([]);
const optionsCompanies = ref([]);
const optionsWarehouses = ref([]);
const optionsDmsTypes = ref([]);
const isLoading = ref(false);
const dms = ref({
hasFile: true,
});
const setCurrentDms = (data) => {
dms.value.reference = data.reference;
dms.value.companyId = data.companyFk;
dms.value.warehouseId = data.warehouseFk;
dms.value.dmsTypeId = data.dmsTypeFk;
dms.value.description = data.description;
};
const saveData = async () => {
try {
const formData = new FormData();
const files = dms.value.files;
if (files && files.length > 0) {
for (let file of files) {
formData.append(file.name, file);
}
dms.value.hasFileAttached = true;
const url = `dms/${route.params.dmsId}/updateFile`;
await axios.post(url, formData, {
params: dms.value,
});
notify('globals.dataSaved', 'positive');
toCustomerFileManagement();
}
} catch (error) {
notify(error.message, 'negative');
}
};
const toCustomerFileManagement = () => {
router.push({ name: 'CustomerFileManagement' });
};
</script>
<template>
<FetchData :url="`Dms/${route.params.dmsId}`" @on-fetch="setCurrentDms" auto-load />
<FetchData
@on-fetch="(data) => (allowedContentTypes = data)"
auto-load
url="DmsContainers/allowedContentTypes"
/>
<FetchData
:filter="filterCompanies"
@on-fetch="(data) => (optionsCompanies = data)"
auto-load
url="Companies"
/>
<FetchData
:filter="filterWarehouses"
@on-fetch="(data) => (optionsWarehouses = data)"
auto-load
url="Warehouses"
/>
<FetchData
:filter="filterWarehouses"
@on-fetch="(data) => (optionsDmsTypes = data)"
auto-load
url="DmsTypes"
/>
<Teleport to="#st-actions">
<QBtnGroup push class="q-gutter-x-sm">
<QBtn
:disabled="isLoading"
:label="t('globals.cancel')"
:loading="isLoading"
@click="toCustomerFileManagement"
color="primary"
flat
icon="close"
/>
<QBtn
:disabled="isLoading"
:label="t('globals.save')"
:loading="isLoading"
@click.stop="saveData"
color="primary"
icon="save"
/>
</QBtnGroup>
</Teleport>
<QCard class="q-pa-lg">
<QCardSection>
<QForm>
<VnRow>
<div class="col">
<VnInput
:label="t('Reference')"
clearable
v-model="dms.reference"
/>
</div>
<div class="col">
<VnSelect
:label="t('Company')"
:options="optionsCompanies"
:rules="validate('entry.companyFk')"
option-label="code"
option-value="id"
v-model="dms.companyId"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnSelect
:label="t('Warehouse')"
:options="optionsWarehouses"
option-label="name"
option-value="id"
v-model="dms.warehouseId"
/>
</div>
<div class="col">
<VnSelect
:label="t('Type')"
:options="optionsDmsTypes"
option-label="name"
option-value="id"
v-model="dms.dmsTypeId"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnInput
:label="t('Description')"
:rules="validate('route.description')"
clearable
type="textarea"
v-model="dms.description"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<QFile
ref="inputFileRef"
class="required"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="vn:attach"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('Select a file') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</div>
</VnRow>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
disable
/>
</QForm>
</QCardSection>
</QCard>
</template>
<i18n>
en:
clientFileDescription: '{dmsTypeName} FROM CLIENT {clientName} ID {clientId}'
es:
Reference: Referencia
Company: Empresa
Warehouse: Almacén
Type: Tipo
Description: Descripción
clientFileDescription: '{dmsTypeName} DEL CLIENTE {clientName} ID {clientId}'
File: Fichero
Select a file: Selecciona un fichero
Allowed content types: Tipos de archivo permitidos
Generate identifier for original file: Generar identificador para archivo original
</i18n>

View File

@ -29,7 +29,7 @@ const saveData = async () => {
finished: timestamp, finished: timestamp,
}; };
await axios.patch(`CreditClassifications/${$props.id}`, payload); await axios.patch(`CreditClassifications/${$props.id}`, payload);
$props.promise(); await $props.promise();
closeButton.value.click(); closeButton.value.click();
}; };
</script> </script>

View File

@ -1,135 +0,0 @@
<script setup>
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore';
import { useState } from 'src/composables/useState';
import { toDate } from 'src/filters';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const state = useState();
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const stateStore = useStateStore();
const user = state.getUser();
const newEntryForm = reactive({
supplierFk: null,
travelFk: Number(route.query?.travelFk) || null,
companyFk: user.value.companyFk || null,
});
const travelsOptions = ref([]);
const companiesOptions = ref([]);
const redirectToEntryBasicData = (_, { id }) => {
router.push({ name: 'EntryBasicData', params: { id } });
};
</script>
<template>
<FetchData
url="Travels/filter"
:filter="{ fields: ['id', 'warehouseInName'] }"
order="id"
@on-fetch="(data) => (travelsOptions = data)"
auto-load
/>
<FetchData
ref="companiesRef"
url="Companies"
:filter="{ fields: ['id', 'code'] }"
order="code"
@on-fetch="(data) => (companiesOptions = data)"
auto-load
/>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<VnSearchbar
url="Entries/filter"
custom-route-redirect-name="EntrySummary"
data-key="Entry"
:label="t('Search entries')"
:info="t('You can search by entry reference')"
/>
</Teleport>
</template>
<QPage>
<VnSubToolbar />
<FormModel
url-create="Entries"
model="entry"
:form-initial-data="newEntryForm"
@on-data-saved="redirectToEntryBasicData"
>
<template #form="{ data, validate }">
<VnRow>
<VnSelectSupplier
class="full-width"
v-model="data.supplierFk"
hide-selected
:required="true"
:rules="validate('entry.supplierFk')"
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('Travel')"
class="full-width"
v-model="data.travelFk"
:options="travelsOptions"
option-value="id"
option-label="warehouseInName"
map-options
hide-selected
:required="true"
:rules="validate('entry.travelFk')"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel
>{{ scope.opt?.agencyModeName }} -
{{ scope.opt?.warehouseInName }} ({{
toDate(scope.opt?.shipped)
}}) &#x2192; {{ scope.opt?.warehouseOutName }} ({{
toDate(scope.opt?.landed)
}})</QItemLabel
>
</QItemSection>
</QItem>
</template>
</VnSelect>
</VnRow>
<VnRow>
<VnSelect
:label="t('Company')"
class="full-width"
v-model="data.companyFk"
:options="companiesOptions"
option-value="id"
option-label="code"
map-options
hide-selected
:required="true"
:rules="validate('entry.companyFk')"
/>
</VnRow>
</template>
</FormModel>
</QPage>
</template>
<i18n>
es:
Travel: Envío
Company: Empresa
</i18n>

View File

@ -218,8 +218,9 @@ const onFormModelInit = () => {
const redirectToCustomerAddress = () => { const redirectToCustomerAddress = () => {
router.push({ router.push({
name: 'CustomerAddressEditCard', name: 'CustomerAddress',
params: { id: clientId.value, addressId: addressId.value }, params: { id: clientId.value },
query: { addressId: addressId.value },
}); });
}; };

View File

@ -82,7 +82,10 @@ const deleteTravel = async (id) => {
<QItem v-ripple clickable> <QItem v-ripple clickable>
<QItemSection> <QItemSection>
<RouterLink <RouterLink
:to="{ name: 'EntryCreate', query: { travelFk: travel.id } }" :to="{
name: 'EntryList',
query: { createForm: JSON.stringify({ travelFk: travel.id }) },
}"
class="color-vn-text" class="color-vn-text"
> >
{{ t('travel.summary.AddEntry') }} {{ t('travel.summary.AddEntry') }}

View File

@ -38,7 +38,10 @@ const redirectToCreateView = (queryParams) => {
}; };
const redirectCreateEntryView = (travelData) => { const redirectCreateEntryView = (travelData) => {
router.push({ name: 'EntryCreate', query: { travelFk: travelData.id } }); router.push({
name: 'EntryList',
query: { createForm: JSON.stringify({ travelFk: travelData.id }) },
});
}; };
const columns = computed(() => [ const columns = computed(() => [

View File

@ -75,33 +75,6 @@ const customerCard = {
component: () => component: () =>
import('src/pages/Customer/Card/CustomerAddress.vue'), import('src/pages/Customer/Card/CustomerAddress.vue'),
}, },
{
path: 'create',
name: 'CustomerAddressCreate',
meta: {
title: 'address-create',
},
component: () =>
import('src/pages/Customer/components/CustomerAddressCreate.vue'),
},
{
path: ':addressId',
name: 'CustomerAddressEditCard',
redirect: { name: 'CustomerAddressEdit' },
children: [
{
path: 'edit',
name: 'CustomerAddressEdit',
meta: {
title: 'addressEdit',
},
component: () =>
import(
'src/pages/Customer/components/CustomerAddressEdit.vue'
),
},
],
},
], ],
}, },
{ {
@ -212,20 +185,12 @@ const customerCard = {
'src/pages/Customer/Card/CustomerCreditContracts.vue' 'src/pages/Customer/Card/CustomerCreditContracts.vue'
), ),
}, },
{
path: 'create',
name: 'CustomerCreditContractsCreate',
component: () =>
import(
'src/pages/Customer/components/CustomerCreditContractsCreate.vue'
),
},
{ {
path: 'insurance/:creditId', path: 'insurance/:creditId',
name: 'CustomerCreditContractsInsurance', name: 'CustomerCreditContractsInsurance',
component: () => component: () =>
import( import(
'src/pages/Customer/components/CustomerCreditContractsInsurance.vue' 'src/pages/Customer/Card/CustomerCreditContractsInsurance.vue'
), ),
}, },
], ],
@ -274,9 +239,9 @@ const customerCard = {
icon: 'vn:onlinepayment', icon: 'vn:onlinepayment',
}, },
{ {
name: 'CustomerFileManagement', name: 'CustomerDms',
title: 'fileManagement', title: 'dms',
icon: 'Upload', icon: 'cloud_upload',
}, },
{ {
name: 'CustomerUnpaid', name: 'CustomerUnpaid',
@ -309,14 +274,6 @@ const customerCard = {
component: () => component: () =>
import('src/pages/Customer/Card/CustomerSamples.vue'), import('src/pages/Customer/Card/CustomerSamples.vue'),
}, },
{
path: 'create',
name: 'CustomerSamplesCreate',
component: () =>
import(
'src/pages/Customer/components/CustomerSamplesCreate.vue'
),
},
], ],
}, },
{ {
@ -356,47 +313,12 @@ const customerCard = {
import('src/pages/Customer/Card/CustomerWebPayment.vue'), import('src/pages/Customer/Card/CustomerWebPayment.vue'),
}, },
{ {
path: 'file-management', path: 'dms',
name: 'CustomerFileManagement', name: 'CustomerDms',
meta: { meta: {
title: 'fileManagement', title: 'dms',
}, },
component: () => component: () => import('src/pages/Customer/Card/CustomerDms.vue'),
import('src/pages/Customer/Card/CustomerFileManagement.vue'),
},
{
path: 'file-management',
name: 'CustomerFileManagementCard',
redirect: { name: 'CustomerFileManagement' },
children: [
{
path: '',
name: 'CustomerFileManagement',
meta: {
title: 'fileManagement',
},
component: () =>
import(
'src/pages/Customer/Card/CustomerFileManagement.vue'
),
},
{
path: 'create',
name: 'CustomerFileManagementCreate',
component: () =>
import(
'src/pages/Customer/components/CustomerFileManagementCreate.vue'
),
},
{
path: ':dmsId/edit',
name: 'CustomerFileManagementEdit',
component: () =>
import(
'src/pages/Customer/components/CustomerFileManagementEdit.vue'
),
},
],
}, },
{ {
path: 'unpaid', path: 'unpaid',

View File

@ -114,15 +114,6 @@ export default {
entryCard, entryCard,
], ],
}, },
{
path: 'create',
name: 'EntryCreate',
meta: {
title: 'entryCreate',
icon: 'add',
},
component: () => import('src/pages/Entry/EntryCreate.vue'),
},
{ {
path: 'my', path: 'my',
name: 'EntrySupplier', name: 'EntrySupplier',

View File

@ -9,18 +9,18 @@ describe('Client consignee', () => {
cy.get('.q-card').should('be.visible'); cy.get('.q-card').should('be.visible');
}); });
it('check as equalizated', function () { it('check as equalizated', () => {
cy.get('.q-card__section > .address-card').then(($el) => { cy.get('.q-card__section > .address-card').then(($el) => {
let addressCards_before = $el.length; const addressCards_before = $el.length;
cy.get('.q-page-sticky > div > .q-btn').click(); cy.get('.q-page-sticky > div > .q-btn').click();
const addressName = 'test'; const addressName = 'test';
cy.dataCy('Consignee_input').type(addressName); cy.dataCy('Consignee_input').type(addressName);
cy.dataCy('Location_select').click(); cy.dataCy('Location_select').click();
cy.getOption(); cy.getOption();
cy.dataCy('Street address_input').type('TEST ADDRESS'); cy.dataCy('Street_input').type('TEST ADDRESS');
cy.get('.q-btn-group > .q-btn--standard').click(); cy.saveCard();
cy.location('href').should('contain', '#/customer/1107/address');
cy.get('.q-card__section > .address-card').should( cy.get('.q-card__section > .address-card').should(
'have.length', 'have.length',
addressCards_before + 1, addressCards_before + 1,
@ -33,13 +33,11 @@ describe('Client consignee', () => {
.should('contain', addressName) .should('contain', addressName)
.click(); .click();
}); });
cy.get( cy.get('[data-cy="isEqualizated_form"] > .q-checkbox__inner')
'.q-card > :nth-child(1) > :nth-child(2) > .q-checkbox > .q-checkbox__inner',
)
.should('have.class', 'q-checkbox__inner--falsy') .should('have.class', 'q-checkbox__inner--falsy')
.click(); .click();
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content').click(); cy.saveCard();
cy.get( cy.get(
':nth-child(2) > :nth-child(2) > .flex > .q-mr-lg > .q-checkbox__inner', ':nth-child(2) > :nth-child(2) > .flex > .q-mr-lg > .q-checkbox__inner',
).should('have.class', 'q-checkbox__inner--truthy'); ).should('have.class', 'q-checkbox__inner--truthy');