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;
}
.card-width {
width: 800px;
}
.vn-card-list {
width: 100%;
max-width: 60em;

View File

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

View File

@ -129,7 +129,7 @@ const updateData = () => {
<QSeparator class="q-mx-lg" vertical />
<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="q-mr-sm color-vn-label">
{{ t('Credit') }}:

View File

@ -1,17 +1,22 @@
<script setup>
import { reactive, ref } from 'vue';
import { computed, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { QBtn } from 'quasar';
import { toCurrency, toDateHourMin } from 'src/filters';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
const { t } = useI18n();
const route = useRoute();
const informationOptions = ref([]);
const rows = ref([]);
const filter = {
include: [
@ -32,12 +37,64 @@ const initialData = reactive({
rating: 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>
<template>
<FetchData
:filter="filter"
@on-fetch="(data) => (informationOptions = data)"
@on-fetch="(data) => (rows = data)"
auto-load
url="ClientInformas"
/>
@ -68,10 +125,41 @@ const initialData = reactive({
</VnRow>
</template>
</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>
<i18n>
es:
Rating: Clasificación
Recommended credit: Crédito recomendado
Since: Desde
Employee: Empleado
</i18n>

View File

@ -85,39 +85,45 @@ const toCustomerCreditCreate = () => {
url="ClientCredits"
/>
<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="tableColumnComponents[props.col.name].component"
@click="tableColumnComponents[props.col.name].event(props)"
class="rounded-borders q-pa-sm"
v-bind="tableColumnComponents[props.col.name].props(props)"
>
{{ props.value }}
<WorkerDescriptorProxy
:id="props.row.workerFk"
v-if="props.col.name === 'employee'"
/>
</component>
</QTr>
</QTd>
</template>
</QTable>
<div class="full-width flex justify-center">
<QCard class="card-width q-pa-lg">
<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="tableColumnComponents[props.col.name].component"
@click="
tableColumnComponents[props.col.name].event(props)
"
class="rounded-borders q-pa-sm"
v-bind="
tableColumnComponents[props.col.name].props(props)
"
>
{{ props.value }}
<WorkerDescriptorProxy
:id="props.row.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>
<h5 class="flex justify-center color-vn-label" v-else>
{{ t('globals.noResults') }}
</h5>
</QCard>
</div>
<QPageSticky :offset="[18, 18]">
<QBtn @click.stop="toCustomerCreditCreate()" color="primary" fab icon="add" />

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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