|
|
@ -235,47 +235,7 @@ export default { |
|
|
|
let c = 1; |
|
|
|
let c = 1; |
|
|
|
try { |
|
|
|
try { |
|
|
|
while (!isNaN(offset) && offset > -1) { |
|
|
|
while (!isNaN(offset) && offset > -1) { |
|
|
|
let res; |
|
|
|
const res = await this.getExportData({ offset, exportType: ExportTypes.EXCEL, responseType: 'base64' }); |
|
|
|
if (this.publicViewId) { |
|
|
|
|
|
|
|
console.log('IF', this.publicViewId) |
|
|
|
|
|
|
|
res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.EXCEL, { |
|
|
|
|
|
|
|
responseType: 'blob', |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
fields: |
|
|
|
|
|
|
|
this.queryParams && |
|
|
|
|
|
|
|
this.queryParams.fieldsOrder && |
|
|
|
|
|
|
|
this.queryParams.fieldsOrder.filter(c => this.queryParams.showFields[c]), |
|
|
|
|
|
|
|
offset, |
|
|
|
|
|
|
|
sortArrJson: JSON.stringify( |
|
|
|
|
|
|
|
this.reqPayload && |
|
|
|
|
|
|
|
this.reqPayload.sorts && |
|
|
|
|
|
|
|
this.reqPayload.sorts.map(({ fk_column_id, direction }) => ({ |
|
|
|
|
|
|
|
direction, |
|
|
|
|
|
|
|
fk_column_id, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
filterArrJson: JSON.stringify(this.reqPayload && this.reqPayload.filters), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-password': this.reqPayload && this.reqPayload.password, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.log('ELSE') |
|
|
|
|
|
|
|
res = await this.$api.dbViewRow.export( |
|
|
|
|
|
|
|
'noco', |
|
|
|
|
|
|
|
this.projectName, |
|
|
|
|
|
|
|
this.meta.title, |
|
|
|
|
|
|
|
this.selectedView.title, |
|
|
|
|
|
|
|
ExportTypes.EXCEL, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
responseType: 'base64', |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
offset, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const workbook = XLSX.read(res.data, { type: 'base64' }); |
|
|
|
const workbook = XLSX.read(res.data, { type: 'base64' }); |
|
|
|
XLSX.writeFile(workbook, `${this.meta.title}_exported_${c++}.xlsx`); |
|
|
|
XLSX.writeFile(workbook, `${this.meta.title}_exported_${c++}.xlsx`); |
|
|
|
|
|
|
|
|
|
|
@ -297,45 +257,7 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
while (!isNaN(offset) && offset > -1) { |
|
|
|
while (!isNaN(offset) && offset > -1) { |
|
|
|
let res; |
|
|
|
const res = await this.getExportData({ offset, exportType: ExportTypes.CSV, responseType: 'blob' }) |
|
|
|
if (this.publicViewId) { |
|
|
|
|
|
|
|
res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.CSV, { |
|
|
|
|
|
|
|
responseType: 'blob', |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
fields: |
|
|
|
|
|
|
|
this.queryParams && |
|
|
|
|
|
|
|
this.queryParams.fieldsOrder && |
|
|
|
|
|
|
|
this.queryParams.fieldsOrder.filter(c => this.queryParams.showFields[c]), |
|
|
|
|
|
|
|
offset, |
|
|
|
|
|
|
|
sortArrJson: JSON.stringify( |
|
|
|
|
|
|
|
this.reqPayload && |
|
|
|
|
|
|
|
this.reqPayload.sorts && |
|
|
|
|
|
|
|
this.reqPayload.sorts.map(({ fk_column_id, direction }) => ({ |
|
|
|
|
|
|
|
direction, |
|
|
|
|
|
|
|
fk_column_id, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
filterArrJson: JSON.stringify(this.reqPayload && this.reqPayload.filters), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-password': this.reqPayload && this.reqPayload.password, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
res = await this.$api.dbViewRow.export( |
|
|
|
|
|
|
|
'noco', |
|
|
|
|
|
|
|
this.projectName, |
|
|
|
|
|
|
|
this.meta.title, |
|
|
|
|
|
|
|
this.selectedView.title, |
|
|
|
|
|
|
|
ExportTypes.CSV, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
responseType: 'blob', |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
offset, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const { data } = res; |
|
|
|
const { data } = res; |
|
|
|
|
|
|
|
|
|
|
|
offset = +res.headers['nc-export-offset']; |
|
|
|
offset = +res.headers['nc-export-offset']; |
|
|
@ -352,6 +274,48 @@ export default { |
|
|
|
this.$toast.error(e.message).goAway(3000); |
|
|
|
this.$toast.error(e.message).goAway(3000); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
async getExportData({ offset, exportType, responseType }) { |
|
|
|
|
|
|
|
let res; |
|
|
|
|
|
|
|
if (this.publicViewId) { |
|
|
|
|
|
|
|
res = await this.$api.public.csvExport(this.publicViewId, exportType, { |
|
|
|
|
|
|
|
responseType, |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
fields: |
|
|
|
|
|
|
|
this.queryParams && |
|
|
|
|
|
|
|
this.queryParams.fieldsOrder && |
|
|
|
|
|
|
|
this.queryParams.fieldsOrder.filter(c => this.queryParams.showFields[c]), |
|
|
|
|
|
|
|
offset, |
|
|
|
|
|
|
|
sortArrJson: JSON.stringify( |
|
|
|
|
|
|
|
this.reqPayload && |
|
|
|
|
|
|
|
this.reqPayload.sorts && |
|
|
|
|
|
|
|
this.reqPayload.sorts.map(({ fk_column_id, direction }) => ({ |
|
|
|
|
|
|
|
direction, |
|
|
|
|
|
|
|
fk_column_id, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
filterArrJson: JSON.stringify(this.reqPayload && this.reqPayload.filters), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-password': this.reqPayload && this.reqPayload.password, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
res = await this.$api.dbViewRow.export( |
|
|
|
|
|
|
|
'noco', |
|
|
|
|
|
|
|
this.projectName, |
|
|
|
|
|
|
|
this.meta.title, |
|
|
|
|
|
|
|
this.selectedView.title, |
|
|
|
|
|
|
|
exportType, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
responseType, |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
offset, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
}, |
|
|
|
async importData(columnMappings) { |
|
|
|
async importData(columnMappings) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const data = this.parsedCsv.data; |
|
|
|
const data = this.parsedCsv.data; |
|
|
|