From f2006663b732bf70908254362624e4e08078fce1 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 10 Jan 2024 14:29:01 +0100 Subject: [PATCH] refs #6664 popup --- src/components/ui/VnConfirm.vue | 13 ++++++++++--- src/pages/Claim/Card/ClaimAction.vue | 16 +++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/components/ui/VnConfirm.vue b/src/components/ui/VnConfirm.vue index f8715f685..c6650a28f 100644 --- a/src/components/ui/VnConfirm.vue +++ b/src/components/ui/VnConfirm.vue @@ -2,6 +2,7 @@ import { ref } from 'vue'; import { useDialogPluginComponent } from 'quasar'; import { useI18n } from 'vue-i18n'; +import { onMounted } from 'vue'; const { t } = useI18n(); @@ -28,6 +29,7 @@ const props = defineProps({ required: false, default: null, }, + callbackFn: Function, }); defineEmits(['confirm', ...useDialogPluginComponent.emits]); @@ -37,12 +39,17 @@ const { dialogRef, onDialogOK } = useDialogPluginComponent(); const title = props.title || t('Confirm'); const message = props.message || t('Are you sure you want to continue?'); const isLoading = ref(false); - +onMounted(() => { + if (props.callbackFn) props.callbackFn(); +}); async function confirm() { + let html = null; + html = document.getElementById(props.data.inputId); isLoading.value = true; if (props.promise) { try { - await props.promise(props.data); + if (html) await props.promise({ ...props.data, return: html.value }); + else await props.promise(props.data); } finally { isLoading.value = false; } @@ -66,7 +73,7 @@ async function confirm() { - + [ { @@ -140,22 +141,27 @@ async function regularizeClaim() { component: VnConfirm, componentProps: { title: t('confirmGreuges'), - message: t('confirmGreugesMessage'), + message: ` + + `, + data: { inputId: 'multiplicatorValue' }, + promise: onUpdateGreugeAccept, }, }) .onOk(async () => await onUpdateGreugeAccept()); } } -async function onUpdateGreugeAccept() { +async function onUpdateGreugeAccept({ return: multiplicatorValue }) { const greugeTypeFreightId = ( await axios.get(`GreugeTypes/findOne`, { filter: { where: { code: 'freightPickUp' } }, }) ).data.id; - const freightPickUpPrice = (await axios.get(`GreugeConfigs/findOne`)).data - .freightPickUpPrice; - + const freightPickUpPrice = + (await axios.get(`GreugeConfigs/findOne`)).data.freightPickUpPrice * + +multiplicatorValue; + console.log(freightPickUpPrice); await axios.post(`Greuges`, { clientFk: claim.value.clientFk, description: `${t('ClaimGreugeDescription')} ${claimId}`.toUpperCase(),