refs #6664 popup
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-01-10 14:29:01 +01:00
parent ceeba871ce
commit f2006663b7
2 changed files with 21 additions and 8 deletions

View File

@ -2,6 +2,7 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { useDialogPluginComponent } from 'quasar'; import { useDialogPluginComponent } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
const { t } = useI18n(); const { t } = useI18n();
@ -28,6 +29,7 @@ const props = defineProps({
required: false, required: false,
default: null, default: null,
}, },
callbackFn: Function,
}); });
defineEmits(['confirm', ...useDialogPluginComponent.emits]); defineEmits(['confirm', ...useDialogPluginComponent.emits]);
@ -37,12 +39,17 @@ const { dialogRef, onDialogOK } = useDialogPluginComponent();
const title = props.title || t('Confirm'); const title = props.title || t('Confirm');
const message = props.message || t('Are you sure you want to continue?'); const message = props.message || t('Are you sure you want to continue?');
const isLoading = ref(false); const isLoading = ref(false);
onMounted(() => {
if (props.callbackFn) props.callbackFn();
});
async function confirm() { async function confirm() {
let html = null;
html = document.getElementById(props.data.inputId);
isLoading.value = true; isLoading.value = true;
if (props.promise) { if (props.promise) {
try { try {
await props.promise(props.data); if (html) await props.promise({ ...props.data, return: html.value });
else await props.promise(props.data);
} finally { } finally {
isLoading.value = false; isLoading.value = false;
} }
@ -66,7 +73,7 @@ async function confirm() {
<QBtn icon="close" :disable="isLoading" flat round dense v-close-popup /> <QBtn icon="close" :disable="isLoading" flat round dense v-close-popup />
</QCardSection> </QCardSection>
<QCardSection class="row items-center"> <QCardSection class="row items-center">
<span v-html="message"></span> <span id="spanHTML" v-html="message"></span>
</QCardSection> </QCardSection>
<QCardActions align="right"> <QCardActions align="right">
<QBtn <QBtn

View File

@ -37,6 +37,7 @@ const marker_labels = [
{ value: DEFAULT_MIN_RESPONSABILITY, label: t('claim.summary.company') }, { value: DEFAULT_MIN_RESPONSABILITY, label: t('claim.summary.company') },
{ value: DEFAULT_MAX_RESPONSABILITY, label: t('claim.summary.person') }, { value: DEFAULT_MAX_RESPONSABILITY, label: t('claim.summary.person') },
]; ];
const portesMultiplicator = ref();
const columns = computed(() => [ const columns = computed(() => [
{ {
@ -140,22 +141,27 @@ async function regularizeClaim() {
component: VnConfirm, component: VnConfirm,
componentProps: { componentProps: {
title: t('confirmGreuges'), title: t('confirmGreuges'),
message: t('confirmGreugesMessage'), message: `
<input class="q-field__native q-m-md" type="number" placeholder="1" id="multiplicatorValue" name="multiplicatorValue" min="0" max="50"/>
`,
data: { inputId: 'multiplicatorValue' },
promise: onUpdateGreugeAccept,
}, },
}) })
.onOk(async () => await onUpdateGreugeAccept()); .onOk(async () => await onUpdateGreugeAccept());
} }
} }
async function onUpdateGreugeAccept() { async function onUpdateGreugeAccept({ return: multiplicatorValue }) {
const greugeTypeFreightId = ( const greugeTypeFreightId = (
await axios.get(`GreugeTypes/findOne`, { await axios.get(`GreugeTypes/findOne`, {
filter: { where: { code: 'freightPickUp' } }, filter: { where: { code: 'freightPickUp' } },
}) })
).data.id; ).data.id;
const freightPickUpPrice = (await axios.get(`GreugeConfigs/findOne`)).data const freightPickUpPrice =
.freightPickUpPrice; (await axios.get(`GreugeConfigs/findOne`)).data.freightPickUpPrice *
+multiplicatorValue;
console.log(freightPickUpPrice);
await axios.post(`Greuges`, { await axios.post(`Greuges`, {
clientFk: claim.value.clientFk, clientFk: claim.value.clientFk,
description: `${t('ClaimGreugeDescription')} ${claimId}`.toUpperCase(), description: `${t('ClaimGreugeDescription')} ${claimId}`.toUpperCase(),