Merge branch '8219-InvoiceOutE2E' of https://gitea.verdnatura.es/verdnatura/salix-front into 8219-InvoiceOutE2E
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
248288fd89
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-front",
|
"name": "salix-front",
|
||||||
"version": "24.50.0",
|
"version": "24.52.0",
|
||||||
"description": "Salix frontend",
|
"description": "Salix frontend",
|
||||||
"productName": "Salix",
|
"productName": "Salix",
|
||||||
"author": "Verdnatura",
|
"author": "Verdnatura",
|
||||||
|
@ -64,4 +64,4 @@
|
||||||
"vite": "^5.1.4",
|
"vite": "^5.1.4",
|
||||||
"vitest": "^0.31.1"
|
"vitest": "^0.31.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ const onDataSaved = (...args) => {
|
||||||
url-create="towns"
|
url-create="towns"
|
||||||
model="city"
|
model="city"
|
||||||
@on-data-saved="onDataSaved"
|
@on-data-saved="onDataSaved"
|
||||||
|
data-cy="newCityForm"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
@ -48,12 +49,14 @@ const onDataSaved = (...args) => {
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
:rules="validate('city.name')"
|
:rules="validate('city.name')"
|
||||||
required
|
required
|
||||||
|
data-cy="cityName"
|
||||||
/>
|
/>
|
||||||
<VnSelectProvince
|
<VnSelectProvince
|
||||||
:province-selected="$props.provinceSelected"
|
:province-selected="$props.provinceSelected"
|
||||||
:country-fk="$props.countryFk"
|
:country-fk="$props.countryFk"
|
||||||
v-model="data.provinceFk"
|
v-model="data.provinceFk"
|
||||||
required
|
required
|
||||||
|
data-cy="provinceCity"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
@ -21,14 +21,14 @@ const postcodeFormData = reactive({
|
||||||
provinceFk: null,
|
provinceFk: null,
|
||||||
townFk: null,
|
townFk: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const townsFetchDataRef = ref(false);
|
const townsFetchDataRef = ref(false);
|
||||||
|
const townFilter = ref({});
|
||||||
|
|
||||||
const countriesRef = ref(false);
|
const countriesRef = ref(false);
|
||||||
const townsRef = ref(false);
|
|
||||||
const provincesFetchDataRef = ref(false);
|
const provincesFetchDataRef = ref(false);
|
||||||
const provincesOptions = ref([]);
|
const provincesOptions = ref([]);
|
||||||
|
const townsOptions = ref([]);
|
||||||
const town = ref({});
|
const town = ref({});
|
||||||
const townFilter = ref({});
|
|
||||||
const countryFilter = ref({});
|
const countryFilter = ref({});
|
||||||
|
|
||||||
function onDataSaved(formData) {
|
function onDataSaved(formData) {
|
||||||
|
@ -48,6 +48,49 @@ function onDataSaved(formData) {
|
||||||
emit('onDataSaved', newPostcode);
|
emit('onDataSaved', newPostcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setCountry(countryFk, data) {
|
||||||
|
data.townFk = null;
|
||||||
|
data.provinceFk = null;
|
||||||
|
data.countryFk = countryFk;
|
||||||
|
await fetchTowns();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Province
|
||||||
|
|
||||||
|
async function handleProvinces(data) {
|
||||||
|
provincesOptions.value = data;
|
||||||
|
if (postcodeFormData.countryFk) {
|
||||||
|
await fetchTowns();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function setProvince(id, data) {
|
||||||
|
if (data.provinceFk === id) return;
|
||||||
|
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||||
|
if (newProvince) data.countryFk = newProvince.countryFk;
|
||||||
|
postcodeFormData.provinceFk = id;
|
||||||
|
await fetchTowns();
|
||||||
|
}
|
||||||
|
async function onProvinceCreated(data) {
|
||||||
|
await provincesFetchDataRef.value.fetch({
|
||||||
|
where: { countryFk: postcodeFormData.countryFk },
|
||||||
|
});
|
||||||
|
postcodeFormData.provinceFk = data.id;
|
||||||
|
}
|
||||||
|
function provinceByCountry(countryFk = postcodeFormData.countryFk) {
|
||||||
|
return provincesOptions.value
|
||||||
|
.filter((province) => province.countryFk === countryFk)
|
||||||
|
.map(({ id }) => id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Town
|
||||||
|
async function handleTowns(data) {
|
||||||
|
townsOptions.value = data;
|
||||||
|
}
|
||||||
|
function setTown(newTown, data) {
|
||||||
|
town.value = newTown;
|
||||||
|
data.provinceFk = newTown?.provinceFk ?? newTown;
|
||||||
|
data.countryFk = newTown?.province?.countryFk ?? newTown;
|
||||||
|
}
|
||||||
async function onCityCreated(newTown, formData) {
|
async function onCityCreated(newTown, formData) {
|
||||||
await provincesFetchDataRef.value.fetch();
|
await provincesFetchDataRef.value.fetch();
|
||||||
newTown.province = provincesOptions.value.find(
|
newTown.province = provincesOptions.value.find(
|
||||||
|
@ -56,44 +99,29 @@ async function onCityCreated(newTown, formData) {
|
||||||
formData.townFk = newTown;
|
formData.townFk = newTown;
|
||||||
setTown(newTown, formData);
|
setTown(newTown, formData);
|
||||||
}
|
}
|
||||||
|
async function fetchTowns(countryFk = postcodeFormData.countryFk) {
|
||||||
function setTown(newTown, data) {
|
if (!countryFk) return;
|
||||||
town.value = newTown;
|
const provinces = postcodeFormData.provinceFk
|
||||||
data.provinceFk = newTown?.provinceFk ?? newTown;
|
? [postcodeFormData.provinceFk]
|
||||||
data.countryFk = newTown?.province?.countryFk ?? newTown;
|
: provinceByCountry();
|
||||||
}
|
townFilter.value.where = {
|
||||||
|
|
||||||
async function setCountry(countryFk, data) {
|
|
||||||
data.townFk = null;
|
|
||||||
data.provinceFk = null;
|
|
||||||
data.countryFk = countryFk;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleProvinces(data) {
|
|
||||||
provincesOptions.value = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setProvince(id, data) {
|
|
||||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
|
||||||
if (!newProvince) return;
|
|
||||||
|
|
||||||
data.countryFk = newProvince.countryFk;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onProvinceCreated(data) {
|
|
||||||
await provincesFetchDataRef.value.fetch({
|
|
||||||
where: { countryFk: postcodeFormData.countryFk },
|
|
||||||
});
|
|
||||||
postcodeFormData.provinceFk = data.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
const whereTowns = computed(() => {
|
|
||||||
return {
|
|
||||||
provinceFk: {
|
provinceFk: {
|
||||||
inq: provincesOptions.value.map(({ id }) => id),
|
inq: provinces,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
await townsFetchDataRef.value?.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function filterTowns(name) {
|
||||||
|
if (name !== '') {
|
||||||
|
townFilter.value.where = {
|
||||||
|
name: {
|
||||||
|
like: `%${name}%`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await townsFetchDataRef.value?.fetch();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -105,6 +133,15 @@ const whereTowns = computed(() => {
|
||||||
auto-load
|
auto-load
|
||||||
url="Provinces/location"
|
url="Provinces/location"
|
||||||
/>
|
/>
|
||||||
|
<FetchData
|
||||||
|
ref="townsFetchDataRef"
|
||||||
|
:sort-by="['name ASC']"
|
||||||
|
:limit="30"
|
||||||
|
:filter="townFilter"
|
||||||
|
@on-fetch="handleTowns"
|
||||||
|
auto-load
|
||||||
|
url="Towns/location"
|
||||||
|
/>
|
||||||
|
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
url-create="postcodes"
|
url-create="postcodes"
|
||||||
|
@ -123,25 +160,22 @@ const whereTowns = computed(() => {
|
||||||
:rules="validate('postcode.code')"
|
:rules="validate('postcode.code')"
|
||||||
clearable
|
clearable
|
||||||
required
|
required
|
||||||
|
data-cy="locationPostcode"
|
||||||
/>
|
/>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
ref="townsRef"
|
|
||||||
:sort-by="['name ASC']"
|
|
||||||
:limit="30"
|
|
||||||
auto-load
|
|
||||||
url="Towns/location"
|
|
||||||
:where="whereTowns"
|
|
||||||
:label="t('City')"
|
:label="t('City')"
|
||||||
@update:model-value="(value) => setTown(value, data)"
|
@update:model-value="(value) => setTown(value, data)"
|
||||||
|
@filter="filterTowns"
|
||||||
:tooltip="t('Create city')"
|
:tooltip="t('Create city')"
|
||||||
v-model="data.townFk"
|
v-model="data.townFk"
|
||||||
|
:options="townsOptions"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
:rules="validate('postcode.city')"
|
:rules="validate('postcode.city')"
|
||||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
:clearable="true"
|
|
||||||
required
|
required
|
||||||
|
data-cy="locationTown"
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -172,7 +206,6 @@ const whereTowns = computed(() => {
|
||||||
:province-selected="data.provinceFk"
|
:province-selected="data.provinceFk"
|
||||||
@update:model-value="(value) => setProvince(value, data)"
|
@update:model-value="(value) => setProvince(value, data)"
|
||||||
v-model="data.provinceFk"
|
v-model="data.provinceFk"
|
||||||
@on-province-fetched="handleProvinces"
|
|
||||||
@on-province-created="onProvinceCreated"
|
@on-province-created="onProvinceCreated"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
@ -191,6 +224,7 @@ const whereTowns = computed(() => {
|
||||||
v-model="data.countryFk"
|
v-model="data.countryFk"
|
||||||
:rules="validate('postcode.countryFk')"
|
:rules="validate('postcode.countryFk')"
|
||||||
@update:model-value="(value) => setCountry(value, data)"
|
@update:model-value="(value) => setCountry(value, data)"
|
||||||
|
data-cy="locationCountry"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -53,8 +53,10 @@ const where = computed(() => {
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
:rules="validate('province.name')"
|
:rules="validate('province.name')"
|
||||||
required
|
required
|
||||||
|
data-cy="provinceName"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
data-cy="autonomyProvince"
|
||||||
required
|
required
|
||||||
ref="autonomiesRef"
|
ref="autonomiesRef"
|
||||||
auto-load
|
auto-load
|
||||||
|
|
|
@ -10,6 +10,7 @@ import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
|
import getDifferences from 'src/filters/getDifferences';
|
||||||
|
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
@ -175,14 +176,13 @@ async function saveChanges(data) {
|
||||||
const changes = data || getChanges();
|
const changes = data || getChanges();
|
||||||
try {
|
try {
|
||||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||||
} catch (e) {
|
} finally {
|
||||||
return (isLoading.value = false);
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
if (changes.creates?.length) await vnPaginateRef.value.fetch();
|
||||||
|
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
isLoading.value = false;
|
|
||||||
emit('saveChanges', data);
|
emit('saveChanges', data);
|
||||||
quasar.notify({
|
quasar.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
|
@ -268,28 +268,6 @@ function getChanges() {
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDifferences(obj1, obj2) {
|
|
||||||
let diff = {};
|
|
||||||
delete obj1.$index;
|
|
||||||
delete obj2.$index;
|
|
||||||
|
|
||||||
for (let key in obj1) {
|
|
||||||
if (obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
|
|
||||||
diff[key] = obj2[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let key in obj2) {
|
|
||||||
if (
|
|
||||||
obj1[key] === undefined ||
|
|
||||||
JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])
|
|
||||||
) {
|
|
||||||
diff[key] = obj2[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isEmpty(obj) {
|
function isEmpty(obj) {
|
||||||
if (obj == null) return true;
|
if (obj == null) return true;
|
||||||
if (obj === undefined) return true;
|
if (obj === undefined) return true;
|
||||||
|
|
|
@ -110,6 +110,7 @@ const originalData = ref({});
|
||||||
const formData = computed(() => state.get(modelValue));
|
const formData = computed(() => state.get(modelValue));
|
||||||
const defaultButtons = computed(() => ({
|
const defaultButtons = computed(() => ({
|
||||||
save: {
|
save: {
|
||||||
|
dataCy: 'saveDefaultBtn',
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'save',
|
icon: 'save',
|
||||||
label: 'globals.save',
|
label: 'globals.save',
|
||||||
|
@ -117,6 +118,7 @@ const defaultButtons = computed(() => ({
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
},
|
},
|
||||||
reset: {
|
reset: {
|
||||||
|
dataCy: 'resetDefaultBtn',
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'restart_alt',
|
icon: 'restart_alt',
|
||||||
label: 'globals.reset',
|
label: 'globals.reset',
|
||||||
|
@ -207,7 +209,9 @@ async function save() {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
try {
|
try {
|
||||||
formData.value = trimData(formData.value);
|
formData.value = trimData(formData.value);
|
||||||
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
const body = $props.mapper
|
||||||
|
? $props.mapper(formData.value, originalData.value)
|
||||||
|
: formData.value;
|
||||||
const method = $props.urlCreate ? 'post' : 'patch';
|
const method = $props.urlCreate ? 'post' : 'patch';
|
||||||
const url =
|
const url =
|
||||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
||||||
|
@ -322,6 +326,7 @@ defineExpose({
|
||||||
:title="t(defaultButtons.reset.label)"
|
:title="t(defaultButtons.reset.label)"
|
||||||
/>
|
/>
|
||||||
<QBtnDropdown
|
<QBtnDropdown
|
||||||
|
data-cy="saveAndContinueDefaultBtn"
|
||||||
v-if="$props.goTo"
|
v-if="$props.goTo"
|
||||||
@click="saveAndGo"
|
@click="saveAndGo"
|
||||||
:label="tMobile('globals.saveAndContinue')"
|
:label="tMobile('globals.saveAndContinue')"
|
||||||
|
|
|
@ -64,11 +64,11 @@ watch(
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
|
data-cy="locationProvince"
|
||||||
:label="t('Province')"
|
:label="t('Province')"
|
||||||
:options="provincesOptions"
|
:options="provincesOptions"
|
||||||
:tooltip="t('Create province')"
|
:tooltip="t('Create province')"
|
||||||
hide-selected
|
hide-selected
|
||||||
:clearable="true"
|
|
||||||
v-model="provinceFk"
|
v-model="provinceFk"
|
||||||
:rules="validate && validate('postcode.provinceFk')"
|
:rules="validate && validate('postcode.provinceFk')"
|
||||||
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
|
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
|
||||||
|
|
|
@ -75,7 +75,6 @@ const handleModelValue = (data) => {
|
||||||
:input-debounce="300"
|
:input-debounce="300"
|
||||||
:class="{ required: isRequired }"
|
:class="{ required: isRequired }"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
clearable
|
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
:tooltip="t('Create new location')"
|
:tooltip="t('Create new location')"
|
||||||
:rules="mixinRules"
|
:rules="mixinRules"
|
||||||
|
|
|
@ -8,7 +8,14 @@ import dataByOrder from 'src/utils/dataByOrder';
|
||||||
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
||||||
const $attrs = useAttrs();
|
const $attrs = useAttrs();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
||||||
|
const isRequired = computed(() => {
|
||||||
|
return useRequired($attrs).isRequired;
|
||||||
|
});
|
||||||
|
const requiredFieldRule = computed(() => {
|
||||||
|
return useRequired($attrs).requiredFieldRule;
|
||||||
|
});
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [String, Number, Object],
|
type: [String, Number, Object],
|
||||||
|
@ -308,9 +315,9 @@ function handleKeyDown(event) {
|
||||||
@virtual-scroll="onScroll"
|
@virtual-scroll="onScroll"
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
||||||
>
|
>
|
||||||
<template v-if="isClearable" #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-show="value"
|
v-show="isClearable && value"
|
||||||
name="close"
|
name="close"
|
||||||
@click.stop="
|
@click.stop="
|
||||||
() => {
|
() => {
|
||||||
|
@ -323,7 +330,22 @@ function handleKeyDown(event) {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
||||||
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
<div v-if="slotName == 'append'">
|
||||||
|
<QIcon
|
||||||
|
v-show="isClearable && value"
|
||||||
|
name="close"
|
||||||
|
@click.stop="
|
||||||
|
() => {
|
||||||
|
value = null;
|
||||||
|
emit('remove');
|
||||||
|
}
|
||||||
|
"
|
||||||
|
class="cursor-pointer"
|
||||||
|
size="xs"
|
||||||
|
/>
|
||||||
|
<slot name="append" v-if="$slots.append" v-bind="slotData ?? {}" />
|
||||||
|
</div>
|
||||||
|
<slot v-else :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
|
||||||
</template>
|
</template>
|
||||||
</QSelect>
|
</QSelect>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -43,6 +43,7 @@ const isAllowedToCreate = computed(() => {
|
||||||
>
|
>
|
||||||
<template v-if="isAllowedToCreate" #append>
|
<template v-if="isAllowedToCreate" #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
:data-cy="$attrs.dataCy ?? $attrs.label + '_icon'"
|
||||||
@click.stop.prevent="$refs.dialog.show()"
|
@click.stop.prevent="$refs.dialog.show()"
|
||||||
:name="actionIcon"
|
:name="actionIcon"
|
||||||
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { useColor } from 'src/composables/useColor';
|
||||||
import { getCssVar } from 'quasar';
|
import { getCssVar } from 'quasar';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
workerId: { type: Number, required: true },
|
workerId: { type: [Number, undefined], default: null },
|
||||||
description: { type: String, default: null },
|
description: { type: String, default: null },
|
||||||
title: { type: String, default: null },
|
title: { type: String, default: null },
|
||||||
color: { type: String, default: null },
|
color: { type: String, default: null },
|
||||||
|
@ -38,7 +38,13 @@ watch(src, () => (showLetter.value = false));
|
||||||
<template v-if="showLetter">
|
<template v-if="showLetter">
|
||||||
{{ title.charAt(0) }}
|
{{ title.charAt(0) }}
|
||||||
</template>
|
</template>
|
||||||
<QImg v-else :src="src" spinner-color="white" @error="showLetter = true" />
|
<QImg
|
||||||
|
v-else-if="workerId"
|
||||||
|
:src="src"
|
||||||
|
spinner-color="white"
|
||||||
|
@error="showLetter = true"
|
||||||
|
/>
|
||||||
|
<QIcon v-else name="mood" size="xs" />
|
||||||
</QAvatar>
|
</QAvatar>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<slot name="description" v-if="description">
|
<slot name="description" v-if="description">
|
||||||
|
|
|
@ -1,23 +1,28 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
import { ref, reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { parsePhone } from 'src/filters';
|
import { parsePhone } from 'src/filters';
|
||||||
|
import useOpenURL from 'src/composables/useOpenURL';
|
||||||
|
|
||||||
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 },
|
||||||
|
country: { type: String, default: null },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const phone = ref(props.phoneNumber);
|
||||||
const config = reactive({
|
const config = reactive({
|
||||||
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
||||||
'say-simple': {
|
'say-simple': {
|
||||||
icon: 'vn:saysimple',
|
icon: 'vn:saysimple',
|
||||||
href: null,
|
url: null,
|
||||||
channel: props.channel,
|
channel: props.channel,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
|
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
|
if (!phone.value) return;
|
||||||
let { channel } = config[type];
|
let { channel } = config[type];
|
||||||
|
|
||||||
if (type === 'say-simple') {
|
if (type === 'say-simple') {
|
||||||
|
@ -25,23 +30,28 @@ onBeforeMount(async () => {
|
||||||
.data;
|
.data;
|
||||||
if (!channel) channel = defaultChannel;
|
if (!channel) channel = defaultChannel;
|
||||||
|
|
||||||
config[type].href = `${url}?customerIdentity=%2B${parsePhone(
|
phone.value = await parsePhone(props.phoneNumber, props.country.toLowerCase());
|
||||||
props.phoneNumber
|
config[
|
||||||
)}&channelId=${channel}`;
|
type
|
||||||
|
].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function handleClick() {
|
||||||
|
if (config[type].url) useOpenURL(config[type].url);
|
||||||
|
else if (config[type].href) window.location.href = config[type].href;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="phoneNumber"
|
v-if="phone"
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
:icon="config[type].icon"
|
:icon="config[type].icon"
|
||||||
size="sm"
|
size="sm"
|
||||||
color="primary"
|
color="primary"
|
||||||
padding="none"
|
padding="none"
|
||||||
:href="config[type].href"
|
@click.stop="handleClick"
|
||||||
@click.stop
|
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ capitalize(type).replace('-', '') }}
|
{{ capitalize(type).replace('-', '') }}
|
||||||
|
|
|
@ -101,6 +101,7 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
@click="insert"
|
@click="insert"
|
||||||
class="q-mb-xs"
|
class="q-mb-xs"
|
||||||
dense
|
dense
|
||||||
|
data-cy="saveNote"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnInput>
|
</VnInput>
|
||||||
|
|
|
@ -2,8 +2,14 @@ import { useValidator } from 'src/composables/useValidator';
|
||||||
|
|
||||||
export function useRequired($attrs) {
|
export function useRequired($attrs) {
|
||||||
const { validations } = useValidator();
|
const { validations } = useValidator();
|
||||||
|
const hasRequired = Object.keys($attrs).includes('required');
|
||||||
const isRequired = Object.keys($attrs).includes('required');
|
let isRequired = false;
|
||||||
|
if (hasRequired) {
|
||||||
|
const required = $attrs['required'];
|
||||||
|
if (typeof required === 'boolean') {
|
||||||
|
isRequired = required;
|
||||||
|
}
|
||||||
|
}
|
||||||
const requiredFieldRule = (val) => validations().required(isRequired, val);
|
const requiredFieldRule = (val) => validations().required(isRequired, val);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
export default function getDifferences(obj1, obj2) {
|
||||||
|
let diff = {};
|
||||||
|
delete obj1.$index;
|
||||||
|
delete obj2.$index;
|
||||||
|
|
||||||
|
for (let key in obj1) {
|
||||||
|
if (obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let key in obj2) {
|
||||||
|
if (
|
||||||
|
obj1[key] === undefined ||
|
||||||
|
JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])
|
||||||
|
) {
|
||||||
|
diff[key] = obj2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
export default function getUpdatedValues(keys, formData) {
|
||||||
|
return keys.reduce((acc, key) => {
|
||||||
|
acc[key] = formData[key];
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
|
@ -11,11 +11,15 @@ import dashIfEmpty from './dashIfEmpty';
|
||||||
import dateRange from './dateRange';
|
import dateRange from './dateRange';
|
||||||
import toHour from './toHour';
|
import toHour from './toHour';
|
||||||
import dashOrCurrency from './dashOrCurrency';
|
import dashOrCurrency from './dashOrCurrency';
|
||||||
|
import getDifferences from './getDifferences';
|
||||||
|
import getUpdatedValues from './getUpdatedValues';
|
||||||
import getParamWhere from './getParamWhere';
|
import getParamWhere from './getParamWhere';
|
||||||
import parsePhone from './parsePhone';
|
import parsePhone from './parsePhone';
|
||||||
import isDialogOpened from './isDialogOpened';
|
import isDialogOpened from './isDialogOpened';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
getUpdatedValues,
|
||||||
|
getDifferences,
|
||||||
isDialogOpened,
|
isDialogOpened,
|
||||||
parsePhone,
|
parsePhone,
|
||||||
toLowerCase,
|
toLowerCase,
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
export default function (phone, prefix = 34) {
|
import axios from 'axios';
|
||||||
if (phone.startsWith('+')) {
|
|
||||||
return `${phone.slice(1)}`;
|
export default async function parsePhone(phone, country) {
|
||||||
}
|
if (!phone) return;
|
||||||
if (phone.startsWith('00')) {
|
if (phone.startsWith('+')) return `${phone.slice(1)}`;
|
||||||
return `${phone.slice(2)}`;
|
if (phone.startsWith('00')) return `${phone.slice(2)}`;
|
||||||
}
|
|
||||||
if (phone.startsWith(prefix) && phone.length === prefix.length + 9) {
|
let prefix;
|
||||||
return `${prefix}${phone.slice(prefix.length)}`;
|
try {
|
||||||
|
prefix = (await axios.get(`Prefixes/${country.toLowerCase()}`)).data?.prefix;
|
||||||
|
} catch (e) {
|
||||||
|
prefix = (await axios.get('PbxConfigs/findOne')).data?.defaultPrefix;
|
||||||
}
|
}
|
||||||
|
prefix = prefix.replace(/^0+/, '');
|
||||||
|
|
||||||
|
if (phone.startsWith(prefix)) return phone;
|
||||||
return `${prefix}${phone}`;
|
return `${prefix}${phone}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -769,7 +769,7 @@ travel:
|
||||||
thermographs: Thermographs
|
thermographs: Thermographs
|
||||||
hb: HB
|
hb: HB
|
||||||
basicData:
|
basicData:
|
||||||
daysInForward: Days in forward
|
daysInForward: Automatic movement (Raid)
|
||||||
isRaid: Raid
|
isRaid: Raid
|
||||||
thermographs:
|
thermographs:
|
||||||
temperature: Temperature
|
temperature: Temperature
|
||||||
|
@ -865,6 +865,7 @@ 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
|
||||||
|
|
|
@ -762,7 +762,7 @@ travel:
|
||||||
thermographs: Termógrafos
|
thermographs: Termógrafos
|
||||||
hb: HB
|
hb: HB
|
||||||
basicData:
|
basicData:
|
||||||
daysInForward: Días redada
|
daysInForward: Desplazamiento automatico (redada)
|
||||||
isRaid: Redada
|
isRaid: Redada
|
||||||
thermographs:
|
thermographs:
|
||||||
temperature: Temperatura
|
temperature: Temperatura
|
||||||
|
|
|
@ -41,8 +41,12 @@ const fetchAccountExistence = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchMailForwards = async () => {
|
const fetchMailForwards = async () => {
|
||||||
const response = await axios.get(`MailForwards/${route.params.id}`);
|
try {
|
||||||
return response.data;
|
const response = await axios.get(`MailForwards/${route.params.id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteMailForward = async () => {
|
const deleteMailForward = async () => {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { onBeforeMount, ref, watch } from 'vue';
|
import { onBeforeMount, ref, watch } 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 FetchData from 'components/FetchData.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
@ -52,7 +53,6 @@ const addressFilter = {
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
const { id } = route.params;
|
const { id } = route.params;
|
||||||
getAddressesData(id);
|
|
||||||
getClientData(id);
|
getClientData(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -60,23 +60,10 @@ watch(
|
||||||
() => route.params.id,
|
() => route.params.id,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
if (!newValue) return;
|
if (!newValue) return;
|
||||||
getAddressesData(newValue);
|
|
||||||
getClientData(newValue);
|
getClientData(newValue);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const getAddressesData = async (id) => {
|
|
||||||
try {
|
|
||||||
const { data } = await axios.get(`Clients/${id}/addresses`, {
|
|
||||||
params: { filter: JSON.stringify(addressFilter) },
|
|
||||||
});
|
|
||||||
addresses.value = data;
|
|
||||||
sortAddresses();
|
|
||||||
} catch (error) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getClientData = async (id) => {
|
const getClientData = async (id) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(`Clients/${id}`);
|
const { data } = await axios.get(`Clients/${id}`);
|
||||||
|
@ -101,9 +88,9 @@ const setDefault = (address) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortAddresses = () => {
|
const sortAddresses = (data) => {
|
||||||
if (!client.value || !addresses.value) return;
|
if (!client.value || !data) return;
|
||||||
addresses.value = addresses.value.sort((a, b) => {
|
addresses.value = data.sort((a, b) => {
|
||||||
return isDefaultAddress(b) - isDefaultAddress(a);
|
return isDefaultAddress(b) - isDefaultAddress(a);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -124,8 +111,17 @@ const toCustomerAddressEdit = (addressId) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="sortAddresses"
|
||||||
|
auto-load
|
||||||
|
data-key="CustomerAddresses"
|
||||||
|
order="id DESC"
|
||||||
|
ref="vnPaginateRef"
|
||||||
|
:filter="addressFilter"
|
||||||
|
:url="`Clients/${route.params.id}/addresses`"
|
||||||
|
/>
|
||||||
<div class="full-width flex justify-center">
|
<div class="full-width flex justify-center">
|
||||||
<QCard class="card-width q-pa-lg" v-if="addresses.length">
|
<QCard class="card-width q-pa-lg">
|
||||||
<QCardSection>
|
<QCardSection>
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in addresses"
|
v-for="(item, index) in addresses"
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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 VnAvatar from 'src/components/ui/VnAvatar.vue';
|
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||||
|
import { getDifferences, getUpdatedValues } from 'src/filters';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -30,6 +31,13 @@ const exprBuilder = (param, value) => {
|
||||||
and: [{ active: { neq: false } }, handleSalesModelValue(value)],
|
and: [{ active: { neq: false } }, handleSalesModelValue(value)],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onBeforeSave(formData, originalData) {
|
||||||
|
return getUpdatedValues(
|
||||||
|
Object.keys(getDifferences(formData, originalData)),
|
||||||
|
formData
|
||||||
|
);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -43,7 +51,12 @@ const exprBuilder = (param, value) => {
|
||||||
@on-fetch="(data) => (businessTypes = data)"
|
@on-fetch="(data) => (businessTypes = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FormModel :url="`Clients/${route.params.id}`" auto-load model="customer">
|
<FormModel
|
||||||
|
:url="`Clients/${route.params.id}`"
|
||||||
|
auto-load
|
||||||
|
model="customer"
|
||||||
|
:mapper="onBeforeSave"
|
||||||
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnInput
|
<VnInput
|
||||||
|
@ -94,6 +107,7 @@ const exprBuilder = (param, value) => {
|
||||||
:rules="validate('client.phone')"
|
:rules="validate('client.phone')"
|
||||||
clearable
|
clearable
|
||||||
v-model="data.phone"
|
v-model="data.phone"
|
||||||
|
data-cy="customerPhone"
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('customer.summary.mobile')"
|
:label="t('customer.summary.mobile')"
|
||||||
|
@ -155,7 +169,6 @@ const exprBuilder = (param, value) => {
|
||||||
url="Clients"
|
url="Clients"
|
||||||
:input-debounce="0"
|
:input-debounce="0"
|
||||||
:label="t('customer.basicData.previousClient')"
|
:label="t('customer.basicData.previousClient')"
|
||||||
:options="clients"
|
|
||||||
:rules="validate('client.transferorFk')"
|
:rules="validate('client.transferorFk')"
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
|
|
@ -28,12 +28,7 @@ const getBankEntities = (data, formData) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FormModel
|
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="customer">
|
||||||
:url-update="`Clients/${route.params.id}`"
|
|
||||||
:url="`Clients/${route.params.id}/getCard`"
|
|
||||||
auto-load
|
|
||||||
model="customer"
|
|
||||||
>
|
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
|
|
@ -93,22 +93,6 @@ const columns = computed(() => [
|
||||||
<WorkerDescriptorProxy :id="row.worker.id" />
|
<WorkerDescriptorProxy :id="row.worker.id" />
|
||||||
</template>
|
</template>
|
||||||
</VnTable>
|
</VnTable>
|
||||||
<!-- <QTable
|
|
||||||
:columns="columns"
|
|
||||||
:pagination="{ rowsPerPage: 0 }"
|
|
||||||
:rows="rows"
|
|
||||||
hide-bottom
|
|
||||||
row-key="id"
|
|
||||||
v-model:selected="selected"
|
|
||||||
class="card-width q-px-lg"
|
|
||||||
>
|
|
||||||
<template #body-cell-employee="{ row }">
|
|
||||||
<QTd @click.stop>
|
|
||||||
<span class="link">{{ row.worker.user.nickname }}</span>
|
|
||||||
<WorkerDescriptorProxy :id="row.clientFk" />
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
</QTable> -->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
|
@ -36,7 +36,10 @@ const entityId = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = ref(useCardDescription());
|
const data = ref(useCardDescription());
|
||||||
const setData = (entity) => (data.value = useCardDescription(entity?.name, entity?.id));
|
const setData = (entity) => {
|
||||||
|
data.value = useCardDescription(entity?.name, entity?.id);
|
||||||
|
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
|
||||||
|
};
|
||||||
const debtWarning = computed(() => {
|
const debtWarning = computed(() => {
|
||||||
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary';
|
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary';
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,7 +34,6 @@ function handleLocation(data, location) {
|
||||||
/>
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
||||||
:url="`Clients/${route.params.id}/getCard`"
|
|
||||||
auto-load
|
auto-load
|
||||||
model="customer"
|
model="customer"
|
||||||
>
|
>
|
||||||
|
@ -68,6 +67,7 @@ function handleLocation(data, location) {
|
||||||
option-label="vat"
|
option-label="vat"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="data.sageTaxTypeFk"
|
v-model="data.sageTaxTypeFk"
|
||||||
|
data-cy="sageTaxTypeFk"
|
||||||
:required="data.isTaxDataChecked"
|
:required="data.isTaxDataChecked"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
@ -76,6 +76,7 @@ function handleLocation(data, location) {
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="transaction"
|
option-label="transaction"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
data-cy="sageTransactionTypeFk"
|
||||||
v-model="data.sageTransactionTypeFk"
|
v-model="data.sageTransactionTypeFk"
|
||||||
:required="data.isTaxDataChecked"
|
:required="data.isTaxDataChecked"
|
||||||
>
|
>
|
||||||
|
|
|
@ -95,6 +95,7 @@ const sumRisk = ({ clientRisks }) => {
|
||||||
:phone-number="entity.mobile"
|
:phone-number="entity.mobile"
|
||||||
:channel="entity.country?.saySimpleCountry?.channel"
|
:channel="entity.country?.saySimpleCountry?.channel"
|
||||||
class="q-ml-xs"
|
class="q-ml-xs"
|
||||||
|
:country="entity.country?.code"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnLv>
|
</VnLv>
|
||||||
|
|
|
@ -1,164 +1,82 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onBeforeMount, ref, watch, nextTick } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import FormModel from 'components/FormModel.vue';
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import axios from 'axios';
|
const formModelRef = ref(false);
|
||||||
import useNotify from 'src/composables/useNotify';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { notify } = useNotify();
|
|
||||||
const stateStore = useStateStore();
|
|
||||||
|
|
||||||
const amountInputRef = ref(null);
|
const amountInputRef = ref(null);
|
||||||
const initialDated = Date.vnNew();
|
|
||||||
const unpaidClient = ref(false);
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const amount = ref(null);
|
|
||||||
const dated = ref(initialDated);
|
|
||||||
|
|
||||||
const initialData = ref({
|
const initialData = ref({
|
||||||
dated: initialDated,
|
dated: Date.vnNew(),
|
||||||
|
amount: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasChanged = computed(() => {
|
const filterClientFindOne = {
|
||||||
return (
|
fields: ['unpaid', 'dated', 'amount'],
|
||||||
initialData.value.dated !== dated.value ||
|
where: {
|
||||||
initialData.value.amount !== amount.value
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
getData(route.params.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.params.id,
|
|
||||||
(newValue) => {
|
|
||||||
if (!newValue) return;
|
|
||||||
getData(newValue);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const getData = async (id) => {
|
|
||||||
const filter = { where: { clientFk: id } };
|
|
||||||
try {
|
|
||||||
const { data } = await axios.get('ClientUnpaids', {
|
|
||||||
params: { filter: JSON.stringify(filter) },
|
|
||||||
});
|
|
||||||
if (data.length) {
|
|
||||||
setValues(data[0]);
|
|
||||||
} else {
|
|
||||||
defaultValues();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
defaultValues();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const setValues = (data) => {
|
|
||||||
unpaidClient.value = true;
|
|
||||||
amount.value = data.amount;
|
|
||||||
dated.value = data.dated;
|
|
||||||
initialData.value = data;
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultValues = () => {
|
|
||||||
unpaidClient.value = false;
|
|
||||||
initialData.value.amount = null;
|
|
||||||
setInitialData();
|
|
||||||
};
|
|
||||||
|
|
||||||
const setInitialData = () => {
|
|
||||||
amount.value = initialData.value.amount;
|
|
||||||
dated.value = initialData.value.dated;
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSubmit = async () => {
|
|
||||||
isLoading.value = true;
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
amount: amount.value,
|
|
||||||
clientFk: route.params.id,
|
clientFk: route.params.id,
|
||||||
dated: dated.value,
|
},
|
||||||
};
|
|
||||||
try {
|
|
||||||
await axios.patch('ClientUnpaids', payload);
|
|
||||||
notify('globals.dataSaved', 'positive');
|
|
||||||
unpaidClient.value = true;
|
|
||||||
} catch (error) {
|
|
||||||
notify('errors.writeRequest', 'negative');
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
|
||||||
() => unpaidClient.value,
|
|
||||||
async (val) => {
|
|
||||||
await nextTick();
|
|
||||||
if (val) amountInputRef.value.focus();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Teleport v-if="stateStore?.isSubToolbarShown()" to="#st-actions">
|
<FetchData
|
||||||
<QBtnGroup push class="q-gutter-x-sm">
|
:filter="filterClientFindOne"
|
||||||
<QBtn
|
auto-load
|
||||||
:disabled="!hasChanged"
|
url="ClientUnpaids"
|
||||||
:label="t('globals.reset')"
|
@on-fetch="
|
||||||
:loading="isLoading"
|
(data) => {
|
||||||
@click="setInitialData"
|
const unpaid = data.length == 1;
|
||||||
color="primary"
|
initialData = { ...data[0], unpaid };
|
||||||
flat
|
}
|
||||||
icon="restart_alt"
|
"
|
||||||
type="reset"
|
/>
|
||||||
/>
|
<QCard>
|
||||||
<QBtn
|
<FormModel
|
||||||
:disabled="!hasChanged"
|
v-if="'unpaid' in initialData"
|
||||||
:label="t('globals.save')"
|
:observe-form-changes="false"
|
||||||
:loading="isLoading"
|
ref="formModelRef"
|
||||||
@click="onSubmit"
|
model="unpaid"
|
||||||
color="primary"
|
url-update="ClientUnpaids"
|
||||||
icon="save"
|
:mapper="(formData) => ({ ...formData, clientFk: route.params.id })"
|
||||||
/>
|
:form-initial-data="initialData"
|
||||||
</QBtnGroup>
|
>
|
||||||
</Teleport>
|
<template #form="{ data }">
|
||||||
|
|
||||||
<div class="full-width flex justify-center">
|
|
||||||
<QCard class="card-width q-pa-lg">
|
|
||||||
<QForm>
|
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<div class="col">
|
<QCheckbox :label="t('Unpaid client')" v-model="data.unpaid" />
|
||||||
<QCheckbox :label="t('Unpaid client')" v-model="unpaidClient" />
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
||||||
<VnRow class="row q-gutter-md q-mb-md" v-show="unpaidClient">
|
<VnRow class="row q-gutter-md q-mb-md" v-show="data.unpaid">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<VnInputDate :label="t('Date')" v-model="dated" />
|
<VnInputDate
|
||||||
|
data-cy="customerUnpaidDate"
|
||||||
|
:label="t('Date')"
|
||||||
|
v-model="data.dated"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<VnInput
|
<VnInputNumber
|
||||||
|
data-cy="customerUnpaidAmount"
|
||||||
ref="amountInputRef"
|
ref="amountInputRef"
|
||||||
:label="t('Amount')"
|
:label="t('Amount')"
|
||||||
clearable
|
clearable
|
||||||
type="number"
|
v-model="data.amount"
|
||||||
v-model="amount"
|
|
||||||
autofocus
|
autofocus
|
||||||
>
|
>
|
||||||
<template #append>€</template></VnInput
|
<template #append>€</template></VnInputNumber
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</QForm>
|
</template>
|
||||||
</QCard>
|
</FormModel>
|
||||||
</div>
|
</QCard>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
|
@ -25,10 +25,9 @@ async function hasCustomerRole() {
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FormModel
|
<FormModel
|
||||||
url="VnUsers/preview"
|
|
||||||
:url-update="`Clients/${route.params.id}/updateUser`"
|
:url-update="`Clients/${route.params.id}/updateUser`"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
model="webAccess"
|
model="customer"
|
||||||
:mapper="
|
:mapper="
|
||||||
({ active, name, email }) => {
|
({ active, name, email }) => {
|
||||||
return {
|
return {
|
||||||
|
@ -42,14 +41,14 @@ async function hasCustomerRole() {
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<QCheckbox :label="t('Enable web access')" v-model="data.active" />
|
<QCheckbox :label="t('Enable web access')" v-model="data.account.active" />
|
||||||
<VnInput :label="t('User')" clearable v-model="data.name" />
|
<VnInput :label="t('User')" clearable v-model="data.account.name" />
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('Recovery email')"
|
:label="t('Recovery email')"
|
||||||
:rules="validate('client.email')"
|
:rules="validate('client.email')"
|
||||||
clearable
|
clearable
|
||||||
type="email"
|
type="email"
|
||||||
v-model="data.email"
|
v-model="data.account.email"
|
||||||
class="q-mt-sm"
|
class="q-mt-sm"
|
||||||
:info="t('This email is used for user to regain access their account')"
|
:info="t('This email is used for user to regain access their account')"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onBeforeMount, ref, watch } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import axios from 'axios';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
|
|
||||||
import { toCurrency, toDateHourMin } from 'src/filters';
|
import { toCurrency, toDateHourMin } from 'src/filters';
|
||||||
|
|
||||||
|
@ -20,10 +20,11 @@ const filter = {
|
||||||
{ relation: 'mandateType', scope: { fields: ['id', 'name'] } },
|
{ relation: 'mandateType', scope: { fields: ['id', 'name'] } },
|
||||||
{ relation: 'company', scope: { fields: ['id', 'code'] } },
|
{ relation: 'company', scope: { fields: ['id', 'code'] } },
|
||||||
],
|
],
|
||||||
where: { clientFk: null },
|
where: { clientFk: route.params.id },
|
||||||
order: ['created DESC'],
|
order: ['created DESC'],
|
||||||
limit: 20,
|
limit: 20,
|
||||||
};
|
};
|
||||||
|
const ClientDmsRef = ref(false);
|
||||||
|
|
||||||
const tableColumnComponents = {
|
const tableColumnComponents = {
|
||||||
state: {
|
state: {
|
||||||
|
@ -50,7 +51,7 @@ const tableColumnComponents = {
|
||||||
component: CustomerCheckIconTooltip,
|
component: CustomerCheckIconTooltip,
|
||||||
props: ({ row }) => ({
|
props: ({ row }) => ({
|
||||||
transaction: row,
|
transaction: row,
|
||||||
promise: refreshData,
|
promise: () => ClientDmsRef.value.fetch(),
|
||||||
}),
|
}),
|
||||||
event: () => {},
|
event: () => {},
|
||||||
},
|
},
|
||||||
|
@ -89,72 +90,45 @@ const columns = computed(() => [
|
||||||
name: 'validate',
|
name: 'validate',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
getData(route.params.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.params.id,
|
|
||||||
(newValue) => {
|
|
||||||
if (!newValue) return;
|
|
||||||
getData(newValue);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const getData = async (id) => {
|
|
||||||
filter.where.clientFk = id;
|
|
||||||
try {
|
|
||||||
const { data } = await axios.get('clients/transactions', {
|
|
||||||
params: { filter: JSON.stringify(filter) },
|
|
||||||
});
|
|
||||||
rows.value = data;
|
|
||||||
} catch (error) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const refreshData = () => {
|
|
||||||
getData(route.params.id);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="full-width flex justify-center">
|
<FetchData
|
||||||
<QPage class="card-width q-pa-lg">
|
ref="ClientDmsRef"
|
||||||
<QTable
|
:filter="filter"
|
||||||
:columns="columns"
|
@on-fetch="(data) => (rows = data)"
|
||||||
:pagination="{ rowsPerPage: 12 }"
|
auto-load
|
||||||
:rows="rows"
|
url="Clients/transactions"
|
||||||
class="full-width q-mt-md"
|
/>
|
||||||
row-key="id"
|
<QPage class="card-width q-pa-lg">
|
||||||
v-if="rows?.length"
|
<QTable
|
||||||
>
|
:columns="columns"
|
||||||
<template #body-cell="props">
|
:pagination="{ rowsPerPage: 12 }"
|
||||||
<QTd :props="props">
|
:rows="rows"
|
||||||
<QTr :props="props">
|
class="full-width q-mt-md"
|
||||||
<component
|
row-key="id"
|
||||||
:is="tableColumnComponents[props.col.name].component"
|
v-if="rows?.length"
|
||||||
@click="
|
>
|
||||||
tableColumnComponents[props.col.name].event(props)
|
<template #body-cell="props">
|
||||||
"
|
<QTd :props="props">
|
||||||
class="rounded-borders q-pa-sm"
|
<QTr :props="props">
|
||||||
v-bind="
|
<component
|
||||||
tableColumnComponents[props.col.name].props(props)
|
:is="tableColumnComponents[props.col.name].component"
|
||||||
"
|
@click="tableColumnComponents[props.col.name].event(props)"
|
||||||
>
|
class="rounded-borders q-pa-sm"
|
||||||
{{ props.value }}
|
v-bind="tableColumnComponents[props.col.name].props(props)"
|
||||||
</component>
|
>
|
||||||
</QTr>
|
{{ props.value }}
|
||||||
</QTd>
|
</component>
|
||||||
</template>
|
</QTr>
|
||||||
</QTable>
|
</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>
|
</QPage>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
|
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
|
||||||
import { toDate } from 'src/filters';
|
import { toDate } from 'src/filters';
|
||||||
import CustomerFilter from './CustomerFilter.vue';
|
import CustomerFilter from './CustomerFilter.vue';
|
||||||
|
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, reactive, ref } from 'vue';
|
import { reactive, 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 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 FormModel from 'components/FormModel.vue';
|
||||||
|
@ -19,26 +18,10 @@ const router = useRouter();
|
||||||
|
|
||||||
const formInitialData = reactive({ isDefaultAddress: false });
|
const formInitialData = reactive({ isDefaultAddress: false });
|
||||||
|
|
||||||
const urlCreate = ref('');
|
|
||||||
|
|
||||||
const agencyModes = ref([]);
|
const agencyModes = ref([]);
|
||||||
const incoterms = ref([]);
|
const incoterms = ref([]);
|
||||||
const customsAgents = ref([]);
|
const customsAgents = ref([]);
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
urlCreate.value = `Clients/${route.params.id}/createAddress`;
|
|
||||||
getCustomsAgents();
|
|
||||||
});
|
|
||||||
|
|
||||||
const getCustomsAgents = async () => {
|
|
||||||
const { data } = await axios.get('CustomsAgents');
|
|
||||||
customsAgents.value = data;
|
|
||||||
};
|
|
||||||
|
|
||||||
const refreshData = () => {
|
|
||||||
getCustomsAgents();
|
|
||||||
};
|
|
||||||
|
|
||||||
const toCustomerAddress = () => {
|
const toCustomerAddress = () => {
|
||||||
router.push({
|
router.push({
|
||||||
name: 'CustomerAddress',
|
name: 'CustomerAddress',
|
||||||
|
@ -54,9 +37,19 @@ 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
|
||||||
|
@ -67,7 +60,7 @@ function handleLocation(data, location) {
|
||||||
<FormModel
|
<FormModel
|
||||||
:form-initial-data="formInitialData"
|
:form-initial-data="formInitialData"
|
||||||
:observe-form-changes="false"
|
:observe-form-changes="false"
|
||||||
:url-create="urlCreate"
|
:url-create="`Clients/${route.params.id}/createAddress`"
|
||||||
@on-data-saved="toCustomerAddress()"
|
@on-data-saved="toCustomerAddress()"
|
||||||
model="client"
|
model="client"
|
||||||
>
|
>
|
||||||
|
@ -139,6 +132,7 @@ function handleLocation(data, location) {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
|
url="CustomsAgents"
|
||||||
:label="t('Customs agent')"
|
:label="t('Customs agent')"
|
||||||
:options="customsAgents"
|
:options="customsAgents"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
@ -148,7 +142,11 @@ function handleLocation(data, location) {
|
||||||
:tooltip="t('Create a new expense')"
|
:tooltip="t('Create a new expense')"
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CustomerNewCustomsAgent @on-data-saved="refreshData()" />
|
<CustomerNewCustomsAgent
|
||||||
|
@on-data-saved="
|
||||||
|
(requestResponse) => onAgentCreated(requestResponse, data)
|
||||||
|
"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnSelectDialog>
|
</VnSelectDialog>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -144,7 +144,7 @@ function handleLocation(data, location) {
|
||||||
:url="`Addresses/${route.params.addressId}`"
|
:url="`Addresses/${route.params.addressId}`"
|
||||||
@on-data-saved="onDataSaved()"
|
@on-data-saved="onDataSaved()"
|
||||||
auto-load
|
auto-load
|
||||||
model="client"
|
model="customer"
|
||||||
>
|
>
|
||||||
<template #moreActions>
|
<template #moreActions>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
|
|
@ -82,11 +82,11 @@ const entriesTableColumns = computed(() => [
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardActions align="right">
|
<QCardActions align="right">
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('printLabels')"
|
:label="t('myEntries.printLabels')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="print"
|
icon="print"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
@click="openReport(`Entries/${entityId}/buy-label-supplier`)"
|
@click="openReport(`Entries/${entityId}/labelSupplier`)"
|
||||||
unelevated
|
unelevated
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
|
@ -126,7 +126,9 @@ const entriesTableColumns = computed(() => [
|
||||||
"
|
"
|
||||||
unelevated
|
unelevated
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('viewLabel') }}</QTooltip>
|
<QTooltip>{{
|
||||||
|
t('myEntries.viewLabel')
|
||||||
|
}}</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</QTr>
|
</QTr>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -101,7 +101,7 @@ const columns = computed(() => [
|
||||||
name: 'tableActions',
|
name: 'tableActions',
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
title: t('printLabels'),
|
title: t('myEntries.printLabels'),
|
||||||
icon: 'print',
|
icon: 'print',
|
||||||
isPrimary: true,
|
isPrimary: true,
|
||||||
action: (row) => printBuys(row.id),
|
action: (row) => printBuys(row.id),
|
||||||
|
|
|
@ -11,7 +11,7 @@ invoiceOutList:
|
||||||
ref: Referencia
|
ref: Referencia
|
||||||
issued: Fecha emisión
|
issued: Fecha emisión
|
||||||
created: F. creación
|
created: F. creación
|
||||||
dueDate: F. máxima
|
dueDate: Fecha vencimiento
|
||||||
invoiceOutSerial: Serial
|
invoiceOutSerial: Serial
|
||||||
ticket: Ticket
|
ticket: Ticket
|
||||||
taxArea: Area
|
taxArea: Area
|
||||||
|
|
|
@ -66,6 +66,7 @@ const insertTag = (rows) => {
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Tags"
|
url="Tags"
|
||||||
:filter="{ fields: ['id', 'name', 'isFree', 'sourceTable'] }"
|
:filter="{ fields: ['id', 'name', 'isFree', 'sourceTable'] }"
|
||||||
|
sort-by="name"
|
||||||
@on-fetch="(data) => (tagOptions = data)"
|
@on-fetch="(data) => (tagOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
@ -137,6 +138,7 @@ const insertTag = (rows) => {
|
||||||
:required="false"
|
:required="false"
|
||||||
:rules="validate('itemTag.tagFk')"
|
:rules="validate('itemTag.tagFk')"
|
||||||
:use-like="false"
|
:use-like="false"
|
||||||
|
sort-by="value"
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
v-else-if="
|
v-else-if="
|
||||||
|
|
|
@ -24,13 +24,14 @@ const supplier = ref(null);
|
||||||
const supplierAccountRef = ref(null);
|
const supplierAccountRef = ref(null);
|
||||||
const wireTransferFk = ref(null);
|
const wireTransferFk = ref(null);
|
||||||
const bankEntitiesOptions = ref([]);
|
const bankEntitiesOptions = ref([]);
|
||||||
|
const filteredBankEntitiesOptions = ref([]);
|
||||||
|
|
||||||
const onBankEntityCreated = async (dataSaved, rowData) => {
|
const onBankEntityCreated = async (dataSaved, rowData) => {
|
||||||
await bankEntitiesRef.value.fetch();
|
await bankEntitiesRef.value.fetch();
|
||||||
rowData.bankEntityFk = dataSaved.id;
|
rowData.bankEntityFk = dataSaved.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChangesSaved = () => {
|
const onChangesSaved = async () => {
|
||||||
if (supplier.value.payMethodFk !== wireTransferFk.value)
|
if (supplier.value.payMethodFk !== wireTransferFk.value)
|
||||||
quasar
|
quasar
|
||||||
.dialog({
|
.dialog({
|
||||||
|
@ -55,12 +56,35 @@ const setWireTransfer = async () => {
|
||||||
await axios.patch(`Suppliers/${route.params.id}`, params);
|
await axios.patch(`Suppliers/${route.params.id}`, params);
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function findBankFk(value, row) {
|
||||||
|
row.bankEntityFk = null;
|
||||||
|
if (!value) return;
|
||||||
|
|
||||||
|
const bankEntityFk = bankEntitiesOptions.value.find((b) => b.id == value.slice(4, 8));
|
||||||
|
if (bankEntityFk) row.bankEntityFk = bankEntityFk.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bankEntityFilter(val, update) {
|
||||||
|
update(() => {
|
||||||
|
const needle = val.toLowerCase();
|
||||||
|
filteredBankEntitiesOptions.value = bankEntitiesOptions.value.filter(
|
||||||
|
(bank) =>
|
||||||
|
bank.bic.toLowerCase().startsWith(needle) ||
|
||||||
|
bank.name.toLowerCase().includes(needle)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
ref="bankEntitiesRef"
|
ref="bankEntitiesRef"
|
||||||
url="BankEntities"
|
url="BankEntities"
|
||||||
@on-fetch="(data) => (bankEntitiesOptions = data)"
|
@on-fetch="
|
||||||
|
(data) => {
|
||||||
|
(bankEntitiesOptions = data), (filteredBankEntitiesOptions = data);
|
||||||
|
}
|
||||||
|
"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -98,6 +122,7 @@ const setWireTransfer = async () => {
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('supplier.accounts.iban')"
|
:label="t('supplier.accounts.iban')"
|
||||||
v-model="row.iban"
|
v-model="row.iban"
|
||||||
|
@update:model-value="(value) => findBankFk(value, row)"
|
||||||
:required="true"
|
:required="true"
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
|
@ -109,7 +134,9 @@ const setWireTransfer = async () => {
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
:label="t('worker.create.bankEntity')"
|
:label="t('worker.create.bankEntity')"
|
||||||
v-model="row.bankEntityFk"
|
v-model="row.bankEntityFk"
|
||||||
:options="bankEntitiesOptions"
|
:options="filteredBankEntitiesOptions"
|
||||||
|
:default-filter="false"
|
||||||
|
@filter="(val, update) => bankEntityFilter(val, update)"
|
||||||
option-label="bic"
|
option-label="bic"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
|
|
@ -124,8 +124,7 @@ const columns = computed(() => [
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
en:
|
es:
|
||||||
Search suppliers: Search suppliers
|
|
||||||
es:
|
|
||||||
Search suppliers: Buscar proveedores
|
Search suppliers: Buscar proveedores
|
||||||
|
Create Supplier: Crear proveedor
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -321,10 +321,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<span v-for="(saleComponent, index) in row.components" :key="index">
|
<span v-for="(saleComponent, index) in row.components" :key="index">
|
||||||
{{ toCurrency(saleComponent.value * row.quantity, 'EUR', 3) }}
|
{{ toCurrency(saleComponent.value * row.quantity, 'EUR', 3) }}
|
||||||
<!-- <QTooltip>
|
|
||||||
{{ saleComponent.component?.name }}:
|
|
||||||
{{ toCurrency(saleComponent.value, 'EUR', 3) }}
|
|
||||||
</QTooltip> -->
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -676,7 +676,7 @@ async function uploadDocuware(force) {
|
||||||
<VnConfirm
|
<VnConfirm
|
||||||
ref="weightDialog"
|
ref="weightDialog"
|
||||||
:title="t('Set weight')"
|
:title="t('Set weight')"
|
||||||
:message="t('This ticket may be invoiced, do you want to continue?')"
|
:message="false"
|
||||||
:promise="actions.setWeight"
|
:promise="actions.setWeight"
|
||||||
>
|
>
|
||||||
<template #customHTML>
|
<template #customHTML>
|
||||||
|
@ -741,7 +741,6 @@ es:
|
||||||
Ticket invoiced: Ticket facturado
|
Ticket invoiced: Ticket facturado
|
||||||
Set weight: Establecer peso
|
Set weight: Establecer peso
|
||||||
Weight set: Peso establecido
|
Weight set: Peso establecido
|
||||||
This ticket may be invoiced, do you want to continue?: Es posible que se facture este ticket, desea continuar?
|
|
||||||
invoiceIds: "Se han generado las facturas con los siguientes ids: {invoiceIds}"
|
invoiceIds: "Se han generado las facturas con los siguientes ids: {invoiceIds}"
|
||||||
This ticket will be removed from current route! Continue anyway?: ¡Se eliminará el ticket de la ruta actual! ¿Continuar de todas formas?
|
This ticket will be removed from current route! Continue anyway?: ¡Se eliminará el ticket de la ruta actual! ¿Continuar de todas formas?
|
||||||
You are going to delete this ticket: Vas a eliminar este ticket
|
You are going to delete this ticket: Vas a eliminar este ticket
|
||||||
|
|
|
@ -181,17 +181,34 @@ const resetChanges = async () => {
|
||||||
arrayData.fetch({ append: false });
|
arrayData.fetch({ append: false });
|
||||||
tableRef.value.reload();
|
tableRef.value.reload();
|
||||||
};
|
};
|
||||||
|
const rowToUpdate = ref(null);
|
||||||
|
const changeQuantity = async (sale) => {
|
||||||
|
canProceed.value = await isSalePrepared(sale);
|
||||||
|
if (!canProceed.value) return;
|
||||||
|
if (
|
||||||
|
!sale.itemFk ||
|
||||||
|
sale.quantity == null ||
|
||||||
|
edit.value?.oldQuantity === sale.quantity
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
if (!sale.id) return addSale(sale);
|
||||||
|
|
||||||
const updateQuantity = async (sale) => {
|
|
||||||
const params = { quantity: sale.quantity };
|
|
||||||
try {
|
try {
|
||||||
await axios.post(`Sales/${sale.id}/updateQuantity`, params);
|
if (!rowToUpdate.value) return;
|
||||||
|
rowToUpdate.value = null;
|
||||||
|
await updateQuantity(sale);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sale.quantity = tableRef.value.CrudModelRef.originalData.find(
|
const { quantity } = tableRef.value.CrudModelRef.originalData.find(
|
||||||
(s) => s.id === sale.id
|
(s) => s.id === sale.id
|
||||||
).quantity;
|
);
|
||||||
|
sale.quantity = quantity;
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateQuantity = async ({ quantity, id }) => {
|
||||||
|
const params = { quantity: quantity };
|
||||||
|
await axios.post(`Sales/${id}/updateQuantity`, params);
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -219,19 +236,6 @@ const addSale = async (sale) => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeQuantity = async (sale) => {
|
|
||||||
canProceed.value = await isSalePrepared(sale);
|
|
||||||
if (!canProceed.value) return;
|
|
||||||
if (
|
|
||||||
!sale.itemFk ||
|
|
||||||
sale.quantity == null ||
|
|
||||||
edit.value?.oldQuantity === sale.quantity
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
if (!sale.id) return addSale(sale);
|
|
||||||
await updateQuantity(sale);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateConcept = async (sale) => {
|
const updateConcept = async (sale) => {
|
||||||
canProceed.value = await isSalePrepared(sale);
|
canProceed.value = await isSalePrepared(sale);
|
||||||
if (!canProceed.value) return;
|
if (!canProceed.value) return;
|
||||||
|
@ -778,16 +782,12 @@ watch(
|
||||||
</template>
|
</template>
|
||||||
<template #column-quantity="{ row }">
|
<template #column-quantity="{ row }">
|
||||||
<VnInput
|
<VnInput
|
||||||
v-if="row.isNew"
|
v-if="row.isNew || isTicketEditable"
|
||||||
v-model.number="row.quantity"
|
|
||||||
type="number"
|
type="number"
|
||||||
@blur="changeQuantity(row)"
|
|
||||||
@focus="edit.oldQuantity = row.quantity"
|
|
||||||
/>
|
|
||||||
<VnInput
|
|
||||||
v-else-if="isTicketEditable"
|
|
||||||
v-model.number="row.quantity"
|
v-model.number="row.quantity"
|
||||||
@blur="changeQuantity(row)"
|
@blur="changeQuantity(row)"
|
||||||
|
@keyup.enter="changeQuantity(row)"
|
||||||
|
@update:model-value="() => (rowToUpdate = row)"
|
||||||
@focus="edit.oldQuantity = row.quantity"
|
@focus="edit.oldQuantity = row.quantity"
|
||||||
/>
|
/>
|
||||||
<span v-else>{{ row.quantity }}</span>
|
<span v-else>{{ row.quantity }}</span>
|
||||||
|
|
|
@ -471,7 +471,7 @@ const qCheckBoxController = (sale, action) => {
|
||||||
url="Shelvings"
|
url="Shelvings"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="code"
|
option-label="code"
|
||||||
option-value="code"
|
option-value="id"
|
||||||
v-model="row.shelvingFk"
|
v-model="row.shelvingFk"
|
||||||
@update:model-value="updateShelving(row)"
|
@update:model-value="updateShelving(row)"
|
||||||
style="max-width: 120px"
|
style="max-width: 120px"
|
||||||
|
|
|
@ -258,7 +258,7 @@ function toTicketUrl(section) {
|
||||||
<QCard class="vn-one" v-if="entity.notes.length">
|
<QCard class="vn-one" v-if="entity.notes.length">
|
||||||
<VnTitle
|
<VnTitle
|
||||||
:url="toTicketUrl('observation')"
|
:url="toTicketUrl('observation')"
|
||||||
:text="t('ticket.pageTitles.notes')"
|
:text="t('globals.pageTitles.notes')"
|
||||||
/>
|
/>
|
||||||
<QVirtualScroll
|
<QVirtualScroll
|
||||||
:items="entity.notes"
|
:items="entity.notes"
|
||||||
|
|
|
@ -104,7 +104,7 @@ const warehousesOptionsIn = ref([]);
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
raidDays: Si se marca "Redada", la fecha de entrega se moverá automáticamente los días indicados.
|
raidDays: El travel se desplaza automáticamente cada día para estar desde hoy al número de días indicado. Si se deja vacio no se moverá
|
||||||
en:
|
en:
|
||||||
raidDays: If "Raid" is checked, the landing date will automatically shift by the specified number of days.
|
raidDays: The travel adjusts itself daily to match the number of days set, starting from today. If left blank, it won’t move
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -7,13 +7,13 @@ import filter from './TravelFilter.js';
|
||||||
<VnCard
|
<VnCard
|
||||||
data-key="Travel"
|
data-key="Travel"
|
||||||
base-url="Travels"
|
base-url="Travels"
|
||||||
search-data-key="TravelList"
|
|
||||||
:filter="filter"
|
|
||||||
:descriptor="TravelDescriptor"
|
:descriptor="TravelDescriptor"
|
||||||
|
:filter="filter"
|
||||||
|
search-data-key="TravelList"
|
||||||
:searchbar-props="{
|
:searchbar-props="{
|
||||||
url: 'Travels',
|
url: 'Travels/filter',
|
||||||
|
searchUrl: 'table',
|
||||||
label: 'Search travel',
|
label: 'Search travel',
|
||||||
info: 'You can search by travel id or name',
|
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -208,6 +208,7 @@ const columns = computed(() => [
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
data-key="TravelList"
|
data-key="TravelList"
|
||||||
url="Travels/filter"
|
url="Travels/filter"
|
||||||
|
redirect="travel"
|
||||||
:create="{
|
:create="{
|
||||||
urlCreate: 'Travels',
|
urlCreate: 'Travels',
|
||||||
title: t('Create Travels'),
|
title: t('Create Travels'),
|
||||||
|
@ -221,9 +222,7 @@ const columns = computed(() => [
|
||||||
order="landed DESC"
|
order="landed DESC"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
auto-load
|
auto-load
|
||||||
redirect="travel"
|
|
||||||
:is-editable="false"
|
:is-editable="false"
|
||||||
:use-model="true"
|
|
||||||
>
|
>
|
||||||
<template #column-status="{ row }">
|
<template #column-status="{ row }">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted } from 'vue';
|
import { ref, computed, onMounted, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ const { t } = useI18n();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
|
|
||||||
const isNew = computed(() => props.isNewMode);
|
const isNew = computed(() => props.isNewMode);
|
||||||
const dated = ref(props.date);
|
const dated = reactive(props.date);
|
||||||
const tickedNodes = ref();
|
const tickedNodes = ref();
|
||||||
|
|
||||||
const _excludeType = ref('all');
|
const _excludeType = ref('all');
|
||||||
|
@ -67,12 +67,12 @@ const exclusionGeoCreate = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const exclusionCreate = async () => {
|
const exclusionCreate = async () => {
|
||||||
if (isNew.value)
|
const url = `Zones/${route.params.id}/exclusions`;
|
||||||
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated.value }]);
|
const body = {
|
||||||
else
|
dated,
|
||||||
await axios.post(`Zones/${route.params.id}/exclusions`, {
|
};
|
||||||
dated: dated.value,
|
if (isNew.value || props.event?.type) await axios.post(`${url}`, [body]);
|
||||||
});
|
else await axios.put(`${url}/${props.event?.id}`, body);
|
||||||
await refetchEvents();
|
await refetchEvents();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@ const onSubmit = async () => {
|
||||||
|
|
||||||
const deleteEvent = async () => {
|
const deleteEvent = async () => {
|
||||||
if (!props.event) return;
|
if (!props.event) return;
|
||||||
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
const exclusionId = props.event?.zoneExclusionFk || props.event?.id;
|
||||||
|
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`);
|
||||||
await refetchEvents();
|
await refetchEvents();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -118,11 +119,7 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
<template #form-inputs>
|
<template #form-inputs>
|
||||||
<VnRow class="row q-gutter-md q-mb-lg">
|
<VnRow class="row q-gutter-md q-mb-lg">
|
||||||
<VnInputDate
|
<VnInputDate :label="t('eventsInclusionForm.day')" v-model="dated" />
|
||||||
:label="t('eventsInclusionForm.day')"
|
|
||||||
v-model="dated"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<div class="column q-gutter-y-sm q-mb-md">
|
<div class="column q-gutter-y-sm q-mb-md">
|
||||||
<QRadio
|
<QRadio
|
||||||
|
@ -172,8 +169,8 @@ onMounted(() => {
|
||||||
class="q-mr-sm"
|
class="q-mr-sm"
|
||||||
@click="
|
@click="
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('zone.deleteTitle'),
|
t('eventsPanel.deleteTitle'),
|
||||||
t('zone.deleteSubtitle'),
|
t('eventsPanel.deleteSubtitle'),
|
||||||
() => deleteEvent()
|
() => deleteEvent()
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|
|
@ -24,13 +24,14 @@ const zoneEventsFormProps = reactive({
|
||||||
date: null,
|
date: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const openForm = (data) => {
|
const openForm = (data, isBtnAdd) => {
|
||||||
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
|
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
|
||||||
zoneEventsFormProps.date = date;
|
zoneEventsFormProps.date = date;
|
||||||
zoneEventsFormProps.isNewMode = isNewMode;
|
zoneEventsFormProps.isNewMode = isNewMode;
|
||||||
zoneEventsFormProps.event = event;
|
zoneEventsFormProps.event = event;
|
||||||
zoneEventsFormProps.eventType = eventType;
|
zoneEventsFormProps.eventType = eventType;
|
||||||
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
|
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
|
||||||
|
if (isBtnAdd) formModeName.value = 'include';
|
||||||
|
|
||||||
showZoneEventForm.value = true;
|
showZoneEventForm.value = true;
|
||||||
};
|
};
|
||||||
|
@ -51,7 +52,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
:last-day="lastDay"
|
:last-day="lastDay"
|
||||||
:events="events"
|
:events="events"
|
||||||
v-model:formModeName="formModeName"
|
v-model:formModeName="formModeName"
|
||||||
@open-zone-form="openForm"
|
|
||||||
/>
|
/>
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
|
@ -65,7 +65,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
/>
|
/>
|
||||||
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
|
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
|
||||||
<ZoneEventInclusionForm
|
<ZoneEventInclusionForm
|
||||||
v-if="formModeName === 'include'"
|
v-if="!formModeName || formModeName === 'include'"
|
||||||
v-bind="zoneEventsFormProps"
|
v-bind="zoneEventsFormProps"
|
||||||
@close-form="onZoneEventFormClose()"
|
@close-form="onZoneEventFormClose()"
|
||||||
/>
|
/>
|
||||||
|
@ -78,9 +78,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
<QPageSticky :offset="[20, 20]">
|
<QPageSticky :offset="[20, 20]">
|
||||||
<QBtn
|
<QBtn
|
||||||
@click="
|
@click="
|
||||||
openForm({
|
openForm(
|
||||||
isNewMode: true,
|
{
|
||||||
})
|
isNewMode: true,
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
"
|
"
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
|
|
|
@ -11,6 +11,10 @@ import { dashIfEmpty } from 'src/filters';
|
||||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
|
|
||||||
|
const formModeName = defineModel('formModeName', {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
firstDay: {
|
firstDay: {
|
||||||
type: Date,
|
type: Date,
|
||||||
|
@ -27,25 +31,13 @@ const props = defineProps({
|
||||||
required: true,
|
required: true,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
formModeName: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
default: 'include',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const weekdayStore = useWeekdayStore();
|
const weekdayStore = useWeekdayStore();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
|
|
||||||
const formName = computed({
|
|
||||||
get: () => props.formModeName,
|
|
||||||
set: (value) => emit('update:formModeName', value),
|
|
||||||
});
|
|
||||||
|
|
||||||
const params = computed(() => ({
|
const params = computed(() => ({
|
||||||
zoneFk: route.params.id,
|
zoneFk: route.params.id,
|
||||||
started: props.firstDay,
|
started: props.firstDay,
|
||||||
|
@ -88,16 +80,6 @@ const deleteEvent = async (id) => {
|
||||||
await fetchData();
|
await fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openInclusionForm = (event) => {
|
|
||||||
formName.value = 'include';
|
|
||||||
emit('openZoneForm', {
|
|
||||||
date: event.dated,
|
|
||||||
event,
|
|
||||||
isNewMode: false,
|
|
||||||
eventType: 'event',
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
weekdayStore.initStore();
|
weekdayStore.initStore();
|
||||||
});
|
});
|
||||||
|
@ -110,13 +92,13 @@ onMounted(async () => {
|
||||||
t('eventsPanel.editMode')
|
t('eventsPanel.editMode')
|
||||||
}}</span>
|
}}</span>
|
||||||
<QRadio
|
<QRadio
|
||||||
v-model="formName"
|
v-model="formModeName"
|
||||||
dense
|
dense
|
||||||
val="include"
|
val="include"
|
||||||
:label="t('eventsPanel.include')"
|
:label="t('eventsPanel.include')"
|
||||||
/>
|
/>
|
||||||
<QRadio
|
<QRadio
|
||||||
v-model="formName"
|
v-model="formModeName"
|
||||||
dense
|
dense
|
||||||
val="exclude"
|
val="exclude"
|
||||||
:label="t('eventsPanel.exclude')"
|
:label="t('eventsPanel.exclude')"
|
||||||
|
|
|
@ -61,6 +61,8 @@ eventsPanel:
|
||||||
events: Events
|
events: Events
|
||||||
everyday: Everyday
|
everyday: Everyday
|
||||||
delete: Delete
|
delete: Delete
|
||||||
|
deleteTitle: This item will be deleted
|
||||||
|
deleteSubtitle: Are you sure you want to continue?
|
||||||
eventsExclusionForm:
|
eventsExclusionForm:
|
||||||
addExclusion: Add exclusion
|
addExclusion: Add exclusion
|
||||||
editExclusion: Edit exclusion
|
editExclusion: Edit exclusion
|
||||||
|
@ -76,6 +78,7 @@ eventsInclusionForm:
|
||||||
rangeOfDates: Range of dates
|
rangeOfDates: Range of dates
|
||||||
from: From
|
from: From
|
||||||
to: To
|
to: To
|
||||||
|
day: Day
|
||||||
upcomingDeliveries:
|
upcomingDeliveries:
|
||||||
province: Province
|
province: Province
|
||||||
closing: Closing
|
closing: Closing
|
||||||
|
|
|
@ -61,6 +61,8 @@ eventsPanel:
|
||||||
events: Eventos
|
events: Eventos
|
||||||
everyday: Todos los días
|
everyday: Todos los días
|
||||||
delete: Eliminar
|
delete: Eliminar
|
||||||
|
deleteTitle: Eliminar evento
|
||||||
|
deleteSubtitle: ¿Seguro que quieres eliminar este evento?
|
||||||
eventsExclusionForm:
|
eventsExclusionForm:
|
||||||
addExclusion: Añadir exclusión
|
addExclusion: Añadir exclusión
|
||||||
editExclusion: Editar exclusión
|
editExclusion: Editar exclusión
|
||||||
|
@ -76,5 +78,6 @@ eventsInclusionForm:
|
||||||
rangeOfDates: Rango de fechas
|
rangeOfDates: Rango de fechas
|
||||||
from: Desde
|
from: Desde
|
||||||
to: Hasta
|
to: Hasta
|
||||||
|
day: Día
|
||||||
upcomingDeliveries:
|
upcomingDeliveries:
|
||||||
province: Provincia
|
province: Provincia
|
||||||
|
|
|
@ -75,9 +75,9 @@ export default {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'TravelHistory',
|
name: 'TravelHistory',
|
||||||
path: 'history',
|
path: 'log',
|
||||||
meta: {
|
meta: {
|
||||||
title: 'history',
|
title: 'log',
|
||||||
icon: 'history',
|
icon: 'history',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Travel/Card/TravelLog.vue'),
|
component: () => import('src/pages/Travel/Card/TravelLog.vue'),
|
||||||
|
|
|
@ -106,7 +106,7 @@ export default {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ZoneHistory',
|
name: 'ZoneHistory',
|
||||||
path: 'history',
|
path: 'log',
|
||||||
meta: {
|
meta: {
|
||||||
title: 'log',
|
title: 'log',
|
||||||
icon: 'history',
|
icon: 'history',
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
function orderData(data, order) {
|
function orderData(data, order) {
|
||||||
if (typeof order === 'function') return data.sort(data);
|
if (typeof order === 'function') return data.sort(data);
|
||||||
if (typeof order === 'string') order = [order];
|
if (typeof order === 'string') order = [order];
|
||||||
|
if (!Array.isArray(data)) return [];
|
||||||
if (Array.isArray(order)) {
|
if (Array.isArray(order)) {
|
||||||
let orderComp = [];
|
let orderComp = [];
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,17 @@ describe('Client basic data', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit('#/customer/1110/basic-data', {
|
cy.visit('#/customer/1102/basic-data');
|
||||||
timeout: 5000,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
it('Should load layout', () => {
|
it('Should load layout', () => {
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-card').should('be.visible');
|
||||||
|
cy.dataCy('customerPhone').filter('input').should('be.visible');
|
||||||
|
cy.dataCy('customerPhone').filter('input').type('123456789');
|
||||||
|
cy.get('.q-btn-group > .q-btn--standard').click();
|
||||||
|
cy.intercept('PATCH', '/api/Clients/1102', (req) => {
|
||||||
|
const { body } = req;
|
||||||
|
cy.wrap(body).should('have.property', 'phone', '123456789');
|
||||||
|
});
|
||||||
|
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,6 +8,6 @@ describe('Client billing data', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Should load layout', () => {
|
it('Should load layout', () => {
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-page').should('be.visible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,11 +3,16 @@ describe('Client fiscal data', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit('#/customer/1110/fiscal-data', {
|
cy.visit('#/customer/1107/fiscal-data', {
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Should load layout', () => {
|
it('Should change required value when change customer', () => {
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-card').should('be.visible');
|
||||||
|
cy.dataCy('sageTaxTypeFk').filter('input').should('not.have.attr', 'required');
|
||||||
|
cy.get('#searchbar input').clear();
|
||||||
|
cy.get('#searchbar input').type('1{enter}');
|
||||||
|
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
|
||||||
|
cy.dataCy('sageTaxTypeFk').filter('input').should('have.attr', 'required');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,12 +17,14 @@ describe('Client list', () => {
|
||||||
|
|
||||||
it('Client list create new client', () => {
|
it('Client list create new client', () => {
|
||||||
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
|
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
|
||||||
|
const randomInt = Math.floor(Math.random() * 90) + 10;
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
Name: { val: 'Name 1' },
|
Name: { val: `Name ${randomInt}` },
|
||||||
'Social name': { val: 'TEST 1' },
|
'Social name': { val: `TEST ${randomInt}` },
|
||||||
'Tax number': { val: '20852113Z' },
|
'Tax number': { val: `20852${randomInt.length}3Z` },
|
||||||
'Web user': { val: 'user_test_1' },
|
'Web user': { val: `user_test_${randomInt}` },
|
||||||
Street: { val: 'C/ STREET 1' },
|
Street: { val: `C/ STREET ${randomInt}` },
|
||||||
Email: { val: 'user.test@1.com' },
|
Email: { val: 'user.test@1.com' },
|
||||||
'Sales person': { val: 'employee', type: 'select' },
|
'Sales person': { val: 'employee', type: 'select' },
|
||||||
Location: { val: '46000, Valencia(Province one), España', type: 'select' },
|
Location: { val: '46000, Valencia(Province one), España', type: 'select' },
|
||||||
|
@ -32,7 +34,7 @@ describe('Client list', () => {
|
||||||
|
|
||||||
cy.get('.q-mt-lg > .q-btn--standard').click();
|
cy.get('.q-mt-lg > .q-btn--standard').click();
|
||||||
|
|
||||||
cy.checkNotification('created');
|
cy.checkNotification('Data saved');
|
||||||
cy.url().should('include', '/summary');
|
cy.url().should('include', '/summary');
|
||||||
});
|
});
|
||||||
it('Client list search client', () => {
|
it('Client list search client', () => {
|
||||||
|
@ -54,8 +56,8 @@ describe('Client list', () => {
|
||||||
cy.openActionDescriptor('Create ticket');
|
cy.openActionDescriptor('Create ticket');
|
||||||
cy.waitForElement('#formModel');
|
cy.waitForElement('#formModel');
|
||||||
cy.waitForElement('.q-form');
|
cy.waitForElement('.q-form');
|
||||||
cy.checkValueSelectForm(1, search);
|
cy.checkValueForm(1, search);
|
||||||
cy.checkValueSelectForm(2, search);
|
cy.checkValueForm(2, search);
|
||||||
});
|
});
|
||||||
it('Client founded create order', () => {
|
it('Client founded create order', () => {
|
||||||
const search = 'Jessica Jones';
|
const search = 'Jessica Jones';
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
describe('Client notes', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.viewport(1280, 720);
|
||||||
|
cy.login('developer');
|
||||||
|
cy.visit('#/customer/1101/sms');
|
||||||
|
});
|
||||||
|
it('Should load layout', () => {
|
||||||
|
cy.get('.q-page').should('be.visible');
|
||||||
|
cy.get('.q-page > :nth-child(2) > :nth-child(1)').should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
|
@ -3,11 +3,26 @@ describe('Client web-access', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit('#/customer/1110/web-access', {
|
|
||||||
timeout: 5000,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
it('Should load layout', () => {
|
it('Should test buttons ', () => {
|
||||||
|
cy.visit('#/customer/1101/web-access');
|
||||||
|
cy.get('.q-page').should('be.visible');
|
||||||
|
cy.get('#formModel').should('be.visible');
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-card').should('be.visible');
|
||||||
|
cy.get('.q-btn-group > :nth-child(1)').should('not.be.disabled');
|
||||||
|
cy.get('.q-checkbox__inner').click();
|
||||||
|
cy.get('.q-btn-group > .q-btn--standard.q-btn--actionable').should(
|
||||||
|
'not.be.disabled'
|
||||||
|
);
|
||||||
|
cy.get('.q-btn-group > .q-btn--flat').should('not.be.disabled');
|
||||||
|
cy.get('.q-btn-group > :nth-child(1)').click();
|
||||||
|
cy.get('.q-dialog__inner > .q-card > :nth-child(1)')
|
||||||
|
.should('be.visible')
|
||||||
|
.find('.text-h6')
|
||||||
|
.should('have.text', 'Change password');
|
||||||
|
});
|
||||||
|
it('Should disabled buttons', () => {
|
||||||
|
cy.visit('#/customer/1110/web-access');
|
||||||
|
cy.get('.q-btn-group > :nth-child(1)').should('be.disabled');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
describe('Client credit opinion', () => {
|
describe('Client credit contracts', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
|
@ -8,6 +8,6 @@ describe('Client credit opinion', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Should load layout', () => {
|
it('Should load layout', () => {
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-page').should('be.visible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,11 +3,17 @@ describe('Client unpaid', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit('#/customer/1110/others/unpaid', {
|
|
||||||
timeout: 5000,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
it('Should load layout', () => {
|
it('Should add unpaid', () => {
|
||||||
|
cy.visit('#/customer/1102/others/unpaid');
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-card').should('be.visible');
|
||||||
|
cy.get('.q-checkbox__inner').click();
|
||||||
|
cy.dataCy('customerUnpaidAmount').find('input').type('100');
|
||||||
|
cy.dataCy('customerUnpaidDate').find('input').type('01/01/2001');
|
||||||
|
cy.get('.q-btn-group > .q-btn--standard').click();
|
||||||
|
cy.reload();
|
||||||
|
cy.get('.q-checkbox__inner')
|
||||||
|
.should('be.visible')
|
||||||
|
.and('not.have.class', 'q-checkbox__inner--active');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,7 @@ describe('VnBreadcrumbs', () => {
|
||||||
const firstCard = '.q-infinite-scroll > :nth-child(1)';
|
const firstCard = '.q-infinite-scroll > :nth-child(1)';
|
||||||
const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el';
|
const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el';
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
cy.viewport(1920, 1080);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,11 +43,9 @@ describe('VnLocation', () => {
|
||||||
province
|
province
|
||||||
);
|
);
|
||||||
cy.get(
|
cy.get(
|
||||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) > .q-icon`
|
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) `
|
||||||
).click();
|
).click();
|
||||||
cy.get(
|
cy.dataCy('locationProvince').should('have.value', province);
|
||||||
`#q-portal--dialog--5 > .q-dialog > ${createForm.prefix} > .vn-row > .q-select > ${createForm.sufix} > :nth-child(1) input`
|
|
||||||
).should('have.value', province);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Worker Create', () => {
|
describe('Worker Create', () => {
|
||||||
|
@ -123,32 +121,16 @@ describe('VnLocation', () => {
|
||||||
const province = randomString({ length: 4 });
|
const province = randomString({ length: 4 });
|
||||||
cy.get(createLocationButton).click();
|
cy.get(createLocationButton).click();
|
||||||
cy.get(dialogInputs).eq(0).type(postCode);
|
cy.get(dialogInputs).eq(0).type(postCode);
|
||||||
cy.get(
|
cy.dataCy('City_icon').click();
|
||||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
cy.selectOption('[data-cy="locationProvince"]:last', 'Province one');
|
||||||
).click();
|
cy.dataCy('cityName').type(province);
|
||||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||||
cy.get('#q-portal--dialog--3 .q-input').type(province);
|
cy.dataCy('FormModelPopup_save').eq(0).click();
|
||||||
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
|
|
||||||
cy.get('#q-portal--dialog--1 .q-btn--standard').click();
|
|
||||||
cy.waitForElement('.q-form');
|
cy.waitForElement('.q-form');
|
||||||
checkVnLocation(postCode, province);
|
checkVnLocation(postCode, province);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Create province without country', () => {
|
|
||||||
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
|
||||||
cy.get(createLocationButton).click();
|
|
||||||
cy.get(
|
|
||||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
|
||||||
)
|
|
||||||
.eq(0)
|
|
||||||
.click();
|
|
||||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
|
||||||
cy.countSelectOptions('#q-portal--dialog--3 .q-select', 4);
|
|
||||||
cy.get('#q-portal--dialog--3 .q-input').type(provinceName);
|
|
||||||
|
|
||||||
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Create city with country', () => {
|
it('Create city with country', () => {
|
||||||
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
|
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||||
cy.get(createLocationButton).click();
|
cy.get(createLocationButton).click();
|
||||||
|
@ -156,14 +138,23 @@ describe('VnLocation', () => {
|
||||||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||||
'Italia'
|
'Italia'
|
||||||
);
|
);
|
||||||
cy.get(
|
cy.dataCy('City_icon').click();
|
||||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
cy.selectOption('[data-cy="locationProvince"]:last', 'Province four');
|
||||||
).click();
|
cy.countSelectOptions('[data-cy="locationProvince"]:last', 1);
|
||||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'Province four');
|
|
||||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 1);
|
|
||||||
|
|
||||||
cy.get('#q-portal--dialog--4 .q-input').type(cityName);
|
cy.dataCy('cityName').type(cityName);
|
||||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Create province without country', () => {
|
||||||
|
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||||
|
cy.get(createLocationButton).click();
|
||||||
|
cy.dataCy('Province_icon').click();
|
||||||
|
cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
|
||||||
|
cy.countSelectOptions('[data-cy="autonomyProvince"]', 4);
|
||||||
|
cy.dataCy('provinceName').type(provinceName);
|
||||||
|
|
||||||
|
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Create province with country', () => {
|
it('Create province with country', () => {
|
||||||
|
@ -173,17 +164,13 @@ describe('VnLocation', () => {
|
||||||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||||
'España'
|
'España'
|
||||||
);
|
);
|
||||||
cy.get(
|
cy.dataCy('Province_icon').click();
|
||||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
|
||||||
)
|
|
||||||
.eq(0)
|
|
||||||
.click();
|
|
||||||
|
|
||||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'one');
|
cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
|
||||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 2);
|
cy.countSelectOptions('[data-cy="autonomyProvince"]', 2);
|
||||||
|
|
||||||
cy.get('#q-portal--dialog--4 .q-input').type(provinceName);
|
cy.dataCy('provinceName').type(provinceName);
|
||||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
cy.dataCy('FormModelPopup_save').eq(1).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkVnLocation(postCode, province) {
|
function checkVnLocation(postCode, province) {
|
||||||
|
|
|
@ -260,6 +260,7 @@ Cypress.Commands.add('writeSearchbar', (value) => {
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('validateContent', (selector, expectedValue) => {
|
Cypress.Commands.add('validateContent', (selector, expectedValue) => {
|
||||||
cy.get(selector).should('have.text', expectedValue);
|
cy.get(selector).should('have.text', expectedValue);
|
||||||
});
|
});
|
||||||
|
@ -281,16 +282,38 @@ Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
||||||
.click();
|
.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('openActionDescriptor', (opt) => {
|
||||||
|
cy.openActionsDescriptor();
|
||||||
|
const listItem = '[role="menu"] .q-list .q-item';
|
||||||
|
cy.contains(listItem, opt).click();
|
||||||
|
1;
|
||||||
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
||||||
|
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
|
||||||
|
.invoke('removeAttr', 'target')
|
||||||
|
.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('openActionDescriptor', (opt) => {
|
||||||
|
cy.openActionsDescriptor();
|
||||||
|
const listItem = '[role="menu"] .q-list .q-item';
|
||||||
|
cy.contains(listItem, opt).click();
|
||||||
|
1;
|
||||||
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
||||||
|
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
|
||||||
|
.invoke('removeAttr', 'target')
|
||||||
|
.click();
|
||||||
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('openUserPanel', () => {
|
Cypress.Commands.add('openUserPanel', () => {
|
||||||
cy.get(
|
cy.get(
|
||||||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
||||||
).click();
|
).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('openActions', (row) => {
|
|
||||||
cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click();
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('checkNotification', (text) => {
|
Cypress.Commands.add('checkNotification', (text) => {
|
||||||
cy.get('.q-notification')
|
cy.get('.q-notification')
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
|
@ -301,10 +324,14 @@ Cypress.Commands.add('checkNotification', (text) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('openActions', (row) => {
|
||||||
|
cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click();
|
||||||
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('checkValueForm', (id, search) => {
|
Cypress.Commands.add('checkValueForm', (id, search) => {
|
||||||
cy.get(
|
cy.get(`.grid-create > :nth-child(${id}) `)
|
||||||
`.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input`
|
.find('input')
|
||||||
).should('have.value', search);
|
.should('have.value', search);
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('checkValueSelectForm', (id, search) => {
|
Cypress.Commands.add('checkValueSelectForm', (id, search) => {
|
||||||
|
@ -317,6 +344,6 @@ Cypress.Commands.add('searchByLabel', (label, value) => {
|
||||||
cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`);
|
cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('dataCy', (dataTestId, attr = 'data-cy') => {
|
Cypress.Commands.add('dataCy', (tag, attr = 'data-cy') => {
|
||||||
return cy.get(`[${attr}="${dataTestId}"]`);
|
return cy.get(`[${attr}="${tag}"]`);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,29 +1,50 @@
|
||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect, beforeAll, vi } from 'vitest';
|
||||||
|
import { axios } from 'app/test/vitest/helper';
|
||||||
import parsePhone from 'src/filters/parsePhone';
|
import parsePhone from 'src/filters/parsePhone';
|
||||||
|
|
||||||
describe('parsePhone filter', () => {
|
describe('parsePhone filter', () => {
|
||||||
it("adds prefix +34 if it doesn't have one", () => {
|
beforeAll(async () => {
|
||||||
const resultado = parsePhone('123456789', '34');
|
vi.spyOn(axios, 'get').mockReturnValue({ data: { prefix: '34' } });
|
||||||
expect(resultado).toBe('34123456789');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('maintains prefix +34 if it is already correct', () => {
|
it('no phone', async () => {
|
||||||
const resultado = parsePhone('+34123456789', '34');
|
const phone = await parsePhone(null, '34');
|
||||||
expect(resultado).toBe('34123456789');
|
expect(phone).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts prefix 0034 to +34', () => {
|
it("adds prefix +34 if it doesn't have one", async () => {
|
||||||
const resultado = parsePhone('0034123456789', '34');
|
const phone = await parsePhone('123456789', '34');
|
||||||
expect(resultado).toBe('34123456789');
|
expect(phone).toBe('34123456789');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts prefix 34 without symbol to +34', () => {
|
it('maintains prefix +34 if it is already correct', async () => {
|
||||||
const resultado = parsePhone('34123456789', '34');
|
const phone = await parsePhone('+34123456789', '34');
|
||||||
expect(resultado).toBe('34123456789');
|
expect(phone).toBe('34123456789');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('replaces incorrect prefix with the correct one', () => {
|
it('converts prefix 0034 to +34', async () => {
|
||||||
const resultado = parsePhone('+44123456789', '34');
|
const phone = await parsePhone('0034123456789', '34');
|
||||||
expect(resultado).toBe('44123456789');
|
expect(phone).toBe('34123456789');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('converts prefix 34 without symbol to +34', async () => {
|
||||||
|
const phone = await parsePhone('34123456789', '34');
|
||||||
|
expect(phone).toBe('34123456789');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('replaces incorrect prefix with the correct one', async () => {
|
||||||
|
const phone = await parsePhone('+44123456789', '34');
|
||||||
|
expect(phone).toBe('44123456789');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('adds default prefix on error', async () => {
|
||||||
|
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||||
|
if (url.includes('Prefixes'))
|
||||||
|
return Promise.reject(new Error('Network error'));
|
||||||
|
else if (url.includes('PbxConfigs'))
|
||||||
|
return Promise.resolve({ data: { defaultPrefix: '39' } });
|
||||||
|
});
|
||||||
|
const phone = await parsePhone('123456789', '34');
|
||||||
|
expect(phone).toBe('39123456789');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue