Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev
This commit is contained in:
commit
a251e348a8
|
@ -1,6 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { parsePhone } from 'src/filters';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
phoneNumber: { type: [String, Number], default: null },
|
phoneNumber: { type: [String, Number], default: null },
|
||||||
channel: { type: Number, default: null },
|
channel: { type: Number, default: null },
|
||||||
|
@ -24,9 +25,9 @@ onBeforeMount(async () => {
|
||||||
.data;
|
.data;
|
||||||
if (!channel) channel = defaultChannel;
|
if (!channel) channel = defaultChannel;
|
||||||
|
|
||||||
config[
|
config[type].href = `${url}?customerIdentity=%2B${parsePhone(
|
||||||
type
|
props.phoneNumber
|
||||||
].href = `${url}?customerIdentity=%2B${props.phoneNumber}&channelId=${channel}`;
|
)}&channelId=${channel}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -133,7 +133,7 @@ const addFilter = async (filter, params) => {
|
||||||
async function fetch(params) {
|
async function fetch(params) {
|
||||||
useArrayData(props.dataKey, params);
|
useArrayData(props.dataKey, params);
|
||||||
arrayData.reset(['filter.skip', 'skip', 'page']);
|
arrayData.reset(['filter.skip', 'skip', 'page']);
|
||||||
await arrayData.fetch({ append: false });
|
await arrayData.fetch({ append: false, updateRouter: mounted.value });
|
||||||
return emitStoreData();
|
return emitStoreData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,12 @@ import dateRange from './dateRange';
|
||||||
import toHour from './toHour';
|
import toHour from './toHour';
|
||||||
import dashOrCurrency from './dashOrCurrency';
|
import dashOrCurrency from './dashOrCurrency';
|
||||||
import getParamWhere from './getParamWhere';
|
import getParamWhere from './getParamWhere';
|
||||||
|
import parsePhone from './parsePhone';
|
||||||
import isDialogOpened from './isDialogOpened';
|
import isDialogOpened from './isDialogOpened';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
isDialogOpened,
|
isDialogOpened,
|
||||||
|
parsePhone,
|
||||||
toLowerCase,
|
toLowerCase,
|
||||||
toLowerCamel,
|
toLowerCamel,
|
||||||
toDate,
|
toDate,
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
export default function (phone, prefix = 34) {
|
||||||
|
if (phone.startsWith('+')) {
|
||||||
|
return `${phone.slice(1)}`;
|
||||||
|
}
|
||||||
|
if (phone.startsWith('00')) {
|
||||||
|
return `${phone.slice(2)}`;
|
||||||
|
}
|
||||||
|
if (phone.startsWith(prefix) && phone.length === prefix.length + 9) {
|
||||||
|
return `${prefix}${phone.slice(prefix.length)}`;
|
||||||
|
}
|
||||||
|
return `${prefix}${phone}`;
|
||||||
|
}
|
|
@ -864,7 +864,6 @@ components:
|
||||||
cardDescriptor:
|
cardDescriptor:
|
||||||
mainList: Main list
|
mainList: Main list
|
||||||
summary: Summary
|
summary: Summary
|
||||||
moreOptions: More options
|
|
||||||
leftMenu:
|
leftMenu:
|
||||||
addToPinned: Add to pinned
|
addToPinned: Add to pinned
|
||||||
removeFromPinned: Remove from pinned
|
removeFromPinned: Remove from pinned
|
||||||
|
|
|
@ -101,8 +101,8 @@ const exprBuilder = (param, value) => {
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mb-sm">
|
<QItem class="q-mb-sm">
|
||||||
<QItemSection
|
<QItemSection>
|
||||||
><VnSelect
|
<VnSelect
|
||||||
url="Provinces"
|
url="Provinces"
|
||||||
:label="t('Province')"
|
:label="t('Province')"
|
||||||
v-model="params.provinceFk"
|
v-model="params.provinceFk"
|
||||||
|
@ -120,14 +120,12 @@ const exprBuilder = (param, value) => {
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mb-md">
|
<QItem class="q-mb-sm">
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInput :label="t('City')" v-model="params.city" is-outlined />
|
<VnInput :label="t('City')" v-model="params.city" is-outlined />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QItem class="q-mb-sm">
|
||||||
<QExpansionItem :label="t('More options')" expand-separator>
|
|
||||||
<QItem>
|
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInput :label="t('Phone')" v-model="params.phone" is-outlined>
|
<VnInput :label="t('Phone')" v-model="params.phone" is-outlined>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
|
@ -136,7 +134,7 @@ const exprBuilder = (param, value) => {
|
||||||
</VnInput>
|
</VnInput>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem class="q-mb-sm">
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInput :label="t('Email')" v-model="params.email" is-outlined>
|
<VnInput :label="t('Email')" v-model="params.email" is-outlined>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
|
@ -145,7 +143,8 @@ const exprBuilder = (param, value) => {
|
||||||
</VnInput>
|
</VnInput>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem class="q-mb-sm">
|
||||||
|
<QItemSection>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
url="Zones"
|
url="Zones"
|
||||||
:label="t('Zone')"
|
:label="t('Zone')"
|
||||||
|
@ -160,9 +159,9 @@ const exprBuilder = (param, value) => {
|
||||||
outlined
|
outlined
|
||||||
rounded
|
rounded
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/></QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem class="q-mb-sm">
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('Postcode')"
|
:label="t('Postcode')"
|
||||||
|
@ -171,7 +170,6 @@ const exprBuilder = (param, value) => {
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QExpansionItem>
|
|
||||||
</template>
|
</template>
|
||||||
</VnFilterPanel>
|
</VnFilterPanel>
|
||||||
</template>
|
</template>
|
||||||
|
@ -203,7 +201,6 @@ es:
|
||||||
Salesperson: Comercial
|
Salesperson: Comercial
|
||||||
Province: Provincia
|
Province: Provincia
|
||||||
City: Ciudad
|
City: Ciudad
|
||||||
More options: Más opciones
|
|
||||||
Phone: Teléfono
|
Phone: Teléfono
|
||||||
Email: Email
|
Email: Email
|
||||||
Zone: Zona
|
Zone: Zona
|
||||||
|
|
|
@ -86,7 +86,7 @@ const entriesTableColumns = computed(() => [
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="print"
|
icon="print"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
@click="openReport(`Entries/${entityId}/print`)"
|
@click="openReport(`Entries/${entityId}/buy-label-supplier`)"
|
||||||
unelevated
|
unelevated
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -184,5 +184,4 @@ es:
|
||||||
Amount: Importe
|
Amount: Importe
|
||||||
Issued: Fecha factura
|
Issued: Fecha factura
|
||||||
Id or supplier: Id o proveedor
|
Id or supplier: Id o proveedor
|
||||||
More options: Más opciones
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -83,8 +83,6 @@ const states = ref();
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
|
||||||
<QExpansionItem :label="t('More options')" expand-separator>
|
|
||||||
<QItem>
|
<QItem>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
|
@ -105,14 +103,9 @@ const states = ref();
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInputDate
|
<VnInputDate v-model="params.dued" :label="t('Dued')" is-outlined />
|
||||||
v-model="params.dued"
|
|
||||||
:label="t('Dued')"
|
|
||||||
is-outlined
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QExpansionItem>
|
|
||||||
</template>
|
</template>
|
||||||
</VnFilterPanel>
|
</VnFilterPanel>
|
||||||
</template>
|
</template>
|
||||||
|
@ -149,5 +142,4 @@ es:
|
||||||
Issued: Fecha emisión
|
Issued: Fecha emisión
|
||||||
Created: Fecha creación
|
Created: Fecha creación
|
||||||
Dued: Fecha vencimiento
|
Dued: Fecha vencimiento
|
||||||
More options: Más opciones
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -60,8 +60,15 @@ const columns = computed(() => [
|
||||||
label: t('globals.reference'),
|
label: t('globals.reference'),
|
||||||
isTitle: true,
|
isTitle: true,
|
||||||
component: 'select',
|
component: 'select',
|
||||||
attrs: { url: MODEL, optionLabel: 'ref', optionValue: 'id' },
|
attrs: {
|
||||||
|
url: MODEL,
|
||||||
|
optionLabel: 'ref',
|
||||||
|
optionValue: 'ref',
|
||||||
|
},
|
||||||
columnField: { component: null },
|
columnField: { component: null },
|
||||||
|
columnFilter: {
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -146,9 +153,7 @@ function downloadPdf() {
|
||||||
const [invoiceOut] = selectedCardsArray;
|
const [invoiceOut] = selectedCardsArray;
|
||||||
openPdf(invoiceOut.id);
|
openPdf(invoiceOut.id);
|
||||||
} else {
|
} else {
|
||||||
const invoiceOutIdsArray = selectedCardsArray.map(
|
const invoiceOutIdsArray = selectedCardsArray.map((invoiceOut) => invoiceOut.id);
|
||||||
(invoiceOut) => invoiceOut.id
|
|
||||||
);
|
|
||||||
const invoiceOutIds = invoiceOutIdsArray.join(',');
|
const invoiceOutIds = invoiceOutIdsArray.join(',');
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -157,7 +162,6 @@ function downloadPdf() {
|
||||||
|
|
||||||
openReport(`${MODEL}/downloadZip`, params);
|
openReport(`${MODEL}/downloadZip`, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watchEffect(selectedRows);
|
watchEffect(selectedRows);
|
||||||
|
|
|
@ -15,6 +15,7 @@ import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vu
|
||||||
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
|
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
|
||||||
import { toDateTimeFormat } from 'src/filters/date';
|
import { toDateTimeFormat } from 'src/filters/date';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
import dataByOrder from 'src/utils/dataByOrder';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
|
@ -149,7 +150,12 @@ onMounted(() => {
|
||||||
});
|
});
|
||||||
async function fetchClientAddress(id, formData = {}) {
|
async function fetchClientAddress(id, formData = {}) {
|
||||||
const { data } = await axios.get(`Clients/${id}`, {
|
const { data } = await axios.get(`Clients/${id}`, {
|
||||||
params: { filter: { include: { relation: 'addresses' } } },
|
params: {
|
||||||
|
filter: {
|
||||||
|
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||||
|
include: { relation: 'addresses' },
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
addressesList.value = data.addresses;
|
addressesList.value = data.addresses;
|
||||||
formData.addressId = data.defaultAddressFk;
|
formData.addressId = data.defaultAddressFk;
|
||||||
|
@ -162,7 +168,7 @@ async function fetchAgencies({ landed, addressId }) {
|
||||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||||
params: { addressFk: addressId, landed },
|
params: { addressFk: addressId, landed },
|
||||||
});
|
});
|
||||||
agencyList.value = data;
|
agencyList.value = dataByOrder(data, 'agencyMode ASC');
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDateColor = (date) => {
|
const getDateColor = (date) => {
|
||||||
|
@ -253,22 +259,27 @@ const getDateColor = (date) => {
|
||||||
@update:model-value="() => fetchAgencies(data)"
|
@update:model-value="() => fetchAgencies(data)"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem
|
||||||
<QItemSection>
|
v-bind="scope.itemProps"
|
||||||
<QItemLabel
|
:class="{ disabled: !scope.opt.isActive }"
|
||||||
:class="{
|
|
||||||
'color-vn-label': !scope.opt?.isActive,
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
{{
|
<QItemSection style="min-width: min-content" avatar>
|
||||||
`${
|
<QIcon
|
||||||
!scope.opt?.isActive
|
v-if="
|
||||||
? t('basicData.inactive')
|
scope.opt.isActive && data.addressId === scope.opt.id
|
||||||
: ''
|
"
|
||||||
} `
|
size="sm"
|
||||||
}}
|
color="grey"
|
||||||
{{ scope.opt?.nickname }}: {{ scope.opt?.street }},
|
name="star"
|
||||||
{{ scope.opt?.city }}
|
class="fill-icon"
|
||||||
|
/>
|
||||||
|
</QItemSection>
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>
|
||||||
|
{{ scope.opt.nickname }}
|
||||||
|
</QItemLabel>
|
||||||
|
<QItemLabel caption>
|
||||||
|
{{ `${scope.opt.street}, ${scope.opt.city}` }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
|
@ -212,8 +212,6 @@ const getGroupedStates = (data) => {
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
|
||||||
<QExpansionItem :label="t('More options')" expand-separator>
|
|
||||||
<QItem>
|
<QItem>
|
||||||
<QItemSection v-if="!provinces">
|
<QItemSection v-if="!provinces">
|
||||||
<QSkeleton type="QInput" class="full-width" />
|
<QSkeleton type="QInput" class="full-width" />
|
||||||
|
@ -286,7 +284,6 @@ const getGroupedStates = (data) => {
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QExpansionItem>
|
|
||||||
</template>
|
</template>
|
||||||
</VnFilterPanel>
|
</VnFilterPanel>
|
||||||
</template>
|
</template>
|
||||||
|
@ -340,7 +337,6 @@ es:
|
||||||
With problems: Con problemas
|
With problems: Con problemas
|
||||||
Invoiced: Facturado
|
Invoiced: Facturado
|
||||||
Routed: Enrutado
|
Routed: Enrutado
|
||||||
More options: Más opciones
|
|
||||||
Province: Provincia
|
Province: Provincia
|
||||||
Agency: Agencia
|
Agency: Agencia
|
||||||
Warehouse: Almacén
|
Warehouse: Almacén
|
||||||
|
|
|
@ -274,7 +274,7 @@ const fetchAddresses = async (formData) => {
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
||||||
order: 'nickname ASC',
|
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||||
};
|
};
|
||||||
const params = { filter: JSON.stringify(filter) };
|
const params = { filter: JSON.stringify(filter) };
|
||||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||||
|
@ -590,7 +590,22 @@ function setReference(data) {
|
||||||
@update:model-value="() => fetchAvailableAgencies(data)"
|
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem
|
||||||
|
v-bind="scope.itemProps"
|
||||||
|
:class="{ disabled: !scope.opt.isActive }"
|
||||||
|
>
|
||||||
|
<QItemSection style="min-width: min-content" avatar>
|
||||||
|
<QIcon
|
||||||
|
v-if="
|
||||||
|
scope.opt.isActive &&
|
||||||
|
selectedClient?.defaultAddressFk === scope.opt.id
|
||||||
|
"
|
||||||
|
size="sm"
|
||||||
|
color="grey"
|
||||||
|
name="star"
|
||||||
|
class="fill-icon"
|
||||||
|
/>
|
||||||
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<QItemLabel
|
<QItemLabel
|
||||||
:class="{
|
:class="{
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import parsePhone from 'src/filters/parsePhone';
|
||||||
|
|
||||||
|
describe('parsePhone filter', () => {
|
||||||
|
it("adds prefix +34 if it doesn't have one", () => {
|
||||||
|
const resultado = parsePhone('123456789', '34');
|
||||||
|
expect(resultado).toBe('34123456789');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('maintains prefix +34 if it is already correct', () => {
|
||||||
|
const resultado = parsePhone('+34123456789', '34');
|
||||||
|
expect(resultado).toBe('34123456789');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('converts prefix 0034 to +34', () => {
|
||||||
|
const resultado = parsePhone('0034123456789', '34');
|
||||||
|
expect(resultado).toBe('34123456789');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('converts prefix 34 without symbol to +34', () => {
|
||||||
|
const resultado = parsePhone('34123456789', '34');
|
||||||
|
expect(resultado).toBe('34123456789');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('replaces incorrect prefix with the correct one', () => {
|
||||||
|
const resultado = parsePhone('+44123456789', '34');
|
||||||
|
expect(resultado).toBe('44123456789');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue