diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index e0178c44..5a42d5c1 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -368,6 +368,10 @@ export const shared_consts = { Outcoming: 2, }, + CmdConvertPDF: { + RIDUCI_DIMENSIONI: 1, + }, + Cmd: { PROVINCE: 1, COMUNI: 2, diff --git a/src/components/CCatalogoCard/CCatalogoCard.scss b/src/components/CCatalogoCard/CCatalogoCard.scss index ea866cf1..3fbab11d 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.scss +++ b/src/components/CCatalogoCard/CCatalogoCard.scss @@ -360,4 +360,11 @@ .q-img { position: relative; /* Per la sovrapposizione */ z-index: 2; /* Posiziona l'immagine principale sopra l'ombra */ -} \ No newline at end of file +} + +.border-box { + border-left: 1px solid lightgray; + border-top: 1px solid lightgray; + border-right: 1px solid gray; + border-bottom: 1px solid gray; +} diff --git a/src/components/CCatalogoCard/CCatalogoCard.vue b/src/components/CCatalogoCard/CCatalogoCard.vue index b8c3a285..ae3eedf9 100755 --- a/src/components/CCatalogoCard/CCatalogoCard.vue +++ b/src/components/CCatalogoCard/CCatalogoCard.vue @@ -75,7 +75,7 @@ :class="[ 'flex', // Classi comuni 'image-container', - { 'shadow-2': options.in_3d }, // Classe condizionale + { 'shadow-2': options.in_3d && !optcatalogo.pdf }, // Classe condizionale scheda.testo_right.font?.posiz_text === costanti.POSIZ_TESTO.IN_BASSO ? 'flex-col' @@ -120,8 +120,8 @@ :class="{ 'book-image-fixed': complete, 'cursor-pointer': !complete, - 'shadow-4': true, - 'image-wrapper': optcatalogo.pdf, + 'shadow-4': !optcatalogo.pdf, + 'border-box': optcatalogo.pdf, }" :style="{ zIndex: 2, @@ -175,7 +175,6 @@ costanti.POSIZ_TESTO.IN_BASSO ? '100%' : scheda.testo_right.font?.perc_text ?? '50%', - textAlign: 'center', marginTop: scheda.testo_right.font?.posiz_text === costanti.POSIZ_TESTO.IN_BASSO @@ -260,7 +259,6 @@ v-if="scheda.testo_bottom && scheda.testo_bottom.contenuto" :style="{ width: '100%', - textAlign: 'center', }" >
+ - + + []) + const arrSectorGood = ref([]) + const arrSkill = ref([]) + const arrGood = ref([]) + + const importasulserver = ref(false) + const skipfirstrow = ref(true) + + const incaricamento = ref(false) + const checkAggiornaQta = ref(false) + + const inputfile = ref('') + const risultato = ref('') + const risraw = ref('') + + const width = ref('8.88') + const height = ref('12.31') + + const cosafare = ref(shared_consts.CmdConvertPDF.RIDUCI_DIMENSIONI) + + const caricaDatiToggle = ref(false) + + const pdfFile = ref(null); + + const compressione = ref('prepress') + + const ListaCmd = ref( + [ + { + label: 'Riduci Dimensioni', + value: shared_consts.CmdConvertPDF.RIDUCI_DIMENSIONI, + }, + ] + ) + const ListaCompressione = ref( + [ + { + label: '[Nessuna]', + value: '', + }, + { + label: '[screen - Buona per la visualizzazione su schermo; bassa qualità e dimensione del file ridotta]', + value: 'screen', + }, + { + label: '[Ebook - Ottimizza il PDF per la lettura su ebook; qualità media e dimensione media]', + value: 'ebook', + }, + { + label: '[Printer - Ottimizza il PDF per la stampa di qualità; migliora la risoluzione rispetto a /ebook.]', + value: 'printer', + }, + { + label: '[Prepress - Ottimizza per la stampa di alta qualità; ideale per progetti di stampa professionali.]', + value: 'prepress', + }, + { + label: '[Default - Usa impostazioni predefinite; generalmente fornisce un buon equilibrio tra qualità e dimensione]', + value: 'default', + }, + ] + ) + + function caricadati() { + + } + + function created() { + + inputfile.value = '' + + if (caricaDatiToggle.value) { + caricadati() + } + } + + const uploadPdf = (event: any) => { + pdfFile.value = event.target.files[0]; + }; + + const convertPdf = async () => { + globalStore.convertPdf(pdfFile.value, width.value, height.value, compressione.value) + } + + const execPdf = async () => { + + if (cosafare.value === shared_consts.CmdConvertPDF.RIDUCI_DIMENSIONI) { + convertPdf() + } + } + + onMounted(created) + + return { + shared_consts, + ListaCmd, + cosafare, + convertPdf, + uploadPdf, + width, + height, + execPdf, + ListaCompressione, + compressione, + } + } +}) + + diff --git a/src/rootgen/admin/convertPDF/convertPDF.vue b/src/rootgen/admin/convertPDF/convertPDF.vue new file mode 100755 index 00000000..5d4d128d --- /dev/null +++ b/src/rootgen/admin/convertPDF/convertPDF.vue @@ -0,0 +1,40 @@ + + + + diff --git a/src/router/routesAdmin.ts b/src/router/routesAdmin.ts index 2398f201..24c026e6 100644 --- a/src/router/routesAdmin.ts +++ b/src/router/routesAdmin.ts @@ -67,7 +67,20 @@ function getRoutesAd(site: ISites) { inmenu: true, submenu: true, onlyAdmin: true - } + }, + { + active: true, + order: 1040, + path: '/admin/convertPDF', + materialIcon: 'event_seat', + name: 'otherpages.manage.convertPDF', + component: () => import('@/rootgen/admin/convertPDF/convertPDF.vue'), + level_parent: 0.0, + level_child: 0.5, + inmenu: true, + submenu: true, + onlyAdmin: true + }, ] diff --git a/src/statics/lang/enUs.js b/src/statics/lang/enUs.js index 0e11cf00..d0c2447d 100755 --- a/src/statics/lang/enUs.js +++ b/src/statics/lang/enUs.js @@ -66,6 +66,7 @@ const msg_enUs = { nessuno: 'None', sendpushnotif: 'Invia Msg Push', importfile: 'Importa File', + convertPDF: 'Converti PDF', }, messages: { menu: 'Your Messages', diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index 1caf984f..358999f3 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -177,6 +177,7 @@ const msg_it = { nessuno: 'Nessuno', sendpushnotif: 'Invia Messaggi', importfile: 'Importa File', + convertPDF: 'Converti PDF', }, messages: { menu: 'I tuoi Messaggi', diff --git a/src/store/Api/Inst-Pao.ts b/src/store/Api/Inst-Pao.ts index ebd2beb1..efce0f6a 100755 --- a/src/store/Api/Inst-Pao.ts +++ b/src/store/Api/Inst-Pao.ts @@ -4,15 +4,16 @@ import axios, { import { Api } from '@api' import * as Types from '@src/store/Api/ApiTypes' -async function sendRequest(url: string, method: string, mydata: any) { - // if (process.env.DEBUG) console.log('sendRequest', method, url) +async function sendRequest(url: string, method: string, mydata: any, myformdata?: any, responsedata?: any) { + console.log('sendRequest', method, url, mydata) let request - if (method === 'GET') request = Api.get(url, mydata) - else if (method === 'POST') request = Api.post(url, mydata) - else if (method === 'DELETE') request = Api.Delete(url, mydata) - else if (method === 'PUT') request = Api.put(url, mydata) - else if (method === 'PATCH') request = Api.patch(url, mydata) + if (method === 'GET') request = Api.get(url, mydata, responsedata) + else if (method === 'POST') request = Api.post(url, mydata, responsedata) + else if (method === 'postFormData') request = Api.postFormData(url, myformdata, responsedata) + else if (method === 'DELETE') request = Api.Delete(url, mydata, responsedata) + else if (method === 'PUT') request = Api.put(url, mydata, responsedata) + else if (method === 'PATCH') request = Api.patch(url, mydata, responsedata) // @ts-ignore const req: Promise = request diff --git a/src/store/Api/Instance.ts b/src/store/Api/Instance.ts index a7bb0323..075944df 100755 --- a/src/store/Api/Instance.ts +++ b/src/store/Api/Instance.ts @@ -47,7 +47,7 @@ export const addAuthHeaders = () => { // delete axiosInstance.defaults.headers.Authorization //} -async function Request(type: string, path: string, payload: any): Promise { +async function Request(type: string, path: string, payload: any, responsedata?: any): Promise { let ricevuto = false const userStore = useUserStore() @@ -65,6 +65,7 @@ async function Request(type: string, path: string, payload: any): Promise { + async SendReqBase(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, myformdata?: any, responsedata?: any): Promise { const mydataout = { ...mydata, keyappid: process.env.PAO_APP_ID, @@ -145,7 +145,7 @@ export const Api = { userStore.setServerCode(tools.EMPTY) userStore.setResStatus(0) - return new Promise((resolve, reject) => sendRequest(url, method, mydataout) + return new Promise((resolve, reject) => sendRequest(url, method, mydataout, myformdata, responsedata) .then((res) => { setTimeout(() => { if (method === 'get') { @@ -245,10 +245,12 @@ export const Api = { setAuthToken = false, evitaloop = false, retryCount = 3, - retryDelay = 5000 + retryDelay = 5000, + myformdata?: any, + responsedata?: any, ): Promise { try { - const response = await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop); + const response = await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata); return response; } catch (error: any) { if (retryCount > 0) { @@ -262,7 +264,9 @@ export const Api = { setAuthToken, evitaloop, retryCount - 1, - retryDelay + retryDelay, + myformdata, + responsedata, ); } throw error; diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index a169cd88..05ad6e23 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -380,16 +380,24 @@ export const tools = { SelectListFormatPDF: [ { label: 'a4 (mm)', value: [210, 297] }, { label: '22,60 x 31,26 (in mm)', value: [226.0, 312.6] }, + { label: '22,60 x 31,31 (in mm)', value: [226.0, 313.1] }, + { label: '22,60 x 31,20 (in mm)', value: [226.0, 312.0] }, + { label: '22,60 x 31,10 (in mm)', value: [226.0, 311.0] }, ], SelectListScalePDF: [ - { label: 'Normale (100 DPI)', value: 1 }, - { label: 'Medio (200 PDI)', value: 2 }, - { label: 'Alto (300 PDI)', value: 3 }, + { label: 'Normale (72 DPI)', value: 1 }, + { label: 'Medio (144 PDI)', value: 2 }, + { label: 'Medio-Alta (180 PDI)', value: 2.5 }, + { label: 'Medio-Alta2 (201 PDI)', value: 2.8 }, + { label: 'Alto (216 PDI)', value: 3 }, + { label: 'Alto2 (288 PDI)', value: 4 }, ], SelectListQualityPDF: [ { label: 'Bassa (1 scale)', value: 1 }, + { label: 'Bassa-Norm (1.5 scale)', value: 1.5 }, { label: 'Normale (2 scale)', value: 2 }, + { label: 'Normale2.5 (2.5 scale)', value: 2.5 }, { label: 'Media (3 scale)', value: 3 }, { label: 'Elevata (4 scale)', value: 4 }, ], @@ -8629,6 +8637,20 @@ export const tools = { }, + removeFileExtension(filename: string) { + // Trova l'ultima occorrenza del punto nel nome del file + const lastDotIndex = filename.lastIndexOf('.'); + + // Se non c'è un punto o il punto è all'inizio del nome file, + // restituisci il nome file originale + if (lastDotIndex === -1 || lastDotIndex === 0) { + return filename; + } + + // Altrimenti, restituisci la parte del nome file prima dell'ultimo punto + return filename.substring(0, lastDotIndex); + }, + removeescape(inputString: string): string { return inputString.replace('\\', '').replace(/"/g, '') }, diff --git a/src/store/globalStore.ts b/src/store/globalStore.ts index 590502b0..1323e307 100644 --- a/src/store/globalStore.ts +++ b/src/store/globalStore.ts @@ -2283,6 +2283,56 @@ export const useGlobalStore = defineStore('GlobalStore', { }) }, + async execConvertPDF(paramquery: any) { + // console.log('paramquery', paramquery) + return Api.SendReq('/admin/convert-pdf', 'postFormData', {}, false, false, 1, 5000, paramquery, { responseType: 'blob' }) + .then((res) => { + return res.data + }).catch((error) => { + return false + }) + }, + + async convertPdf(pdfFile: any, width: string, height: string, compressione: string) { + try { + + if (!pdfFile) { + console.error('No PDF file selected'); + return; + } + + const filenameToDownload = tools.removeFileExtension(pdfFile.name) + '-output.pdf' + + const formData = new FormData(); + if (pdfFile instanceof File) { + formData.append('pdf', pdfFile); + } + formData.append('width', width); // Dimensione del PDF in cm + formData.append('height', height); // Dimensione del PDF in cm + formData.append('compressione', compressione); + + const response = await this.execConvertPDF(formData) + + if (response) { + const blob = new Blob([response], { type: 'application/pdf' }); + const downloadUrl = window.URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = downloadUrl; + link.setAttribute('download', filenameToDownload); + document.body.appendChild(link); + link.click(); + link.remove(); + + window.URL.revokeObjectURL(downloadUrl); + } else { + console.error('No data returned from the server.'); + } + + } catch (error) { + console.error('Error converting PDF:', error); + } + }, + async saveServerMysql(paramquery: any) { return Api.SendReq('/admin/mysql', 'POST', paramquery) .then((res) => { diff --git a/src/views/ecommerce/catalogo/catalogo.scss b/src/views/ecommerce/catalogo/catalogo.scss index a3611df3..6b44caff 100755 --- a/src/views/ecommerce/catalogo/catalogo.scss +++ b/src/views/ecommerce/catalogo/catalogo.scss @@ -100,6 +100,7 @@ body { .book-descr-estesa { font-family: 'DINPro', sans-serif; font-size: calc(14 * var(--scalecatalog) * 1px); + text-align: justify !important; } .book-link{ diff --git a/src/views/ecommerce/catalogo/catalogo.ts b/src/views/ecommerce/catalogo/catalogo.ts index 68aedf58..f99af4e5 100755 --- a/src/views/ecommerce/catalogo/catalogo.ts +++ b/src/views/ecommerce/catalogo/catalogo.ts @@ -769,8 +769,8 @@ export default defineComponent({ const element = document.getElementById('pdf-content') const opt = { margin: [ - props.optcatalogo.printable ? (parseFloat(props.optcatalogo.areadistampa!.margini?.left) || defaultMargin) : defaultMargin, props.optcatalogo.printable ? (parseFloat(props.optcatalogo.areadistampa!.margini?.top) || defaultMargin) : defaultMargin, + props.optcatalogo.printable ? (parseFloat(props.optcatalogo.areadistampa!.margini?.left) || defaultMargin) : defaultMargin, props.optcatalogo.printable ? (parseFloat(props.optcatalogo.areadistampa!.margini?.bottom) || defaultMargin) : defaultMargin, props.optcatalogo.printable ? (parseFloat(props.optcatalogo.areadistampa!.margini?.right) || defaultMargin) : defaultMargin ], @@ -791,6 +791,7 @@ export default defineComponent({ compress: props.optcatalogo.areadistampa!.compress, }, enableLinks: true, + pagebreak: { mode: 'avoid-all', before: '.card-page' } } console.log('opt di stampa', opt) diff --git a/src/views/ecommerce/catalogo/catalogo.vue b/src/views/ecommerce/catalogo/catalogo.vue index 073b48fd..9d582ade 100755 --- a/src/views/ecommerce/catalogo/catalogo.vue +++ b/src/views/ecommerce/catalogo/catalogo.vue @@ -286,15 +286,9 @@