feat: #7449 added new button on claimLines, prevented claimAction to import lines with 0 quantity #1550
|
@ -347,8 +347,8 @@ watch(formUrl, async () => {
|
|||
<QBtnDropdown
|
||||
v-if="$props.goTo && $props.defaultSave"
|
||||
@click="onSubmitAndGo"
|
||||
:label="tMobile('globals.saveAndContinue')"
|
||||
:title="t('globals.saveAndContinue')"
|
||||
:label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:disable="!hasChanges"
|
||||
color="primary"
|
||||
icon="save"
|
||||
|
@ -397,4 +397,4 @@ watch(formUrl, async () => {
|
|||
:label="t && t('globals.pleaseWait')"
|
||||
color="primary"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
|
@ -380,8 +380,8 @@ defineExpose({
|
|||
data-cy="saveAndContinueDefaultBtn"
|
||||
v-if="$props.goTo"
|
||||
@click="saveAndGo"
|
||||
:label="tMobile('globals.saveAndContinue')"
|
||||
:title="t('globals.saveAndContinue')"
|
||||
:label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:disable="!hasChanges"
|
||||
color="primary"
|
||||
icon="save"
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { ref, reactive, useAttrs, computed } from 'vue';
|
||||
import { onBeforeRouteLeave } from 'vue-router';
|
||||
import { ref, reactive, useAttrs, computed, onMounted, nextTick, } from 'vue';
|
||||
import { onBeforeRouteLeave , useRouter, useRoute} from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import { toDateHourMin } from 'src/filters';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
|
@ -33,10 +34,15 @@ const $props = defineProps({
|
|||
addNote: { type: Boolean, default: false },
|
||||
selectType: { type: Boolean, default: false },
|
||||
justInput: { type: Boolean, default: false },
|
||||
goTo: { type: String, default: '', },
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const stateStore = useStateStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const componentIsRendered = ref(false);
|
||||
const newNote = reactive({ text: null, observationTypeFk: null });
|
||||
const observationTypes = ref([]);
|
||||
const vnPaginateRef = ref();
|
||||
|
@ -45,6 +51,7 @@ const defaultObservationType = computed(() =>
|
|||
observationTypes.value.find(ot => ot.code === 'salesPerson')?.id
|
||||
);
|
||||
|
||||
let savedNote = false;
|
||||
let originalText;
|
||||
|
||||
function handleClick(e) {
|
||||
|
@ -68,6 +75,7 @@ async function insert() {
|
|||
};
|
||||
await axios.post($props.url, newBody);
|
||||
await vnPaginateRef.value.fetch();
|
||||
savedNote = true;
|
||||
}
|
||||
|
||||
function confirmAndUpdate() {
|
||||
|
@ -129,8 +137,29 @@ const handleObservationTypes = (data) => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => (componentIsRendered.value = true));
|
||||
});
|
||||
|
||||
async function saveAndGo() {
|
||||
savedNote = false;
|
||||
await insert();
|
||||
await savedNote;
|
||||
router.push({ path: $props.goTo });
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && componentIsRendered && $props.goTo && !route.path.includes('summary')">
|
||||
<QBtn
|
||||
:label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
color="primary"
|
||||
icon="save"
|
||||
@click="saveAndGo"
|
||||
data-cy="save-continue-note-button"
|
||||
/>
|
||||
</Teleport>
|
||||
<FetchData
|
||||
v-if="selectType"
|
||||
url="ObservationTypes"
|
||||
|
@ -176,7 +205,7 @@ const handleObservationTypes = (data) => {
|
|||
:required="'required' in originalAttrs"
|
||||
clearable
|
||||
>
|
||||
<template #append>
|
||||
<template #append v-if="!$props.goTo">
|
||||
<QBtn
|
||||
:title="t('Save (Enter)')"
|
||||
icon="save"
|
||||
|
|
|
@ -24,13 +24,14 @@ globals:
|
|||
dataDeleted: Data deleted
|
||||
delete: Delete
|
||||
search: Search
|
||||
lines: Lines
|
||||
changes: Changes
|
||||
dataCreated: Data created
|
||||
add: Add
|
||||
create: Create
|
||||
edit: Edit
|
||||
save: Save
|
||||
saveAndContinue: Save and continue
|
||||
saveAndContinue: Save and go to
|
||||
remove: Remove
|
||||
reset: Reset
|
||||
close: Close
|
||||
|
@ -107,6 +108,8 @@ globals:
|
|||
from: From
|
||||
to: To
|
||||
notes: Notes
|
||||
photos: Photos
|
||||
due-day: Due day
|
||||
refresh: Refresh
|
||||
item: Item
|
||||
ticket: Ticket
|
||||
|
@ -394,6 +397,7 @@ errors:
|
|||
updateUserConfig: Error updating user config
|
||||
tokenConfig: Error fetching token config
|
||||
writeRequest: The requested operation could not be completed
|
||||
claimBeginningQuantity: Cannot import a line with a claimed quantity of 0
|
||||
login:
|
||||
title: Login
|
||||
username: Username
|
||||
|
|
|
@ -25,12 +25,13 @@ globals:
|
|||
openDetail: Ver detalle
|
||||
delete: Eliminar
|
||||
search: Buscar
|
||||
lines: Lineas
|
||||
changes: Cambios
|
||||
add: Añadir
|
||||
create: Crear
|
||||
edit: Modificar
|
||||
save: Guardar
|
||||
saveAndContinue: Guardar y continuar
|
||||
saveAndContinue: Guardar e ir a
|
||||
remove: Eliminar
|
||||
reset: Restaurar
|
||||
close: Cerrar
|
||||
|
@ -111,6 +112,8 @@ globals:
|
|||
from: Desde
|
||||
to: Hasta
|
||||
notes: Notas
|
||||
photos: Fotos
|
||||
due-day: Vencimiento
|
||||
refresh: Actualizar
|
||||
item: Artículo
|
||||
ticket: Ticket
|
||||
|
@ -390,6 +393,7 @@ errors:
|
|||
updateUserConfig: Error al actualizar la configuración de usuario
|
||||
tokenConfig: Error al obtener configuración de token
|
||||
writeRequest: No se pudo completar la operación solicitada
|
||||
claimBeginningQuantity: No se puede importar una linea sin una cantidad reclamada
|
||||
login:
|
||||
title: Inicio de sesión
|
||||
username: Nombre de usuario
|
||||
|
|
|
@ -13,8 +13,10 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
|||
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const quasar = useQuasar();
|
||||
const route = useRoute();
|
||||
const claim = ref(null);
|
||||
|
@ -176,12 +178,17 @@ async function save(data) {
|
|||
}
|
||||
|
||||
async function importToNewRefundTicket() {
|
||||
await post(`ClaimBeginnings/${claimId}/importToNewRefundTicket`);
|
||||
await claimActionsForm.value.reload();
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
try{
|
||||
await post(`ClaimBeginnings/${claimId}/importToNewRefundTicket`);
|
||||
await claimActionsForm.value.reload();
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
} catch (error) {
|
||||
const errorMessage = error.response?.data?.error?.message;
|
||||
notify( t(errorMessage), 'negative' );
|
||||
}
|
||||
}
|
||||
|
||||
async function post(query, params) {
|
||||
|
|
|
@ -33,6 +33,7 @@ function onBeforeSave(formData, originalData) {
|
|||
<FetchData url="ClaimStates" @on-fetch="setClaimStates" auto-load />
|
||||
<FormModel
|
||||
model="Claim"
|
||||
:go-to="`/claim/${route.params.id}/notes`"
|
||||
:url-update="`Claims/updateClaim/${route.params.id}`"
|
||||
:mapper="onBeforeSave"
|
||||
auto-load
|
||||
|
|
|
@ -78,6 +78,8 @@ const columns = computed(() => [
|
|||
label: t('Quantity'),
|
||||
field: ({ sale }) => sale.quantity,
|
||||
sortable: true,
|
||||
style: 'padding-right: 20px;',
|
||||
headerStyle: 'padding-right: 20px;'
|
||||
},
|
||||
{
|
||||
name: 'claimed',
|
||||
|
@ -110,6 +112,8 @@ const columns = computed(() => [
|
|||
field: ({ sale }) => totalRow(sale),
|
||||
format: (value) => toCurrency(value),
|
||||
sortable: true,
|
||||
style: 'padding-right: 20px;',
|
||||
headerStyle: 'padding-right: 20px;'
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -152,12 +156,33 @@ function showImportDialog() {
|
|||
.onOk(() => claimLinesForm.value.reload());
|
||||
}
|
||||
|
||||
async function saveWhenHasChanges() {
|
||||
if (claimLinesForm.value.getChanges().updates) {
|
||||
await claimLinesForm.value.onSubmit();
|
||||
onFetch(claimLinesForm.value.formData);
|
||||
function fillClaimedQuantities() {
|
||||
const formData = claimLinesForm.value.formData;
|
||||
let hasChanges = false;
|
||||
|
||||
const selectedRows = formData.filter(row => selected.value.includes(row));
|
||||
|
||||
for (const row of selectedRows) {
|
||||
if (row.quantity === 0 || row.quantity === null) {
|
||||
row.quantity = row.sale.quantity;
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasChanges) {
|
||||
quasar.notify({
|
||||
message: t('Cantidades rellenadas automáticamente'),
|
||||
type: 'positive',
|
||||
});
|
||||
} else {
|
||||
quasar.notify({
|
||||
message: t('No hay cantidades para rellenar'),
|
||||
type: 'info',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#st-data" v-if="stateStore.isSubToolbarShown()">
|
||||
|
@ -185,15 +210,16 @@ async function saveWhenHasChanges() {
|
|||
auto-load
|
||||
/>
|
||||
<div class="q-pa-md">
|
||||
|
||||
<CrudModel
|
||||
data-key="ClaimLines"
|
||||
ref="claimLinesForm"
|
||||
:go-to="`photos`"
|
||||
:url="`Claims/${route.params.id}/lines`"
|
||||
save-url="ClaimBeginnings/crud"
|
||||
:user-filter="linesFilter"
|
||||
@on-fetch="onFetch"
|
||||
v-model:selected="selected"
|
||||
:default-save="false"
|
||||
:default-reset="false"
|
||||
auto-load
|
||||
:limit="0"
|
||||
|
@ -214,8 +240,7 @@ async function saveWhenHasChanges() {
|
|||
v-model.number="row.quantity"
|
||||
type="number"
|
||||
dense
|
||||
@keyup.enter="saveWhenHasChanges()"
|
||||
@blur="saveWhenHasChanges()"
|
||||
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
|
@ -272,10 +297,7 @@ async function saveWhenHasChanges() {
|
|||
type="number"
|
||||
dense
|
||||
autofocus
|
||||
@keyup.enter="
|
||||
saveWhenHasChanges()
|
||||
"
|
||||
@blur="saveWhenHasChanges()"
|
||||
|
||||
/>
|
||||
</QItemLabel>
|
||||
</template>
|
||||
|
@ -313,6 +335,18 @@ async function saveWhenHasChanges() {
|
|||
</template>
|
||||
</QTable>
|
||||
</template>
|
||||
<template #moreBeforeActions>
|
||||
<QBtn
|
||||
color="primary"
|
||||
text-color="white"
|
||||
:unelevated="true"
|
||||
:label="t('Rellenar cantidades')"
|
||||
:title="t('Rellenar cantidades')"
|
||||
icon="auto_fix_high"
|
||||
:disabled="!selected.length"
|
||||
@click="fillClaimedQuantities"
|
||||
/>
|
||||
</template>
|
||||
</CrudModel>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -35,9 +35,11 @@ const body = {
|
|||
workerFk: user.value.id,
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnNotes
|
||||
url="claimObservations"
|
||||
:go-to="`/claim/${route.params.id}/lines`"
|
||||
:add-note="$props.addNote"
|
||||
:user-filter="claimFilter"
|
||||
:filter="{ where: { claimFk: claimId } }"
|
||||
|
|
|
@ -8,9 +8,9 @@ const claimCard = {
|
|||
meta: {
|
||||
menu: [
|
||||
'ClaimBasicData',
|
||||
'ClaimNotes',
|
||||
'ClaimLines',
|
||||
'ClaimPhotos',
|
||||
'ClaimNotes',
|
||||
'ClaimDevelopment',
|
||||
'ClaimAction',
|
||||
'ClaimLog',
|
||||
|
@ -36,6 +36,15 @@ const claimCard = {
|
|||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimBasicData.vue'),
|
||||
},
|
||||
{
|
||||
path: 'notes',
|
||||
name: 'ClaimNotes',
|
||||
meta: {
|
||||
title: 'notes',
|
||||
icon: 'draft',
|
||||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimNotes.vue'),
|
||||
},
|
||||
{
|
||||
path: 'lines',
|
||||
name: 'ClaimLines',
|
||||
|
@ -54,15 +63,6 @@ const claimCard = {
|
|||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimPhoto.vue'),
|
||||
},
|
||||
{
|
||||
path: 'notes',
|
||||
name: 'ClaimNotes',
|
||||
meta: {
|
||||
title: 'notes',
|
||||
icon: 'draft',
|
||||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimNotes.vue'),
|
||||
},
|
||||
{
|
||||
path: 'development',
|
||||
name: 'ClaimDevelopment',
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('ClaimLines', () => {
|
||||
const claimId = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080);
|
||||
cy.login('developer');
|
||||
cy.visit(`/#/claim/${claimId}/lines`);
|
||||
});
|
||||
|
||||
it('should add new line', () => {
|
||||
cy.get('.q-page-sticky > div > .q-btn').click();
|
||||
cy.get('.q-card > .q-table__container > .q-table__middle > .q-table > thead > tr > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg').click();
|
||||
cy.get('.q-card__actions > .q-btn--unelevated').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Lines added to claim');
|
||||
})
|
||||
|
||||
it('should autofill claimed quantity if 0 or null', () => {
|
||||
cy.get('thead > tr > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg').click();
|
||||
cy.get('.q-btn--unelevated').click();
|
||||
cy.checkNotification('Cantidades rellenadas automáticamente');
|
||||
cy.get('.q-btn--unelevated').click();
|
||||
cy.checkNotification('No hay cantidades para rellenar');
|
||||
})
|
||||
});
|
|
@ -1,5 +1,4 @@
|
|||
describe('ClaimNotes', () => {
|
||||
const saveBtn = '.q-field__append > .q-btn > .q-btn__content > .q-icon';
|
||||
const firstNote = '.q-infinite-scroll :nth-child(1) > .q-card__section--vert';
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
|
@ -11,9 +10,9 @@ describe('ClaimNotes', () => {
|
|||
cy.get('.q-textarea')
|
||||
.should('be.visible')
|
||||
.should('not.be.disabled')
|
||||
.type(message);
|
||||
.type(message, "{{enter}}");
|
||||
|
||||
cy.get(saveBtn).click();
|
||||
cy.dataCy("save-continue-note-button").click();
|
||||
cy.get(firstNote).should('have.text', message);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue