Add support to generate report from print format (#218)
* add support to generate report from print format * bugfix with report format * redefine report format valuepull/3759/head
parent
f0630d79d6
commit
d748a0e35f
|
@ -217,6 +217,9 @@ export function runProcess(process) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.printFormatUuid) {
|
||||||
|
processRequest.setPrintformatuuid(process.printFormatUuid)
|
||||||
|
}
|
||||||
// Run Process
|
// Run Process
|
||||||
return Instance.call(this).requestProcess(processRequest)
|
return Instance.call(this).requestProcess(processRequest)
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,12 +352,22 @@ export const contextMixin = {
|
||||||
href: window.location.href
|
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, {
|
this.$store.dispatch(action.action, {
|
||||||
action: action,
|
action: action,
|
||||||
parentUuid: this.containerUuid,
|
parentUuid: this.containerUuid,
|
||||||
containerUuid: containerParams, // EVALUATE IF IS action.uuid
|
containerUuid: containerParams, // EVALUATE IF IS action.uuid
|
||||||
panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser)
|
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)
|
menuParentUuid: parentMenu, // to load relations in context menu (report view)
|
||||||
routeToDelete: this.$route
|
routeToDelete: this.$route
|
||||||
})
|
})
|
||||||
|
|
|
@ -46,7 +46,8 @@ const staticRoutes = [
|
||||||
component: () => import('@/views/ADempiere/ReportViewer'),
|
component: () => import('@/views/ADempiere/ReportViewer'),
|
||||||
name: 'Report Viewer',
|
name: 'Report Viewer',
|
||||||
meta: {
|
meta: {
|
||||||
title: 'ReportViewer'
|
title: 'ReportViewer',
|
||||||
|
reportFormat: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -26,9 +26,15 @@ const process = {
|
||||||
containerUuid,
|
containerUuid,
|
||||||
routeToDelete
|
routeToDelete
|
||||||
}) {
|
}) {
|
||||||
|
var printFormatsAvailable
|
||||||
|
dispatch('requestPrintFormats', { processUuid: containerUuid })
|
||||||
|
.then(response => {
|
||||||
|
printFormatsAvailable = response
|
||||||
|
})
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getProcessMetadata(containerUuid)
|
getProcessMetadata(containerUuid)
|
||||||
.then(responseProcess => {
|
.then(responseProcess => {
|
||||||
|
responseProcess.printFormatsAvailable = printFormatsAvailable
|
||||||
const { processDefinition, actions } = generateProcess({
|
const { processDefinition, actions } = generateProcess({
|
||||||
processToGenerate: responseProcess
|
processToGenerate: responseProcess
|
||||||
})
|
})
|
||||||
|
|
|
@ -178,6 +178,7 @@ const processControl = {
|
||||||
panelType: params.panelType,
|
panelType: params.panelType,
|
||||||
menuParentUuid: params.menuParentUuid,
|
menuParentUuid: params.menuParentUuid,
|
||||||
processIdPath: params.routeToDelete.path,
|
processIdPath: params.routeToDelete.path,
|
||||||
|
printFormatUuid: params.action.printFormatUuid,
|
||||||
// process attributes
|
// process attributes
|
||||||
lastRun: timeInitialized,
|
lastRun: timeInitialized,
|
||||||
action: processDefinition.name,
|
action: processDefinition.name,
|
||||||
|
@ -240,7 +241,6 @@ const processControl = {
|
||||||
selection: selection,
|
selection: selection,
|
||||||
tableName: windowSelectionProcess.tableName,
|
tableName: windowSelectionProcess.tableName,
|
||||||
recordId: selection[windowSelectionProcess.tableName]
|
recordId: selection[windowSelectionProcess.tableName]
|
||||||
|
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
var output = {
|
var output = {
|
||||||
|
@ -439,6 +439,7 @@ const processControl = {
|
||||||
recordId: itemLog.getRecordid()
|
recordId: itemLog.getRecordid()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
reportViewList.childs = getters.getReportViewList(processResult.processUuid)
|
reportViewList.childs = getters.getReportViewList(processResult.processUuid)
|
||||||
if (reportViewList && !reportViewList.childs.length) {
|
if (reportViewList && !reportViewList.childs.length) {
|
||||||
dispatch('requestReportViews', {
|
dispatch('requestReportViews', {
|
||||||
|
@ -463,23 +464,27 @@ const processControl = {
|
||||||
href: undefined,
|
href: undefined,
|
||||||
download: undefined
|
download: undefined
|
||||||
}
|
}
|
||||||
printFormatList.childs = rootGetters.getPrintFormatList(processResult.processUuid)
|
if (processDefinition.isReport) {
|
||||||
if (printFormatList && !printFormatList.childs.length) {
|
const blob = new Blob([output.outputStream], { type: output.mimeType })
|
||||||
dispatch('requestPrintFormats', {
|
link = document.createElement('a')
|
||||||
processUuid: processResult.processUuid,
|
link.href = window.URL.createObjectURL(blob)
|
||||||
instanceUuid: response.getInstanceuuid(),
|
link.download = output.fileName
|
||||||
processId: processDefinition.id,
|
if (reportType !== 'pdf' && reportType !== 'html') {
|
||||||
tableName: output.tableName,
|
link.click()
|
||||||
printFormatUuid: output.printFormatUuid,
|
}
|
||||||
reportViewUuid: output.reportViewUuid
|
|
||||||
})
|
// Report views List to context menu
|
||||||
.then(response => {
|
var reportViewList = {
|
||||||
printFormatList.childs = response
|
name: language.t('views.reportView'),
|
||||||
if (printFormatList.childs.length) {
|
type: 'summary',
|
||||||
// Get contextMenu metadata and concat print Format List with contextMenu actions
|
action: '',
|
||||||
var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid)
|
childs: [],
|
||||||
contextMenuMetadata.actions.push(printFormatList)
|
option: 'reportView'
|
||||||
}
|
}
|
||||||
|
reportViewList.childs = getters.getReportViewList(processResult.processUuid)
|
||||||
|
if (!reportViewList.childs.length) {
|
||||||
|
dispatch('requestReportViews', {
|
||||||
|
processUuid: processResult.processUuid
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
reportViewList.childs = response
|
reportViewList.childs = response
|
||||||
|
@ -509,50 +514,52 @@ const processControl = {
|
||||||
contextMenuMetadata.actions.push(printFormatList)
|
contextMenuMetadata.actions.push(printFormatList)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Drill Tables to context menu
|
// Drill Tables to context menu
|
||||||
var drillTablesList = {
|
var drillTablesList = {
|
||||||
name: language.t('views.drillTable'),
|
name: language.t('views.drillTable'),
|
||||||
type: 'summary',
|
type: 'summary',
|
||||||
action: '',
|
action: '',
|
||||||
childs: [],
|
childs: [],
|
||||||
option: 'drillTable'
|
option: 'drillTable'
|
||||||
}
|
}
|
||||||
if (!isEmptyValue(output.tableName)) {
|
if (!isEmptyValue(output.tableName)) {
|
||||||
drillTablesList.childs = rootGetters.getDrillTablesList(processResult.processUuid)
|
drillTablesList.childs = rootGetters.getDrillTablesList(processResult.processUuid)
|
||||||
if (drillTablesList && isEmptyValue(drillTablesList.childs)) {
|
if (drillTablesList && isEmptyValue(drillTablesList.childs)) {
|
||||||
dispatch('requestDrillTables', {
|
dispatch('requestDrillTables', {
|
||||||
processUuid: processResult.processUuid,
|
processUuid: processResult.processUuid,
|
||||||
instanceUuid: response.getInstanceuuid(),
|
instanceUuid: response.getInstanceuuid(),
|
||||||
processId: processDefinition.id,
|
processId: processDefinition.id,
|
||||||
tableName: output.tableName,
|
tableName: output.tableName,
|
||||||
printFormatUuid: output.printFormatUuid,
|
printFormatUuid: output.printFormatUuid,
|
||||||
reportViewUuid: output.reportViewUuid
|
reportViewUuid: output.reportViewUuid
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
drillTablesList.childs = response
|
|
||||||
if (drillTablesList.childs.length) {
|
|
||||||
// Get contextMenu metadata and concat print Format List with contextMenu actions
|
|
||||||
var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid)
|
|
||||||
contextMenuMetadata.actions.push(drillTablesList)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
.then(response => {
|
||||||
|
drillTablesList.childs = response
|
||||||
|
if (drillTablesList.childs.length) {
|
||||||
|
// Get contextMenu metadata and concat print Format List with contextMenu actions
|
||||||
|
var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid)
|
||||||
|
contextMenuMetadata.actions.push(drillTablesList)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
// assign new attributes
|
||||||
// assign new attributes
|
Object.assign(processResult, {
|
||||||
Object.assign(processResult, {
|
instanceUuid: response.getInstanceuuid(),
|
||||||
instanceUuid: response.getInstanceuuid(),
|
url: link.href,
|
||||||
url: link.href,
|
download: link.download,
|
||||||
download: link.download,
|
isError: response.getIserror(),
|
||||||
isError: response.getIserror(),
|
isProcessing: response.getIsprocessing(),
|
||||||
isProcessing: response.getIsprocessing(),
|
summary: response.getSummary(),
|
||||||
summary: response.getSummary(),
|
resultTableName: response.getResulttablename(),
|
||||||
resultTableName: response.getResulttablename(),
|
lastRun: response.getLastrun(),
|
||||||
lastRun: response.getLastrun(),
|
logs: logList,
|
||||||
logs: logList,
|
output: output
|
||||||
output: output
|
})
|
||||||
|
dispatch('setReportTypeToShareLink', processResult.output.reportType)
|
||||||
|
resolve(processResult)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Object.assign(processResult, {
|
Object.assign(processResult, {
|
||||||
|
@ -586,6 +593,11 @@ const processControl = {
|
||||||
processOutput: processResult,
|
processOutput: processResult,
|
||||||
routeToDelete: params.routeToDelete
|
routeToDelete: params.routeToDelete
|
||||||
})
|
})
|
||||||
|
|
||||||
|
commit('deleteInExecution', {
|
||||||
|
containerUuid: params.containerUuid
|
||||||
|
})
|
||||||
|
|
||||||
dispatch('setProcessTable', {
|
dispatch('setProcessTable', {
|
||||||
valueRecord: 0,
|
valueRecord: 0,
|
||||||
tableName: '',
|
tableName: '',
|
||||||
|
@ -594,9 +606,6 @@ const processControl = {
|
||||||
dispatch('setProcessSelect', {
|
dispatch('setProcessSelect', {
|
||||||
finish: true
|
finish: true
|
||||||
})
|
})
|
||||||
commit('deleteInExecution', {
|
|
||||||
containerUuid: params.containerUuid
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -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
|
// Add summary Actions
|
||||||
actions.push(summaryAction)
|
actions.push(summaryAction)
|
||||||
|
actions.push(printFormats)
|
||||||
|
|
||||||
const processDefinition = {
|
const processDefinition = {
|
||||||
...processToGenerate,
|
...processToGenerate,
|
||||||
|
|
|
@ -100,6 +100,7 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getCachedReport()
|
this.getCachedReport()
|
||||||
|
this.$route.meta.reportFormat = this.reportFormat
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showNotification,
|
showNotification,
|
||||||
|
|
Loading…
Reference in New Issue