Add support to generate report from print format (#218)

* add support to generate report from print format

* bugfix with report format

* redefine report format value
pull/3759/head
Leonel Matos 2020-01-14 10:53:45 -04:00 committed by Yamel Senih
parent f0630d79d6
commit d748a0e35f
7 changed files with 124 additions and 63 deletions

View File

@ -217,6 +217,9 @@ export function runProcess(process) {
})
}
if (process.printFormatUuid) {
processRequest.setPrintformatuuid(process.printFormatUuid)
}
// Run Process
return Instance.call(this).requestProcess(processRequest)
}

View File

@ -352,12 +352,22 @@ export const contextMixin = {
href: window.location.href
})
}
var reportFormat = action.reportExportType
if (this.isEmptyValue(reportFormat)) {
if (!this.isEmptyValue(this.$route.query.reportType)) {
reportFormat = this.$route.query.reportType
} else if (!this.isEmptyValue(this.$route.meta.reportFormat)) {
reportFormat = this.$route.meta.reportFormat
} else {
reportFormat = 'html'
}
}
this.$store.dispatch(action.action, {
action: action,
parentUuid: this.containerUuid,
containerUuid: containerParams, // EVALUATE IF IS action.uuid
panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser)
reportFormat: this.$route.query.reportType ? this.$route.query.reportType : action.reportExportType,
reportFormat: reportFormat, // this.$route.query.reportType ? this.$route.query.reportType : action.reportExportType,
menuParentUuid: parentMenu, // to load relations in context menu (report view)
routeToDelete: this.$route
})

View File

@ -46,7 +46,8 @@ const staticRoutes = [
component: () => import('@/views/ADempiere/ReportViewer'),
name: 'Report Viewer',
meta: {
title: 'ReportViewer'
title: 'ReportViewer',
reportFormat: ''
}
}
]

View File

@ -26,9 +26,15 @@ const process = {
containerUuid,
routeToDelete
}) {
var printFormatsAvailable
dispatch('requestPrintFormats', { processUuid: containerUuid })
.then(response => {
printFormatsAvailable = response
})
return new Promise((resolve, reject) => {
getProcessMetadata(containerUuid)
.then(responseProcess => {
responseProcess.printFormatsAvailable = printFormatsAvailable
const { processDefinition, actions } = generateProcess({
processToGenerate: responseProcess
})

View File

@ -178,6 +178,7 @@ const processControl = {
panelType: params.panelType,
menuParentUuid: params.menuParentUuid,
processIdPath: params.routeToDelete.path,
printFormatUuid: params.action.printFormatUuid,
// process attributes
lastRun: timeInitialized,
action: processDefinition.name,
@ -240,7 +241,6 @@ const processControl = {
selection: selection,
tableName: windowSelectionProcess.tableName,
recordId: selection[windowSelectionProcess.tableName]
})
.then(response => {
var output = {
@ -439,6 +439,7 @@ const processControl = {
recordId: itemLog.getRecordid()
}
})
}
reportViewList.childs = getters.getReportViewList(processResult.processUuid)
if (reportViewList && !reportViewList.childs.length) {
dispatch('requestReportViews', {
@ -463,23 +464,27 @@ const processControl = {
href: undefined,
download: undefined
}
printFormatList.childs = rootGetters.getPrintFormatList(processResult.processUuid)
if (printFormatList && !printFormatList.childs.length) {
dispatch('requestPrintFormats', {
processUuid: processResult.processUuid,
instanceUuid: response.getInstanceuuid(),
processId: processDefinition.id,
tableName: output.tableName,
printFormatUuid: output.printFormatUuid,
reportViewUuid: output.reportViewUuid
})
.then(response => {
printFormatList.childs = response
if (printFormatList.childs.length) {
// Get contextMenu metadata and concat print Format List with contextMenu actions
var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid)
contextMenuMetadata.actions.push(printFormatList)
if (processDefinition.isReport) {
const blob = new Blob([output.outputStream], { type: output.mimeType })
link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = output.fileName
if (reportType !== 'pdf' && reportType !== 'html') {
link.click()
}
// Report views List to context menu
var reportViewList = {
name: language.t('views.reportView'),
type: 'summary',
action: '',
childs: [],
option: 'reportView'
}
reportViewList.childs = getters.getReportViewList(processResult.processUuid)
if (!reportViewList.childs.length) {
dispatch('requestReportViews', {
processUuid: processResult.processUuid
})
.then(response => {
reportViewList.childs = response
@ -509,7 +514,6 @@ const processControl = {
contextMenuMetadata.actions.push(printFormatList)
})
}
}
// Drill Tables to context menu
var drillTablesList = {
@ -540,7 +544,7 @@ const processControl = {
})
}
}
}),
}
// assign new attributes
Object.assign(processResult, {
instanceUuid: response.getInstanceuuid(),
@ -554,6 +558,9 @@ const processControl = {
logs: logList,
output: output
})
dispatch('setReportTypeToShareLink', processResult.output.reportType)
resolve(processResult)
})
.catch(error => {
Object.assign(processResult, {
isError: true,
@ -586,6 +593,11 @@ const processControl = {
processOutput: processResult,
routeToDelete: params.routeToDelete
})
commit('deleteInExecution', {
containerUuid: params.containerUuid
})
dispatch('setProcessTable', {
valueRecord: 0,
tableName: '',
@ -594,9 +606,6 @@ const processControl = {
dispatch('setProcessSelect', {
finish: true
})
commit('deleteInExecution', {
containerUuid: params.containerUuid
})
})
}
})

View File

@ -246,8 +246,39 @@ export function generateProcess({ processToGenerate, containerUuidAssociated = u
})
})
const printFormats = {
name: language.t('views.printFormat'),
processName: processToGenerate.name,
type: 'summary',
action: '',
childs: [],
uuid: processToGenerate.uuid,
id: processToGenerate.id,
description: processToGenerate.description,
isReport: processToGenerate.isReport,
isDirectPrint: processToGenerate.isDirectPrint,
process: processToGenerate
}
processToGenerate.printFormatsAvailable.forEach(actionValue => {
// Push values
printFormats.childs.push({
name: actionValue.name,
processName: processToGenerate.name,
type: 'action',
action: 'startProcess',
uuid: processToGenerate.uuid,
id: processToGenerate.id,
description: actionValue.description,
isReport: processToGenerate.isReport,
isDirectPrint: processToGenerate.isDirectPrint,
reportExportType: undefined,
printFormatUuid: actionValue.printFormatUuid
})
})
// Add summary Actions
actions.push(summaryAction)
actions.push(printFormats)
const processDefinition = {
...processToGenerate,

View File

@ -100,6 +100,7 @@ export default {
},
mounted() {
this.getCachedReport()
this.$route.meta.reportFormat = this.reportFormat
},
methods: {
showNotification,