1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-13 07:04:21 +08:00

fix: Print formats unnecessary request. (#414)

This commit is contained in:
Edwin Betancourt 2020-03-24 21:34:57 -04:00 committed by GitHub
parent 1e837db9e0
commit 8c9e2f0513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 173 additions and 177 deletions

View File

@ -130,7 +130,6 @@ export default {
mixins: [contextMixin], mixins: [contextMixin],
computed: { computed: {
isPanelTypeMobile() { isPanelTypeMobile() {
console.log(this.panelType, this.$route.meta.type)
if (this.$route.meta.type === 'process' || this.$route.meta.type === 'report') { if (this.$route.meta.type === 'process' || this.$route.meta.type === 'report') {
return true return true
} }

View File

@ -170,8 +170,8 @@ export default {
}, },
report: { report: {
ExportXlsx: '(xlsx) Extencion de Archivo Excel', ExportXlsx: '(xlsx) Extencion de Archivo Excel',
ExportXls: '(xls) Archivo Excel ', ExportXls: '(xls) Archivo Excel',
ExporXml: '(xml) Archivo Lenguaje de marcas Extensible', ExporXml: '(xml) Archivo Lenguaje de marcas Extensible',
ExporCsv: '(csv) Archivo Separado por Coma', ExporCsv: '(csv) Archivo Separado por Coma',
ExportTxt: '(txt) Archivo de Texto Delimitado por Tabuladores', ExportTxt: '(txt) Archivo de Texto Delimitado por Tabuladores',
ExportHtml: '(html) Lenguaje de Marcas de Hipertexto' ExportHtml: '(html) Lenguaje de Marcas de Hipertexto'

View File

@ -116,6 +116,24 @@ const browser = {
} }
}) })
// Panel for save on store
const newBrowser = {
...browserResponse,
containerUuid,
fieldList: fieldsList,
panelType,
// app attributes
awaitForValues, // control to values
awaitForValuesToQuery: awaitForValues, // get values from request search
isShowedCriteria,
isShowedTotals: true
}
commit('addBrowser', newBrowser)
dispatch('addPanel', newBrowser)
resolve(newBrowser)
// Convert from gRPC process list // Convert from gRPC process list
const actions = [] const actions = []
if (process) { if (process) {
@ -140,28 +158,8 @@ const browser = {
// Add process menu // Add process menu
dispatch('setContextMenu', { dispatch('setContextMenu', {
containerUuid, containerUuid,
relations: [], actions
actions,
references: []
}) })
// Panel for save on store
const newBrowser = {
...browserResponse,
containerUuid,
fieldList: fieldsList,
panelType,
// app attributes
awaitForValues, // control to values
awaitForValuesToQuery: awaitForValues, // get values from request search
isShowedCriteria,
isShowedTotals: true
}
commit('addBrowser', newBrowser)
dispatch('addPanel', newBrowser)
resolve(newBrowser)
}) })
.catch(error => { .catch(error => {
router.push({ path: '/dashboard' }) router.push({ path: '/dashboard' })

View File

@ -10,8 +10,6 @@ import { requestListDocumentActions, requestListDocumentStatuses } from '@/api/A
// relations: [], // relations: [],
// actions: [], // actions: [],
// references: [] // references: []
// defaultAction: {},
// lastAction: {}
// } // }
// ] // ]
const initStateContextMenu = { const initStateContextMenu = {
@ -50,8 +48,25 @@ const contextMenu = {
} }
}, },
actions: { actions: {
setContextMenu({ commit }, payload) { /**
commit('setContextMenu', payload) * Sub menu associated with panel
* @param {string} containerUuid
* @param {array} relations
* @param {array} actions
* @param {array} references
*/
setContextMenu({ commit }, {
containerUuid,
relations = [],
actions = [],
references = []
}) {
commit('setContextMenu', {
containerUuid,
relations,
actions,
references
})
}, },
/** /**
* TODO: Verify tableName params to change in constant * TODO: Verify tableName params to change in constant

View File

@ -18,7 +18,7 @@ const process = {
}, },
actions: { actions: {
/** /**
* * Get process metadata from server
* @param {string} containerUuid * @param {string} containerUuid
* @param {object} routeToDelete, route to close in tagView when fail * @param {object} routeToDelete, route to close in tagView when fail
*/ */
@ -26,31 +26,32 @@ const process = {
containerUuid, containerUuid,
routeToDelete routeToDelete
}) { }) {
let printFormatsAvailable
dispatch('requestPrintFormats', {
processUuid: containerUuid
})
.then(response => {
printFormatsAvailable = response
})
return new Promise(resolve => { return new Promise(resolve => {
getProcessMetadata(containerUuid) getProcessMetadata(containerUuid)
.then(responseProcess => { .then(async responseProcess => {
responseProcess.printFormatsAvailable = printFormatsAvailable let printFormatsAvailable = []
if (responseProcess.isReport) {
printFormatsAvailable = await dispatch('requestPrintFormats', {
processUuid: containerUuid
})
}
const { processDefinition, actions } = generateProcess({ const { processDefinition, actions } = generateProcess({
processToGenerate: responseProcess processToGenerate: {
...responseProcess,
printFormatsAvailable
}
}) })
dispatch('addPanel', processDefinition) dispatch('addPanel', processDefinition)
commit('addProcess', processDefinition) commit('addProcess', processDefinition)
resolve(processDefinition)
// Add process menu // Add process menu
dispatch('setContextMenu', { dispatch('setContextMenu', {
containerUuid, containerUuid,
relations: [], actions
actions,
references: []
}) })
resolve(processDefinition)
}) })
.catch(error => { .catch(error => {
router.push({ router.push({
@ -79,16 +80,13 @@ const process = {
dispatch('addPanel', processDefinition) dispatch('addPanel', processDefinition)
commit('addProcess', processDefinition) commit('addProcess', processDefinition)
resolve(processDefinition)
// Add process menu // Add process menu
dispatch('setContextMenu', { dispatch('setContextMenu', {
containerUuid: processDefinition.uuid, containerUuid: processDefinition.uuid,
relations: [], actions
actions,
references: []
}) })
resolve(processDefinition)
}) })
} }
}, },

View File

@ -38,27 +38,30 @@ const reportControl = {
processUuid, processUuid,
instanceUuid instanceUuid
}) { }) {
return requestPrintFormats({ processUuid }) return new Promise(resolve => {
.then(printFormatResponse => { requestPrintFormats({ processUuid })
const printFormatList = printFormatResponse.printFormatsList.map(printFormatItem => { .then(printFormatResponse => {
return { const printFormatList = printFormatResponse.printFormatsList.map(printFormatItem => {
...printFormatItem, return {
type: 'updateReport', ...printFormatItem,
option: 'printFormat', type: 'updateReport',
instanceUuid, option: 'printFormat',
processUuid, instanceUuid,
processId processUuid,
} processId
}
})
commit('setReportFormatsList', {
containerUuid: processUuid,
printFormatList
})
resolve(printFormatList)
}) })
commit('setReportFormatsList', { .catch(error => {
containerUuid: processUuid, console.warn(`Error getting print formats: ${error.message}. Code: ${error.code}.`)
printFormatList
}) })
return printFormatList })
})
.catch(error => {
console.warn(`Error getting print formats: ${error.message}. Code: ${error.code}.`)
})
}, },
requestReportViews({ commit }, { requestReportViews({ commit }, {
processId, processId,
@ -66,28 +69,31 @@ const reportControl = {
instanceUuid, instanceUuid,
printFormatUuid printFormatUuid
}) { }) {
return requestReportViews({ processUuid }) return new Promise(resolve => {
.then(reportViewResponse => { requestReportViews({ processUuid })
const reportViewList = reportViewResponse.reportViewsList.map(reportViewItem => { .then(reportViewResponse => {
return { const reportViewList = reportViewResponse.reportViewsList.map(reportViewItem => {
...reportViewItem, return {
type: 'updateReport', ...reportViewItem,
option: 'reportView', type: 'updateReport',
instanceUuid, option: 'reportView',
printFormatUuid, instanceUuid,
processUuid, printFormatUuid,
processId processUuid,
} processId
}
})
commit('setReportViewsList', {
containerUuid: processUuid,
viewList: reportViewList
})
resolve(reportViewList)
}) })
commit('setReportViewsList', { .catch(error => {
containerUuid: processUuid, console.warn(`Error getting report views: ${error.message}. Code: ${error.code}.`)
viewList: reportViewList
}) })
return reportViewList })
})
.catch(error => {
console.warn(`Error getting report views: ${error.message}. Code: ${error.code}.`)
})
}, },
requestDrillTables({ commit }, { requestDrillTables({ commit }, {
processId, processId,
@ -97,97 +103,79 @@ const reportControl = {
tableName, tableName,
reportViewUuid reportViewUuid
}) { }) {
return requestDrillTables({ tableName }) return new Promise(resolve => {
.then(responseDrillTables => { requestDrillTables({ tableName })
const drillTablesList = responseDrillTables.drillTablesList.map(drillTableItem => { .then(responseDrillTables => {
return { const drillTablesList = responseDrillTables.drillTablesList.map(drillTableItem => {
...drillTableItem, return {
name: drillTableItem.printName, ...drillTableItem,
type: 'updateReport', name: drillTableItem.printName,
option: 'drillTable', type: 'updateReport',
instanceUuid, option: 'drillTable',
printFormatUuid, instanceUuid,
reportViewUuid, printFormatUuid,
processUuid, reportViewUuid,
processId processUuid,
} processId
}
})
commit('setDrillTablesList', {
containerUuid: processUuid,
drillTablesList
})
resolve(drillTablesList)
}) })
commit('setDrillTablesList', { .catch(error => {
containerUuid: processUuid, console.warn(`Error getting drill tables: ${error.message}. Code: ${error.code}.`)
drillTablesList
}) })
return drillTablesList
})
.catch(error => {
console.warn(`Error getting drill tables: ${error.message}. Code: ${error.code}.`)
})
},
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 parametersList = rootGetters.getParametersToServer({ containerUuid: processUuid })
return getReportOutput({
parametersList,
printFormatUuid,
reportViewUuid,
isSummary,
reportName,
reportType,
tableName
}) })
.then(response => { },
const reportOutput = { getReportOutputFromServer({ commit, getters, rootGetters }, {
...response, tableName,
processId: processId, printFormatUuid,
processUuid: processUuid, reportViewUuid,
isError: false, isSummary,
instanceUuid: instanceUuid, reportName,
isReport: true, reportType,
option: option processUuid,
} processId,
commit('setNewReportOutput', reportOutput) instanceUuid,
return reportOutput option
}) }) {
.catch(error => { if (isEmptyValue(printFormatUuid)) {
const reportOutput = { printFormatUuid = getters.getDefaultPrintFormat(processUuid).printFormatUuid
uuid: '', }
processName: '',
description: '', const parametersList = rootGetters.getParametersToServer({ containerUuid: processUuid })
fileName: '', return new Promise(resolve => {
output: '', getReportOutput({
mimeType: '', parametersList,
dataCols: null, printFormatUuid,
dataRows: null, reportViewUuid,
headerName: '', isSummary,
footerName: '', reportName,
printFormatUuid: '', reportType,
reportViewUuid: '', tableName
tableName: '',
outputStream: [],
reportType: '',
processId: null,
processUuid: '',
isError: true,
instanceUuid: '',
isReport: true,
option: ''
}
console.warn(`Error getting report output: ${error.message}. Code: ${error.code}.`)
return reportOutput
}) })
.then(response => {
const reportOutput = {
...response,
processId,
processUuid,
isError: false,
instanceUuid,
isReport: true,
option: option
}
commit('setNewReportOutput', reportOutput)
resolve(reportOutput)
})
.catch(error => {
console.warn(`Error getting report output: ${error.message}. Code: ${error.code}.`)
})
})
} }
}, },
getters: { getters: {

View File

@ -189,9 +189,7 @@ const window = {
// Add process menu // Add process menu
dispatch('setContextMenu', { dispatch('setContextMenu', {
containerUuid: tab.uuid, containerUuid: tab.uuid,
relations: [], actions: actions
actions: actions,
references: []
}) })
if (tab.isParentTab) { if (tab.isParentTab) {