8315-devToTest #1094
|
@ -75,19 +75,17 @@ watch(
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
const onItemSaved = (updatedItem) => {
|
// const onItemSaved = (updatedItem) => {
|
||||||
requestAnimationFrame(() => {
|
// console.error(stateStore);
|
||||||
scrollToItem(updatedItem.items[0].itemFk);
|
// };
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const scrollToItem = async (id) => {
|
// const scrollToItem = async (id) => {
|
||||||
const element = itemRefs.value[id]?.$el;
|
// const element = itemRefs.value[id]?.$el;
|
||||||
if (element) {
|
// if (element) {
|
||||||
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
// element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
provide('onItemSaved', onItemSaved);
|
// provide('onItemSaved', onItemSaved);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import toCurrency from 'src/filters/toCurrency';
|
import toCurrency from 'src/filters/toCurrency';
|
||||||
import { inject, ref } from 'vue';
|
import { computed, inject, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import useNotify from 'composables/useNotify';
|
import useNotify from 'composables/useNotify';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
|
||||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
@ -18,9 +18,12 @@ const props = defineProps({
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const onItemSaved = inject('onItemSaved');
|
const state = useState();
|
||||||
|
|
||||||
|
const total = computed(() => state.get('orderTotal'));
|
||||||
|
|
||||||
|
// const onItemSaved = inject('onItemSaved');
|
||||||
const prices = ref((props.item.prices || []).map((item) => ({ ...item, quantity: 0 })));
|
const prices = ref((props.item.prices || []).map((item) => ({ ...item, quantity: 0 })));
|
||||||
const descriptorData = useArrayData('orderData');
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const addToOrder = async () => {
|
const addToOrder = async () => {
|
||||||
if (isLoading.value) return;
|
if (isLoading.value) return;
|
||||||
|
@ -30,9 +33,9 @@ const addToOrder = async () => {
|
||||||
items,
|
items,
|
||||||
orderFk: Number(route.params.id),
|
orderFk: Number(route.params.id),
|
||||||
});
|
});
|
||||||
|
state.set('orderTotal', total.value + 100);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
await descriptorData.fetch({});
|
// onItemSaved({ ...props, items, saved: true });
|
||||||
onItemSaved({ ...props, items, saved: true });
|
|
||||||
emit('added', items);
|
emit('added', items);
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,21 +63,26 @@ const setData = (entity) => {
|
||||||
if (!entity) return;
|
if (!entity) return;
|
||||||
getTotalRef.value && getTotalRef.value.fetch();
|
getTotalRef.value && getTotalRef.value.fetch();
|
||||||
data.value = useCardDescription(entity?.client?.name, entity?.id);
|
data.value = useCardDescription(entity?.client?.name, entity?.id);
|
||||||
state.set('orderData', entity);
|
state.set('orderTotal', _total);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getConfirmationValue = (isConfirmed) => {
|
const getConfirmationValue = (isConfirmed) => {
|
||||||
return t(isConfirmed ? 'globals.confirmed' : 'order.summary.notConfirmed');
|
return t(isConfirmed ? 'globals.confirmed' : 'order.summary.notConfirmed');
|
||||||
};
|
};
|
||||||
|
|
||||||
const total = ref(null);
|
const total = computed(() => state.get('orderTotal') ?? 0);
|
||||||
|
const _total = ref(0);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
ref="getTotalRef"
|
ref="getTotalRef"
|
||||||
:url="`Orders/${entityId}/getTotal`"
|
:url="`Orders/${entityId}/getTotal`"
|
||||||
@on-fetch="(response) => (total = response)"
|
@on-fetch="
|
||||||
|
(response) => {
|
||||||
|
_total = response;
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<CardDescriptor
|
<CardDescriptor
|
||||||
ref="descriptor"
|
ref="descriptor"
|
||||||
|
|
Loading…
Reference in New Issue