0
0
Fork 0

refs #6157 refactor

This commit is contained in:
Carlos Satorres 2023-11-17 14:06:43 +01:00
parent 9b11ca05a4
commit ce4fe44b03
6 changed files with 68 additions and 49 deletions

View File

@ -68,6 +68,7 @@ const arrayData = useArrayData(props.dataKey, {
limit: props.limit, limit: props.limit,
order: props.order, order: props.order,
userParams: props.userParams, userParams: props.userParams,
skip: 0,
}); });
const store = arrayData.store; const store = arrayData.store;

View File

@ -42,7 +42,7 @@ export function useArrayData(key, userOptions) {
]; ];
if (typeof userOptions === 'object') { if (typeof userOptions === 'object') {
for (const option in userOptions) { for (const option in userOptions) {
const isEmpty = userOptions[option] == null || userOptions[option] == ''; const isEmpty = userOptions[option] == null || userOptions[option] === '';
if (isEmpty || !allowedOptions.includes(option)) continue; if (isEmpty || !allowedOptions.includes(option)) continue;
if (Object.prototype.hasOwnProperty.call(store, option)) { if (Object.prototype.hasOwnProperty.call(store, option)) {

View File

@ -45,3 +45,9 @@ body.body--dark {
.bg-vn-dark { .bg-vn-dark {
background-color: var(--vn-dark); background-color: var(--vn-dark);
} }
.vn-card {
background-color: var(--vn-gray);
color: var(--vn-text);
border-radius: 8px;
}

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed, watchEffect } from 'vue'; import { ref, computed, watchEffect, onMounted } from 'vue';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -10,6 +10,7 @@ import { tMobile } from 'src/composables/tMobile';
import CrudModel from 'src/components/CrudModel.vue'; import CrudModel from 'src/components/CrudModel.vue';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
const { t } = useI18n(); const { t } = useI18n();
@ -17,8 +18,10 @@ const quasar = useQuasar();
const route = useRoute(); const route = useRoute();
const stateStore = computed(() => useStateStore()); const stateStore = computed(() => useStateStore());
const claim = ref(null); const claim = ref(null);
const claimRef = ref();
const claimId = route.params.id; const claimId = route.params.id;
const dialogDestination = ref(false); const dialogDestination = ref(false);
const dialogRegularize = ref(false);
const claimDestinationFk = ref(null); const claimDestinationFk = ref(null);
const resolvedStateId = ref(null); const resolvedStateId = ref(null);
const claimActionsForm = ref(); const claimActionsForm = ref();
@ -27,7 +30,7 @@ const selectedRows = ref([]);
const destinationTypes = ref([]); const destinationTypes = ref([]);
const destinations = ref([]); const destinations = ref([]);
const totalClaimed = ref(null); const totalClaimed = ref(null);
const maxResponsibility = computed(() => 5); const DEFAULT_MAX_RESPONSABILITY = 5;
const dialogGreuge = ref(false); const dialogGreuge = ref(false);
const columns = computed(() => [ const columns = computed(() => [
@ -45,7 +48,7 @@ const columns = computed(() => [
{ {
name: 'destination', name: 'destination',
label: t('Destination'), label: t('Destination'),
field: (row) => getDestination(row.claimDestinationFk), field: (row) => row.claimDestinationFk,
align: 'left', align: 'left',
}, },
{ {
@ -90,17 +93,18 @@ const columns = computed(() => [
}, },
]); ]);
watchEffect(() => { onMounted(() => {
if (rows.value.length) { getTotal();
destinations.value = rows.value.map((row) =>
getDestination(row.claimDestinationFk)
);
totalClaimed.value = rows.value.reduce((total, row) => total + row.total, 0);
}
}); });
function getDestination(destinationId) { function setData(data) {
return destinationTypes.value.find((type) => type.id == destinationId); rows.value = data;
getTotal();
}
function getTotal() {
if (rows.value.length) {
totalClaimed.value = rows.value.reduce((total, row) => total + row.total, 0);
}
} }
async function updateDestinations(claimDestinationFk) { async function updateDestinations(claimDestinationFk) {
@ -121,16 +125,22 @@ async function regularizeClaim() {
const query = `Claims/${claimId}/regularizeClaim`; const query = `Claims/${claimId}/regularizeClaim`;
await axios.post(query); await axios.post(query);
if (claim.value.responsibility >= Math.ceil(maxResponsibility.value) / 2) { if (claim.value.responsibility >= Math.ceil(DEFAULT_MAX_RESPONSABILITY) / 2) {
dialogGreuge.value = true; await claimRef.value.fetch();
quasar
.dialog({
component: VnConfirm,
title: t('confirmGreuges'),
message: t('confirmGreugesMessage'),
})
.onOk(async () => await onUpdateGreugeAccept());
} else { } else {
quasar.notify({ quasar.notify({
message: t('globals.dataSaved'), message: t('globals.dataSaved'),
type: 'positive', type: 'positive',
}); });
claimActionsForm.value.reload();
} }
claimActionsForm.value.reload();
} }
async function updateGreuge(greuges) { async function updateGreuge(greuges) {
@ -189,6 +199,7 @@ async function importToNewRefundTicket() {
</script> </script>
<template> <template>
<FetchData <FetchData
ref="claimRef"
:url="`Claims/${claimId}`" :url="`Claims/${claimId}`"
@on-fetch="(data) => (claim = data)" @on-fetch="(data) => (claim = data)"
auto-load auto-load
@ -228,10 +239,10 @@ async function importToNewRefundTicket() {
show-if-above show-if-above
v-if="claim" v-if="claim"
> >
<div class="totalClaim q-mb-md"> <QCard class="totalClaim vn-card q-my-md q-pa-sm">
{{ `${t('Total claimed')}: ${toCurrency(totalClaimed)}` }} {{ `${t('Total claimed')}: ${toCurrency(totalClaimed)}` }}
</div> </QCard>
<QCard class="q-mb-md q-pa-sm"> <QCard class="vn-card q-mb-md q-pa-sm">
<QItem class="justify-between"> <QItem class="justify-between">
<QItemLabel class="slider-container"> <QItemLabel class="slider-container">
<p class="text-primary"> <p class="text-primary">
@ -275,7 +286,7 @@ async function importToNewRefundTicket() {
:default-remove="true" :default-remove="true"
:default-save="false" :default-save="false"
:default-reset="false" :default-reset="false"
@on-fetch="(data) => (rows = data)" @on-fetch="setData"
auto-load auto-load
> >
<template #body> <template #body>
@ -283,11 +294,9 @@ async function importToNewRefundTicket() {
:columns="columns" :columns="columns"
:rows="rows" :rows="rows"
:dense="$q.screen.lt.md" :dense="$q.screen.lt.md"
:pagination="{ rowsPerPage: 0 }"
row-key="id" row-key="id"
selection="multiple" selection="multiple"
v-model:selected="selectedRows" v-model:selected="selectedRows"
hide-pagination
:grid="$q.screen.lt.md" :grid="$q.screen.lt.md"
> >
<template #body-cell-ticket="{ value }"> <template #body-cell-ticket="{ value }">
@ -392,7 +401,7 @@ async function importToNewRefundTicket() {
<QDialog v-model="dialogDestination"> <QDialog v-model="dialogDestination">
<QCard> <QCard>
<QCardSection> <QCardSection>
<QItem class="q-pa-none"> <QItem class="q-pa-sm">
<span class="q-dialog__title text-white"> <span class="q-dialog__title text-white">
{{ t('dialog title') }} {{ t('dialog title') }}
</span> </span>
@ -401,6 +410,7 @@ async function importToNewRefundTicket() {
</QCardSection> </QCardSection>
<QItemSection> <QItemSection>
<VnSelectFilter <VnSelectFilter
class="q-pa-sm"
v-model="claimDestinationFk" v-model="claimDestinationFk"
:options="destinationTypes" :options="destinationTypes"
option-label="description" option-label="description"
@ -423,13 +433,13 @@ async function importToNewRefundTicket() {
</QCardActions> </QCardActions>
</QCard> </QCard>
</QDialog> </QDialog>
<QDialog v-model="dialogGreuge"> <!-- <QDialog v-model="dialogGreuge">
<QCardSection> <QCardSection>
<QItem class="q-pa-none"> <QItem class="q-pa-sm">
<span class="q-dialog__title text-white"> <span class="q-pa-sm q-dialog__title text-white">
{{ t('dialogGreuge title') }} {{ t('dialogGreuge title') }}
</span> </span>
<QBtn icon="close" flat round dense v-close-popup /> <QBtn class="q-pa-sm" icon="close" flat round dense v-close-popup />
</QItem> </QItem>
<QCardActions class="justify-end q-mr-sm"> <QCardActions class="justify-end q-mr-sm">
<QBtn flat :label="t('globals.close')" color="primary" v-close-popup /> <QBtn flat :label="t('globals.close')" color="primary" v-close-popup />
@ -441,17 +451,8 @@ async function importToNewRefundTicket() {
/> />
</QCardActions> </QCardActions>
</QCardSection> </QCardSection>
</QDialog> </QDialog> -->
</template> </template>
<style lang="scss">
.claim-action {
.q-table {
.q-select .q-field__input {
display: none !important;
}
}
}
</style>
<style lang="scss" scoped> <style lang="scss" scoped>
.slider-container { .slider-container {
width: 50%; width: 50%;
@ -472,20 +473,12 @@ async function importToNewRefundTicket() {
height: min-content; height: min-content;
} }
} }
.totalClaim {
background-color: #313131;
color: white;
padding: 10px;
margin: 5px;
border-radius: 8px;
}
.responsibility { .responsibility {
max-width: 100%; max-width: 100%;
margin-left: 40px; margin-left: 40px;
} }
.mana { .mana {
color: white;
float: inline-start; float: inline-start;
} }
</style> </style>
@ -493,8 +486,8 @@ async function importToNewRefundTicket() {
en: en:
mana: Is paid with mana mana: Is paid with mana
dialog title: Change destination to all selected rows dialog title: Change destination to all selected rows
dialogGreuge title: Insert greuges on client card confirmGreuges: Do you want to insert complaints?
ClaimGreugeDescription: Claim Id confirmGreugesMessage: Insert complaints into the client's record
es: es:
mana: Cargado al maná mana: Cargado al maná
@ -516,4 +509,6 @@ es:
dialogGreuge title: Insertar greuges en la ficha del cliente dialogGreuge title: Insertar greuges en la ficha del cliente
ClaimGreugeDescription: Id reclamación ClaimGreugeDescription: Id reclamación
Id item: Id artículo Id item: Id artículo
confirmGreuges: ¿Desea insertar greuges?
confirmGreugesMessage: Insertar greuges en la ficha del cliente
</i18n> </i18n>

View File

@ -19,7 +19,23 @@ describe('ClaimAction', () => {
cy.fillRow(firstRow, rowData); cy.fillRow(firstRow, rowData);
}); });
// it('should change destination with 2 rows', () => {
// cy.get('[title="Change destination"]').click();
// const rowData = ['Basura'];
// cy.fillRow()
// });
it('should regularize', () => { it('should regularize', () => {
cy.get('[title="Regularize"]').click(); cy.get('[title="Regularize"]').click();
}); });
it('should remove the line', () => {
cy.fillRow(firstRow, [true]);
cy.removeCard();
cy.clickConfirm();
cy.reload();
cy.get(firstRow).should('not.exist');
});
}); });

View File

@ -88,7 +88,8 @@ Cypress.Commands.add('addCard', () => {
cy.get('.q-page-sticky > div > .q-btn').click(); cy.get('.q-page-sticky > div > .q-btn').click();
}); });
Cypress.Commands.add('clickConfirm', () => { Cypress.Commands.add('clickConfirm', () => {
cy.get('.q-btn--unelevated > .q-btn__content > .block').click(); cy.waitForElement('.q-dialog__inner > .q-card');
cy.get('.q-card__actions > .q-btn--unelevated > .q-btn__content > .block').click();
}); });
Cypress.Commands.add('notificationHas', (selector, text) => { Cypress.Commands.add('notificationHas', (selector, text) => {