0
0
Fork 0
This commit is contained in:
William Buezas 2024-02-22 10:38:30 -03:00
commit f69b25716d
11 changed files with 287 additions and 140 deletions

View File

@ -66,6 +66,10 @@ body.body--dark {
border-radius: 8px; border-radius: 8px;
} }
.card-width {
width: 800px;
}
.vn-card-list { .vn-card-list {
width: 100%; width: 100%;
max-width: 60em; max-width: 60em;

View File

@ -3,6 +3,8 @@ 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 axios from 'axios';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
@ -10,6 +12,7 @@ const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const addresses = ref([]);
const client = ref(null); const client = ref(null);
const provincesLocation = ref([]); const provincesLocation = ref([]);
@ -45,6 +48,11 @@ const addressFilter = {
], ],
}; };
const setRows = (data) => {
addresses.value = data;
sortAddresses();
};
const setProvince = (provinceFk) => { const setProvince = (provinceFk) => {
const result = provincesLocation.value.filter( const result = provincesLocation.value.filter(
(province) => province.id === provinceFk (province) => province.id === provinceFk
@ -56,6 +64,24 @@ const isDefaultAddress = (address) => {
return client?.value?.defaultAddressFk === address.id ? 1 : 0; return client?.value?.defaultAddressFk === address.id ? 1 : 0;
}; };
const setDefault = (address) => {
const url = `Clients/${route.params.id}`;
const payload = { defaultAddressFk: address.id };
axios.patch(url, payload).then((res) => {
if (res.data) {
client.value.defaultAddressFk = res.data.defaultAddressFk;
sortAddresses();
}
});
};
const sortAddresses = () => {
if (!client.value || !addresses.value) return;
addresses.value = addresses.value.sort((a, b) => {
return isDefaultAddress(b) - isDefaultAddress(a);
});
};
const toCustomerAddressCreate = () => { const toCustomerAddressCreate = () => {
router.push({ name: 'CustomerAddressCreate' }); router.push({ name: 'CustomerAddressCreate' });
}; };
@ -72,6 +98,12 @@ const toCustomerAddressEdit = (addressId) => {
</script> </script>
<template> <template>
<FetchData
@on-fetch="setRows"
auto-load
:filter="addressFilter"
:url="`Clients/${route.params.id}/addresses`"
/>
<FetchData <FetchData
@on-fetch="(data) => (client = data)" @on-fetch="(data) => (client = data)"
auto-load auto-load
@ -83,21 +115,15 @@ const toCustomerAddressEdit = (addressId) => {
url="Provinces/location" url="Provinces/location"
/> />
<QCard class="q-pa-lg"> <div class="full-width flex justify-center">
<VnPaginate <QCard class="card-width q-pa-lg" v-if="addresses.length">
data-key="CustomerAddress" <QCardSection>
:url="`Clients/${route.params.id}/addresses`" <div
order="id" v-for="(item, index) in addresses"
auto-load
:filter="addressFilter"
>
<template #body="{ rows }">
<QCard
v-for="(item, index) in rows"
:key="index" :key="index"
:class="{ :class="{
'address-card': true, 'address-card': true,
'q-mb-md': index < rows.length - 1, 'q-mb-md': index < addresses.length - 1,
'item-disabled': !item.isActive, 'item-disabled': !item.isActive,
}" }"
@click="toCustomerAddressEdit(item.id)" @click="toCustomerAddressEdit(item.id)"
@ -112,7 +138,18 @@ const toCustomerAddressEdit = (addressId) => {
color="primary" color="primary"
name="star" name="star"
size="md" size="md"
/> @click.stop="!isDefaultAddress(item) && setDefault(item)"
>
<QTooltip>
{{
t(
isDefaultAddress(item)
? 'Default address'
: 'Set as default'
)
}}
</QTooltip>
</QIcon>
</div> </div>
<div> <div>
<div class="text-weight-bold q-mb-sm"> <div class="text-weight-bold q-mb-sm">
@ -156,10 +193,10 @@ const toCustomerAddressEdit = (addressId) => {
<div>{{ observation.description }}</div> <div>{{ observation.description }}</div>
</div> </div>
</div> </div>
</QCard> </div>
</template> </QCardSection>
</VnPaginate> </QCard>
</QCard> </div>
<QPageSticky :offset="[18, 18]"> <QPageSticky :offset="[18, 18]">
<QBtn @click.stop="toCustomerAddressCreate()" color="primary" fab icon="add" /> <QBtn @click.stop="toCustomerAddressCreate()" color="primary" fab icon="add" />
@ -192,4 +229,6 @@ es:
Is equalizated: Recargo de equivalencia Is equalizated: Recargo de equivalencia
Is logiflora allowed: Compra directa en Holanda Is logiflora allowed: Compra directa en Holanda
New consignee: Nuevo consignatario New consignee: Nuevo consignatario
Default address: Consignatario predeterminado
Set as default: Establecer como predeterminado
</i18n> </i18n>

View File

@ -129,7 +129,7 @@ const updateData = () => {
<QSeparator class="q-mx-lg" vertical /> <QSeparator class="q-mx-lg" vertical />
<div class="flex"> <div class="flex">
<div class="flex items-center"> <div class="flex items-center" v-if="item?.insurances.length">
<div class="flex q-mr-xl"> <div class="flex q-mr-xl">
<div class="q-mr-sm color-vn-label"> <div class="q-mr-sm color-vn-label">
{{ t('Credit') }}: {{ t('Credit') }}:

View File

@ -1,17 +1,22 @@
<script setup> <script setup>
import { reactive, ref } from 'vue'; import { computed, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { QBtn } from 'quasar';
import { toCurrency, toDateHourMin } from 'src/filters';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.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 WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const informationOptions = ref([]); const rows = ref([]);
const filter = { const filter = {
include: [ include: [
@ -32,12 +37,64 @@ const initialData = reactive({
rating: null, rating: null,
recommendedCredit: null, recommendedCredit: null,
}); });
const tableColumnComponents = {
since: {
component: 'span',
props: () => {},
event: () => {},
},
employee: {
component: QBtn,
props: () => ({ flat: true, color: 'blue' }),
event: () => {},
},
rating: {
component: 'span',
props: () => {},
event: () => {},
},
recommendedCredit: {
component: 'span',
props: () => {},
event: () => {},
},
};
const columns = computed(() => [
{
align: 'left',
field: 'created',
format: (value) => toDateHourMin(value),
label: t('Since'),
name: 'since',
},
{
align: 'left',
field: (row) => row.worker.user.nickname,
label: t('Employee'),
name: 'employee',
},
{
align: 'left',
field: 'rating',
label: t('Rating'),
name: 'rating',
},
{
align: 'left',
field: 'recommendedCredit',
format: (value) => toCurrency(value),
label: t('Recommended credit'),
name: 'recommendedCredit',
},
]);
</script> </script>
<template> <template>
<FetchData <FetchData
:filter="filter" :filter="filter"
@on-fetch="(data) => (informationOptions = data)" @on-fetch="(data) => (rows = data)"
auto-load auto-load
url="ClientInformas" url="ClientInformas"
/> />
@ -68,10 +125,41 @@ const initialData = reactive({
</VnRow> </VnRow>
</template> </template>
</FormModel> </FormModel>
<QTable
:columns="columns"
:pagination="{ rowsPerPage: 0 }"
:rows="rows"
hide-bottom
row-key="id"
v-model:selected="selected"
class="q-pa-lg"
>
<template #body-cell="props">
<QTd :props="props">
<QTr :props="props" class="cursor-pointer">
<component
:is="tableColumnComponents[props.col.name].component"
class="col-content"
v-bind="tableColumnComponents[props.col.name].props(props)"
@click="tableColumnComponents[props.col.name].event(props)"
>
{{ props.value }}
<WorkerDescriptorProxy
:id="props.row.workerFk"
v-if="props.col.name === 'employee'"
/>
</component>
</QTr>
</QTd>
</template>
</QTable>
</template> </template>
<i18n> <i18n>
es: es:
Rating: Clasificación Rating: Clasificación
Recommended credit: Crédito recomendado Recommended credit: Crédito recomendado
Since: Desde
Employee: Empleado
</i18n> </i18n>

View File

@ -85,39 +85,45 @@ const toCustomerCreditCreate = () => {
url="ClientCredits" url="ClientCredits"
/> />
<QPage class="column items-center q-pa-md"> <div class="full-width flex justify-center">
<QTable <QCard class="card-width q-pa-lg">
:columns="columns" <QTable
:pagination="{ rowsPerPage: 12 }" :columns="columns"
:rows="rows" :pagination="{ rowsPerPage: 12 }"
class="full-width q-mt-md" :rows="rows"
row-key="id" class="full-width q-mt-md"
v-if="rows?.length" row-key="id"
> v-if="rows?.length"
<template #body-cell="props"> >
<QTd :props="props"> <template #body-cell="props">
<QTr :props="props" class="cursor-pointer"> <QTd :props="props">
<component <QTr :props="props" class="cursor-pointer">
:is="tableColumnComponents[props.col.name].component" <component
@click="tableColumnComponents[props.col.name].event(props)" :is="tableColumnComponents[props.col.name].component"
class="rounded-borders q-pa-sm" @click="
v-bind="tableColumnComponents[props.col.name].props(props)" tableColumnComponents[props.col.name].event(props)
> "
{{ props.value }} class="rounded-borders q-pa-sm"
<WorkerDescriptorProxy v-bind="
:id="props.row.workerFk" tableColumnComponents[props.col.name].props(props)
v-if="props.col.name === 'employee'" "
/> >
</component> {{ props.value }}
</QTr> <WorkerDescriptorProxy
</QTd> :id="props.row.workerFk"
</template> v-if="props.col.name === 'employee'"
</QTable> />
</component>
</QTr>
</QTd>
</template>
</QTable>
<h5 class="flex justify-center color-vn-label" v-else> <h5 class="flex justify-center color-vn-label" v-else>
{{ t('globals.noResults') }} {{ t('globals.noResults') }}
</h5> </h5>
</QPage> </QCard>
</div>
<QPageSticky :offset="[18, 18]"> <QPageSticky :offset="[18, 18]">
<QBtn @click.stop="toCustomerCreditCreate()" color="primary" fab icon="add" /> <QBtn @click.stop="toCustomerCreditCreate()" color="primary" fab icon="add" />

View File

@ -83,7 +83,7 @@ function handleLocation(data, location) {
:label="t('Sage transaction type')" :label="t('Sage transaction type')"
:options="typesTransactions" :options="typesTransactions"
hide-selected hide-selected
option-label="vat" option-label="transaction"
option-value="id" option-value="id"
v-model="data.sageTransactionTypeFk" v-model="data.sageTransactionTypeFk"
> >

View File

@ -23,45 +23,52 @@ const toCustomerNoteCreate = () => {
</script> </script>
<template> <template>
<QCard class="q-pa-lg"> <div class="full-width flex justify-center">
<VnPaginate <QCard class="card-width q-pa-lg">
data-key="CustomerNotes" <VnPaginate
:url="'clientObservations'" data-key="CustomerNotes"
auto-load :url="'clientObservations'"
:filter="noteFilter" auto-load
> :filter="noteFilter"
<template #body="{ rows }"> >
<div v-if="rows.length"> <template #body="{ rows }">
<QCard <div v-if="rows.length">
v-for="(item, index) in rows" <QCard
:key="index" v-for="(item, index) in rows"
:class="{ :key="index"
'q-pa-md': true, :class="{
'q-rounded': true, 'q-pa-md': true,
'custom-border': true, 'q-rounded': true,
'q-mb-md': index < rows.length - 1, 'custom-border': true,
}" 'q-mb-md': index < rows.length - 1,
> }"
<div class="flex justify-between"> >
<p class="color-vn-label">{{ item.worker.user.nickname }}</p> <div class="flex justify-between">
<p class="color-vn-label"> <p class="color-vn-label">
{{ {{ item.worker.user.nickname }}
date.formatDate(item?.created, 'DD-MM-YYYY HH:mm:ss') </p>
}} <p class="color-vn-label">
</p> {{
</div> date.formatDate(
<h6 class="q-mt-xs q-mb-none">{{ item.text }}</h6> item?.created,
</QCard> 'DD-MM-YYYY HH:mm:ss'
</div> )
}}
</p>
</div>
<h6 class="q-mt-xs q-mb-none">{{ item.text }}</h6>
</QCard>
</div>
<div v-else> <div v-else>
<h5 class="flex justify-center color-vn-label"> <h5 class="flex justify-center color-vn-label">
{{ t('globals.noResults') }} {{ t('globals.noResults') }}
</h5> </h5>
</div> </div>
</template> </template>
</VnPaginate> </VnPaginate>
</QCard> </QCard>
</div>
<QPageSticky :offset="[18, 18]"> <QPageSticky :offset="[18, 18]">
<QBtn @click.stop="toCustomerNoteCreate()" color="primary" fab icon="add" /> <QBtn @click.stop="toCustomerNoteCreate()" color="primary" fab icon="add" />

View File

@ -287,3 +287,8 @@ const creditWarning = computed(() => {
</template> </template>
</CardSummary> </CardSummary>
</template> </template>
<i18n>
es:
Latest tickets: Últimos tickets
</i18n>

View File

@ -135,42 +135,47 @@ const onSubmit = async () => {
</QBtnGroup> </QBtnGroup>
</Teleport> </Teleport>
<QCard class="q-pa-lg"> <div class="full-width flex justify-center">
<QCardSection> <QCard class="card-width q-pa-lg">
<QForm> <QCardSection>
<VnRow class="row q-gutter-md q-mb-md"> <QForm>
<div class="col"> <VnRow class="row q-gutter-md q-mb-md">
<QCheckbox :label="t('Enable web access')" v-model="active" /> <div class="col">
</div> <QCheckbox :label="t('Enable web access')" v-model="active" />
</VnRow> </div>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<VnInput :label="t('User')" clearable v-model="name" /> <VnInput :label="t('User')" clearable v-model="name" />
</div> </div>
<div class="col"> </VnRow>
<VnInput
:label="t('Recovery email')" <VnRow class="row q-gutter-md q-mb-md">
:rules="validate('client.email')" <div class="col">
clearable <VnInput
type="email" :label="t('Recovery email')"
v-model="email" :rules="validate('client.email')"
> clearable
<template #append> type="email"
<QIcon name="info" class="cursor-pointer"> v-model="email"
<QTooltip>{{ >
t( <template #append>
'This email is used for user to regain access their account' <QIcon name="info" class="cursor-pointer">
) <QTooltip>{{
}}</QTooltip> t(
</QIcon> 'This email is used for user to regain access their account'
</template> )
</VnInput> }}</QTooltip>
</div> </QIcon>
</VnRow> </template>
</QForm> </VnInput>
</QCardSection> </div>
</QCard> </VnRow>
</QForm>
</QCardSection>
</QCard>
</div>
</template> </template>
<i18n> <i18n>

View File

@ -69,7 +69,7 @@ const columns = computed(() => [
url="CreditInsurances" url="CreditInsurances"
/> />
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md" v-if="rows.length">
<QTable <QTable
:columns="columns" :columns="columns"
:pagination="{ rowsPerPage: 12 }" :pagination="{ rowsPerPage: 12 }"
@ -93,6 +93,10 @@ const columns = computed(() => [
</template> </template>
</QTable> </QTable>
</QPage> </QPage>
<h5 class="flex justify-center color-vn-label" v-else>
{{ t('globals.noResults') }}
</h5>
</template> </template>
<i18n> <i18n>

View File

@ -366,17 +366,6 @@ export default {
], ],
}, },
children: [ children: [
{
path: 'credit-contracts',
name: 'CustomerCreditContracts',
meta: {
title: 'creditContracts',
},
component: () =>
import(
'src/pages/Customer/Card/CustomerCreditContracts.vue'
),
},
{ {
path: 'credit-contracts', path: 'credit-contracts',
name: 'CreditContractsCard', name: 'CreditContractsCard',
@ -439,7 +428,7 @@ export default {
{ {
name: 'CustomerConsumption', name: 'CustomerConsumption',
title: 'consumption', title: 'consumption',
icon: 'vn:lines', icon: 'show_chart',
}, },
{ {
name: 'CustomerMandates', name: 'CustomerMandates',