From 822700ff5cffe6abd15e2d0b929f5bdcbb2d33e3 Mon Sep 17 00:00:00 2001
From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com>
Date: Mon, 12 Aug 2024 10:43:56 -0400
Subject: [PATCH] Fix Api (#2566)
* Fix Api
* WIP on feature/combination-report-engine Report Manager stash
* Support to Report Engine and Report Run
---
src/api/ADempiere/reportManagement/index.ts | 23 +-
.../ADempiere/reportManagement/printFormat.ts | 19 ++
.../convenienceButtons/PrintProcess.vue | 159 ++++++++--
.../ADempiere/dictionary/report/actions.js | 20 +-
.../ADempiere/dictionary/window/actions.js | 19 ++
src/store/modules/ADempiere/report/Report.ts | 17 --
.../modules/ADempiere/report/ReportEngine.ts | 17 --
.../ADempiere/report/ReportManagert.ts | 17 --
src/store/modules/ADempiere/report/report.js | 120 --------
.../modules/ADempiere/report/reportEnginer.js | 275 ------------------
.../modules/ADempiere/report/reportRun.js | 179 ++++++++++++
src/store/modules/ADempiere/reportManager.js | 74 ++++-
src/views/ADempiere/ReportViewer/index.vue | 8 +-
.../ADempiere/ReportViewerEngine/index.vue | 8 +
14 files changed, 459 insertions(+), 496 deletions(-)
delete mode 100644 src/store/modules/ADempiere/report/Report.ts
delete mode 100644 src/store/modules/ADempiere/report/ReportEngine.ts
delete mode 100644 src/store/modules/ADempiere/report/ReportManagert.ts
delete mode 100644 src/store/modules/ADempiere/report/report.js
delete mode 100644 src/store/modules/ADempiere/report/reportEnginer.js
create mode 100644 src/store/modules/ADempiere/report/reportRun.js
diff --git a/src/api/ADempiere/reportManagement/index.ts b/src/api/ADempiere/reportManagement/index.ts
index 89ac8a25b6..2dd22ab6e7 100644
--- a/src/api/ADempiere/reportManagement/index.ts
+++ b/src/api/ADempiere/reportManagement/index.ts
@@ -33,6 +33,7 @@ import { request } from '@/utils/ADempiere/request'
export function generateReportRequest({
id,
reportType,
+ reportFormat,
parameters,
printFormatId,
reportViewId,
@@ -45,7 +46,7 @@ export function generateReportRequest({
url: `/report-management/report/${id}`,
method: 'post',
data: {
- report_type: reportType,
+ report_type: reportFormat,
parameters,
print_format_id: printFormatId,
report_view_id: reportViewId,
@@ -58,14 +59,16 @@ export function generateReportRequest({
// Get report output from parameters
export function getReportOutputRequest({
- processId,
+ reportId,
+ recordId,
processUuid,
tableName,
printFormatUuid,
+ printFormatId,
reportViewUuid,
isSummary,
reportName,
- reportType,
+ reportFormat,
parametersList = [],
// query criteria
query,
@@ -80,18 +83,20 @@ export function getReportOutputRequest({
})
return request({
- url: '/user-interface/process/report-output',
+ url: `/report-management/report-output/${reportId}/${tableName}`,
method: 'get',
params: {
- process_id: processId,
+ report_id: reportId,
process_uuid: processUuid,
table_name: tableName,
// reference
print_format_uuid: printFormatUuid,
+ print_format_id: printFormatId,
report_view_uuid: reportViewUuid,
+ record_id: recordId,
is_summary: isSummary,
report_name: reportName,
- report_type: reportType,
+ report_type: reportFormat,
// DSL Query
filters,
criteria: filters,
@@ -193,21 +198,21 @@ export function runExport({
})
}
-export function ListNotificationsTypes() {
+export function listNotificationsTypes() {
return request({
url: '/send_notifications/notifications_types',
method: 'get'
})
}
-export function ListUsers() {
+export function listUsers() {
return request({
url: '/send_notifications/user',
method: 'get'
})
}
-export function SendNotification({
+export function sendNotification({
user_id,
title,
recipients,
diff --git a/src/api/ADempiere/reportManagement/printFormat.ts b/src/api/ADempiere/reportManagement/printFormat.ts
index e9c0029925..6da2e819c4 100644
--- a/src/api/ADempiere/reportManagement/printFormat.ts
+++ b/src/api/ADempiere/reportManagement/printFormat.ts
@@ -40,3 +40,22 @@ export function listPrintFormatsRequest({
}
})
}
+
+/**
+ * Get default value for a field, parameter or query criteria
+ * @param {Number} reportId, identifier of report
+ */
+export function listPrintFormatsTableRequest({
+ tableName,
+ pageToken,
+ pageSize = ROWS_OF_RECORDS_BY_PAGE
+}) {
+ return request({
+ url: `/report-management/print-formats/table/${tableName}`,
+ method: 'get',
+ params: {
+ page_size: pageSize,
+ page_token: pageToken
+ }
+ })
+}
diff --git a/src/components/ADempiere/TabManager/convenienceButtons/PrintProcess.vue b/src/components/ADempiere/TabManager/convenienceButtons/PrintProcess.vue
index 3f723a79b1..8bbe48d84c 100644
--- a/src/components/ADempiere/TabManager/convenienceButtons/PrintProcess.vue
+++ b/src/components/ADempiere/TabManager/convenienceButtons/PrintProcess.vue
@@ -1,6 +1,7 @@
-
-
-
+
+
+
+
+
+
+ {{ $t(process.name) }}
+
+
+
+
+
+
+
+
+
diff --git a/src/store/modules/ADempiere/dictionary/report/actions.js b/src/store/modules/ADempiere/dictionary/report/actions.js
index f05621fd56..182c17aac6 100644
--- a/src/store/modules/ADempiere/dictionary/report/actions.js
+++ b/src/store/modules/ADempiere/dictionary/report/actions.js
@@ -69,7 +69,8 @@ export default {
* @param {string} uuid of dictionary
*/
getReportDefinitionFromServer({ dispatch, getters, rootGetters }, {
- id
+ id,
+ tableName
}) {
return new Promise((resolve, reject) => {
const language = rootGetters['getCurrentLanguage']
@@ -89,10 +90,19 @@ export default {
const { processDefinition: reportDefinition } = generateReport({
processToGenerate: reportResponse
})
-
- await dispatch('getListPrintFormatsFromServer', {
- reportId: reportDefinition.id
- })
+ const {
+ type
+ } = router.app._route.meta
+ if (type === 'window') {
+ await dispatch('listPrintFormatWindow', {
+ tableName,
+ reportId: reportDefinition.id
+ })
+ } else {
+ await dispatch('listPrintFormatsFromServer', {
+ reportId: reportDefinition.id
+ })
+ }
dispatch('addReportToList', reportDefinition)
diff --git a/src/store/modules/ADempiere/dictionary/window/actions.js b/src/store/modules/ADempiere/dictionary/window/actions.js
index 39cbd0303d..603d5351f2 100644
--- a/src/store/modules/ADempiere/dictionary/window/actions.js
+++ b/src/store/modules/ADempiere/dictionary/window/actions.js
@@ -22,6 +22,7 @@ import store from '@/store'
// API Request Methods
import { requestWindowMetadata } from '@/api/ADempiere/dictionary/window.ts'
+import { listPrintFormatsTableRequest } from '@/api/ADempiere/reportManagement/printFormat.ts'
// Constants
import { CLIENT, DOCUMENT_ACTION, DOCUMENT_STATUS } from '@/utils/ADempiere/constants/systemColumns'
@@ -964,5 +965,23 @@ export default {
parentUuid: parentUuid + IS_ADVANCED_QUERY,
tabAdvanceQuery
})
+ },
+ setPrintFormatWindow({ commit }, {
+ tableName,
+ reportId
+ }) {
+ return new Promise(resolve => {
+ listPrintFormatsTableRequest({
+ tableName
+ })
+ .then(response => {
+ const { print_formats } = response
+ commit('setPrintFormatsList', {
+ reportId,
+ printFormatList: print_formats
+ })
+ resolve(print_formats)
+ })
+ })
}
}
diff --git a/src/store/modules/ADempiere/report/Report.ts b/src/store/modules/ADempiere/report/Report.ts
deleted file mode 100644
index 3145093500..0000000000
--- a/src/store/modules/ADempiere/report/Report.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
- * Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
- * Contributor(s): Elsio Sanchez elsiosanches@gmail.com https://github.com/elsiosanchez
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
diff --git a/src/store/modules/ADempiere/report/ReportEngine.ts b/src/store/modules/ADempiere/report/ReportEngine.ts
deleted file mode 100644
index 3145093500..0000000000
--- a/src/store/modules/ADempiere/report/ReportEngine.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
- * Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
- * Contributor(s): Elsio Sanchez elsiosanches@gmail.com https://github.com/elsiosanchez
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
diff --git a/src/store/modules/ADempiere/report/ReportManagert.ts b/src/store/modules/ADempiere/report/ReportManagert.ts
deleted file mode 100644
index 3145093500..0000000000
--- a/src/store/modules/ADempiere/report/ReportManagert.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
- * Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
- * Contributor(s): Elsio Sanchez elsiosanches@gmail.com https://github.com/elsiosanchez
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
diff --git a/src/store/modules/ADempiere/report/report.js b/src/store/modules/ADempiere/report/report.js
deleted file mode 100644
index 964c65b607..0000000000
--- a/src/store/modules/ADempiere/report/report.js
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
- * Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
- * Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-import Vue from 'vue'
-
-// Api Reqest Methods
-import {
- getReportOutputRequest
-} from '@/api/ADempiere/reportManagement/index.ts'
-
-// Utils and Helper Methods
-import {
- buildLinkHref
-} from '@/utils/ADempiere/resource.js'
-import { isEmptyValue } from '@/utils/ADempiere'
-const initState = {
- reportsOutput: {}
-}
-
-const reportManager = {
- state: initState,
- mutations: {
- setReportOutput(state, reportOutput) {
- Vue.set(state.reportsOutput, reportOutput.instanceUuid, reportOutput)
- }
- },
- actions: {
- getReportOutputFromServer({ commit, getters, rootGetters }, {
- uuid,
- id,
- instanceUuid,
- tableName,
- printFormatId,
- reportViewId,
- isSummary,
- reportName,
- reportType,
- parametersList = []
- }) {
- return new Promise(resolve => {
- if (isEmptyValue(printFormatId) || printFormatId <= 0) {
- const printFormat = getters.getDefaultPrintFormat(uuid)
- if (!isEmptyValue(printFormat)) {
- printFormatId = printFormat.printFormatId
- }
- }
- if (isEmptyValue(parametersList)) {
- parametersList = rootGetters.getParametersToServer({
- containerUuid: uuid
- })
- }
- getReportOutputRequest({
- processUuid: uuid,
- parametersList,
- printFormatId,
- reportViewId,
- isSummary,
- reportName,
- reportType,
- tableName
- })
- .then(response => {
- let link = {
- href: undefined,
- download: undefined
- }
- if (response && response.output_stream) {
- link = buildLinkHref({
- fileName: response.file_name,
- outputStream: response.output_stream,
- type: response.mime_type
- })
- }
-
- const reportOutput = {
- ...response,
- reportId: id,
- reportUuid: uuid,
- isError: false,
- instanceUuid,
- isReport: true,
- link,
- parametersList,
- url: link.href,
- download: link.download
- }
-
- commit('setReportOutput', reportOutput)
-
- resolve(reportOutput)
- })
- .catch(error => {
- console.warn(`Error getting report output: ${error.message}. Code: ${error.code}.`)
- })
- })
- }
- },
- getters: {
- getReportOutput: (state) => (instanceUuid) => {
- return state.reportsOutput[instanceUuid]
- }
- }
-}
-
-export default reportManager
diff --git a/src/store/modules/ADempiere/report/reportEnginer.js b/src/store/modules/ADempiere/report/reportEnginer.js
deleted file mode 100644
index 5a4f95696d..0000000000
--- a/src/store/modules/ADempiere/report/reportEnginer.js
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
- * Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
- * Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-import Vue from 'vue'
-import router from '@/router'
-import language from '@/lang'
-// API Request Methods
-import {
- getView,
- runExport,
- generateReport
-} from '@/api/ADempiere/reportManagement/index.ts'
-
-// Utils
-import {
- isEmptyValue,
- getOperatorAndValue
-} from '@/utils/ADempiere/valueUtils.js'
-import { showNotification } from '@/utils/ADempiere/notification.js'
-import { config } from '@/utils/ADempiere/config'
-
-const initState = {
- reportManager: {}
-}
-const reportManager = {
- state: initState,
-
- mutations: {
- setReportManager(state, reportManager) {
- Vue.set(state.reportManager, reportManager.instanceUuid, reportManager)
- }
- },
- actions: {
- buildReport({ commit, getters, dispatch }, {
- containerUuid,
- instanceUuid,
- tableName,
- printFormatId,
- reportViewId,
- reportType,
- isSummary,
- pageToken,
- pageSize,
- sortBy
- }) {
- const currentRoute = router.app._route
- if (isEmptyValue(containerUuid)) {
- if (currentRoute.params && currentRoute.params.reportUuid) {
- containerUuid = currentRoute.params.reportUuid
- }
- }
- const reportDefinition = getters.getStoredReport(containerUuid)
- const {
- id,
- name,
- description,
- fieldsList
- } = reportDefinition
- showNotification({
- title: language.t('notifications.processing'),
- message: name,
- summary: description,
- type: 'info'
- })
- commit('setReportIsLoading', true)
- return new Promise((resolve) => {
- const filters = getOperatorAndValue({
- format: 'array',
- containerUuid,
- fieldsList
- })
- if (isEmptyValue(instanceUuid)) {
- dispatch('generateReportViwer', {
- reportId: reportDefinition.id,
- reportUuid: reportDefinition.uuid,
- containerUuid,
- filters,
- printFormatId,
- reportViewId,
- isSummary,
- tableName
- })
- }
- getView({
- printFormatId,
- reportViewId,
- reportType,
- pageToken,
- isSummary,
- tableName,
- pageSize,
- filters,
- sortBy
- })
- .then(response => {
- commit('setReportManager', {
- containerUuid,
- rowCells: response.rows,
- instanceUuid: id,
- pageSize,
- pageToken
- })
- showNotification({
- title: language.t('notifications.succesful'),
- message: name,
- type: 'success'
- })
- resolve(response)
- })
- .catch(error => {
- showNotification({
- title: language.t('notifications.succesful'),
- message: name,
- type: 'success'
- })
- console.warn(`Error getting Get Report: ${error.message}. Code: ${error.code}.`)
- })
- .finally(() => {
- commit('setReportIsLoading', false)
- })
- })
- },
- generateReportViwer({ commit, rootGetters }, {
- containerUuid,
- reportUuid,
- reportId,
- filters,
- printFormatId,
- reportViewId,
- isSummary,
- tableName,
- pageSize,
- pageToken,
- sortBy,
- reportType
- }) {
- return new Promise(resolve => {
- const recordId = rootGetters.getIdOfContainer({
- containerUuid,
- tableName
- })
- generateReport({
- reportId,
- reportType,
- filters,
- sortBy,
- pageSize,
- pageToken,
- printFormatId,
- reportViewId,
- isSummary,
- tableName,
- recordId
- })
- .then(response => {
- const {
- name,
- instance_id,
- report_view_id
- } = response
- router.push({
- path: `report-viewer-engine/${reportId}/${instance_id}/${report_view_id}`,
- name: 'Report Viewer Engine',
- params: {
- reportId,
- instanceUuid: instance_id,
- fileName: name,
- reportUuid,
- // menuParentUuid,
- name: name + instance_id,
- tableName
- }
- }, () => {})
- showNotification({
- title: language.t('notifications.succesful'),
- message: name,
- type: 'success'
- })
- commit('setReportManager', {
- ...response,
- containerUuid,
- rowCells: response.rows,
- instanceUuid: reportId,
- pageSize,
- pageToken
- })
- resolve(response)
- })
- .catch(error => {
- showNotification({
- title: language.t('notifications.error'),
- message: error.message,
- type: 'error'
- })
- console.warn(`Error getting Get Report: ${error.message}. Code: ${error.code}.`)
- })
- .finally(() => {
- commit('setReportIsLoading', false)
- })
- })
- },
- exportReport({ commit, rootGetters }, {
- containerUuid,
- reportId,
- reportName,
- printFormatId,
- reportViewId,
- pageSize,
- pageToken,
- isDownload = true
- }) {
- const reportDefinition = rootGetters.getStoredReport(containerUuid)
- const { fieldsList } = reportDefinition
- const filters = getOperatorAndValue({
- format: 'array',
- containerUuid,
- fieldsList
- })
- return new Promise(resolve => {
- runExport({
- reportId,
- printFormatId,
- reportViewId,
- pageSize,
- pageToken,
- filters
- })
- .then(response => {
- const { file_name } = response
- if (!isEmptyValue(file_name)) {
- if (isDownload) {
- const file = document.createElement('a')
- file.href = `${config.adempiere.resource.url}${file_name}`
- file.download = `${reportName}`
- file.target = '_blank'
- file.click()
- }
- resolve(file_name)
- }
- })
- .catch(error => {
- showNotification({
- title: language.t('notifications.error'),
- message: `Error exporting report: ${error.message}. Code: ${error.code}.`,
- type: 'error'
- })
- console.warn(`Error exporting report: ${error.message}. Code: ${error.code}.`)
- resolve(error)
- })
- })
- }
- },
- getters: {
- getReportManager: (state) => (instanceUuid) => {
- return state.reportManager[instanceUuid]
- }
- }
-}
-
-export default reportManager
diff --git a/src/store/modules/ADempiere/report/reportRun.js b/src/store/modules/ADempiere/report/reportRun.js
new file mode 100644
index 0000000000..15b9a25cff
--- /dev/null
+++ b/src/store/modules/ADempiere/report/reportRun.js
@@ -0,0 +1,179 @@
+/**
+ * ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
+ * Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
+ * Contributor(s): Elsio Sanchez elsiosanches@gmail.com https://github.com/elsiosanchez
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+// import Vue from 'vue'
+import router from '@/router'
+import language from '@/lang'
+// API Request Methods
+import {
+ generateReportRequest,
+ getReportOutputRequest
+} from '@/api/ADempiere/reportManagement/index.ts'
+
+// Constants
+import {
+ DEFAULT_REPORT_TYPE
+} from '@/utils/ADempiere/dictionary/report.js'
+import { REPORT_VIEWER_SUPPORTED_FORMATS } from '@/utils/ADempiere/dictionary/report.js'
+import { REPORT_VIEWER_NAME } from '@/utils/ADempiere/constants/report'
+
+// Utils
+import { buildLinkHref } from '@/utils/ADempiere/resource.js'
+import { isEmptyValue } from '@/utils/ADempiere'
+import { showNotification } from '@/utils/ADempiere/notification.js'
+
+const initState = {
+ reportRun: {}
+}
+const reportRun = {
+ state: initState,
+
+ mutations: {
+ scrollByetTest(state, contactSend) {
+ state.reportRun = contactSend
+ }
+ },
+ actions: {
+ runReport({ commit, getters }, {
+ containerUuid,
+ reportFormat = DEFAULT_REPORT_TYPE,
+ recordId,
+ reportId,
+ printFormatId,
+ reportViewId,
+ tableName
+ }) {
+ return new Promise(resolve => {
+ const reportDefinition = getters.getStoredReport(containerUuid)
+ showNotification({
+ title: language.t('notifications.processing'),
+ message: reportDefinition.name,
+ summary: reportDefinition.description,
+ type: 'info'
+ })
+ generateReportRequest({
+ reportFormat,
+ id: reportId,
+ printFormatId,
+ reportViewId,
+ tableName,
+ recordId
+ })
+ .then(runReportRepsonse => {
+ const { instance_id, output, is_error } = runReportRepsonse
+
+ if (is_error) {
+ showNotification({
+ title: language.t('notifications.error'),
+ message: reportDefinition.name,
+ summary: runReportRepsonse.summary,
+ type: 'error'
+ })
+ console.warn(`Error running the process. ${runReportRepsonse.summary}.`)
+ }
+
+ let link = {
+ href: undefined,
+ download: undefined
+ }
+ if (output && output.output_stream) {
+ link = buildLinkHref({
+ fileName: output.file_name,
+ outputStream: output.output_stream,
+ mimeType: output.mime_type
+ })
+
+ // donwloaded not support render report
+ if (!REPORT_VIEWER_SUPPORTED_FORMATS.includes(reportFormat)) {
+ link.click()
+ }
+
+ router.push({
+ path: `/report-viewer/${reportDefinition.id}/${instance_id}`,
+ name: REPORT_VIEWER_NAME,
+ params: {
+ reportId: reportDefinition.id,
+ reportUuid: reportDefinition.uuid,
+ instanceUuid: instance_id,
+ fileName: output.file_name + instance_id,
+ // menuParentUuid,
+ name: output.name + instance_id,
+ tableName: output.table_name
+ }
+ }, () => {})
+ showNotification({
+ title: language.t('notifications.succesful'),
+ message: output.file_name,
+ type: 'success'
+ })
+ }
+
+ commit('setReportOutput', {
+ ...output,
+ reportId: reportDefinition.id,
+ reportUuid: reportDefinition.uuid,
+ instanceUuid: instance_id,
+ link,
+ url: link.href,
+ download: link.download
+ })
+
+ resolve(runReportRepsonse)
+ })
+ .catch(error => {
+ showNotification({
+ title: language.t('notifications.error'),
+ message: error.message,
+ type: 'error'
+ })
+ console.warn(`Error getting Get Report: ${error.message}. Code: ${error.code}.`)
+ })
+ })
+ },
+ reportOutput({ dispatch, getters }, {
+ reportId,
+ recordId,
+ tableName,
+ reportFormat,
+ printFormatId
+ }) {
+ return new Promise(resolve => {
+ if (isEmptyValue(reportId) || isEmptyValue(tableName)) {
+ // dispatch('generateReport')
+ resolve(null)
+ return
+ }
+ getReportOutputRequest({
+ reportId,
+ tableName,
+ printFormatId,
+ reportFormat,
+ recordId
+ })
+ })
+ }
+ },
+
+ getters: {
+ getReportRun: (state) => {
+ return state.reportRun
+ }
+ }
+}
+
+export default reportRun
diff --git a/src/store/modules/ADempiere/reportManager.js b/src/store/modules/ADempiere/reportManager.js
index 2cd132f8bc..bc3efd6759 100644
--- a/src/store/modules/ADempiere/reportManager.js
+++ b/src/store/modules/ADempiere/reportManager.js
@@ -28,11 +28,11 @@ import {
generateReport,
generateReportRequest,
getReportOutputRequest,
- ListNotificationsTypes,
- ListUsers,
- SendNotification
+ listNotificationsTypes,
+ listUsers,
+ sendNotification
} from '@/api/ADempiere/reportManagement/index.ts'
-import { listPrintFormatsRequest } from '@/api/ADempiere/reportManagement/printFormat.ts'
+import { listPrintFormatsRequest, listPrintFormatsTableRequest } from '@/api/ADempiere/reportManagement/printFormat.ts'
import { listReportViewsRequest } from '@/api/ADempiere/reportManagement/reportView.ts'
import { listDrillTablesRequest } from '@/api/ADempiere/reportManagement/drillTable.ts'
@@ -296,10 +296,15 @@ const reportManager = {
* @param {number} id report identifier
* @returns
*/
- getListPrintFormatsFromServer({ commit, dispatch }, {
+ listPrintFormatsFromServer({ commit, dispatch, getters }, {
reportId
}) {
return new Promise(resolve => {
+ const currentListPrintFormat = getters.getPrintFormatList(reportId)
+ if (!isEmptyValue(currentListPrintFormat)) {
+ resolve(currentListPrintFormat)
+ return
+ }
listPrintFormatsRequest({ reportId })
.then(async printFormatResponse => {
const printFormatList = await Promise.all(
@@ -337,6 +342,58 @@ const reportManager = {
})
},
+ /**
+ * Get list prints Windows formats
+ * @param {number} id report identifier
+ * @returns
+ */
+ listPrintFormatWindow({ commit, dispatch, getters }, {
+ tableName,
+ reportId
+ }) {
+ return new Promise(resolve => {
+ const currentListPrintFormat = getters.getPrintFormatList(reportId)
+ if (!isEmptyValue(currentListPrintFormat)) {
+ resolve(currentListPrintFormat)
+ return
+ }
+ listPrintFormatsTableRequest({ tableName })
+ .then(async printFormatResponse => {
+ const printFormatList = await Promise.all(
+ printFormatResponse.print_formats.map(async printFormatItem => {
+ await Promise.allSettled([
+ dispatch('getReportViewsFromServer', {
+ reportId,
+ // TODO: Verify if table name is required
+ tableName: printFormatItem.table_name
+ }),
+ dispatch('getDrillTablesFromServer', {
+ reportId,
+ tableName: printFormatItem.table_name
+ })
+ ])
+
+ return {
+ ...printFormatItem,
+ // reportUuid: reportDefinition.uuid,
+ reportId: reportId
+ }
+ })
+ )
+
+ commit('setPrintFormatsList', {
+ reportId,
+ printFormatList
+ })
+
+ resolve(printFormatList)
+ })
+ .catch(error => {
+ console.warn(`Error getting print formats: ${error.message}. Code: ${error.code}.`)
+ })
+ })
+ },
+
/**
* Get list report views
* @param {number} id report identifier
@@ -503,7 +560,6 @@ const reportManager = {
parametersList = []
}) {
const currentRoute = router.app._route
- // generated with refresh web browser
if (isEmptyValue(containerUuid)) {
if (currentRoute.params && currentRoute.params.reportUuid) {
containerUuid = currentRoute.params.reportUuid
@@ -759,7 +815,7 @@ const reportManager = {
},
ListNotifications() {
return new Promise(resolve => {
- ListNotificationsTypes()
+ listNotificationsTypes()
.then(response => {
resolve(response)
})
@@ -775,7 +831,7 @@ const reportManager = {
},
ListUser() {
return new Promise(resolve => {
- ListUsers()
+ listUsers()
.then(response => {
resolve(response)
})
@@ -798,7 +854,7 @@ const reportManager = {
subject
}) {
return new Promise(resolve => {
- SendNotification({
+ sendNotification({
user_id,
title,
recipients,
diff --git a/src/views/ADempiere/ReportViewer/index.vue b/src/views/ADempiere/ReportViewer/index.vue
index 4abbfbd014..7d8a84620d 100644
--- a/src/views/ADempiere/ReportViewer/index.vue
+++ b/src/views/ADempiere/ReportViewer/index.vue
@@ -26,14 +26,14 @@
:name="name"
:help="help"
/>
-
+
-
+ /> -->