diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 4ea677b6..dabe88dd 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -4,6 +4,7 @@ import { storeToRefs } from 'pinia'; import { useQuasar } from 'quasar'; import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'; import { + baseUrl, dialogCheckData, dialogWarningClose, formatNumberDecimal, @@ -985,6 +986,16 @@ onMounted(async () => { localStorage.removeItem('new-quotation'); const payload = sessionStorage.getItem('new-quotation'); + const { data: docTemplate, status } = + await api.get('/doc-template'); + + if (status < 400) { + templateFormOption.value = docTemplate.map((v) => ({ + label: v, + value: v, + })); + } + if (!!payload) { const parsed = JSON.parse(payload); date.value = Date.now(); @@ -1235,6 +1246,24 @@ watch( fetchRequest(); }, ); + +async function formDownload() { + if (!quotationFormData.value.id) return; + + const res = await fetch( + baseUrl + + '/doc-template/' + + templateForm.value + + `?data=quotation&dataId=${quotationFormData.value.id}`, + ); + const blob = await res.blob(); + + const a = document.createElement('a'); + a.download = templateForm.value; + a.href = window.URL.createObjectURL(blob); + a.click(); + a.remove(); +} -