0
0
Fork 0

Merge branch 'master' into hotfix-7366TravelSearch

This commit is contained in:
Carlos Satorres 2024-11-28 13:07:55 +00:00
commit bc535ff0a1
40 changed files with 366 additions and 417 deletions

View File

@ -10,6 +10,7 @@ import VnPaginate from 'components/ui/VnPaginate.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
import SkeletonTable from 'components/ui/SkeletonTable.vue';
import { tMobile } from 'src/composables/tMobile';
import getDifferences from 'src/filters/getDifferences';
const { push } = useRouter();
const quasar = useQuasar();
@ -268,28 +269,6 @@ function getChanges() {
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) {
if (obj == null) return true;
if (obj === undefined) return true;

View File

@ -106,6 +106,7 @@ const originalData = ref({});
const formData = computed(() => state.get(modelValue));
const defaultButtons = computed(() => ({
save: {
dataCy: 'saveDefaultBtn',
color: 'primary',
icon: 'save',
label: 'globals.save',
@ -113,6 +114,7 @@ const defaultButtons = computed(() => ({
type: 'submit',
},
reset: {
dataCy: 'resetDefaultBtn',
color: 'primary',
icon: 'restart_alt',
label: 'globals.reset',
@ -203,7 +205,9 @@ async function save() {
isLoading.value = true;
try {
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 url =
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
@ -317,6 +321,7 @@ defineExpose({
:title="t(defaultButtons.reset.label)"
/>
<QBtnDropdown
data-cy="saveAndContinueDefaultBtn"
v-if="$props.goTo"
@click="saveAndGo"
:label="tMobile('globals.saveAndContinue')"

View File

@ -101,6 +101,7 @@ onBeforeRouteLeave((to, from, next) => {
@click="insert"
class="q-mb-xs"
dense
data-cy="saveNote"
/>
</template>
</VnInput>

View File

@ -133,7 +133,7 @@ const addFilter = async (filter, params) => {
async function fetch(params) {
useArrayData(props.dataKey, params);
arrayData.reset(['filter.skip', 'skip', 'page']);
await arrayData.fetch({ append: false });
await arrayData.fetch({ append: false, updateRouter: mounted.value });
return emitStoreData();
}

View File

@ -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;
}

View File

@ -0,0 +1,6 @@
export default function getUpdatedValues(keys, formData) {
return keys.reduce((acc, key) => {
acc[key] = formData[key];
return acc;
}, {});
}

View File

@ -11,11 +11,15 @@ import dashIfEmpty from './dashIfEmpty';
import dateRange from './dateRange';
import toHour from './toHour';
import dashOrCurrency from './dashOrCurrency';
import getDifferences from './getDifferences';
import getUpdatedValues from './getUpdatedValues';
import getParamWhere from './getParamWhere';
import parsePhone from './parsePhone';
import isDialogOpened from './isDialogOpened';
export {
getUpdatedValues,
getDifferences,
isDialogOpened,
parsePhone,
toLowerCase,

View File

@ -861,6 +861,7 @@ components:
cardDescriptor:
mainList: Main list
summary: Summary
moreOptions: More options
leftMenu:
addToPinned: Add to pinned
removeFromPinned: Remove from pinned

View File

@ -2,6 +2,7 @@
import { onBeforeMount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import axios from 'axios';
@ -52,7 +53,6 @@ const addressFilter = {
onBeforeMount(() => {
const { id } = route.params;
getAddressesData(id);
getClientData(id);
});
@ -60,23 +60,10 @@ watch(
() => route.params.id,
(newValue) => {
if (!newValue) return;
getAddressesData(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) => {
try {
const { data } = await axios.get(`Clients/${id}`);
@ -101,9 +88,9 @@ const setDefault = (address) => {
});
};
const sortAddresses = () => {
if (!client.value || !addresses.value) return;
addresses.value = addresses.value.sort((a, b) => {
const sortAddresses = (data) => {
if (!client.value || !data) return;
addresses.value = data.sort((a, b) => {
return isDefaultAddress(b) - isDefaultAddress(a);
});
};
@ -124,8 +111,17 @@ const toCustomerAddressEdit = (addressId) => {
</script>
<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">
<QCard class="card-width q-pa-lg" v-if="addresses.length">
<QCard class="card-width q-pa-lg">
<QCardSection>
<div
v-for="(item, index) in addresses"

View File

@ -9,6 +9,7 @@ import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnAvatar from 'src/components/ui/VnAvatar.vue';
import { getDifferences, getUpdatedValues } from 'src/filters';
const route = useRoute();
const { t } = useI18n();
@ -30,6 +31,13 @@ const exprBuilder = (param, value) => {
and: [{ active: { neq: false } }, handleSalesModelValue(value)],
};
};
function onBeforeSave(formData, originalData) {
return getUpdatedValues(
Object.keys(getDifferences(formData, originalData)),
formData
);
}
</script>
<template>
<FetchData
@ -43,7 +51,12 @@ const exprBuilder = (param, value) => {
@on-fetch="(data) => (businessTypes = data)"
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 }">
<VnRow>
<VnInput
@ -94,6 +107,7 @@ const exprBuilder = (param, value) => {
:rules="validate('client.phone')"
clearable
v-model="data.phone"
data-cy="customerPhone"
/>
<VnInput
:label="t('customer.summary.mobile')"

View File

@ -28,12 +28,7 @@ const getBankEntities = (data, formData) => {
</script>
<template>
<FormModel
:url-update="`Clients/${route.params.id}`"
:url="`Clients/${route.params.id}/getCard`"
auto-load
model="customer"
>
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="customer">
<template #form="{ data, validate }">
<VnRow>
<VnSelect

View File

@ -93,22 +93,6 @@ const columns = computed(() => [
<WorkerDescriptorProxy :id="row.worker.id" />
</template>
</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>
<i18n>

View File

@ -36,7 +36,10 @@ const entityId = computed(() => {
});
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(() => {
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary';
});

View File

@ -34,7 +34,6 @@ function handleLocation(data, location) {
/>
<FormModel
:url-update="`Clients/${route.params.id}/updateFiscalData`"
:url="`Clients/${route.params.id}/getCard`"
auto-load
model="customer"
>

View File

@ -1,164 +1,82 @@
<script setup>
import { computed, onBeforeMount, ref, watch, nextTick } from 'vue';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
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 axios from 'axios';
import useNotify from 'src/composables/useNotify';
import { useStateStore } from 'stores/useStateStore';
const formModelRef = ref(false);
const { t } = useI18n();
const route = useRoute();
const { notify } = useNotify();
const stateStore = useStateStore();
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({
dated: initialDated,
dated: Date.vnNew(),
amount: null,
});
const hasChanged = computed(() => {
return (
initialData.value.dated !== dated.value ||
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,
const filterClientFindOne = {
fields: ['unpaid', 'dated', 'amount'],
where: {
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>
<template>
<Teleport v-if="stateStore?.isSubToolbarShown()" to="#st-actions">
<QBtnGroup push class="q-gutter-x-sm">
<QBtn
:disabled="!hasChanged"
:label="t('globals.reset')"
:loading="isLoading"
@click="setInitialData"
color="primary"
flat
icon="restart_alt"
type="reset"
<FetchData
:filter="filterClientFindOne"
auto-load
url="ClientUnpaids"
@on-fetch="
(data) => {
const unpaid = data.length == 1;
initialData = { ...data[0], unpaid };
}
"
/>
<QBtn
:disabled="!hasChanged"
:label="t('globals.save')"
:loading="isLoading"
@click="onSubmit"
color="primary"
icon="save"
/>
</QBtnGroup>
</Teleport>
<div class="full-width flex justify-center">
<QCard class="card-width q-pa-lg">
<QForm>
<QCard>
<FormModel
v-if="'unpaid' in initialData"
:observe-form-changes="false"
ref="formModelRef"
model="unpaid"
url-update="ClientUnpaids"
:mapper="(formData) => ({ ...formData, clientFk: route.params.id })"
:form-initial-data="initialData"
>
<template #form="{ data }">
<VnRow>
<div class="col">
<QCheckbox :label="t('Unpaid client')" v-model="unpaidClient" />
</div>
<QCheckbox :label="t('Unpaid client')" v-model="data.unpaid" />
</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">
<VnInputDate :label="t('Date')" v-model="dated" />
<VnInputDate
data-cy="customerUnpaidDate"
:label="t('Date')"
v-model="data.dated"
/>
</div>
<div class="col">
<VnInput
<VnInputNumber
data-cy="customerUnpaidAmount"
ref="amountInputRef"
:label="t('Amount')"
clearable
type="number"
v-model="amount"
v-model="data.amount"
autofocus
>
<template #append></template></VnInput
<template #append></template></VnInputNumber
>
</div>
</VnRow>
</QForm>
</template>
</FormModel>
</QCard>
</div>
</template>
<i18n>

View File

@ -25,10 +25,9 @@ async function hasCustomerRole() {
</script>
<template>
<FormModel
url="VnUsers/preview"
:url-update="`Clients/${route.params.id}/updateUser`"
:filter="filter"
model="webAccess"
model="customer"
:mapper="
({ active, name, email }) => {
return {
@ -42,7 +41,7 @@ async function hasCustomerRole() {
auto-load
>
<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('Recovery email')"

View File

@ -1,9 +1,9 @@
<script setup>
import { computed, onBeforeMount, ref, watch } from 'vue';
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import axios from 'axios';
import FetchData from 'src/components/FetchData.vue';
import { toCurrency, toDateHourMin } from 'src/filters';
@ -20,10 +20,11 @@ const filter = {
{ relation: 'mandateType', scope: { fields: ['id', 'name'] } },
{ relation: 'company', scope: { fields: ['id', 'code'] } },
],
where: { clientFk: null },
where: { clientFk: route.params.id },
order: ['created DESC'],
limit: 20,
};
const ClientDmsRef = ref(false);
const tableColumnComponents = {
state: {
@ -50,7 +51,7 @@ const tableColumnComponents = {
component: CustomerCheckIconTooltip,
props: ({ row }) => ({
transaction: row,
promise: refreshData,
promise: () => ClientDmsRef.value.fetch(),
}),
event: () => {},
},
@ -89,38 +90,16 @@ const columns = computed(() => [
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>
<template>
<div class="full-width flex justify-center">
<FetchData
ref="ClientDmsRef"
:filter="filter"
@on-fetch="(data) => (rows = data)"
auto-load
url="Clients/transactions"
/>
<QPage class="card-width q-pa-lg">
<QTable
:columns="columns"
@ -135,13 +114,9 @@ const refreshData = () => {
<QTr :props="props">
<component
:is="tableColumnComponents[props.col.name].component"
@click="
tableColumnComponents[props.col.name].event(props)
"
@click="tableColumnComponents[props.col.name].event(props)"
class="rounded-borders q-pa-sm"
v-bind="
tableColumnComponents[props.col.name].props(props)
"
v-bind="tableColumnComponents[props.col.name].props(props)"
>
{{ props.value }}
</component>
@ -154,7 +129,6 @@ const refreshData = () => {
{{ t('globals.noResults') }}
</h5>
</QPage>
</div>
</template>
<i18n>

View File

@ -1,9 +1,8 @@
<script setup>
import { onBeforeMount, reactive, ref } from 'vue';
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
import VnLocation from 'src/components/common/VnLocation.vue';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
@ -25,20 +24,6 @@ const agencyModes = ref([]);
const incoterms = 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 = () => {
router.push({
name: 'CustomerAddress',
@ -54,6 +39,11 @@ function handleLocation(data, location) {
data.provinceFk = provinceFk;
data.countryFk = countryFk;
}
function onAgentCreated(requestResponse, data) {
customsAgents.value.push(requestResponse);
data.customsAgentFk = requestResponse.id;
}
</script>
<template>
@ -139,6 +129,7 @@ function handleLocation(data, location) {
/>
<VnSelectDialog
url="CustomsAgents"
:label="t('Customs agent')"
:options="customsAgents"
hide-selected
@ -148,7 +139,12 @@ function handleLocation(data, location) {
:tooltip="t('Create a new expense')"
>
<template #form>
<CustomerNewCustomsAgent @on-data-saved="refreshData()" />
<CustomerNewCustomsAgent
@on-data-saved="
(_, requestResponse) =>
onAgentCreated(requestResponse, data)
"
/>
</template>
</VnSelectDialog>
</VnRow>

View File

@ -144,7 +144,7 @@ function handleLocation(data, location) {
:url="`Addresses/${route.params.addressId}`"
@on-data-saved="onDataSaved()"
auto-load
model="client"
model="customer"
>
<template #moreActions>
<QBtn

View File

@ -82,11 +82,11 @@ const entriesTableColumns = computed(() => [
</QCardSection>
<QCardActions align="right">
<QBtn
:label="t('printLabels')"
:label="t('myEntries.printLabels')"
color="primary"
icon="print"
:loading="isLoading"
@click="openReport(`Entries/${entityId}/print`)"
@click="openReport(`Entries/${entityId}/labelSupplier`)"
unelevated
autofocus
/>
@ -126,7 +126,9 @@ const entriesTableColumns = computed(() => [
"
unelevated
>
<QTooltip>{{ t('viewLabel') }}</QTooltip>
<QTooltip>{{
t('myEntries.viewLabel')
}}</QTooltip>
</QBtn>
</QTr>
</template>

View File

@ -101,7 +101,7 @@ const columns = computed(() => [
name: 'tableActions',
actions: [
{
title: t('printLabels'),
title: t('myEntries.printLabels'),
icon: 'print',
isPrimary: true,
action: (row) => printBuys(row.id),

View File

@ -43,16 +43,17 @@ const columns = computed(() => [
{
align: 'left',
name: 'ref',
label: t('invoiceOutList.tableVisibleColumns.ref'),
label: t('globals.reference'),
isTitle: true,
component: 'select',
attrs: {
url: MODEL,
optionLabel: 'ref',
optionValue: 'id',
optionValue: 'ref',
},
columnField: {
component: null,
columnField: { component: null },
columnFilter: {
inWhere: true,
},
},
{
@ -154,9 +155,7 @@ function downloadPdf() {
const [invoiceOut] = selectedCardsArray;
openPdf(invoiceOut.id);
} else {
const invoiceOutIdsArray = selectedCardsArray.map(
(invoiceOut) => invoiceOut.id
);
const invoiceOutIdsArray = selectedCardsArray.map((invoiceOut) => invoiceOut.id);
const invoiceOutIds = invoiceOutIdsArray.join(',');
const params = {
@ -165,7 +164,6 @@ function downloadPdf() {
openReport(`${MODEL}/downloadZip`, params);
}
}
watchEffect(selectedRows);

View File

@ -124,8 +124,7 @@ const columns = computed(() => [
</template>
<i18n>
en:
Search suppliers: Search suppliers
es:
Search suppliers: Buscar proveedores
Create Supplier: Crear proveedor
</i18n>

View File

@ -321,10 +321,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<div class="column">
<span v-for="(saleComponent, index) in row.components" :key="index">
{{ toCurrency(saleComponent.value * row.quantity, 'EUR', 3) }}
<!-- <QTooltip>
{{ saleComponent.component?.name }}:
{{ toCurrency(saleComponent.value, 'EUR', 3) }}
</QTooltip> -->
</span>
</div>
</template>

View File

@ -676,7 +676,7 @@ async function uploadDocuware(force) {
<VnConfirm
ref="weightDialog"
:title="t('Set weight')"
:message="t('This ticket may be invoiced, do you want to continue?')"
:message="false"
:promise="actions.setWeight"
>
<template #customHTML>
@ -741,7 +741,6 @@ es:
Ticket invoiced: Ticket facturado
Set weight: Establecer peso
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}"
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

View File

@ -181,17 +181,34 @@ const resetChanges = async () => {
arrayData.fetch({ append: false });
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 {
await axios.post(`Sales/${sale.id}/updateQuantity`, params);
if (!rowToUpdate.value) return;
rowToUpdate.value = null;
await updateQuantity(sale);
} catch (e) {
sale.quantity = tableRef.value.CrudModelRef.originalData.find(
const { quantity } = tableRef.value.CrudModelRef.originalData.find(
(s) => s.id === sale.id
).quantity;
);
sale.quantity = quantity;
throw e;
}
};
const updateQuantity = async ({ quantity, id }) => {
const params = { quantity: quantity };
await axios.post(`Sales/${id}/updateQuantity`, params);
notify('globals.dataSaved', 'positive');
};
@ -219,19 +236,6 @@ const addSale = async (sale) => {
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) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
@ -768,16 +772,12 @@ watch(
</template>
<template #column-quantity="{ row }">
<VnInput
v-if="row.isNew"
v-model.number="row.quantity"
v-if="row.isNew || isTicketEditable"
type="number"
@blur="changeQuantity(row)"
@focus="edit.oldQuantity = row.quantity"
/>
<VnInput
v-else-if="isTicketEditable"
v-model.number="row.quantity"
@blur="changeQuantity(row)"
@keyup.enter="changeQuantity(row)"
@update:model-value="() => (rowToUpdate = row)"
@focus="edit.oldQuantity = row.quantity"
/>
<span v-else>{{ row.quantity }}</span>

View File

@ -257,7 +257,7 @@ function toTicketUrl(section) {
<QCard class="vn-one" v-if="entity.notes.length">
<VnTitle
:url="toTicketUrl('observation')"
:text="t('ticket.pageTitles.notes')"
:text="t('globals.pageTitles.notes')"
/>
<QVirtualScroll
:items="entity.notes"

View File

@ -1,5 +1,5 @@
<script setup>
import { ref, computed, onMounted } from 'vue';
import { ref, computed, onMounted, reactive } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
@ -43,7 +43,7 @@ const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm();
const isNew = computed(() => props.isNewMode);
const dated = ref(props.date);
const dated = reactive(props.date);
const tickedNodes = ref();
const _excludeType = ref('all');
@ -67,12 +67,12 @@ const exclusionGeoCreate = async () => {
};
const exclusionCreate = async () => {
if (isNew.value)
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated.value }]);
else
await axios.post(`Zones/${route.params.id}/exclusions`, {
dated: dated.value,
});
const url = `Zones/${route.params.id}/exclusions`;
const body = {
dated,
};
if (isNew.value || props.event?.type) await axios.post(`${url}`, [body]);
else await axios.put(`${url}/${props.event?.id}`, body);
await refetchEvents();
};
@ -83,7 +83,8 @@ const onSubmit = async () => {
const deleteEvent = async () => {
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();
};
@ -118,11 +119,7 @@ onMounted(() => {
>
<template #form-inputs>
<VnRow class="row q-gutter-md q-mb-lg">
<VnInputDate
:label="t('eventsInclusionForm.day')"
v-model="dated"
:required="true"
/>
<VnInputDate :label="t('eventsInclusionForm.day')" v-model="dated" />
</VnRow>
<div class="column q-gutter-y-sm q-mb-md">
<QRadio
@ -172,8 +169,8 @@ onMounted(() => {
class="q-mr-sm"
@click="
openConfirmationModal(
t('zone.deleteTitle'),
t('zone.deleteSubtitle'),
t('eventsPanel.deleteTitle'),
t('eventsPanel.deleteSubtitle'),
() => deleteEvent()
)
"

View File

@ -24,13 +24,14 @@ const zoneEventsFormProps = reactive({
date: null,
});
const openForm = (data) => {
const openForm = (data, isBtnAdd) => {
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
zoneEventsFormProps.date = date;
zoneEventsFormProps.isNewMode = isNewMode;
zoneEventsFormProps.event = event;
zoneEventsFormProps.eventType = eventType;
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
if (isBtnAdd) formModeName.value = 'include';
showZoneEventForm.value = true;
};
@ -51,7 +52,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
:last-day="lastDay"
:events="events"
v-model:formModeName="formModeName"
@open-zone-form="openForm"
/>
</QScrollArea>
</QDrawer>
@ -65,7 +65,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
/>
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
<ZoneEventInclusionForm
v-if="formModeName === 'include'"
v-if="!formModeName || formModeName === 'include'"
v-bind="zoneEventsFormProps"
@close-form="onZoneEventFormClose()"
/>
@ -78,9 +78,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<QPageSticky :offset="[20, 20]">
<QBtn
@click="
openForm({
openForm(
{
isNewMode: true,
})
},
true
)
"
color="primary"
fab

View File

@ -11,6 +11,10 @@ import { dashIfEmpty } from 'src/filters';
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
import { useVnConfirm } from 'composables/useVnConfirm';
const formModeName = defineModel('formModeName', {
type: String,
required: true,
});
const props = defineProps({
firstDay: {
type: Date,
@ -27,25 +31,13 @@ const props = defineProps({
required: true,
default: () => [],
},
formModeName: {
type: String,
required: true,
default: 'include',
},
});
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
const { t } = useI18n();
const route = useRoute();
const weekdayStore = useWeekdayStore();
const { openConfirmationModal } = useVnConfirm();
const formName = computed({
get: () => props.formModeName,
set: (value) => emit('update:formModeName', value),
});
const params = computed(() => ({
zoneFk: route.params.id,
started: props.firstDay,
@ -88,16 +80,6 @@ const deleteEvent = async (id) => {
await fetchData();
};
const openInclusionForm = (event) => {
formName.value = 'include';
emit('openZoneForm', {
date: event.dated,
event,
isNewMode: false,
eventType: 'event',
});
};
onMounted(async () => {
weekdayStore.initStore();
});
@ -110,13 +92,13 @@ onMounted(async () => {
t('eventsPanel.editMode')
}}</span>
<QRadio
v-model="formName"
v-model="formModeName"
dense
val="include"
:label="t('eventsPanel.include')"
/>
<QRadio
v-model="formName"
v-model="formModeName"
dense
val="exclude"
:label="t('eventsPanel.exclude')"

View File

@ -61,6 +61,8 @@ eventsPanel:
events: Events
everyday: Everyday
delete: Delete
deleteTitle: This item will be deleted
deleteSubtitle: Are you sure you want to continue?
eventsExclusionForm:
addExclusion: Add exclusion
editExclusion: Edit exclusion
@ -76,6 +78,7 @@ eventsInclusionForm:
rangeOfDates: Range of dates
from: From
to: To
day: Day
upcomingDeliveries:
province: Province
closing: Closing

View File

@ -61,6 +61,8 @@ eventsPanel:
events: Eventos
everyday: Todos los días
delete: Eliminar
deleteTitle: Eliminar evento
deleteSubtitle: ¿Seguro que quieres eliminar este evento?
eventsExclusionForm:
addExclusion: Añadir exclusión
editExclusion: Editar exclusión
@ -76,5 +78,6 @@ eventsInclusionForm:
rangeOfDates: Rango de fechas
from: Desde
to: Hasta
day: Día
upcomingDeliveries:
province: Provincia

View File

@ -3,11 +3,17 @@ describe('Client basic data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/basic-data', {
timeout: 5000,
});
cy.visit('#/customer/1102/basic-data');
});
it('Should load layout', () => {
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');
});
});

View File

@ -8,6 +8,6 @@ describe('Client billing data', () => {
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
cy.get('.q-page').should('be.visible');
});
});

View File

@ -17,12 +17,14 @@ describe('Client list', () => {
it('Client list create new client', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
const randomInt = Math.floor(Math.random() * 90) + 10;
const data = {
Name: { val: 'Name 1' },
'Social name': { val: 'TEST 1' },
'Tax number': { val: '20852113Z' },
'Web user': { val: 'user_test_1' },
Street: { val: 'C/ STREET 1' },
Name: { val: `Name ${randomInt}` },
'Social name': { val: `TEST ${randomInt}` },
'Tax number': { val: `20852${randomInt.length}3Z` },
'Web user': { val: `user_test_${randomInt}` },
Street: { val: `C/ STREET ${randomInt}` },
Email: { val: 'user.test@1.com' },
'Sales person': { val: 'employee', 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.checkNotification('created');
cy.checkNotification('Data saved');
cy.url().should('include', '/summary');
});
it('Client list search client', () => {
@ -54,8 +56,8 @@ describe('Client list', () => {
cy.openActionDescriptor('Create ticket');
cy.waitForElement('#formModel');
cy.waitForElement('.q-form');
cy.checkValueSelectForm(1, search);
cy.checkValueSelectForm(2, search);
cy.checkValueForm(1, search);
cy.checkValueForm(2, search);
});
it('Client founded create order', () => {
const search = 'Jessica Jones';

View File

@ -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');
});
});

View File

@ -3,11 +3,26 @@ describe('Client web-access', () => {
beforeEach(() => {
cy.viewport(1280, 720);
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-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');
});
});

View File

@ -1,5 +1,5 @@
/// <reference types="cypress" />
describe('Client credit opinion', () => {
describe('Client credit contracts', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
@ -8,6 +8,6 @@ describe('Client credit opinion', () => {
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
cy.get('.q-page').should('be.visible');
});
});

View File

@ -3,11 +3,17 @@ describe('Client unpaid', () => {
beforeEach(() => {
cy.viewport(1280, 720);
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-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');
});
});

View File

@ -254,6 +254,7 @@ Cypress.Commands.add('writeSearchbar', (value) => {
value
);
});
Cypress.Commands.add('validateContent', (selector, expectedValue) => {
cy.get(selector).should('have.text', expectedValue);
});
@ -275,16 +276,38 @@ Cypress.Commands.add('clickButtonsDescriptor', (id) => {
.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', () => {
cy.get(
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click();
});
Cypress.Commands.add('openActions', (row) => {
cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click();
});
Cypress.Commands.add('checkNotification', (text) => {
cy.get('.q-notification')
.should('be.visible')
@ -295,10 +318,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) => {
cy.get(
`.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input`
).should('have.value', search);
cy.get(`.grid-create > :nth-child(${id}) `)
.find('input')
.should('have.value', search);
});
Cypress.Commands.add('checkValueSelectForm', (id, search) => {
@ -310,3 +337,7 @@ Cypress.Commands.add('checkValueSelectForm', (id, search) => {
Cypress.Commands.add('searchByLabel', (label, value) => {
cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`);
});
Cypress.Commands.add('dataCy', (tag, attr = 'data-cy') => {
return cy.get(`[${attr}="${tag}"]`);
});