mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 12:01:57 +08:00
* Separate Services - Dictionary: dictionary - Common request: common - ADempiere Generic API:common/api - Dashboard Content: dashboard - Dashboard favorites: dashboard/addons/user - Dashboard Pending Documents: dashboard/addons/tasks - User Management: user - User enrollment: user/enrollment - User Log: user/log - Workflow metadata: workflow - User Interface Common logic: user-interface/common - User Interface Window tools: user-interface/window - User Interface Smart Browser tools: user-interface/smart-browser - User Interface Process tools: user-interface/process - User Interface Attachment Management: user-interface/component/attachment - User Interface Components Preference: user-interface/component/preference - User Interface Components Private Access: user-interface/component/private-access - User Interface Components Record Access: user-interface/component/record-access - User Interface Components Notes: user-interface/component/notes - User Interface Components Translation: user-interface/component/translation - User Interface Forms / POS: form/addons/point-of-sales * Minor change * Remove persistence * Untrack files * Remove persistence * resolve conflicts * Update files
114 lines
3.1 KiB
JavaScript
114 lines
3.1 KiB
JavaScript
import { requestProcessMetadata } from '@/api/ADempiere/dictionary/process.js'
|
|
import { showMessage } from '@/utils/ADempiere'
|
|
import { generateProcess } from '@/utils/ADempiere/dictionaryUtils'
|
|
import language from '@/lang'
|
|
import router from '@/router'
|
|
|
|
const process = {
|
|
state: {
|
|
process: []
|
|
},
|
|
mutations: {
|
|
addProcess(state, payload) {
|
|
state.process.push(payload)
|
|
},
|
|
dictionaryResetCacheProcess(state) {
|
|
state.process = []
|
|
}
|
|
},
|
|
actions: {
|
|
/**
|
|
* Get Process/Report metadata from server
|
|
* @param {string} containerUuid
|
|
* @param {number} processId
|
|
* @param {object} routeToDelete, route to close in tagView when fail
|
|
*/
|
|
getProcessFromServer({ commit, dispatch }, {
|
|
containerUuid,
|
|
processId,
|
|
routeToDelete
|
|
}) {
|
|
return new Promise(resolve => {
|
|
requestProcessMetadata({
|
|
uuid: containerUuid,
|
|
id: processId
|
|
})
|
|
.then(async responseProcess => {
|
|
let printFormatsAvailable = []
|
|
if (responseProcess.isReport) {
|
|
printFormatsAvailable = await dispatch('getListPrintFormats', {
|
|
processUuid: containerUuid,
|
|
processId: responseProcess.id
|
|
})
|
|
}
|
|
|
|
const { processDefinition, actions } = generateProcess({
|
|
processToGenerate: {
|
|
...responseProcess,
|
|
printFormatsAvailable
|
|
}
|
|
})
|
|
|
|
dispatch('addPanel', processDefinition)
|
|
commit('addProcess', processDefinition)
|
|
resolve(processDefinition)
|
|
|
|
// Add process menu
|
|
dispatch('setContextMenu', {
|
|
containerUuid,
|
|
actions
|
|
})
|
|
})
|
|
.catch(error => {
|
|
router.push({
|
|
path: '/dashboard'
|
|
}, () => {})
|
|
dispatch('tagsView/delView', routeToDelete)
|
|
showMessage({
|
|
message: language.t('login.unexpectedError'),
|
|
type: 'error'
|
|
})
|
|
console.warn(`Dictionary Process - Error ${error.message}.`)
|
|
})
|
|
})
|
|
},
|
|
/**
|
|
* Add process associated in window or smart browser
|
|
* @param {object} processToGenerate
|
|
*/
|
|
addProcessAssociated({ commit, dispatch }, {
|
|
processToGenerate
|
|
}) {
|
|
return new Promise(resolve => {
|
|
const { processDefinition, actions } = generateProcess({
|
|
processToGenerate
|
|
})
|
|
|
|
dispatch('addPanel', processDefinition)
|
|
commit('addProcess', processDefinition)
|
|
resolve(processDefinition)
|
|
|
|
// Add process menu
|
|
dispatch('setContextMenu', {
|
|
containerUuid: processDefinition.uuid,
|
|
actions
|
|
})
|
|
})
|
|
}
|
|
},
|
|
getters: {
|
|
getProcess: (state) => (processUuid) => {
|
|
return state.process.find(
|
|
item => item.uuid === processUuid
|
|
)
|
|
},
|
|
getProcessById: (state) => (processId) => {
|
|
return state.process.find(
|
|
item => item.id === parseInt(processId)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
export default process
|