Export Movements to CSV File

fix Visibility for a Circuit
This commit is contained in:
Paolo Arena
2022-09-19 14:37:44 +02:00
parent ce79360d03
commit c75b78ea98
21 changed files with 122 additions and 37 deletions

View File

@@ -885,17 +885,6 @@ export default defineComponent({
// param1: shared_consts.PARAM_SHOW_PROVINCE,
tablesel: 'cities',
},
{
label: 'Visibilità',
table: 'pub_to_share',
key: 'pub_to_share',
type: costanti.FieldType.select,
value: tools.getCookie(tools.COOK_SEARCH + 'pub_to_share', shared_consts.PUBTOSHARE.ALL, true),
addall: false,
arrvalue: [],
useinput: false,
filter: null,
},
]
searchList_MyGroups.value = [
@@ -1100,6 +1089,7 @@ export default defineComponent({
symbol: 1,
idCity: 1,
pub_to_share: 1,
visibility: 1,
color: 1,
abbrev: 1,
data_costituz: 1,

View File

@@ -31,7 +31,7 @@ import { CTitleBanner } from '../CTitleBanner'
import { useUserStore } from '@store/UserStore'
import { useGlobalStore } from '@store/globalStore'
import { useQuasar } from 'quasar'
import { useQuasar, exportFile } from 'quasar'
import { costanti } from '@costanti'
import translate from '@/globalroutines/util'
import { toolsext } from '@store/Modules/toolsext'
@@ -92,6 +92,11 @@ export default defineComponent({
required: false,
default: 0,
},
enableExport: {
type: Boolean,
required: false,
default: false,
},
finder_noNull: {
type: Boolean,
required: false,
@@ -960,7 +965,7 @@ export default defineComponent({
}
function refresh_infscroll(done: any) {
console.log('refresh_infscroll')
// console.log('refresh_infscroll')
rowclicksel.value = null
onUpdateData(0,
@@ -972,7 +977,7 @@ export default defineComponent({
function refresh() {
console.log('refresh', 'startsearch', startsearch.value)
// console.log('refresh', 'startsearch', startsearch.value)
clickbuttsearch.value = true
// console.log('refresh')
@@ -1932,7 +1937,66 @@ export default defineComponent({
done()
}
}
function wrapCsvValue (val: any, formatFn?: any, row?: any, col?: IColGridTable) {
let formatted = formatFn !== void 0
? formatFn(val, row)
: val
formatted = formatted === void 0 || formatted === null
? ''
: String(formatted)
formatted = formatted.split('"').join('""')
/**
* Excel accepts \n and \r in strings, but some other CSV parsers do not
* Uncomment the next two lines to escape new lines
*/
// .split('\n').join('\\n')
// .split('\r').join('\\r')
if (col) {
if (col.label_trans === t('movement.accountFromId')) {
}
}
if (col)
console.log(' valu', formatted, ' (col=', col.name)
return `"${formatted}"`
}
// onMounted(mounted)
function exportTable () {
// console.log('row', serverData.value)
// console.log('mycolumns.value', mycolumns.value)
// naive encoding to csv format
const content = [mycolumns.value.map((col: any) => wrapCsvValue(col.label))].concat(
serverData.value.map((row: any) => mycolumns.value.map((col: any) => wrapCsvValue(
typeof col.field === 'function'
? col.field(row)
: tools.getValue(row, col.field, col.subfield),
col.format,
row,
col
)).join(','))
).join('\r\n')
const status = exportFile(
'export-' + mytable.value + '_' + tools.getstrYYMMDDHHMMDateTime(tools.getDateNow()) + '.csv',
content,
'text/csv'
)
if (status !== true) {
$q.notify({
message: 'Il Browser ha negato il download del file.',
color: 'negative',
icon: 'warning'
})
}
}
created()
mounted()
@@ -2025,6 +2089,7 @@ export default defineComponent({
numRecLoaded,
myinfscroll,
t,
exportTable,
}
}
})

View File

@@ -413,9 +413,18 @@
</q-tr>
</template>
<template v-slot:top-right v-if="tablesList || arrfilters">
<template v-slot:top-right v-if="tablesList || arrfilters || enableExport">
<span style="display: none">{{ actual = null }}</span>
<q-btn
v-if="enableExport"
color="primary"
icon-right="archive"
:label="t('export.csv')"
no-caps
@click="exportTable"
/>
<q-select
v-if="tablesList"
v-model="tablesel"

View File

@@ -66,7 +66,6 @@ export default defineComponent({
const mybutt = []
mybutt.push({ label: t('mypages.follow_circuits') + ' (' + numMyCircuits.value + ')', value: costanti.MY_CIRCUITS })
mybutt.push({ label: t('mypages.find_circuit'), value: costanti.FIND_CIRCUIT })
// mybutt.push({ label: t('mypages.manage_my_circuits') + ' (' + numManageCircuits.value + ')', value: costanti.MANAGE_CIRCUITS })
if (numAskSentCircuits.value > 0 || props.modelValue === costanti.ASK_SENT_CIRCUIT)
@@ -104,8 +103,6 @@ export default defineComponent({
arr = circuitStore.listcircuits
} else if (props.modelValue === costanti.MY_CIRCUITS ) {
arr = circuitStore.listcircuits.filter((circ: any) => userStore.my.profile.mycircuits.findIndex((rec: any) => circ.name === rec.circuitname) >= 0)
} else if (props.modelValue === costanti.MANAGE_CIRCUITS) {
// arr = userStore.my.profile.manage_mycircuits
} else if (props.modelValue === costanti.ASK_SENT_CIRCUIT) {
arr = userStore.my.profile.asked_circuits
}