forked from verdnatura/salix-front
generic FormPopup creation and SendInvoiceForm creation
This commit is contained in:
parent
6ace34cbb1
commit
587baa645e
|
@ -0,0 +1,93 @@
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onDataSaved']);
|
||||||
|
|
||||||
|
const $props = defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
defaultSaveButton: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
defaultCancelButton: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const closeButton = ref(null);
|
||||||
|
const isLoading = ref(false);
|
||||||
|
|
||||||
|
const onDataSaved = (dataSaved) => {
|
||||||
|
emit('onDataSaved', dataSaved);
|
||||||
|
closeForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeForm = () => {
|
||||||
|
if (closeButton.value) closeButton.value.click();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<QForm
|
||||||
|
@submit="onDataSaved($event)"
|
||||||
|
class="all-pointer-events full-width"
|
||||||
|
style="max-width: 800px"
|
||||||
|
>
|
||||||
|
<QCard class="q-pa-lg">
|
||||||
|
<span ref="closeButton" class="close-icon" v-close-popup>
|
||||||
|
<QIcon name="close" size="sm" />
|
||||||
|
</span>
|
||||||
|
<h1 class="title">{{ title }}</h1>
|
||||||
|
<p>{{ subtitle }}</p>
|
||||||
|
<slot name="form-inputs" />
|
||||||
|
<div class="q-mt-lg row justify-end">
|
||||||
|
<QBtn
|
||||||
|
v-if="defaultSaveButton"
|
||||||
|
:label="t('globals.save')"
|
||||||
|
type="submit"
|
||||||
|
color="primary"
|
||||||
|
:disabled="isLoading"
|
||||||
|
:loading="isLoading"
|
||||||
|
/>
|
||||||
|
<QBtn
|
||||||
|
v-if="defaultCancelButton"
|
||||||
|
:label="t('globals.cancel')"
|
||||||
|
type="reset"
|
||||||
|
color="primary"
|
||||||
|
flat
|
||||||
|
class="q-ml-sm"
|
||||||
|
:disabled="isLoading"
|
||||||
|
:loading="isLoading"
|
||||||
|
v-close-popup
|
||||||
|
/>
|
||||||
|
<slot name="customButtons" />
|
||||||
|
</div>
|
||||||
|
</QCard>
|
||||||
|
</QForm>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.title {
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -3,6 +3,7 @@ import { ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import TransferInvoiceForm from 'src/components/TransferInvoiceForm.vue';
|
import TransferInvoiceForm from 'src/components/TransferInvoiceForm.vue';
|
||||||
|
import SendInvoiceForm from './SendInvoiceForm.vue';
|
||||||
|
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { usePrintService } from 'composables/usePrintService';
|
import { usePrintService } from 'composables/usePrintService';
|
||||||
|
@ -20,6 +21,8 @@ const { t } = useI18n();
|
||||||
const { openReport } = usePrintService();
|
const { openReport } = usePrintService();
|
||||||
|
|
||||||
const transferInvoiceDialogRef = ref();
|
const transferInvoiceDialogRef = ref();
|
||||||
|
const sendInvoiceFormRef = ref();
|
||||||
|
const invoiceFormType = ref(null);
|
||||||
|
|
||||||
const showInvoicePdf = () => {
|
const showInvoicePdf = () => {
|
||||||
const url = `api/InvoiceOuts/${$props.invoiceOutData.id}/download?access_token=${token}`;
|
const url = `api/InvoiceOuts/${$props.invoiceOutData.id}/download?access_token=${token}`;
|
||||||
|
@ -31,6 +34,11 @@ const showInvoiceCsv = () => {
|
||||||
recipientId: $props.invoiceOutData.client.id,
|
recipientId: $props.invoiceOutData.client.id,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showSendInvoiceForm = (type) => {
|
||||||
|
invoiceFormType.value = type;
|
||||||
|
sendInvoiceFormRef.value.show();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -60,10 +68,10 @@ const showInvoiceCsv = () => {
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QMenu anchor="top end" self="top start">
|
<QMenu anchor="top end" self="top start">
|
||||||
<QList>
|
<QList>
|
||||||
<QItem v-ripple clickable>
|
<QItem v-ripple clickable @click="showSendInvoiceForm()">
|
||||||
<QItemSection>{{ t('Send PDF') }}</QItemSection>
|
<QItemSection>{{ t('Send PDF') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem v-ripple clickable>
|
<QItem v-ripple clickable @click="showSendInvoiceForm()">
|
||||||
<QItemSection>{{ t('Send CSV') }}</QItemSection>
|
<QItemSection>{{ t('Send CSV') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QList>
|
</QList>
|
||||||
|
@ -98,6 +106,9 @@ const showInvoiceCsv = () => {
|
||||||
<QDialog ref="transferInvoiceDialogRef">
|
<QDialog ref="transferInvoiceDialogRef">
|
||||||
<TransferInvoiceForm :invoice-out-data="invoiceOutData" />
|
<TransferInvoiceForm :invoice-out-data="invoiceOutData" />
|
||||||
</QDialog>
|
</QDialog>
|
||||||
|
<QDialog ref="sendInvoiceFormRef">
|
||||||
|
<SendInvoiceForm />
|
||||||
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
import FormPopup from 'src/components/FormPopup.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onDataSaved']);
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const email = ref(null);
|
||||||
|
|
||||||
|
const onDataSaved = (dataSaved) => {
|
||||||
|
emit('onDataSaved', dataSaved);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<FormPopup
|
||||||
|
:title="t('New thermograph')"
|
||||||
|
:subtitle="t('Are you sure you want to send it?')"
|
||||||
|
@on-data-saved="onDataSaved($event)"
|
||||||
|
>
|
||||||
|
<template #form-inputs>
|
||||||
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
<div class="col">
|
||||||
|
<VnInput :label="t('Email')" v-model="email" type="email" />
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
|
</template>
|
||||||
|
</FormPopup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
Email: Email
|
||||||
|
Confirm: Confirmar
|
||||||
|
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
|
||||||
|
</i18n>
|
Loading…
Reference in New Issue