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

@@ -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,
}
}
})