1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 20:39:48 +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],
computed: {
isPanelTypeMobile() {
console.log(this.panelType, this.$route.meta.type)
if (this.$route.meta.type === 'process' || this.$route.meta.type === 'report') {
return true
}

View File

@ -170,8 +170,8 @@ export default {
},
report: {
ExportXlsx: '(xlsx) Extencion de Archivo Excel',
ExportXls: '(xls) Archivo Excel ',
ExporXml: '(xml) Archivo Lenguaje de marcas Extensible',
ExportXls: '(xls) Archivo Excel',
ExporXml: '(xml) Archivo Lenguaje de marcas Extensible',
ExporCsv: '(csv) Archivo Separado por Coma',
ExportTxt: '(txt) Archivo de Texto Delimitado por Tabuladores',
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
const actions = []
if (process) {
@ -140,28 +158,8 @@ const browser = {
// Add process menu
dispatch('setContextMenu', {
containerUuid,
relations: [],
actions,
references: []
actions
})
// 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 => {
router.push({ path: '/dashboard' })

View File

@ -10,8 +10,6 @@ import { requestListDocumentActions, requestListDocumentStatuses } from '@/api/A
// relations: [],
// actions: [],
// references: []
// defaultAction: {},
// lastAction: {}
// }
// ]
const initStateContextMenu = {
@ -50,8 +48,25 @@ const contextMenu = {
}
},
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

View File

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

View File

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

View File

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