From da3fad95a68127fbce3099c71ae0f7fc41433fb0 Mon Sep 17 00:00:00 2001 From: Leonel Matos Date: Fri, 10 Jan 2020 14:47:25 -0400 Subject: [PATCH] add drill down support to reports (#183) * add drill down support to reports * add validations and service implementation for get report output * add parameters for change report output * add service implementation for report output and add change print format * fix send parameters of report * add support to change view report * bugfix names of properties * minor bugfix * add support to list drill tables by reports * modify styles for childs menu * open drill report in other container * bugfix route definition * bugfix default report format * bugfix to generate reports Co-authored-by: EdwinBetanc0urt --- src/api/ADempiere/data.js | 33 +++ .../ContextMenu/contextMenuDesktop.vue | 10 +- .../ADempiere/ContextMenu/contextMenuMixin.js | 44 ++++ .../ADempiere/ContextMenu/index.vue | 4 + src/lang/ADempiere/en.js | 3 +- src/lang/ADempiere/es.js | 3 +- src/layout/components/TagsView/index.vue | 4 +- src/router/modules/ADempiere/menu.js | 4 +- src/store/modules/ADempiere/data.js | 41 +--- src/store/modules/ADempiere/panel.js | 1 + src/store/modules/ADempiere/processControl.js | 135 +++++++---- src/store/modules/ADempiere/reportControl.js | 216 ++++++++++++++++++ src/store/modules/tagsView.js | 6 +- src/utils/ADempiere/dictionaryUtils.js | 2 +- src/views/ADempiere/ReportViewer/index.vue | 8 +- 15 files changed, 410 insertions(+), 104 deletions(-) create mode 100644 src/store/modules/ADempiere/reportControl.js diff --git a/src/api/ADempiere/data.js b/src/api/ADempiere/data.js index a1d9f99e..52d51859 100644 --- a/src/api/ADempiere/data.js +++ b/src/api/ADempiere/data.js @@ -334,6 +334,7 @@ export function unlockPrivateAccessFromServer({ tableName: tableName, recordId: export function getFavoritesFromServer(userUuid) { return Instance.call(this).requestFavorites(userUuid) } + export function getPendingDocumentsFromServer(userUuid, roleUuid) { return Instance.call(this).requestPendingDocuments(userUuid, roleUuid) } @@ -345,3 +346,35 @@ export function requestReportViews({ tableName, processUuid }) { export function requestPrintFormats({ tableName, reportViewUuid, processUuid }) { return Instance.call(this).requestPrintFormats({ tableName: tableName, reportViewUuid: reportViewUuid, processUuid: processUuid }) } + +export function requestDrillTables(tableName) { + return Instance.call(this).requestDrillTables(tableName) +} + +export function getReportOutput({ + criteria: criteria, + printFormatUuid: printFormatUuid, + reportViewUuid: reportViewUuid, + isSummary: isSummary, + reportName: reportName, + reportType: reportType, + tableName: tableName +}) { + const criteriaForReport = getCriteria(tableName) + if (criteria && criteria.length) { + criteria.forEach(parameter => { + var isAddCodition = true + if (parameter.isRange && criteria.some(param => param.columnName === `${parameter.columnName}_To`)) { + parameter.valueTo = criteria.find(param => param.columnName === `${parameter.columnName}_To`).value + } + const convertedParameter = Instance.call(this).convertCondition(parameter) + if (parameter.isRange && !parameter.hasOwnProperty('valueTo')) { + isAddCodition = false + } + if (isAddCodition) { + criteriaForReport.addConditions(convertedParameter) + } + }) + } + return Instance.call(this).getReportOutput({ criteria: criteriaForReport, printFormatUuid: printFormatUuid, reportViewUuid: reportViewUuid, isSummary: isSummary, reportName: reportName, reportType: reportType }) +} diff --git a/src/components/ADempiere/ContextMenu/contextMenuDesktop.vue b/src/components/ADempiere/ContextMenu/contextMenuDesktop.vue index bc27b83d..3bce600f 100644 --- a/src/components/ADempiere/ContextMenu/contextMenuDesktop.vue +++ b/src/components/ADempiere/ContextMenu/contextMenuDesktop.vue @@ -22,9 +22,11 @@ - - {{ child.name }} - + + + {{ child.name }} + + {{ action.name }} @@ -60,7 +62,7 @@ - + {{ $t('components.contextMenuPrintFormatSetup') }} diff --git a/src/components/ADempiere/ContextMenu/contextMenuMixin.js b/src/components/ADempiere/ContextMenu/contextMenuMixin.js index 91f6afca..c485ddaa 100644 --- a/src/components/ADempiere/ContextMenu/contextMenuMixin.js +++ b/src/components/ADempiere/ContextMenu/contextMenuMixin.js @@ -159,6 +159,9 @@ export const contextMixin = { } } return false + }, + metadataReport() { + return this.$store.getters.getCachedReport(this.$route.params.instanceUuid) } }, watch: { @@ -424,6 +427,38 @@ export const contextMixin = { } }) } + } else if (action.type === 'updateReport') { + var updateReportParams = { + instanceUuid: action.instanceUuid, + processUuid: action.processUuid, + tableName: action.tableName, + processId: action.processId, + printFormatUuid: action.printFormatUuid, + reportViewUuid: action.reportViewUuid, + isSummary: false, + reportName: this.$store.getters.getProcessResult.name, + reportType: this.$store.getters.getReportType, + option: action.option + } + this.$store.dispatch('getReportOutputFromServer', updateReportParams) + .then(response => { + if (!response.isError) { + var link = { + href: undefined, + download: undefined + } + + const blob = new Blob([response.outputStream], { type: response.mimeType }) + link = document.createElement('a') + link.href = window.URL.createObjectURL(blob) + link.download = response.fileName + if (response.reportType !== 'pdf' && response.reportType !== 'html') { + link.click() + } + response.url = link.href + } + this.$store.dispatch('finishProcess', { processOutput: response, routeToDelete: this.$route }) + }) } }, setShareLink() { @@ -489,6 +524,15 @@ export const contextMixin = { duration: 1500 }) }, + redirect() { + this.$router.push({ + name: ROUTES.PRINT_FORMAT_SETUP_WINDOW.uuid, + query: { + action: this.metadataReport.output.printFormatUuid, + tabParent: ROUTES.PRINT_FORMAT_SETUP_WINDOW.tabParent + } + }) + }, validatePrivateAccess(response) { if (response.isLocked) { this.actions.find(item => item.action === 'unlockRecord').hidden = false diff --git a/src/components/ADempiere/ContextMenu/index.vue b/src/components/ADempiere/ContextMenu/index.vue index d762b3b5..ed5add9c 100644 --- a/src/components/ADempiere/ContextMenu/index.vue +++ b/src/components/ADempiere/ContextMenu/index.vue @@ -146,6 +146,10 @@ export default { max-height: 400px; } + .scroll-child { + max-height: 300px; + } + .el-icon-more { transform: rotate(90deg); } diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js index 73a467b4..8f87f7dd 100644 --- a/src/lang/ADempiere/en.js +++ b/src/lang/ADempiere/en.js @@ -161,7 +161,8 @@ export default { unsupportedInfo: 'Please check that the view is supported in this version, or click the button below to return to the homepage.', unsupportedButton: 'Back to dashboard', reportView: 'Report Views', - printFormat: 'Print Formats' + printFormat: 'Print Formats', + drillTable: 'Drill Down' }, report: { ExportXlsx: '(xlsx) Excel File Extension', diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js index 810340ac..920efacb 100644 --- a/src/lang/ADempiere/es.js +++ b/src/lang/ADempiere/es.js @@ -161,7 +161,8 @@ export default { unsupportedInfo: 'Verifique que la vista sea compatible con esta versión, o haga clic en el botón a continuación para volver a la página de inicio.', unsupportedButton: 'Volver al Panel de control', reportView: 'Vistas de Reporte', - printFormat: 'Formatos de Impresión' + printFormat: 'Formatos de Impresión', + drillTable: 'Entrar en Detalle' }, report: { ExportXlsx: '(xlsx) Extencion de Archivo Excel', diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index 1a75d9fa..f4009a70 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -107,7 +107,7 @@ export default { generateTitle, // generateTitle by vue-i18n isActive(route) { if (route.name === 'Report Viewer') { - if (route.params.processId === this.$route.params.processId) { + if (route.params.processId === this.$route.params.processId && route.params.tableName === this.$route.params.tableName) { return route.params.processId === this.$route.params.processId } else { return route.path === this.$route.path @@ -158,7 +158,7 @@ export default { this.$nextTick(() => { for (const tag of tags) { if (this.$route.name === 'Report Viewer') { - if (this.$route.params && tag.to.params && tag.to.params.processId === this.$route.params.processId) { + if (this.$route.params && tag.to.params && tag.to.params.processId === this.$route.params.processId && tag.to.params.tableName === this.$route.params.tableName) { this.$refs.scrollPane.moveToTarget(tag) } } diff --git a/src/router/modules/ADempiere/menu.js b/src/router/modules/ADempiere/menu.js index 7974a7bd..a1f890b8 100644 --- a/src/router/modules/ADempiere/menu.js +++ b/src/router/modules/ADempiere/menu.js @@ -39,10 +39,10 @@ const staticRoutes = [ path: '/report-viewer', component: Layout, hidden: true, - redirect: 'report-viewer/:processId/:instanceUuid/:fileName', + redirect: 'report-viewer/:processId/:instanceUuid/:fileName/:tableName?', children: [ { - path: ':processId/:instanceUuid/:fileName', + path: ':processId/:instanceUuid/:fileName/:tableName?', component: () => import('@/views/ADempiere/ReportViewer'), name: 'Report Viewer', meta: { diff --git a/src/store/modules/ADempiere/data.js b/src/store/modules/ADempiere/data.js index af4ac2c4..e614978f 100644 --- a/src/store/modules/ADempiere/data.js +++ b/src/store/modules/ADempiere/data.js @@ -6,12 +6,11 @@ import { getDefaultValueFromServer, convertValueFromGRPC, getContextInfoValueFromServer, + getFavoritesFromServer, getPrivateAccessFromServer, lockPrivateAccessFromServer, unlockPrivateAccessFromServer, - getFavoritesFromServer, - getPendingDocumentsFromServer, - requestPrintFormats + getPendingDocumentsFromServer } from '@/api/ADempiere' import { convertValuesMapToObject, isEmptyValue } from '@/utils/ADempiere/valueUtils' import { showMessage } from '@/utils/ADempiere/notification' @@ -27,8 +26,7 @@ const data = { pendingDocuments: [], inGetting: [], contextInfoField: [], - recordPrivateAccess: {}, - printFormatList: [] + recordPrivateAccess: {} }, mutations: { addInGetting(state, payload) { @@ -115,9 +113,6 @@ const data = { }, setPrivateAccess(state, payload) { state.recordPrivateAccess = payload - }, - setPrintFormatList(state, payload) { - state.printFormatList.push(payload) } }, actions: { @@ -987,29 +982,6 @@ const data = { }) console.error(error) }) - }, - requestPrintFormats({ commit }, parameters) { - return requestPrintFormats({ - processUuid: parameters.processUuid - }) - .then(response => { - const printFormatList = response.getPrintformatsList().map(printFormat => { - return { - uuid: printFormat.getUuid(), - name: printFormat.getName(), - description: printFormat.getDescription(), - isDefault: printFormat.getIsdefault() - } - }) - commit('setPrintFormatList', { - containerUuid: parameters.processUuid, - printFormatList: printFormatList - }) - return printFormatList - }) - .catch(error => { - console.error(error) - }) } }, getters: { @@ -1153,13 +1125,6 @@ const data = { } return undefined } - }, - getPrintFormatList: (state) => (containerUuid) => { - var printFormatList = state.printFormatList.find(list => list.containerUuid === containerUuid) - if (printFormatList) { - return printFormatList.printFormatList - } - return [] } } } diff --git a/src/store/modules/ADempiere/panel.js b/src/store/modules/ADempiere/panel.js index 541383df..26e2c8cd 100644 --- a/src/store/modules/ADempiere/panel.js +++ b/src/store/modules/ADempiere/panel.js @@ -1227,6 +1227,7 @@ const panel = { return { columnName: parameterItem.columnName, value: value, + isRange: parameterItem.isRange, values: values } }) diff --git a/src/store/modules/ADempiere/processControl.js b/src/store/modules/ADempiere/processControl.js index 29c7a860..24c9619c 100644 --- a/src/store/modules/ADempiere/processControl.js +++ b/src/store/modules/ADempiere/processControl.js @@ -1,4 +1,4 @@ -import { runProcess, requestProcessActivity, requestReportViews } from '@/api/ADempiere' +import { runProcess, requestProcessActivity } from '@/api/ADempiere' import { showNotification } from '@/utils/ADempiere/notification' import { isEmptyValue, convertMapToArrayPairs } from '@/utils/ADempiere' import language from '@/lang' @@ -14,8 +14,7 @@ const processControl = { process: [], // process to run finish sessionProcess: [], notificationProcess: [], - inRequestMetadata: [], - reportViewList: [] + inRequestMetadata: [] }, mutations: { // Add process in execution @@ -57,7 +56,12 @@ const processControl = { }, setReportValues(state, payload) { state.reportObject = payload - state.reportList.push(payload) + if (state.reportList.some(report => report.instanceUuid === payload.instanceUuid)) { + var reportIndex = state.reportList.findIndex(report => report.instanceUuid === payload.instanceUuid) + state.reportList.splice(reportIndex, 1, payload) + } else { + state.reportList.push(payload) + } }, setSessionProcess(state, payload) { state.sessionProcess = payload.processList @@ -74,9 +78,6 @@ const processControl = { state.sessionProcess = [] state.notificationProcess = [] state.inRequestMetadata = [] - }, - setReportViewsList(state, payload) { - state.reportViewList.push(payload) } }, actions: { @@ -208,7 +209,7 @@ const processControl = { outputStream: '', reportType: '' } - if (response.getOutput()) { + if (response.hasOutput()) { const responseOutput = response.getOutput() output = { uuid: responseOutput.getUuid(), @@ -218,7 +219,14 @@ const processControl = { mimeType: responseOutput.getMimetype(), output: responseOutput.getOutput(), outputStream: responseOutput.getOutputstream(), - reportType: responseOutput.getReporttype() + reportType: responseOutput.getReporttype(), + dataCols: responseOutput.getDatacols(), + dataRows: responseOutput.getDatarows(), + footerName: responseOutput.getFootername(), + headerName: responseOutput.getHeadername(), + printFormatUuid: responseOutput.getPrintformatuuid(), + reportViewUuid: responseOutput.getReportviewuuid(), + tableName: responseOutput.getTablename() } } var logList = [] @@ -253,15 +261,22 @@ const processControl = { option: 'reportView' } reportViewList.childs = getters.getReportViewList(processResult.processUuid) - if (!reportViewList.childs.length) { + if (reportViewList && !reportViewList.childs.length) { dispatch('requestReportViews', { - processUuid: processResult.processUuid + processUuid: processResult.processUuid, + instanceUuid: response.getInstanceuuid(), + processId: processDefinition.id, + tableName: output.tableName, + printFormatUuid: output.printFormatUuid, + reportViewUuid: output.reportViewUuid }) .then(response => { reportViewList.childs = response - // Get contextMenu metadata and concat print report views with contextMenu actions - var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid) - contextMenuMetadata.actions.push(reportViewList) + if (reportViewList.childs.length) { + // Get contextMenu metadata and concat print report views with contextMenu actions + var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid) + contextMenuMetadata.actions.push(reportViewList) + } }) } @@ -274,17 +289,54 @@ const processControl = { option: 'printFormat' } printFormatList.childs = rootGetters.getPrintFormatList(processResult.processUuid) - if (!printFormatList.childs.length) { + if (printFormatList && !printFormatList.childs.length) { dispatch('requestPrintFormats', { - processUuid: processResult.processUuid + processUuid: processResult.processUuid, + instanceUuid: response.getInstanceuuid(), + processId: processDefinition.id, + tableName: output.tableName, + printFormatUuid: output.printFormatUuid, + reportViewUuid: output.reportViewUuid }) .then(response => { printFormatList.childs = response - // Get contextMenu metadata and concat print Format List with contextMenu actions - var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid) - contextMenuMetadata.actions.push(printFormatList) + 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) + } }) } + + // 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, { @@ -294,7 +346,7 @@ const processControl = { isError: response.getIserror(), isProcessing: response.getIsprocessing(), summary: response.getSummary(), - ResultTableName: response.getResulttablename(), + resultTableName: response.getResulttablename(), lastRun: response.getLastrun(), logs: logList, output: output @@ -463,13 +515,24 @@ const processControl = { } if (parameters.processOutput.isReport && !parameters.processOutput.isError) { // open report viewer with report response + if (isEmptyValue(parameters.processOutput.menuParentUuid)) { + parameters.processOutput.menuParentUuid = parameters.processOutput.processUuid + } + + var tableName + if (parameters.processOutput.option && !isEmptyValue(parameters.processOutput.option)) { + if (parameters.processOutput.option === 'drillTable') { + tableName = parameters.processOutput.tableName + } + } router.push({ name: 'Report Viewer', params: { processId: parameters.processOutput.processId, instanceUuid: parameters.processOutput.instanceUuid, - fileName: parameters.processOutput.output.fileName, - menuParentUuid: parameters.processOutput.menuParentUuid + fileName: isEmptyValue(parameters.processOutput.output.fileName) ? parameters.processOutput.fileName : parameters.processOutput.output.fileName, + menuParentUuid: parameters.processOutput.menuParentUuid, + tableName: tableName } }) } @@ -485,27 +548,6 @@ const processControl = { }, clearProcessControl({ commit }) { commit('clearProcessControl') - }, - requestReportViews({ commit }, parameters) { - return requestReportViews({ processUuid: parameters.processUuid }) - .then(response => { - const reportViewList = response.getReportviewsList().map(reportView => { - return { - uuid: reportView.getUuid(), - name: reportView.getName(), - tableName: reportView.getTablename(), - description: reportView.getDescription() - } - }) - commit('setReportViewsList', { - containerUuid: parameters.processUuid, - viewList: reportViewList - }) - return reportViewList - }) - .catch(error => { - console.error(error) - }) } }, getters: { @@ -550,13 +592,6 @@ const processControl = { return state.reportList.find( item => item.instanceUuid === instanceUuid ) - }, - getReportViewList: (state) => (containerUuid) => { - var reportViewList = state.reportViewList.find(list => list.containerUuid === containerUuid) - if (reportViewList) { - return reportViewList.viewList - } - return [] } } } diff --git a/src/store/modules/ADempiere/reportControl.js b/src/store/modules/ADempiere/reportControl.js new file mode 100644 index 00000000..09781615 --- /dev/null +++ b/src/store/modules/ADempiere/reportControl.js @@ -0,0 +1,216 @@ +import { requestReportViews, requestPrintFormats, requestDrillTables, getReportOutput } from '@/api/ADempiere' +import { isEmptyValue } from '@/utils/ADempiere' +const contextMenu = { + state: { + reportFormatsList: [], + reportViewsList: [], + drillTablesList: [], + reportOutput: {} + }, + mutations: { + setReportFormatsList(state, payload) { + state.reportFormatsList.push(payload) + }, + setReportViewsList(state, payload) { + state.reportViewsList.push(payload) + }, + setDrillTablesList(state, payload) { + state.drillTablesList.push(payload) + }, + setNewReportOutput(state, payload) { + state.reportOutput = payload + } + }, + actions: { + requestPrintFormats({ commit }, parameters) { + return requestPrintFormats({ processUuid: parameters.processUuid }) + .then(response => { + const printFormatList = response.getPrintformatsList().map(printFormat => { + return { + printFormatUuid: printFormat.getUuid(), + name: printFormat.getName(), + description: printFormat.getDescription(), + isDefault: printFormat.getIsdefault(), + tableName: printFormat.getTablename(), + reportViewUuid: printFormat.getReportviewuuid(), + type: 'updateReport', + option: 'printFormat', + instanceUuid: parameters.instanceUuid, + processUuid: parameters.processUuid, + processId: parameters.processId + } + }) + commit('setReportFormatsList', { + containerUuid: parameters.processUuid, + printFormatList: printFormatList + }) + return printFormatList + }) + .catch(error => { + console.error(error) + }) + }, + requestReportViews({ commit }, parameters) { + return requestReportViews({ processUuid: parameters.processUuid }) + .then(response => { + const reportViewList = response.getReportviewsList().map(reportView => { + return { + reportViewUuid: reportView.getUuid(), + name: reportView.getName(), + tableName: reportView.getTablename(), + description: reportView.getDescription(), + type: 'updateReport', + option: 'reportView', + instanceUuid: parameters.instanceUuid, + printFormatUuid: parameters.printFormatUuid, + processUuid: parameters.processUuid, + processId: parameters.processId + } + }) + commit('setReportViewsList', { + containerUuid: parameters.processUuid, + viewList: reportViewList + }) + return reportViewList + }) + .catch(error => { + console.error(error) + }) + }, + requestDrillTables({ commit }, parameters) { + return requestDrillTables(parameters.tableName) + .then(response => { + const drillTablesList = response.getDrilltablesList().map(drillTable => { + return { + name: drillTable.getPrintname(), + tableName: drillTable.getTablename(), + type: 'updateReport', + option: 'drillTable', + instanceUuid: parameters.instanceUuid, + printFormatUuid: parameters.printFormatUuid, + reportViewUuid: parameters.reportViewUuid, + processUuid: parameters.processUuid, + processId: parameters.processId + } + }) + commit('setDrillTablesList', { + containerUuid: parameters.processUuid, + drillTablesList: drillTablesList + }) + return drillTablesList + }) + .catch(error => { + console.error(error) + }) + }, + getReportOutputFromServer({ commit, getters, rootGetters }, parameters) { + if (isEmptyValue(parameters.printFormatUuid)) { + parameters.printFormatUuid = getters.getDefaultPrintFormat(parameters.processUuid).printFormatUuid + } + const { + tableName, + printFormatUuid, + reportViewUuid, + isSummary, + reportName, + reportType, + processUuid, + processId, + instanceUuid, + option + } = parameters + const processParameters = rootGetters.getParametersToServer({ containerUuid: processUuid }) + return getReportOutput({ + criteria: processParameters, + printFormatUuid: printFormatUuid, + reportViewUuid: reportViewUuid, + isSummary: isSummary, + reportName: reportName, + reportType: reportType, + tableName: tableName + }) + .then(response => { + const reportOutput = { + uuid: response.getUuid(), + processName: response.getName(), + description: response.getDescription(), + fileName: response.getFilename(), + output: response.getOutput(), + mimeType: response.getMimetype(), + dataCols: response.getDatacols(), + dataRows: response.getDatarows(), + headerName: response.getHeadername(), + footerName: response.getFootername(), + printFormatUuid: response.getPrintformatuuid(), + reportViewUuid: response.getReportviewuuid(), + tableName: response.getTablename(), + outputStream: response.getOutputstream(), + reportType: response.getReporttype(), + processId: processId, + processUuid: processUuid, + isError: false, + instanceUuid: instanceUuid, + isReport: true, + option: option + } + commit('setNewReportOutput', reportOutput) + return reportOutput + }) + .catch(error => { + const reportOutput = { + uuid: '', + processName: '', + description: '', + fileName: '', + output: '', + mimeType: '', + dataCols: null, + dataRows: null, + headerName: '', + footerName: '', + printFormatUuid: '', + reportViewUuid: '', + tableName: '', + outputStream: [], + reportType: '', + processId: null, + processUuid: '', + isError: true, + instanceUuid: '', + isReport: true, + option: '' + } + console.error(error) + return reportOutput + }) + } + }, + getters: { + getPrintFormatList: (state) => (containerUuid) => { + var printFormatList = state.reportFormatsList.find(list => list.containerUuid === containerUuid) + if (printFormatList) { + return printFormatList.printFormatList + } + return [] + }, + getDefaultPrintFormat: (state, getters) => (containerUuid) => { + return getters.getPrintFormatList(containerUuid).find(printFormat => printFormat.isDefault) + }, + getReportViewList: (state) => (containerUuid) => { + var reportViewList = state.reportViewsList.find(list => list.containerUuid === containerUuid) + if (reportViewList) { + return reportViewList.viewList + } + return [] + }, + getDrillTablesList: (state) => (containerUuid) => { + var drillTablesList = state.drillTablesList.find(list => list.containerUuid === containerUuid) + if (drillTablesList) { + return drillTablesList.viewList + } + return [] + } + } +} + +export default contextMenu diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index 13ba43ec..6bfb4790 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -6,7 +6,11 @@ const state = { const mutations = { ADD_VISITED_VIEW: (state, view) => { if (view.name === 'Report Viewer') { - if (state.visitedViews.some(v => v.params && v.params.processId === view.params.processId)) return + if (state.visitedViews.some(v => + v.params && + v.params.processId === view.params.processId && + v.params.tableName === view.params.tableName + )) return state.visitedViews.push( Object.assign({}, view, { title: view.meta.title || 'no-name' diff --git a/src/utils/ADempiere/dictionaryUtils.js b/src/utils/ADempiere/dictionaryUtils.js index fbc8e048..2ca509c9 100644 --- a/src/utils/ADempiere/dictionaryUtils.js +++ b/src/utils/ADempiere/dictionaryUtils.js @@ -204,7 +204,7 @@ export function generateProcess({ processToGenerate, containerUuidAssociated = u description: processToGenerate.description, isReport: processToGenerate.isReport, isDirectPrint: processToGenerate.isDirectPrint, - reportExportType: undefined + reportExportType: 'html' }, { name: language.t('components.ChangeParameters'), processName: processToGenerate.name, diff --git a/src/views/ADempiere/ReportViewer/index.vue b/src/views/ADempiere/ReportViewer/index.vue index dfc457d1..d2b72eb7 100644 --- a/src/views/ADempiere/ReportViewer/index.vue +++ b/src/views/ADempiere/ReportViewer/index.vue @@ -105,10 +105,10 @@ export default { showNotification, displayReport(reportResult) { if (!reportResult.isError) { - this.reportFormat = reportResult.output.reportType - this.reportContent = reportResult.output.output - this.reportHeader = reportResult.output.name - this.name = reportResult.output.fileName + this.reportFormat = this.isEmptyValue(reportResult.output.reportType) ? reportResult.reportType : reportResult.output.reportType + this.reportContent = this.isEmptyValue(reportResult.output.output) ? reportResult.output : reportResult.output.output + this.reportHeader = this.isEmptyValue(reportResult.output.name) ? reportResult.processName : reportResult.output.name + this.name = this.isEmptyValue(reportResult.output.fileName) ? reportResult.fileName : reportResult.output.fileName this.isLoading = true } },