feat: #6321 remove row

This commit is contained in:
Javier Segarra 2024-06-19 13:18:32 +02:00
parent 185160aeba
commit 86cfbace72
2 changed files with 125 additions and 94 deletions

View File

@ -14,7 +14,7 @@ const MATCH_VALUES = [5, 6, 7, 8];
const { t } = useI18n(); const { t } = useI18n();
const session = useSession(); const session = useSession();
const primaryColor = 'red'; const primaryColor = '#f5b351';
const colorSpacer = '#ecf0f1'; const colorSpacer = '#ecf0f1';
const compatibilityItem = (value) => `${100 * (value / MATCH_VALUES.length)}%`; const compatibilityItem = (value) => `${100 * (value / MATCH_VALUES.length)}%`;
const gradientStyle = (value) => const gradientStyle = (value) =>
@ -156,6 +156,7 @@ const columns = computed(() => [
field: 'located', field: 'located',
}, },
]); ]);
async function confirm() { async function confirm() {
// console.log(''); // console.log('');
// const response = { address: address.value }; // const response = { address: address.value };
@ -171,12 +172,12 @@ async function confirm() {
// } // }
// } // }
// onDialogOK({ data: true }); // onDialogOK({ data: true });
dialogRef.value.hide({ type: 'refresh', itemProposal: proposalSelected.value[0] }); emit('refreshData', { type: 'refresh', itemProposal: proposalSelected.value[0] });
} }
const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent(); const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent();
// Definir el emisor de eventos // Definir el emisor de eventos
const emit = defineEmits(['dialogClosed']); const emit = defineEmits(['dialogClosed', 'refreshData']);
function onDialogClose() { function onDialogClose() {
console.log('Dialog has been closed'); console.log('Dialog has been closed');

View File

@ -47,6 +47,7 @@ const session = useSession();
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import VnRow from 'src/components/ui/VnRow.vue'; import VnRow from 'src/components/ui/VnRow.vue';
import { useArrayData } from 'src/composables/useArrayData';
const route = useRoute(); const route = useRoute();
const token = session.getTokenMultimedia(); const token = session.getTokenMultimedia();
const itemLack = ref(null); const itemLack = ref(null);
@ -308,6 +309,7 @@ function freeFirst({ alertLevel: a }, { alertLevel: b }) {
// En cualquier otro caso, no se cambia el orden // En cualquier otro caso, no se cambia el orden
return 0; return 0;
} }
const { store } = useArrayData(URL_KEY);
const handleRows = (rows) => { const handleRows = (rows) => {
if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0); if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0);
return rows.sort(freeFirst); return rows.sort(freeFirst);
@ -335,16 +337,23 @@ const itemProposalEvt = ({ itemProposal }) => {
itemProposalSelected.value = itemProposal; itemProposalSelected.value = itemProposal;
replaceItem(); replaceItem();
}; };
const tableRef = ref(null);
const itemProposalSelected = ref(null); const itemProposalSelected = ref(null);
const replaceItem = () => { const replaceItem = () => {
const rows = handleRows(originalRowDataCopy.value).sort((row) => row.quantity); const rows = handleRows(originalRowDataCopy.value).sort((row) => row.quantity);
for (const ticket of rows) { for (const ticket of rows) {
if (ticket.quantity > itemProposalSelected.value.available) continue; if (ticket.quantity > itemProposalSelected.value.available) continue;
originalRowDataCopy.value.splice(originalRowDataCopy.value.indexOf(ticket));
ticket.itemFk = itemProposalSelected.value.id; ticket.itemFk = itemProposalSelected.value.id;
ticket.quantity *= 2; ticket.quantity *= 2;
selectedRows.value.push({ ticketFk: ticket.ticketFk }); selectedRows.value.push({ ticketFk: ticket.ticketFk });
itemProposalSelected.value.available -= ticket.quantity; itemProposalSelected.value.available -= ticket.quantity;
itemLack.value.lack += ticket.quantity; itemLack.value.lack += ticket.quantity;
// tableRef.value.rows.pop();
console.log(store.data);
const index = store.data.findIndex((t) => t.ticketFk === ticket.ticketFk);
store.data.splice(index, 1);
console.log(ticket);
} }
}; };
</script> </script>
@ -442,6 +451,7 @@ const replaceItem = () => {
ref="proposalDialogRef" ref="proposalDialogRef"
:item="item" :item="item"
:tickets="selectedRows" :tickets="selectedRows"
@refresh-data="itemProposalEvt"
></ItemProposal> ></ItemProposal>
<QTooltip bottom anchor="bottom right"> <QTooltip bottom anchor="bottom right">
{{ t('itemProposal') }} {{ t('itemProposal') }}
@ -459,7 +469,7 @@ const replaceItem = () => {
:data-key="URL_KEY" :data-key="URL_KEY"
:url="`${URL_KEY}/${entityId}`" :url="`${URL_KEY}/${entityId}`"
ref="itemLackForm" ref="itemLackForm"
@on-fetch="copyOriginalRowsData($event)" @on-fetch="copyOriginalRowsData"
auto-load auto-load
> >
<!-- :rows="rows" --> <!-- :rows="rows" -->
@ -501,6 +511,7 @@ const replaceItem = () => {
<QIcon name="arrow_right" size="lg" /> <QIcon name="arrow_right" size="lg" />
<VnSelectDialog action-icon="call_split"></VnSelectDialog <VnSelectDialog action-icon="call_split"></VnSelectDialog
></VnRow> --> ></VnRow> -->
<TransitionGroup name="list" tag="div">
<QTable <QTable
ref="tableRef" ref="tableRef"
:columns="columns" :columns="columns"
@ -527,13 +538,18 @@ const replaceItem = () => {
</QTd> </QTd>
<QTd v-for="col in props.cols" :key="col.name"> <QTd v-for="col in props.cols" :key="col.name">
<template <template
v-if="tableColumnComponents[col.name]?.component" v-if="
tableColumnComponents[col.name]?.component
"
> >
<component <component
:is=" :is="
tableColumnComponents[col.name].component tableColumnComponents[col.name]
.component
"
v-bind="
tableColumnComponents[col.name].props
" "
v-bind="tableColumnComponents[col.name].props"
v-model="props.row[col.field]" v-model="props.row[col.field]"
v-on=" v-on="
tableColumnComponents[col.name].event( tableColumnComponents[col.name].event(
@ -541,7 +557,9 @@ const replaceItem = () => {
props props
) )
" "
:style="tableColumnComponents[col.name].style" :style="
tableColumnComponents[col.name].style
"
> >
<template v-if="isComponentVn(col)">{{ <template v-if="isComponentVn(col)">{{
col.value col.value
@ -600,6 +618,7 @@ const replaceItem = () => {
</QTr> </QTr>
</template> </template>
</QTable> </QTable>
</TransitionGroup>
</template> </template>
</VnPaginate></div </VnPaginate></div
></QPage> ></QPage>
@ -611,3 +630,14 @@ const replaceItem = () => {
:tickets="resultSplit" :tickets="resultSplit"
></HandleSplited>--> ></HandleSplited>-->
</template> </template>
<style lang="scss" scoped>
.list-enter-active,
.list-leave-active {
transition: all 1s ease;
}
.list-enter-from,
.list-leave-to {
opacity: 0;
background-color: $primary;
}
</style>