1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 20:39:48 +08:00

feat: Refactor window control vuex module. (#611)

Co-authored-by: EdwinBetanc0urt <EdwinBetanco0urt@outlook.com>
This commit is contained in:
Edwin Betancourt 2021-02-27 12:24:11 -04:00 committed by GitHub
parent aa79d74f3b
commit 6439dcb2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1204 additions and 1137 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
/**
* Vuex Module, Window Control
* Getters
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
*/
export default {
getCurrentRecord: (state) => {
return state.currentRecord
},
getInCreate: (state) => (containerUuid) => {
return state.inCreate.find(item => item.containerUuid === containerUuid)
},
getReferencesList: (state) => (windowUuid, recordUuid) => {
return state.references.find(item => item.windowUuid === windowUuid && item.recordUuid === recordUuid)
},
getReferencesInfo: (state, getters) => ({ windowUuid, recordUuid, referenceUuid }) => {
const references = getters.getReferencesList(windowUuid, recordUuid)
return references.referencesList.find(item => item.uuid === referenceUuid)
},
getTabSequenceRecord: (state) => {
return state.tabSequenceRecord
},
getDataLog: (state) => (containerUuid, recordUuid) => {
const current = state.dataLog
if (current.containerUuid === containerUuid &&
((current.recordUuid === recordUuid) ||
(current.eventType === 'DELETE' && recordUuid === 'create-new'))) {
return current
}
return undefined
}
}

View File

@ -0,0 +1,19 @@
import state from './state.js'
import mutations from './mutations.js'
import actions from './actions.js'
import getters from './getters.js'
/**
* Window Control
* Vuex Module
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
*/
const windowControl = {
state,
mutations,
actions,
getters
}
export default windowControl

View File

@ -0,0 +1,48 @@
import initStateWindowControl from './state.js'
/**
* Window Control Vuex Module
* Muttations to commit state
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
*/
export default {
setCurrentRecord(state, payload) {
state.currentRecord = payload
},
addInCreate(state, payload) {
state.inCreate.push(payload)
},
deleteInCreate(state, payload) {
state.inCreate = state.inCreate.filter(item => item.containerUuid !== payload.containerUuid)
},
addReferencesList(state, payload) {
state.references.push(payload)
},
setDataLog(state, payload) {
state.dataLog = payload
},
setWindowOldRoute(state, payload) {
state.windowOldRoute = payload
},
setTabSequenceRecord(state, payload) {
state.tabSequenceRecord = payload
},
setTotalResponse(state, payload) {
state.totalResponse = payload
},
setTotalRequest(state, payload) {
state.totalRequest = payload
},
resetStateWindowControl(state) {
state = initStateWindowControl
}
}

View File

@ -0,0 +1,20 @@
/**
* Window Control Vuex Module
* State (or initial state) from Window Control
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
*/
export default {
inCreate: [],
references: [],
currentRecord: {},
windowOldRoute: {
path: '',
fullPath: '',
query: {}
},
dataLog: {}, // { containerUuid, recordId, tableName, eventType }
tabSequenceRecord: [],
totalResponse: 0,
totalRequest: 0
}