fet: updates
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-09-17 16:42:22 +02:00
parent 71236c0a01
commit 01cc2d4e75
5 changed files with 66 additions and 25 deletions

View File

@ -403,6 +403,11 @@ function handleOnDataSaved(_) {
<template #top-left v-if="!$props.withoutHeader"> <template #top-left v-if="!$props.withoutHeader">
<slot name="top-left"></slot> <slot name="top-left"></slot>
</template> </template>
<template #body-selection="props">
<slot name="body-selection" v-bind="props">
<QCheckbox class="q-ma-xs" v-model="props.selected"></QCheckbox>
</slot>
</template>
<template #top-right v-if="!$props.withoutHeader"> <template #top-right v-if="!$props.withoutHeader">
<VnVisibleColumn <VnVisibleColumn

View File

@ -1,12 +1,13 @@
<script setup> <script setup>
import { ref, computed, onUnmounted } from 'vue'; import { ref, computed, onUnmounted } from 'vue';
import axios from 'axios';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import FetchedTags from 'components/ui/FetchedTags.vue'; import FetchedTags from 'components/ui/FetchedTags.vue';
import VnImg from 'src/components/ui/VnImg.vue'; import VnImg from 'src/components/ui/VnImg.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'; // import { useDialogPluginComponent } from 'quasar';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
@ -49,6 +50,8 @@ const defaultColumnAttrs = {
align: 'left', align: 'left',
sortable: true, sortable: true,
}; };
const ticket = computed(() => $props.tickets[0]);
const saleFk = computed(() => ticket.value.saleFk);
const statusConditionalValue = (row) => { const statusConditionalValue = (row) => {
const total = MATCH_VALUES.reduce((acc, i) => acc + row[`match${i}`], 0); const total = MATCH_VALUES.reduce((acc, i) => acc + row[`match${i}`], 0);
return total; return total;
@ -132,26 +135,43 @@ const columns = computed(() => [
]); ]);
async function confirm() { async function confirm() {
emit('refreshData', { type: 'refresh', itemProposal: proposalSelected.value[0] }); try {
const params = {
saleFk: saleFk.value,
newItemFK: proposalSelected.value[0].id,
quantity: quantity.value,
};
const { data } = await axios.post('Sales/replaceItem', params);
emit('refreshData', {
type: 'refresh',
itemProposal: proposalSelected.value[0],
...data,
});
proposalSelected.value = []; proposalSelected.value = [];
popupProxyRef.value.hide(); popupProxyRef.value.hide();
} catch (error) {
console.error(error);
} }
const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent(); }
// const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent();
const popupProxyRef = ref(null); const popupProxyRef = ref(null);
const emit = defineEmits(['dialogClosed', 'refreshData']); const emit = defineEmits(['onDialogClosed', 'refreshData']);
function onDialogClose() { // function onDialogClose() {
console.log('Dialog has been closed'); // console.log('Dialog has been closed');
// Emitir el evento personalizado // // Emitir el evento personalizado
emit('dialogClosed', { data: true }); // emit('onDialogClosed', { data: true });
} // }
onUnmounted(() => {}); onUnmounted(() => {});
function handleSelection(value, evt) { function handleSelection(value, _) {
quantity.value = value.available; quantity.value = value.available;
} }
const isSelectionAvailable = ({ row }) => { const isSelectionAvailable = (data) => {
if (!data?.row) return false;
const { row } = data;
return $props.replaceAction && row.available >= $props.itemLack.lack * -1; return $props.replaceAction && row.available >= $props.itemLack.lack * -1;
}; };
// watch(proposalSelected, ({ available }) => (quantity.value = available));
</script> </script>
<template> <template>
<div style="min-width: 65vw"> <div style="min-width: 65vw">
@ -179,7 +199,6 @@ const isSelectionAvailable = ({ row }) => {
}" }"
> >
<template #top-left> <template #top-left>
{{ proposalSelected }}
<div v-if="$props.replaceAction" style="display: flex"> <div v-if="$props.replaceAction" style="display: flex">
<QBtn <QBtn
:label="t('globals.replace')" :label="t('globals.replace')"
@ -201,13 +220,13 @@ const isSelectionAvailable = ({ row }) => {
class="q-ml-xs" class="q-ml-xs"
/></div /></div
></template> ></template>
<template #body-selection="{ data }"> <template #body-selection="props">
<QCheckbox <QCheckbox
class="q-ma-xs" class="q-ma-xs"
flat flat
v-if="isSelectionAvailable(data)" v-if="isSelectionAvailable(props)"
v-model="data.selected" v-model="props.selected"
@update:model-value="(evt, _) => handleSelection(data.row, null)" @update:model-value="(evt, _) => handleSelection(props.row, null)"
> >
</QCheckbox> </QCheckbox>
</template> </template>

View File

@ -42,6 +42,8 @@ const $props = defineProps({
<ItemDescriptorProxy :id="item.id" /> <ItemDescriptorProxy :id="item.id" />
</QBtn> </QBtn>
<FetchedTags :item="item" /> <FetchedTags :item="item" />
<!-- {{ tickets[0].saleFk }} -->
</QCardSection> </QCardSection>
<QCardSection class="q-pt-none"> <QCardSection class="q-pt-none">
<ItemProposal v-bind="$props"></ItemProposal <ItemProposal v-bind="$props"></ItemProposal

View File

@ -69,7 +69,7 @@ function freeFirst({ alertLevel: a }, { alertLevel: b }) {
} }
const { store } = useArrayData(URL_KEY); const { store } = useArrayData(URL_KEY);
const handleRows = (rows) => { const handleRows = (rows) => {
rows.forEach((row) => (row.concept = item.value.name)); // rows.forEach((row) => (row.concept = item.value.name));
rows = rows.sort(freeFirst); rows = rows.sort(freeFirst);
if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0); if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0);
return rows; return rows;
@ -152,7 +152,11 @@ const replaceItem = () => {
> >
</ChangeQuantityDialog> </ChangeQuantityDialog>
</TicketMassiveUpdate> </TicketMassiveUpdate>
<QBtn color="primary" icon="vn:splitline"> <QBtn
color="primary"
icon="vn:splitline"
:disable="selectedRows.length < 1"
>
<QTooltip>{{ t('ticketSale.transferLines') }}</QTooltip> <QTooltip>{{ t('ticketSale.transferLines') }}</QTooltip>
<TicketTransfer <TicketTransfer
class="full-width" class="full-width"
@ -162,7 +166,11 @@ const replaceItem = () => {
}" }"
></TicketTransfer> ></TicketTransfer>
</QBtn> </QBtn>
<QBtn color="primary" @click="showProposalDialog = true"> <QBtn
color="primary"
@click="showProposalDialog = true"
:disable="selectedRows.length < 1"
>
<QIcon name="import_export" class="rotate-90"></QIcon> <QIcon name="import_export" class="rotate-90"></QIcon>
<ItemProposalProxy <ItemProposalProxy
ref="proposalDialogRef" ref="proposalDialogRef"
@ -223,7 +231,11 @@ const replaceItem = () => {
</template> </template>
</VnPaginate> </VnPaginate>
</div> </div>
<TicketLackTable :filter="{ alertLevel: showFree }"></TicketLackTable>
<TicketLackTable
:filter="{ alertLevel: showFree }"
@update:selection="({ value }, _) => (selectedRows = value)"
></TicketLackTable>
</QPage> </QPage>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -10,7 +10,7 @@ import { useRoute } from 'vue-router';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import TicketDescriptorProxy from '../Card/TicketDescriptorProxy.vue'; import TicketDescriptorProxy from '../Card/TicketDescriptorProxy.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
const rowsSelected = ref([]); const selectedRows = ref([]);
const $props = defineProps({ const $props = defineProps({
filter: { filter: {
type: Object, type: Object,
@ -33,7 +33,7 @@ const filterLack = ref({
}, },
}, },
], ],
where: { alertLevel: 'FRasdEE' }, where: { alertLevel: 'FREE' },
}); });
const { t } = useI18n(); const { t } = useI18n();
const URL_KEY = 'Tickets/ItemLack'; const URL_KEY = 'Tickets/ItemLack';
@ -178,11 +178,14 @@ const reload = async () => {
itemLackForm.value.fetch(); itemLackForm.value.fetch();
}; };
defineExpose({ reload }); defineExpose({ reload });
const emit = defineEmits(['update:selection']);
const tableRef = ref(null); const tableRef = ref(null);
watch(selectedRows, () => emit('update:selection', selectedRows));
</script> </script>
<template> <template>
{{ selectedRows }}
<FetchData <FetchData
url="States/editableStates" url="States/editableStates"
@on-fetch="(data) => (editableStates = data)" @on-fetch="(data) => (editableStates = data)"
@ -230,7 +233,7 @@ const tableRef = ref(null);
:is-editable="true" :is-editable="true"
:row-click="false" :row-click="false"
:right-search="false" :right-search="false"
v-model:selected="rowsSelected" v-model:selected="selectedRows"
> >
<template #column-quantity="props"> <template #column-quantity="props">
<VnInputNumber <VnInputNumber