feat: quotation doc view pdf
This commit is contained in:
parent
8f3f499a7a
commit
ea69d6eeb9
2 changed files with 53 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { onMounted, nextTick, ref, watch } from 'vue';
|
import { onMounted, nextTick, ref, watch, toRaw } from 'vue';
|
||||||
import { precisionRound } from 'src/utils/arithmetic';
|
import { precisionRound } from 'src/utils/arithmetic';
|
||||||
import ThaiBahtText from 'thai-baht-text';
|
import ThaiBahtText from 'thai-baht-text';
|
||||||
|
|
||||||
|
|
@ -25,11 +25,13 @@ import {
|
||||||
} from 'src/stores/quotations/types';
|
} from 'src/stores/quotations/types';
|
||||||
|
|
||||||
// NOTE: Import Components
|
// NOTE: Import Components
|
||||||
|
import ViewPDF from './ViewPdf.vue';
|
||||||
import ViewHeader from './ViewHeader.vue';
|
import ViewHeader from './ViewHeader.vue';
|
||||||
import ViewFooter from './ViewFooter.vue';
|
import ViewFooter from './ViewFooter.vue';
|
||||||
import BankComponents from './BankComponents.vue';
|
import BankComponents from './BankComponents.vue';
|
||||||
import PrintButton from 'src/components/button/PrintButton.vue';
|
import PrintButton from 'src/components/button/PrintButton.vue';
|
||||||
import { convertTemplate } from 'src/utils/string-template';
|
import { convertTemplate } from 'src/utils/string-template';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
const quotationForm = useQuotationForm();
|
const quotationForm = useQuotationForm();
|
||||||
const optionStore = useOptionStore();
|
const optionStore = useOptionStore();
|
||||||
|
|
@ -67,9 +69,9 @@ const elements = ref<HTMLElement[]>([]);
|
||||||
const chunks = ref<Product[][]>([[]]);
|
const chunks = ref<Product[][]>([[]]);
|
||||||
const attachmentList = ref<
|
const attachmentList = ref<
|
||||||
{
|
{
|
||||||
name: string;
|
|
||||||
typeFile: string;
|
|
||||||
url: string;
|
url: string;
|
||||||
|
isImage?: boolean;
|
||||||
|
isPDF?: boolean;
|
||||||
}[]
|
}[]
|
||||||
>([]);
|
>([]);
|
||||||
const data = ref<
|
const data = ref<
|
||||||
|
|
@ -90,16 +92,21 @@ async function getAttachment(quotationId: string) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (attachment) {
|
if (attachment) {
|
||||||
attachment.forEach(async (v) => {
|
attachmentList.value = await Promise.all(
|
||||||
attachmentList.value.push({
|
attachment.map(async (v) => {
|
||||||
name: v,
|
const url = await quotationStore.getAttachment({
|
||||||
typeFile: v.substring(v.lastIndexOf('.') + 1),
|
|
||||||
url: await quotationStore.getAttachment({
|
|
||||||
parentId: quotationId,
|
parentId: quotationId,
|
||||||
name: v,
|
name: v,
|
||||||
}),
|
});
|
||||||
});
|
const ft = v.substring(v.lastIndexOf('.') + 1);
|
||||||
});
|
|
||||||
|
return {
|
||||||
|
url,
|
||||||
|
isImage: ['png', 'jpg', 'jpeg'].includes(ft),
|
||||||
|
isPDF: ft === 'pdf',
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -531,11 +538,16 @@ function print() {
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section
|
<section
|
||||||
v-for="v in attachmentList.filter((v) => v.typeFile !== 'pdf')"
|
v-for="item in attachmentList.filter((v) => v.isImage)"
|
||||||
class="content"
|
class="content"
|
||||||
>
|
>
|
||||||
<q-img :src="v.url" />
|
<q-img :src="item.url" />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<ViewPDF
|
||||||
|
v-for="item in attachmentList.filter((v) => v.isPDF)"
|
||||||
|
:url="item.url"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -611,8 +623,7 @@ td {
|
||||||
font-size: 95%;
|
font-size: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content,
|
.content {
|
||||||
.container > :deep(.content) {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.5in;
|
padding: 0.5in;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
27
src/pages/05_quotation/preview/ViewPdf.vue
Normal file
27
src/pages/05_quotation/preview/ViewPdf.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { VuePDF, usePDF } from '@tato30/vue-pdf';
|
||||||
|
const props = defineProps<{
|
||||||
|
url: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const { pdf, pages } = usePDF(props.url);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section v-for="page in pages" class="content">
|
||||||
|
<VuePDF style="width: 100%" :pdf="pdf" :page="page" :scale="1.5" />
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.content :deep(canvas) {
|
||||||
|
width: 100% !important;
|
||||||
|
height: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.content :deep(canvas) {
|
||||||
|
scale: 1.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue