- Aggiornati margini.

- Cataloghi: Export ed Import di una pagine ed i suoi elementi !
This commit is contained in:
Surya Paolo
2024-12-13 18:10:04 +01:00
parent 29c59588c7
commit 8baf1e99f0
39 changed files with 752 additions and 141 deletions

View File

@@ -0,0 +1,55 @@
import { tools } from '../../store/Modules/tools'
import { useQuasar } from 'quasar'
import { useI18n } from '@src/boot/i18n'
import { useUserStore } from '@store/UserStore'
import { useGlobalStore } from '@store/globalStore'
import { defineComponent } from 'vue'
export default defineComponent({
name: 'CDownloadJsonFile',
props: {
testoJson: {
type: String,
required: true,
},
title: {
type: String,
required: false,
default: '',
},
nomefile: {
type: String,
required: false,
default: '',
},
},
components: {},
setup(props) {
const $q = useQuasar()
const downloadJsonFile = () => {
// Crea un blob dalla jsonString passata come proprietà
const blob = new Blob([props.testoJson], { type: 'application/json' });
const url = URL.createObjectURL(blob);
// Crea un link temporaneo
const link = document.createElement('a');
link.href = url;
const fileName = `${props.nomefile}-${tools.getDateYYYYMMDD_Today()}.json`;
link.download = fileName; // Nome del file da scaricare
// Aggiungi il link al DOM e clicca per scaricare
document.body.appendChild(link);
link.click();
// Rimuovi il link dal DOM e libera l'oggetto URL
document.body.removeChild(link);
URL.revokeObjectURL(url);
};
return {
tools,
downloadJsonFile,
}
},
})

View File

@@ -0,0 +1,13 @@
<template>
<div>
<div v-if="testoJson">
<button @click="downloadJsonFile">{{ title }}</button>
</div>
</div>
</template>
<script lang="ts" src="./CDownloadJsonFile.ts"></script>
<style lang="scss" scoped>
@import './CDownloadJsonFile.scss';
</style>

View File

@@ -0,0 +1 @@
export {default as CDownloadJsonFile} from './CDownloadJsonFile.vue'