0
0
Fork 0

fet: updates

This commit is contained in:
Javier Segarra 2024-09-18 13:10:11 +02:00
parent 53b522c488
commit d0eb1d97ac
8 changed files with 98 additions and 77 deletions

View File

@ -372,9 +372,7 @@ function handleOnDataSaved(_) {
ref="CrudModelRef"
@on-fetch="(...args) => emit('onFetch', ...args)"
:search-url="searchUrl"
:disable-infinite-scroll="
$attrs['disableInfiniteScroll'] ? isTableMode : !disableInfiniteScroll
"
:disable-infinite-scroll="$attrs['disableInfiniteScroll']"
@save-changes="reload"
:has-sub-toolbar="$props.hasSubToolbar ?? isEditable"
:auto-load="hasParams || $attrs['auto-load']"
@ -394,7 +392,7 @@ function handleOnDataSaved(_) {
card-container-class="grid-three"
flat
:style="isTableMode && `max-height: ${tableHeight}`"
:virtual-scroll="!isTableMode"
virtual-scroll
@virtual-scroll="
(event) =>
event.index > rows.length - 2 &&

View File

@ -84,8 +84,12 @@ const styleAttrs = computed(() => {
outlined: true,
rounded: true,
}
: {};
: { eventColor: handleEventColor };
});
const handleEventColor = (date) => {
console.error(date);
return date === Date.now() ? null : 'orange';
};
</script>
<template>
@ -139,6 +143,10 @@ const styleAttrs = computed(() => {
:landscape="true"
:today-btn="true"
:options="$attrs.options"
color="orange"
text-color="black"
dark
bordered
@update:model-value="
(date) => {
formattedDate = date;
@ -158,6 +166,12 @@ const styleAttrs = computed(() => {
.vn-input-date.q-field--outlined.q-field--readonly .q-field__control:before {
border-style: solid;
}
.calendar-event {
background-color: red;
&.--today {
border: 2px solid $info;
}
}
</style>
<i18n>
es:

View File

@ -63,22 +63,18 @@ const columns = computed(() => [
label: t('proposal.available'),
name: 'available',
field: 'available',
columnClass: 'shrink',
columnFilter: {
component: 'input',
type: 'number',
columnClass: 'shrink',
},
component: 'input',
type: 'number',
class: 'shrink',
},
{
...defaultColumnAttrs,
label: t('proposal.difference'),
name: 'difference',
columnFilter: {
component: 'input',
type: 'number',
columnClass: 'shrink',
},
component: 'input',
type: 'number',
class: 'shrink',
style: 'background-color:red;max-width: 75px',
},
{
...defaultColumnAttrs,
@ -92,6 +88,9 @@ const columns = computed(() => [
label: t('proposal.counter'),
name: 'counter',
field: 'counter',
component: 'input',
type: 'number',
class: 'shrink',
},
{
@ -109,22 +108,18 @@ const columns = computed(() => [
label: t('proposal.price2'),
name: 'price2',
field: 'price2',
columnFilter: {
component: 'input',
type: 'number',
class: 'expand',
},
component: 'input',
type: 'number',
class: 'shrink',
},
{
...defaultColumnAttrs,
label: t('proposal.minQuantity'),
name: 'minQuantity',
field: 'minQuantity',
columnFilter: {
component: 'input',
type: 'number',
class: 'expand',
},
component: 'input',
type: 'number',
class: 'shrink',
},
{
...defaultColumnAttrs,
@ -141,11 +136,11 @@ async function confirm() {
newItemFK: proposalSelected.value[0].id,
quantity: quantity.value,
};
const { data } = await axios.post('Sales/replaceItem', params);
emit('refreshData', {
// const { data } = await axios.post('Sales/replaceItem', params);
emit('itemReplaced', {
type: 'refresh',
itemProposal: proposalSelected.value[0],
...data,
...params,
});
proposalSelected.value = [];
popupProxyRef.value.hide();
@ -155,7 +150,7 @@ async function confirm() {
}
// const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent();
const popupProxyRef = ref(null);
const emit = defineEmits(['onDialogClosed', 'refreshData']);
const emit = defineEmits(['onDialogClosed', 'itemReplaced']);
// function onDialogClose() {
// console.log('Dialog has been closed');
@ -270,7 +265,9 @@ const isSelectionAvailable = (data) => {
}}</span>
</template>
<template #column-difference="{ row }">
<VnStockValueDisplay :value="row.id % 2 === 0 ? 10 : -10" />
<QTd style="width: 75px; background-color: red"
><VnStockValueDisplay :value="row.id % 2 === 0 ? 10 : -10"
/></QTd>
</template>
</VnTable>
</div>

View File

@ -3,6 +3,7 @@ import ItemProposal from './ItemProposal.vue';
import VnImg from 'src/components/ui/VnImg.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
const emit = defineEmits(['onDialogClosed', 'itemReplaced']);
const $props = defineProps({
item: {
@ -46,7 +47,10 @@ const $props = defineProps({
<!-- {{ tickets[0].saleFk }} -->
</QCardSection>
<QCardSection class="q-pt-none">
<ItemProposal v-bind="$props"></ItemProposal
<ItemProposal
v-bind="$props"
@item-replaced="(data) => emit('itemReplaced', data)"
></ItemProposal
></QCardSection>
</QCard>
</QPopupProxy>

View File

@ -5,6 +5,7 @@ import FetchData from 'components/FetchData.vue';
import { ref } from 'vue';
import CrudModel from 'components/CrudModel.vue';
import RoadmapAddStopForm from 'pages/Route/Roadmap/RoadmapAddStopForm.vue';
import { QBtn } from 'quasar';
const { t } = useI18n();
const route = useRoute();
@ -65,9 +66,10 @@ const updateDefaultStop = (data) => {
</div>
</QCardSection>
<QCardSection>
<QIcon
name="add"
size="sm"
<QBtn
flat
icon="add"
shortcut="+"
class="cursor-pointer"
color="primary"
@click="roadmapStopsCrudRef.insert()"
@ -75,7 +77,7 @@ const updateDefaultStop = (data) => {
<QTooltip>
{{ t('Add stop') }}
</QTooltip>
</QIcon>
</QBtn>
</QCardSection>
</QCard>
</template>

View File

@ -19,8 +19,8 @@ const sageTransactionTypesOptions = ref([]);
const supplierActivitiesOptions = ref([]);
function handleLocation(data, location) {
const { town, label, provinceFk, countryFk } = location ?? {};
data.postCode = label;
const { town, code, provinceFk, countryFk } = location ?? {};
data.postCode = code;
data.city = town;
data.provinceFk = provinceFk;
data.countryFk = countryFk;

View File

@ -12,7 +12,7 @@ import VnPaginate from 'src/components/ui/VnPaginate.vue';
import FetchData from 'src/components/FetchData.vue';
import { useStateStore } from 'stores/useStateStore';
import { useRoute } from 'vue-router';
import { useArrayData } from 'src/composables/useArrayData';
// import { useArrayData } from 'src/composables/useArrayData';
import VnImg from 'src/components/ui/VnImg.vue';
import TicketLackTable from './TicketLackTable.vue';
import ItemProposalProxy from 'src/pages/Item/components/ItemProposalProxy.vue';
@ -23,6 +23,7 @@ const URL_KEY = 'Tickets/ItemLack';
const editableStates = ref([]);
const stateStore = useStateStore();
const proposalDialogRef = ref();
const tableRef = ref();
const changeStateDialogRef = ref();
const changeQuantityDialogRef = ref();
const showProposalDialog = ref(false);
@ -54,48 +55,49 @@ const reload = async () => {
defineExpose({ reload });
// Función de comparación
function freeFirst({ alertLevel: a }, { alertLevel: b }) {
const DEFAULT = 0;
// Si el estado de 'a' es 'free' y el de 'b' no lo es, 'a' viene primero
if (a === DEFAULT && b !== DEFAULT) {
return -1;
}
// Si el estado de 'b' es 'free' y el de 'a' no lo es, 'b' viene primero
if (b === DEFAULT && a !== DEFAULT) {
return 1;
}
// En cualquier otro caso, no se cambia el orden
return 0;
}
const { store } = useArrayData(URL_KEY);
const handleRows = (rows) => {
// rows.forEach((row) => (row.concept = item.value.name));
rows = rows.sort(freeFirst);
if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0);
return rows;
};
// function freeFirst({ alertLevel: a }, { alertLevel: b }) {
// const DEFAULT = 0;
// // Si el estado de 'a' es 'free' y el de 'b' no lo es, 'a' viene primero
// if (a === DEFAULT && b !== DEFAULT) {
// return -1;
// }
// // Si el estado de 'b' es 'free' y el de 'a' no lo es, 'b' viene primero
// if (b === DEFAULT && a !== DEFAULT) {
// return 1;
// }
// // En cualquier otro caso, no se cambia el orden
// return 0;
// }
// const { store } = useArrayData(URL_KEY);
// const handleRows = (rows) => {
// // rows.forEach((row) => (row.concept = item.value.name));
// rows = rows.sort(freeFirst);
// if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0);
// return rows;
// };
const itemProposalEvt = ({ itemProposal }) => {
itemProposalSelected.value = itemProposal;
replaceItem();
tableRef.value.reload();
// 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;
originalRowDataCopy.value.splice(originalRowDataCopy.value.indexOf(ticket));
ticket.itemFk = itemProposalSelected.value.id;
selectedRows.value.push({ ticketFk: ticket.ticketFk });
itemProposalSelected.value.available -= ticket.quantity;
itemLack.value.lack += ticket.quantity;
const index = store.data.findIndex((t) => t.ticketFk === ticket.ticketFk);
store.data.splice(index, 1);
console.log(ticket);
useArrayData('ItemsGetSimilar').store.data[1].available =
itemProposalSelected.value.available;
}
};
// const replaceItem = () => {
// const rows = handleRows(originalRowDataCopy.value).sort((row) => row.quantity);
// for (const ticket of rows) {
// if (ticket.quantity > itemProposalSelected.value.available) continue;
// originalRowDataCopy.value.splice(originalRowDataCopy.value.indexOf(ticket));
// ticket.itemFk = itemProposalSelected.value.id;
// selectedRows.value.push({ ticketFk: ticket.ticketFk });
// itemProposalSelected.value.available -= ticket.quantity;
// itemLack.value.lack += ticket.quantity;
// const index = store.data.findIndex((t) => t.ticketFk === ticket.ticketFk);
// store.data.splice(index, 1);
// console.log(ticket);
// useArrayData('ItemsGetSimilar').store.data[1].available =
// itemProposalSelected.value.available;
// }
// };
</script>
<template>
@ -178,7 +180,7 @@ const replaceItem = () => {
:item-lack="itemLack"
:replace-action="true"
:tickets="selectedRows"
@refresh-data="itemProposalEvt"
@item-replaced="itemProposalEvt"
></ItemProposalProxy>
<QTooltip bottom anchor="bottom right">
{{ t('itemProposal') }}
@ -216,6 +218,7 @@ const replaceItem = () => {
:label="itemLack.lack"
/>
<QBadge
color="secondary"
class="q-ml-xs q-mt-xs"
v-if="itemLack"
:label="toCurrency(itemLack.lack)"
@ -233,6 +236,7 @@ const replaceItem = () => {
</div>
<TicketLackTable
ref="tableRef"
:filter="{ alertLevel: showFree }"
@update:selection="({ value }, _) => (selectedRows = value)"
></TicketLackTable>

View File

@ -34,6 +34,7 @@ const filterLack = ref({
},
],
where: { alertLevel: 'FREE' },
order: 'ts.alertLevelCODE ASC',
});
const { t } = useI18n();
const URL_KEY = 'Tickets/ItemLack';
@ -225,6 +226,7 @@ watch(selectedRows, () => emit('update:selection', selectedRows));
:create-as-dialog="false"
:use-model="true"
:filter="filterLack"
:order="['ts.alertLevelCode ASC']"
:table="{
'row-key': 'id',
selection: 'multiple',