fat: #6321 handle events through components

This commit is contained in:
Javier Segarra 2024-06-17 22:32:39 +02:00
parent 20e439f31e
commit cd5a64fcc6
2 changed files with 48 additions and 17 deletions

View File

@ -8,6 +8,7 @@ import { useSession } from 'src/composables/useSession';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import { toCurrency } from 'filters/index'; import { toCurrency } from 'filters/index';
import VnStockValueDisplay from 'src/components/ui/VnStockValueDisplay.vue'; import VnStockValueDisplay from 'src/components/ui/VnStockValueDisplay.vue';
import { useDialogPluginComponent } from 'quasar';
const MATCH_VALUES = [5, 6, 7, 8]; const MATCH_VALUES = [5, 6, 7, 8];
const { t } = useI18n(); const { t } = useI18n();
@ -156,8 +157,7 @@ const columns = computed(() => [
}, },
]); ]);
async function confirm() { async function confirm() {
console.log(''); // console.log('');
quantity.value = 0;
// const response = { address: address.value }; // const response = { address: address.value };
// if (props.promise) { // if (props.promise) {
// isLoading.value = true; // isLoading.value = true;
@ -170,7 +170,18 @@ async function confirm() {
// isLoading.value = false; // isLoading.value = false;
// } // }
// } // }
// onDialogOK(response); // onDialogOK({ data: true });
dialogRef.value.hide({ type: 'refresh', itemProposal: proposalSelected.value[0] });
}
const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent();
// Definir el emisor de eventos
const emit = defineEmits(['dialogClosed']);
function onDialogClose() {
console.log('Dialog has been closed');
// Emitir el evento personalizado
emit('dialogClosed', { data: true });
} }
</script> </script>
<template> <template>
@ -242,6 +253,7 @@ async function confirm() {
auto-load auto-load
:rows-per-page-options="[0]" :rows-per-page-options="[0]"
hide-pagination hide-pagination
hide-bottom
> >
<template #top-row> <template #top-row>
<!-- <QTr> <!-- <QTr>

View File

@ -23,12 +23,7 @@ import { useStateStore } from 'stores/useStateStore';
import { useDialogPluginComponent } from 'quasar'; import { useDialogPluginComponent } from 'quasar';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import ZoneDescriptorProxy from 'pages/Zone/Card/ZoneDescriptorProxy.vue'; import ZoneDescriptorProxy from 'pages/Zone/Card/ZoneDescriptorProxy.vue';
onMounted(() => {
stateStore.rightDrawer = false;
nextTick(() => {
componentIsRendered.value = true;
});
});
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const { t } = useI18n(); const { t } = useI18n();
const URL_KEY = 'Tickets/ItemLack'; const URL_KEY = 'Tickets/ItemLack';
@ -53,7 +48,7 @@ import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import VnRow from 'src/components/ui/VnRow.vue'; import VnRow from 'src/components/ui/VnRow.vue';
const route = useRoute(); const route = useRoute();
const token = session.getTokenMultimedia(); const token = session.getTokenMultimedia();
const itemLack = ref(null);
const originalRowDataCopy = ref(null); const originalRowDataCopy = ref(null);
// const $props = defineProps({ // const $props = defineProps({
// item: { // item: {
@ -68,13 +63,19 @@ const originalRowDataCopy = ref(null);
// }, // },
// }, // },
// }); // });
onMounted(() => {
onUnmounted(() => (stateStore.rightDrawer = true)); stateStore.rightDrawer = false;
nextTick(() => {
componentIsRendered.value = true;
});
});
onUnmounted(() => {
stateStore.rightDrawer = true;
});
const copyOriginalRowsData = (rows) => { const copyOriginalRowsData = (rows) => {
originalRowDataCopy.value = JSON.parse(JSON.stringify(rows)); originalRowDataCopy.value = JSON.parse(JSON.stringify(rows));
}; };
const getInputEvents = (colField, props) => ({ const getInputEvents = (colField, props) => ({
'update:modelValue': () => saveChange(colField, props), 'update:modelValue': () => saveChange(colField, props),
'keyup.enter': () => saveChange(colField, props), 'keyup.enter': () => saveChange(colField, props),
@ -329,6 +330,20 @@ const split = async () => {
}, },
}); });
}; };
const itemProposalEvt = ({ itemProposal }) => {
itemProposalSelected.value = itemProposal;
replaceItem();
};
const itemProposalSelected = ref(null);
const replaceItem = () => {
const rows = handleRows(originalRowDataCopy.value).sort((row) => row.quantity);
for (const ticket of rows) {
if (ticket.quantity > itemProposalSelected.value.available) continue;
ticket.itemFk = itemProposalSelected.value.id;
selectedRows.value.push(ticket.ticketFk);
itemProposalSelected.value.available -= ticket.quantity;
}
};
</script> </script>
<template> <template>
@ -343,6 +358,12 @@ const split = async () => {
@on-fetch="(data) => (item = data)" @on-fetch="(data) => (item = data)"
auto-load auto-load
/> />
<FetchData
:url="`Tickets/itemLack`"
:filter="{ id: entityId }"
@on-fetch="(data) => (itemLack = data)"
auto-load
/>
<!-- <Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()"> <!-- <Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()">
<QBtnGroup push style="column-gap: 1px" <QBtnGroup push style="column-gap: 1px"
><QBtn ><QBtn
@ -423,15 +444,13 @@ const split = async () => {
<div class="full-width q-pa-md"> <div class="full-width q-pa-md">
<VnPaginate <VnPaginate
:data-key="URL_KEY" :data-key="URL_KEY"
:url="`${URL_KEY}/${entityId}/detail`" :url="`${URL_KEY}/${entityId}`"
ref="itemLackForm" ref="itemLackForm"
@on-fetch="copyOriginalRowsData($event)" @on-fetch="copyOriginalRowsData($event)"
auto-load auto-load
> >
<!-- :rows="rows" --> <!-- :rows="rows" -->
<template #body="{ rows }"> <template #body="{ rows }">
{{ item }}
<VnLv class="image"> <VnLv class="image">
<template #label> <template #label>
<QImg <QImg
@ -586,7 +605,7 @@ const split = async () => {
></HandleSplited>--> ></HandleSplited>-->
<ItemProposal <ItemProposal
ref="proposalDialogRef" ref="proposalDialogRef"
@hide="onDialogHide" @hide="itemProposalEvt"
v-model="showProposalDialog" v-model="showProposalDialog"
:item="item" :item="item"
:tickets="selectedRows" :tickets="selectedRows"