mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 12:01:57 +08:00
feat: Refactor process vuex module. (#563)
Co-authored-by: EdwinBetanc0urt <EdwinBetanco0urt@outlook.com>
This commit is contained in:
parent
4716f3d7f7
commit
7706b7715c
File diff suppressed because it is too large
Load Diff
1141
src/store/modules/ADempiere/process/actions.js
Normal file
1141
src/store/modules/ADempiere/process/actions.js
Normal file
File diff suppressed because it is too large
Load Diff
48
src/store/modules/ADempiere/process/getters.js
Normal file
48
src/store/modules/ADempiere/process/getters.js
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Process Getters
|
||||
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
|
||||
*/
|
||||
export default {
|
||||
/**
|
||||
* Running processes that have not received a response from the server
|
||||
* @param {string} containerUuid
|
||||
*/
|
||||
getInExecution: (state) => (containerUuid) => {
|
||||
return state.inExecution.find(item => item.containerUuid === containerUuid)
|
||||
},
|
||||
/**
|
||||
* Process for send to server, or send without response
|
||||
*/
|
||||
getAllInExecution: (state) => {
|
||||
return state.inExecution
|
||||
},
|
||||
/**
|
||||
* Process send to server, with response from server
|
||||
*/
|
||||
getAllFinishProcess: (state) => {
|
||||
return state.process
|
||||
},
|
||||
getNotificationProcess: (state) => {
|
||||
return state.notificationProcess
|
||||
},
|
||||
/**
|
||||
* Process receibed from server associated whith this session
|
||||
*/
|
||||
getAllSessionProcess: (state) => {
|
||||
return state.sessionProcess
|
||||
},
|
||||
/**
|
||||
* Process request metadata from server filter form uuid process
|
||||
*/
|
||||
getInRequestMetadata: (state) => (containerUuid) => {
|
||||
return state.inRequestMetadata.find(item => item === containerUuid)
|
||||
},
|
||||
getProcessResult: (state) => {
|
||||
return state.reportObject
|
||||
},
|
||||
getCachedReport: (state) => (instanceUuid) => {
|
||||
return state.reportList.find(
|
||||
item => item.instanceUuid === instanceUuid
|
||||
)
|
||||
}
|
||||
}
|
18
src/store/modules/ADempiere/process/index.js
Normal file
18
src/store/modules/ADempiere/process/index.js
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
import state from './state.js'
|
||||
import mutations from './mutations.js'
|
||||
import actions from './actions.js'
|
||||
import getters from './getters.js'
|
||||
|
||||
/**
|
||||
* Process Vuex Module
|
||||
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
|
||||
*/
|
||||
const processControl = {
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
getters
|
||||
}
|
||||
|
||||
export default processControl
|
79
src/store/modules/ADempiere/process/mutations.js
Normal file
79
src/store/modules/ADempiere/process/mutations.js
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
import initStateProcessControl from './state.js'
|
||||
|
||||
/**
|
||||
* Process Mutations
|
||||
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
|
||||
*/
|
||||
export default {
|
||||
// Add process in execution
|
||||
addInExecution(state, payload) {
|
||||
state.inExecution.push(payload)
|
||||
},
|
||||
// Add process in notifation
|
||||
addNotificationProcess(state, payload) {
|
||||
state.notificationProcess.push(payload)
|
||||
},
|
||||
// Delete process in execution afther some response from server
|
||||
deleteInExecution(state, payload) {
|
||||
state.inExecution = state.inExecution.filter(item => item.containerUuid !== payload.containerUuid)
|
||||
},
|
||||
// Add process in request metadata from server
|
||||
addInRequestMetadata(state, payload) {
|
||||
state.inRequestMetadata.push(payload)
|
||||
},
|
||||
// Delete process in request metadata
|
||||
deleteInRequestMetadata(state, payload) {
|
||||
state.inRequestMetadata = state.inRequestMetadata.filter(item => item !== payload)
|
||||
},
|
||||
addStartedProcess(state, payload) {
|
||||
state.process.push(payload)
|
||||
},
|
||||
resetStateProcessControl(state) {
|
||||
state = initStateProcessControl
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {object} state
|
||||
* @param {boolean} payload, true or false value to change displayed dialog
|
||||
*/
|
||||
setShowDialog(state, payload) {
|
||||
state.isVisibleDialog = payload
|
||||
},
|
||||
setMetadata(state, payload) {
|
||||
state.metadata = payload
|
||||
},
|
||||
setReportValues(state, payload) {
|
||||
state.reportObject = payload
|
||||
if (state.reportList.some(report => report.instanceUuid === payload.instanceUuid)) {
|
||||
const 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
|
||||
},
|
||||
changeFormatReport(state, payload) {
|
||||
state.reportFormat = payload
|
||||
},
|
||||
setReportViewsList(state, payload) {
|
||||
state.reportViewList.push(payload)
|
||||
},
|
||||
setTotalResponse(state, payload) {
|
||||
state.totalResponse = payload
|
||||
},
|
||||
setTotalSelection(state, payload) {
|
||||
state.totalSelection = payload
|
||||
},
|
||||
setSuccessSelection(state, payload) {
|
||||
state.successSelection = payload
|
||||
},
|
||||
setErrorSelection(state, payload) {
|
||||
state.errorSelection = payload
|
||||
},
|
||||
setTotalRequest(state, payload) {
|
||||
state.totalRequest = payload
|
||||
}
|
||||
}
|
21
src/store/modules/ADempiere/process/state.js
Normal file
21
src/store/modules/ADempiere/process/state.js
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Process State
|
||||
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
|
||||
*/
|
||||
export default {
|
||||
inExecution: [], // process not response from server
|
||||
isVisibleDialog: false,
|
||||
reportObject: {},
|
||||
reportList: [],
|
||||
metadata: {},
|
||||
process: [], // process to run finish
|
||||
sessionProcess: [],
|
||||
notificationProcess: [],
|
||||
inRequestMetadata: [],
|
||||
reportViewList: [],
|
||||
totalResponse: 0,
|
||||
totalRequest: 0,
|
||||
totalSelection: 0,
|
||||
errorSelection: 0,
|
||||
successSelection: 0
|
||||
}
|
@ -127,6 +127,7 @@ const reportControl = {
|
||||
processId
|
||||
}
|
||||
})
|
||||
|
||||
commit('setDrillTablesList', {
|
||||
containerUuid: processUuid,
|
||||
drillTablesList
|
||||
|
@ -2,6 +2,18 @@ import { export_json_to_excel } from '@/vendor/Export2Excel'
|
||||
import { export_txt_to_zip } from '@/vendor/Export2Zip'
|
||||
import language from '@/lang'
|
||||
|
||||
export const reportFormatsList = [
|
||||
'ps',
|
||||
'xml',
|
||||
'pdf',
|
||||
'txt',
|
||||
'ssv',
|
||||
'csv',
|
||||
'xls',
|
||||
'xlsx',
|
||||
'arxml'
|
||||
]
|
||||
|
||||
export const supportedTypes = {
|
||||
xlsx: language.t('report.ExportXlsx'),
|
||||
xls: language.t('report.ExportXls'),
|
||||
@ -10,15 +22,25 @@ export const supportedTypes = {
|
||||
txt: language.t('report.ExportTxt'),
|
||||
html: language.t('report.ExportHtml')
|
||||
}
|
||||
|
||||
/**
|
||||
* Export data from json
|
||||
* @autor Edwin Betancourt <EdwinBetanc0urt@outlook.com>
|
||||
* @param {array} header
|
||||
* @param {array} data
|
||||
* @param {string} exportType, supportedTypes array
|
||||
*/
|
||||
export function exportFileFromJson({
|
||||
header,
|
||||
data,
|
||||
exportType
|
||||
}) {
|
||||
var Json = data.map(dataJson => {
|
||||
const Json = data.map(dataJson => {
|
||||
Object.keys(dataJson).forEach(key => {
|
||||
if (typeof dataJson[key] === 'boolean') {
|
||||
dataJson[key] = dataJson[key] ? language.t('components.switchActiveText') : language.t('components.switchInactiveText')
|
||||
dataJson[key] = dataJson[key]
|
||||
? language.t('components.switchActiveText')
|
||||
: language.t('components.switchInactiveText')
|
||||
}
|
||||
})
|
||||
return dataJson
|
||||
@ -31,19 +53,29 @@ export function exportFileFromJson({
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Export txt data into zip file
|
||||
* @autor Edwin Betancourt <EdwinBetanc0urt@outlook.com>
|
||||
* @param {array} header
|
||||
* @param {array} data
|
||||
* @param {string} title
|
||||
*/
|
||||
export function exportFileZip({
|
||||
header,
|
||||
data,
|
||||
title
|
||||
}) {
|
||||
var Json = data.map(dataJson => {
|
||||
const Json = data.map(dataJson => {
|
||||
Object.keys(dataJson).forEach(key => {
|
||||
if (typeof dataJson[key] === 'boolean') {
|
||||
dataJson[key] = dataJson[key] ? language.t('components.switchActiveText') : language.t('components.switchInactiveText')
|
||||
dataJson[key] = dataJson[key]
|
||||
? language.t('components.switchActiveText')
|
||||
: language.t('components.switchInactiveText')
|
||||
}
|
||||
})
|
||||
return dataJson
|
||||
})
|
||||
|
||||
export_txt_to_zip(
|
||||
header,
|
||||
Json,
|
||||
|
@ -8,6 +8,7 @@
|
||||
:last-parameter="reportResult.processUuid"
|
||||
:report-format="reportFormat"
|
||||
/>
|
||||
|
||||
<el-row type="flex" style="min-height: inherit;">
|
||||
<el-col :span="24">
|
||||
<div class="content">
|
||||
@ -39,13 +40,7 @@
|
||||
height="100%"
|
||||
/>
|
||||
<div
|
||||
v-else-if="collectionReportFormat.includes(reportFormat)"
|
||||
key="report-content-all"
|
||||
class="content-api"
|
||||
:src="url"
|
||||
/>
|
||||
<div
|
||||
v-else-if="reportFormat === 'html'"
|
||||
v-else-if="['html', 'txt'].includes(reportFormat)"
|
||||
key="report-content-html"
|
||||
class="content-txt"
|
||||
>
|
||||
@ -58,9 +53,16 @@
|
||||
</el-main>
|
||||
</el-container>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="reportFormatsList.includes(reportFormat)"
|
||||
key="report-content-all"
|
||||
class="content-api"
|
||||
:src="url"
|
||||
/>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<modal-dialog
|
||||
:metadata="processMetadata"
|
||||
:parent-uuid="reportResult.processUuid"
|
||||
@ -83,6 +85,7 @@
|
||||
import ContextMenu from '@/components/ADempiere/ContextMenu'
|
||||
import ModalDialog from '@/components/ADempiere/Dialog'
|
||||
import { showNotification } from '@/utils/ADempiere/notification'
|
||||
import { reportFormatsList } from '@/utils/ADempiere/exportUtil.js'
|
||||
|
||||
export default {
|
||||
name: 'ReportViewer',
|
||||
@ -95,17 +98,7 @@ export default {
|
||||
panelType: 'process',
|
||||
processMetadata: {},
|
||||
reportFormat: '',
|
||||
collectionReportFormat: [
|
||||
'ps',
|
||||
'xml',
|
||||
'pdf',
|
||||
'txt',
|
||||
'ssv',
|
||||
'csv',
|
||||
'xls',
|
||||
'xlsx',
|
||||
'arxml'
|
||||
],
|
||||
reportFormatsList,
|
||||
reportContent: '',
|
||||
isLoading: false,
|
||||
reportResult: {}
|
||||
@ -141,8 +134,12 @@ export default {
|
||||
displayReport(reportResult) {
|
||||
if (!reportResult.isError) {
|
||||
const { output } = reportResult
|
||||
this.reportFormat = this.isEmptyValue(output.reportType) ? reportResult.reportType : output.reportType
|
||||
this.reportContent = this.isEmptyValue(output.output) ? reportResult.output : output.output
|
||||
this.reportFormat = this.isEmptyValue(output.reportType)
|
||||
? reportResult.reportType
|
||||
: output.reportType
|
||||
this.reportContent = this.isEmptyValue(output.output)
|
||||
? reportResult.output
|
||||
: output.output
|
||||
|
||||
this.isLoading = true
|
||||
}
|
||||
@ -150,7 +147,12 @@ export default {
|
||||
getCachedReport() {
|
||||
this.reportResult = this.getterCachedReport
|
||||
if (this.reportResult === undefined) {
|
||||
this.$store.dispatch('getSessionProcessFromServer')
|
||||
const pageSize = undefined
|
||||
const pageToken = undefined
|
||||
this.$store.dispatch('getSessionProcessFromServer', {
|
||||
pageSize,
|
||||
pageToken
|
||||
})
|
||||
.then(response => {
|
||||
this.reportResult = this.getterCachedReport
|
||||
if (this.reportResult === undefined) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user