diff --git a/src/api/ADempiere/data.js b/src/api/ADempiere/data.js index b3d9efac..56dc7fc9 100644 --- a/src/api/ADempiere/data.js +++ b/src/api/ADempiere/data.js @@ -217,6 +217,9 @@ export function runProcess(process) { }) } + if (process.printFormatUuid) { + processRequest.setPrintformatuuid(process.printFormatUuid) + } // Run Process return Instance.call(this).requestProcess(processRequest) } diff --git a/src/components/ADempiere/ContextMenu/contextMenuMixin.js b/src/components/ADempiere/ContextMenu/contextMenuMixin.js index c485ddaa..2806bdec 100644 --- a/src/components/ADempiere/ContextMenu/contextMenuMixin.js +++ b/src/components/ADempiere/ContextMenu/contextMenuMixin.js @@ -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 }) diff --git a/src/router/modules/ADempiere/menu.js b/src/router/modules/ADempiere/menu.js index a1f890b8..73bbd295 100644 --- a/src/router/modules/ADempiere/menu.js +++ b/src/router/modules/ADempiere/menu.js @@ -46,7 +46,8 @@ const staticRoutes = [ component: () => import('@/views/ADempiere/ReportViewer'), name: 'Report Viewer', meta: { - title: 'ReportViewer' + title: 'ReportViewer', + reportFormat: '' } } ] diff --git a/src/store/modules/ADempiere/process.js b/src/store/modules/ADempiere/process.js index f1a3a1f1..02bbfbd0 100644 --- a/src/store/modules/ADempiere/process.js +++ b/src/store/modules/ADempiere/process.js @@ -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 }) diff --git a/src/store/modules/ADempiere/processControl.js b/src/store/modules/ADempiere/processControl.js index 40376652..9e6b258e 100644 --- a/src/store/modules/ADempiere/processControl.js +++ b/src/store/modules/ADempiere/processControl.js @@ -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,50 +514,52 @@ const processControl = { contextMenuMetadata.actions.push(printFormatList) }) } - } - // Drill Tables to context menu - var drillTablesList = { - name: language.t('views.drillTable'), - type: 'summary', - action: '', - childs: [], - option: 'drillTable' - } - if (!isEmptyValue(output.tableName)) { - drillTablesList.childs = rootGetters.getDrillTablesList(processResult.processUuid) - if (drillTablesList && isEmptyValue(drillTablesList.childs)) { - dispatch('requestDrillTables', { - processUuid: processResult.processUuid, - instanceUuid: response.getInstanceuuid(), - processId: processDefinition.id, - tableName: output.tableName, - printFormatUuid: output.printFormatUuid, - 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) - } + // Drill Tables to context menu + var drillTablesList = { + name: language.t('views.drillTable'), + type: 'summary', + action: '', + childs: [], + option: 'drillTable' + } + if (!isEmptyValue(output.tableName)) { + drillTablesList.childs = rootGetters.getDrillTablesList(processResult.processUuid) + if (drillTablesList && isEmptyValue(drillTablesList.childs)) { + dispatch('requestDrillTables', { + processUuid: processResult.processUuid, + instanceUuid: response.getInstanceuuid(), + processId: processDefinition.id, + tableName: output.tableName, + printFormatUuid: output.printFormatUuid, + 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) + } + }) + } } } - }), - // assign new attributes - Object.assign(processResult, { - instanceUuid: response.getInstanceuuid(), - url: link.href, - download: link.download, - isError: response.getIserror(), - isProcessing: response.getIsprocessing(), - summary: response.getSummary(), - resultTableName: response.getResulttablename(), - lastRun: response.getLastrun(), - logs: logList, - output: output + // assign new attributes + Object.assign(processResult, { + instanceUuid: response.getInstanceuuid(), + url: link.href, + download: link.download, + isError: response.getIserror(), + isProcessing: response.getIsprocessing(), + summary: response.getSummary(), + resultTableName: response.getResulttablename(), + lastRun: response.getLastrun(), + logs: logList, + output: output + }) + dispatch('setReportTypeToShareLink', processResult.output.reportType) + resolve(processResult) }) .catch(error => { Object.assign(processResult, { @@ -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 - }) }) } }) diff --git a/src/utils/ADempiere/dictionaryUtils.js b/src/utils/ADempiere/dictionaryUtils.js index 2ca509c9..e0141106 100644 --- a/src/utils/ADempiere/dictionaryUtils.js +++ b/src/utils/ADempiere/dictionaryUtils.js @@ -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, diff --git a/src/views/ADempiere/ReportViewer/index.vue b/src/views/ADempiere/ReportViewer/index.vue index d2b72eb7..ff547398 100644 --- a/src/views/ADempiere/ReportViewer/index.vue +++ b/src/views/ADempiere/ReportViewer/index.vue @@ -100,6 +100,7 @@ export default { }, mounted() { this.getCachedReport() + this.$route.meta.reportFormat = this.reportFormat }, methods: { showNotification,