2022-01-20 00:38:49 +01:00
|
|
|
import { CMyPage } from '../../../components/CMyPage/index'
|
|
|
|
|
|
|
|
|
|
import { shared_consts } from '@src/common/shared_vuejs'
|
|
|
|
|
import { tools } from '@src/store/Modules/tools'
|
|
|
|
|
|
|
|
|
|
import { defineComponent, ref, onMounted } from 'vue'
|
|
|
|
|
import { useI18n } from '@src/boot/i18n'
|
|
|
|
|
import { useUserStore } from '@store/UserStore'
|
|
|
|
|
import { useGlobalStore } from '@store/globalStore'
|
|
|
|
|
import { useQuasar } from 'quasar'
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: 'Sendpushnotif',
|
|
|
|
|
components: { CMyPage },
|
|
|
|
|
setup(props, { emit }) {
|
|
|
|
|
const $q = useQuasar()
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const globalStore = useGlobalStore()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const incaricamento = ref(false)
|
|
|
|
|
|
|
|
|
|
const cosafare = ref(shared_consts.Cmd.PROVINCE)
|
|
|
|
|
|
|
|
|
|
const inputfile = ref('')
|
|
|
|
|
const risultato = ref('')
|
|
|
|
|
|
|
|
|
|
const ListaCmd = ref(
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
label: 'Importa Province',
|
|
|
|
|
value: shared_consts.Cmd.PROVINCE
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Importa Comuni',
|
|
|
|
|
value: shared_consts.Cmd.COMUNI
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Tabella Cities',
|
|
|
|
|
value: shared_consts.Cmd.CITIES_SERVER
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
function created() {
|
|
|
|
|
inputfile.value = ''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function importCmd(cmd: number, testo: string) {
|
|
|
|
|
|
|
|
|
|
let risultato = '(nessuno)'
|
|
|
|
|
let delim = ','
|
|
|
|
|
|
|
|
|
|
if (cmd === shared_consts.Cmd.PROVINCE) {
|
|
|
|
|
delim = ','
|
|
|
|
|
} else if ((cmd === shared_consts.Cmd.COMUNI) || (cmd === shared_consts.Cmd.CITIES_SERVER)) {
|
|
|
|
|
delim = ';'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const myarr = tools.CSVToArray(testo, delim)
|
|
|
|
|
|
|
|
|
|
let strris = ''
|
|
|
|
|
|
|
|
|
|
let ind = 1
|
|
|
|
|
|
|
|
|
|
for (const rec of myarr) {
|
|
|
|
|
|
2022-01-23 23:25:19 +01:00
|
|
|
let lab = tools.addslashes(rec[0])
|
|
|
|
|
let val = tools.addslashes(rec[1])
|
2022-01-20 00:38:49 +01:00
|
|
|
if (cmd === shared_consts.Cmd.PROVINCE) {
|
|
|
|
|
|
|
|
|
|
strris += '{ \n'
|
2022-01-23 23:25:19 +01:00
|
|
|
strris += ' _id:' + ind + ','
|
|
|
|
|
strris += ' prov:\'' + val + '\','
|
|
|
|
|
strris += ' descr:\'' + lab + '\','
|
2022-01-20 00:38:49 +01:00
|
|
|
strris += '}, \n'
|
|
|
|
|
|
|
|
|
|
} else if (cmd === shared_consts.Cmd.COMUNI) {
|
|
|
|
|
strris += '{ \n'
|
2022-01-23 23:25:19 +01:00
|
|
|
strris += ' istat:\'' + tools.addslashes(rec[0]) + '\','
|
|
|
|
|
strris += ' comune:\'' + tools.addslashes(rec[1]) + '\','
|
|
|
|
|
strris += ' prov:\'' + tools.addslashes(rec[2]) + '\''
|
2022-01-20 00:38:49 +01:00
|
|
|
|
|
|
|
|
} else if (cmd === shared_consts.Cmd.CITIES_SERVER) {
|
|
|
|
|
strris += '{ \n'
|
|
|
|
|
strris += ' _id :' + ind + ',\n'
|
|
|
|
|
strris += ' istat :\'' + rec[0] + '\'\n,'
|
2022-01-23 23:25:19 +01:00
|
|
|
strris += ' comune :\'' + tools.addslashes(rec[1]) + '\'\n,'
|
2022-01-20 00:38:49 +01:00
|
|
|
strris += ' prov :\'' + rec[2] + '\'\n,'
|
2022-01-23 23:25:19 +01:00
|
|
|
strris += ' reg :\'' + tools.addslashes(rec[3]) + '\'\n,'
|
|
|
|
|
strris += ' pref :\'' + tools.addslashes(rec[4]) + '\'\n,'
|
2022-01-20 00:38:49 +01:00
|
|
|
strris += ' cap :\'' + rec[5] + '\'\n,'
|
|
|
|
|
strris += ' abitanti :\'' + rec[6] + '\'\n,'
|
|
|
|
|
strris += ' country : \'IT\'\n'
|
|
|
|
|
strris += '}, \n'
|
|
|
|
|
}
|
2022-01-23 23:25:19 +01:00
|
|
|
ind += 1
|
2022-01-20 00:38:49 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cmd === shared_consts.Cmd.CITIES_SERVER) {
|
|
|
|
|
userStore.importToServerCmd($q, t, cmd, null)
|
|
|
|
|
}
|
|
|
|
|
risultato = strris
|
|
|
|
|
|
|
|
|
|
return risultato
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadTextFromFile(ev: any) {
|
|
|
|
|
console.log('ev', ev)
|
|
|
|
|
const file = ev.target.files[0]
|
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
|
|
|
|
|
reader.onload = (e: any) => {
|
|
|
|
|
|
|
|
|
|
const testo = e.target.result
|
|
|
|
|
|
|
|
|
|
risultato.value = importCmd(cosafare.value, testo)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reader.readAsText(file)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function eseguiCmd() {
|
|
|
|
|
risultato.value = ''
|
|
|
|
|
userStore.importToServerCmd($q, t, cosafare.value, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(created)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
inputfile,
|
|
|
|
|
shared_consts,
|
|
|
|
|
loadTextFromFile,
|
|
|
|
|
risultato,
|
|
|
|
|
cosafare,
|
|
|
|
|
ListaCmd,
|
|
|
|
|
eseguiCmd,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|