- Generazione PDF e per Stampa
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 148 KiB |
@@ -38,7 +38,7 @@ const firstPage = {
|
||||
path: '/',
|
||||
materialIcon: 'home',
|
||||
name: 'pages.home',
|
||||
component: () => import('@src/root/mainview/mainview/home.vue'),
|
||||
component: () => import('@src/root/mainview/mainview.vue'),
|
||||
reqauth: false,
|
||||
inmenu: true,
|
||||
infooter: true,
|
||||
|
||||
@@ -767,6 +767,11 @@ export default defineComponent({
|
||||
globalStore.myselector.data = { _id: 0, comune: '' }
|
||||
}
|
||||
|
||||
} else {
|
||||
const rec = searchList.value.find((rec) => rec.table === table && rec.bool)
|
||||
if (rec) {
|
||||
tools.setCookieBool(tools.COOK_SEARCH + costanti.FILTER_SEP + table + costanti.FILTER_SEP + rec.key, rec.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2839,7 +2844,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function getisDettagliByCatalog() {
|
||||
const rec = searchList.value.find((myrec) => myrec.table === shared_consts.TABLES_CATALOG && myrec.key === 'dettagli')
|
||||
const rec = searchList.value.find((myrec) => myrec.table === ('finto_' + myrec.key) && myrec.key === 'dettagli')
|
||||
if (rec) {
|
||||
return rec.value
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@
|
||||
v-else-if="item.type === costanti.FieldType.boolean"
|
||||
:label="item.label"
|
||||
v-model="item.value"
|
||||
@update:model-value="refresh"
|
||||
@update:model-value="searchval(item.value, item.table)"
|
||||
color="green"
|
||||
/>
|
||||
</div>
|
||||
@@ -923,7 +923,7 @@
|
||||
v-else-if="item.type === costanti.FieldType.boolean"
|
||||
:label="item.label"
|
||||
v-model="item.value"
|
||||
@update:model-value="refresh"
|
||||
@update:model-value="searchval(item.value, item.table)"
|
||||
color="green"
|
||||
/>
|
||||
</span>
|
||||
|
||||
@@ -38,7 +38,7 @@ const firstPage = {
|
||||
path: '/',
|
||||
materialIcon: 'home',
|
||||
name: 'pages.home',
|
||||
component: () => import('@src/root/mainview/mainview/home.vue'),
|
||||
component: () => import('@src/root/mainview/mainview.vue'),
|
||||
reqauth: false,
|
||||
inmenu: true,
|
||||
infooter: true,
|
||||
|
||||
@@ -4482,6 +4482,14 @@ export const tools = {
|
||||
return def
|
||||
}
|
||||
},
|
||||
getCookieBool(mytok: any, def?: any) {
|
||||
const ris = Cookies.get(mytok)
|
||||
if (ris === 'null')
|
||||
return def
|
||||
|
||||
return ris === '1' ? true : false
|
||||
|
||||
},
|
||||
|
||||
localStSetItem(item: string, value: string) {
|
||||
if (localStorage.getItem('cookie-id') === 'decline')
|
||||
@@ -4502,6 +4510,13 @@ export const tools = {
|
||||
return Cookies.set(mytok, value)
|
||||
},
|
||||
|
||||
setCookieBool(mytok: any, valbool: boolean) {
|
||||
if (localStorage.getItem('cookie-id') === 'decline')
|
||||
return null
|
||||
|
||||
return Cookies.set(mytok, valbool ? '1' : '0')
|
||||
},
|
||||
|
||||
removeCookie(mytok: any) {
|
||||
return Cookies.remove(mytok)
|
||||
},
|
||||
@@ -9846,11 +9861,13 @@ export const tools = {
|
||||
icon: 'fas fa-user'
|
||||
},
|
||||
{
|
||||
table: 'finto_active',
|
||||
visible: !this.isUtente(),
|
||||
label: 'Pubblicati OnLine',
|
||||
key: 'active',
|
||||
type: costanti.FieldType.boolean,
|
||||
value: this.isUtente() ? true: this.getCookie(this.COOK_SEARCH + costanti.FILTER_SEP + shared_consts.TABLES_CATALOG + costanti.FILTER_SEP + 'active', true),
|
||||
value: this.isUtente() ? true: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_active' + costanti.FILTER_SEP + 'active', true),
|
||||
bool: true,
|
||||
keycookie: '',
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
@@ -9859,11 +9876,13 @@ export const tools = {
|
||||
icon: 'fas fa-globe'
|
||||
},
|
||||
{
|
||||
table: 'finto_isCatalogoGenerale',
|
||||
visible: !this.isUtente(),
|
||||
label: 'Solo Catalogo Generale',
|
||||
key: 'isCatalogoGenerale',
|
||||
type: costanti.FieldType.boolean,
|
||||
value: this.isUtente() ? isCatalogoGenerale: this.getCookie(this.COOK_SEARCH + costanti.FILTER_SEP + shared_consts.TABLES_CATALOG + costanti.FILTER_SEP + 'isCatalogoGenerale', isCatalogoGenerale),
|
||||
value: this.isUtente() ? isCatalogoGenerale: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_isCatalogoGenerale' + costanti.FILTER_SEP + 'isCatalogoGenerale', isCatalogoGenerale),
|
||||
bool: true,
|
||||
keycookie: '',
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
@@ -9874,11 +9893,12 @@ export const tools = {
|
||||
{
|
||||
visible: !this.isUtente(),
|
||||
label: 'Dettagli',
|
||||
table: shared_consts.TABLES_CATALOG,
|
||||
table: 'finto_dettagli',
|
||||
key: 'dettagli',
|
||||
bool: true,
|
||||
notinsearch: true, // non usarlo nella ricerca filtro
|
||||
type: costanti.FieldType.boolean,
|
||||
value: this.isUtente() ? false: this.getCookie(this.COOK_SEARCH + costanti.FILTER_SEP + shared_consts.TABLES_CATALOG + costanti.FILTER_SEP + 'dettagli', true),
|
||||
value: this.isUtente() ? false: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_dettagli' + costanti.FILTER_SEP + 'dettagli', true),
|
||||
keycookie: '',
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
|
||||
@@ -2538,6 +2538,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
file_out: string = '',
|
||||
print: boolean = false,
|
||||
optcatalogo: IOptCatalogo | null = null,
|
||||
salvasufiledascaricare
|
||||
) {
|
||||
try {
|
||||
if (!pdfFile) {
|
||||
@@ -2567,6 +2568,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
const response = await this.execConvertPDF(formData);
|
||||
|
||||
if (response) {
|
||||
if (salvasufiledascaricare) {
|
||||
const blob = new Blob([response], { type: 'application/pdf' });
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
@@ -2577,6 +2579,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
link.remove();
|
||||
|
||||
window.URL.revokeObjectURL(downloadUrl);
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
} else {
|
||||
console.error('No data returned from the server.');
|
||||
}
|
||||
|
||||
@@ -1747,6 +1747,7 @@ export default defineComponent({
|
||||
const pages = document.querySelectorAll(pagesSelector);
|
||||
const pdfs = [];
|
||||
|
||||
try {
|
||||
for (let i = 0; i < pages.length; i++) {
|
||||
const page = pages[i];
|
||||
|
||||
@@ -1793,7 +1794,7 @@ export default defineComponent({
|
||||
const pdfFile = new File([blob], 'report.pdf', { type: 'application/pdf' });
|
||||
|
||||
// Converti il file appena generato
|
||||
await globalStore.convertPdf(
|
||||
const ris = await globalStore.convertPdf(
|
||||
pdfFile,
|
||||
widthpdf.value,
|
||||
heightpdf.value,
|
||||
@@ -1802,11 +1803,29 @@ export default defineComponent({
|
||||
file_out,
|
||||
true,
|
||||
optcatalogo.value,
|
||||
salvasufiledascaricare
|
||||
);
|
||||
|
||||
if (ris) {
|
||||
const catalog = getCatalogoByMyPage.value;
|
||||
if (ris.pdf_generato) {
|
||||
catalog.pdf_generato = ris.pdf_generato;
|
||||
catalog.data_generato = tools.getDateNow();
|
||||
}
|
||||
if (ris.pdf_generato_stampa) {
|
||||
catalog.pdf_generato_stampa = ris.pdf_generato_stampa;
|
||||
catalog.data_generato_stampa = tools.getDateNow();
|
||||
}
|
||||
|
||||
await saveCatalog();
|
||||
}
|
||||
}
|
||||
|
||||
// Ripristina visibilità
|
||||
pages.forEach((p) => p.classList.remove('hidden'));
|
||||
} catch (e) {
|
||||
console.error('Err', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
const generatePDF = async () => {
|
||||
@@ -1860,12 +1879,7 @@ export default defineComponent({
|
||||
|
||||
const element = document.getElementById('pdf-content');
|
||||
const opt = {
|
||||
margin: [
|
||||
defaultMargin,
|
||||
defaultMargin,
|
||||
defaultMargin,
|
||||
defaultMargin,
|
||||
],
|
||||
margin: [defaultMargin, defaultMargin, defaultMargin, defaultMargin],
|
||||
filename: myfile,
|
||||
image: {
|
||||
type: 'jpeg',
|
||||
@@ -1890,7 +1904,7 @@ export default defineComponent({
|
||||
// a4: [595.28, 841.89]
|
||||
|
||||
if (true) {
|
||||
await generateLargePDF(opt, '.pdf-section', false, 'upload/', file_out);
|
||||
await generateLargePDF(opt, '.pdf-section', false, 'upload/cataloghi/', file_out);
|
||||
} else {
|
||||
await html2pdf().set(opt).from(element).save();
|
||||
}
|
||||
|
||||
@@ -432,6 +432,25 @@
|
||||
:color="optcatalogo.indebug ? `positive` : 'primary'"
|
||||
></q-btn>
|
||||
</div>
|
||||
<div v-if="getCatalogoByMyPage.pdf_generato" class="column justify-center q-ma-sm q-pa-sm">
|
||||
<div >
|
||||
PDF:
|
||||
<a :href="tools.getHost() + getCatalogoByMyPage.pdf_generato" target="_blank" v-if="getCatalogoByMyPage.pdf_generato" class="text-bold">
|
||||
{{tools.getHost() + getCatalogoByMyPage.pdf_generato}}
|
||||
</a>
|
||||
<span v-else>-</span>
|
||||
<br>(Generato il {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato)}})
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
PDF Stampa:
|
||||
<a :href="tools.getHost() + getCatalogoByMyPage.pdf_generato_stampa" target="_blank" v-if="getCatalogoByMyPage.pdf_generato_stampa" class="text-bold">
|
||||
{{tools.getHost() + getCatalogoByMyPage.pdf_generato_stampa}}
|
||||
</a>
|
||||
<span v-else>-</span>
|
||||
<br>(Generato il {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato_stampa) }})
|
||||
</div>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="ricerca">
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user