feat: fix minor bugs
gitea/salix-front/pipeline/pr-master This commit is unstable Details

This commit is contained in:
Javier Segarra 2025-04-11 15:04:24 +02:00
parent b32a889dfe
commit 510eab8af0
9 changed files with 65 additions and 37 deletions

View File

@ -28,6 +28,7 @@ const props = defineProps({
onMounted(() => { onMounted(() => {
restoreTicket(); restoreTicket();
hasDocuware();
}); });
watch( watch(

View File

@ -768,6 +768,7 @@ watch(
v-model="row.itemFk" v-model="row.itemFk"
:use-like="false" :use-like="false"
@update:model-value="changeItem(row)" @update:model-value="changeItem(row)"
autofocus
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">

View File

@ -25,7 +25,13 @@ const splitSelectedRows = async () => {
</script> </script>
<template> <template>
<VnInputDate class="q-mr-sm" :label="$t('New date')" v-model="splitDate" clearable /> <VnInputDate
class="q-mr-sm"
:label="$t('New date')"
v-model="splitDate"
clearable
autofocus
/>
<QBtn class="q-mr-sm" color="primary" label="Split" @click="splitSelectedRows"></QBtn> <QBtn class="q-mr-sm" color="primary" label="Split" @click="splitSelectedRows"></QBtn>
</template> </template>
<style lang="scss"> <style lang="scss">

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import TicketTransfer from './TicketTransfer.vue'; import TicketTransfer from './TicketTransfer.vue';
import Split from './TicketSplit.vue'; import TicketSplit from './TicketSplit.vue';
const emit = defineEmits(['ticketTransferred']); const emit = defineEmits(['ticketTransferred']);
const $props = defineProps({ const $props = defineProps({
@ -35,7 +35,7 @@ const transferRef = ref(null);
<template> <template>
<QPopupProxy ref="popupProxyRef" data-cy="ticketTransferPopup"> <QPopupProxy ref="popupProxyRef" data-cy="ticketTransferPopup">
<div class="flex row items-center q-ma-lg" v-if="$props.split"> <div class="flex row items-center q-ma-lg" v-if="$props.split">
<Split <TicketSplit
ref="splitRef" ref="splitRef"
@splitSelectedRows="splitSelectedRows" @splitSelectedRows="splitSelectedRows"
:ticket="$props.ticket" :ticket="$props.ticket"

View File

@ -124,7 +124,7 @@ const showItemProposal = () => {
<QBtn <QBtn
color="primary" color="primary"
@click="showItemProposal" @click="showItemProposal"
:disable="selectedRows.length < 1" :disable="!(selectedRows.length === 1)"
data-cy="itemProposal" data-cy="itemProposal"
> >
<QIcon name="import_export" class="rotate-90" /> <QIcon name="import_export" class="rotate-90" />
@ -135,7 +135,7 @@ const showItemProposal = () => {
<VnPopupProxy <VnPopupProxy
data-cy="changeItem" data-cy="changeItem"
icon="sync" icon="sync"
:disable="selectedRows.length < 1" :disable="!(selectedRows.length === 1)"
:tooltip="t('negative.detail.modal.changeItem.title')" :tooltip="t('negative.detail.modal.changeItem.title')"
> >
<template #extraIcon> <QIcon name="vn:item" /> </template> <template #extraIcon> <QIcon name="vn:item" /> </template>
@ -149,7 +149,7 @@ const showItemProposal = () => {
<VnPopupProxy <VnPopupProxy
data-cy="changeState" data-cy="changeState"
icon="sync" icon="sync"
:disable="selectedRows.length < 1" :disable="!(selectedRows.length === 1)"
:tooltip="t('negative.detail.modal.changeState.title')" :tooltip="t('negative.detail.modal.changeState.title')"
> >
<template #extraIcon> <QIcon name="vn:eye" /> </template> <template #extraIcon> <QIcon name="vn:eye" /> </template>
@ -163,7 +163,7 @@ const showItemProposal = () => {
<VnPopupProxy <VnPopupProxy
data-cy="changeQuantity" data-cy="changeQuantity"
icon="sync" icon="sync"
:disable="selectedRows.length < 1" :disable="!(selectedRows.length === 1)"
:tooltip="t('negative.detail.modal.changeQuantity.title')" :tooltip="t('negative.detail.modal.changeQuantity.title')"
@click="showChangeQuantityDialog = true" @click="showChangeQuantityDialog = true"
> >

View File

@ -48,6 +48,7 @@ const updateItem = async () => {
option-label="name" option-label="name"
option-value="id" option-value="id"
v-model="newItem" v-model="newItem"
autofocus
> >
</VnSelect> </VnSelect>
</QCardSection> </QCardSection>

View File

@ -44,6 +44,7 @@ const updateQuantity = async () => {
:min="0" :min="0"
:label="$t('negative.detail.modal.changeQuantity.placeholder')" :label="$t('negative.detail.modal.changeQuantity.placeholder')"
v-model="newQuantity" v-model="newQuantity"
autofocus
/> />
</QCardSection> </QCardSection>
<QCardActions align="right"> <QCardActions align="right">

View File

@ -50,6 +50,7 @@ const updateState = async () => {
:options="editableStates" :options="editableStates"
option-label="name" option-label="name"
option-value="code" option-value="code"
autofocus
/> />
</QCardSection> </QCardSection>
<QCardActions align="right"> <QCardActions align="right">

View File

@ -4,36 +4,53 @@ import { useI18n } from 'vue-i18n';
export function displayResults() { export function displayResults() {
const { t } = useI18n(); const { t } = useI18n();
const notifyResults = (results, key, path = 'sale') =>
results.forEach((result, index) => { const createSuccessNotification = (id, path) => {
if (result.status === 'fulfilled') { Notify.create({
const data = JSON.parse(result.value.config.data); type: 'positive',
if (result.value.data.status === 'noSplit') { message: t('globals.dataSaved'),
Notify.create({ actions: [
type: 'warning', {
message: `Ticket ${data[key]}: ${t('negative.split.noSplit')}`, label: t('globals.openDetail'),
}); color: 'white',
} else handler: () => useOpenURL(`#/ticket/${id}/${path}`),
Notify.create({ },
type: 'positive', ],
message: t('globals.dataSaved'),
actions: [
{
label: t('globals.openDetail'),
color: 'white',
handler: () => {
useOpenURL(`#/ticket/${data[key]}/${path}`);
},
},
],
});
} else {
const data = JSON.parse(result.reason.config.data);
Notify.create({
type: 'negative',
message: `Ticket ${data[key]}: ${result.reason.response?.data?.error?.message ?? result.reason.message}`,
});
}
}); });
};
const handleResult = (result, key, path) => {
if (result.status !== 'fulfilled') {
const data = JSON.parse(result.reason.config.data);
const error =
result.reason.response?.data?.error?.message ?? result.reason.message;
Notify.create({
type: 'negative',
message: `Ticket ${data[key]}: ${error}`,
});
return;
}
const data = JSON.parse(result.value.config.data);
let id = data[key];
if (result.value.data.status === 'noSplit') {
Notify.create({
type: 'warning',
message: `Ticket ${id}: ${t('negative.split.noSplit')}`,
});
return;
}
if (result.value.data.status === 'split') {
id = result.value.data.newTicket;
}
createSuccessNotification(id, path);
};
const notifyResults = (results, key, path = 'sale') =>
results.forEach((result) => handleResult(result, key, path));
return { notifyResults }; return { notifyResults };
} }