diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index a2155f36..c2ed1f97 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -2,6 +2,7 @@ import { useI18n } from 'vue-i18n'; import { storeToRefs } from 'pinia'; import { useQuasar } from 'quasar'; +import { QFile } from 'quasar'; import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'; import { dialogCheckData, @@ -168,7 +169,8 @@ const selectedWorker = ref< })[] >([]); const workerList = ref([]); - +const fileAcceptance = ref(); +const refQFileAcceptance = ref>(); const selectedProductGroup = ref(''); const selectedInstallmentNo = ref([]); const installmentAmount = ref(0); @@ -908,6 +910,8 @@ async function getAttachment() { }); if (attachment && attachment.length > 0) { + await checkFileAcceptance(attachment); + attachmentData.value = attachmentData.value.filter((item) => attachment.includes(item.name), ); @@ -1189,6 +1193,22 @@ async function getWorkerFromCriteria( return true; } + +async function checkFileAcceptance(attachment: string[]) { + const nameFile = `acceptance-${quotationFormData.value.id}`; + + const isFound = attachment.findIndex((v) => v.includes(nameFile)); + if (isFound !== -1) { + const blob = new Blob([''], { type: 'application/pdf' }); // สร้าง blob จำลอง + fileAcceptance.value = new File([blob], nameFile, { + type: 'application/pdf', + }); + } else fileAcceptance.value = undefined; +} + +function viewAttachment(url: string) { + window.open(url, '_blank'); +}