mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 07:04:21 +08:00
* Improve source code and define structure for api Note that currently does not exist a way for spared api and search from backend or push, this pull request want reorder use of api by functionality or tool: - All inside ADempiere folder is dedicated for adempiere functionality - ADempiere/dashboard: use this path for add your api resource for all related with dashboard, note that already exist a file named dashboard.js with standard dashboard for ADempiere, if you want to add a new dashboard just create a new file <dashboard name>.js for gest info from backend - ADempiere/form: used for all form, for now exist the first implementation named price-checking.js that matched with components/ADempiere/form/PriceChecking, if you want to add a new form just add a new file here - ADempiere/browser.js: browser is a native functionality for Smart Browser tool, just add here all functions related for browser - ADempiere/private-access.js: just handle private access, will be used for add role table access and record access (nice to have) - ADempiere/process.js: related with all action for process and get information from server like getProcessLog and others - ADempiere/report.js: get info like getReportOutput from parameters used for window report and change print formats - ADempiere/rule.js: for now is used for dispatch callouts from server but will be implemented for run rules directly for client on languages like javascript, kotlin and groovy - ADempiere/system-core.js: just get generic functions like getWarehouseList and organization, also can be used for get langages and other infor from server - ADempiere/values.js: get info like lookup list, default values and other values like systen configurator - ADempiere/window.js: all functions related to window like record log, workflow log and other infor that can be used for container - ADempiere/persistence.js: handle standard CRUD for all entities and implement functions like getTranslation from entity * Improve source code and define structure for api Note that currently does not exist a way for spared api and search from backend or push, this pull request want reorder use of api by functionality or tool: - All inside ADempiere folder is dedicated for adempiere functionality - ADempiere/dashboard: use this path for add your api resource for all related with dashboard, note that already exist a file named dashboard.js with standard dashboard for ADempiere, if you want to add a new dashboard just create a new file <dashboard name>.js for gest info from backend - ADempiere/form: used for all form, for now exist the first implementation named price-checking.js that matched with components/ADempiere/form/PriceChecking, if you want to add a new form just add a new file here - ADempiere/browser.js: browser is a native functionality for Smart Browser tool, just add here all functions related for browser - ADempiere/private-access.js: just handle private access, will be used for add role table access and record access (nice to have) - ADempiere/process.js: related with all action for process and get information from server like getProcessLog and others - ADempiere/report.js: get info like getReportOutput from parameters used for window report and change print formats - ADempiere/rule.js: for now is used for dispatch callouts from server but will be implemented for run rules directly for client on languages like javascript, kotlin and groovy - ADempiere/system-core.js: just get generic functions like getWarehouseList and organization, also can be used for get langages and other infor from server - ADempiere/values.js: get info like lookup list, default values and other values like systen configurator - ADempiere/window.js: all functions related to window like record log, workflow log and other infor that can be used for container - ADempiere/persistence.js: handle standard CRUD for all entities and implement functions like getTranslation from entity
209 lines
5.9 KiB
JavaScript
209 lines
5.9 KiB
JavaScript
import {
|
|
requestReportViews,
|
|
requestPrintFormats,
|
|
requestDrillTables,
|
|
getReportOutput
|
|
} from '@/api/ADempiere/report'
|
|
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
|
|
|
const initStateReportControl = {
|
|
reportFormatsList: [],
|
|
reportViewsList: [],
|
|
drillTablesList: [],
|
|
reportOutput: {}
|
|
}
|
|
|
|
const reportControl = {
|
|
state: initStateReportControl,
|
|
mutations: {
|
|
setReportFormatsList(state, payload) {
|
|
state.reportFormatsList.push(payload)
|
|
},
|
|
setReportViewsList(state, payload) {
|
|
state.reportViewsList.push(payload)
|
|
},
|
|
setDrillTablesList(state, payload) {
|
|
state.drillTablesList.push(payload)
|
|
},
|
|
setNewReportOutput(state, payload) {
|
|
state.reportOutput = payload
|
|
},
|
|
resetReportControl(state) {
|
|
state = initStateReportControl
|
|
}
|
|
},
|
|
actions: {
|
|
requestPrintFormats({ commit }, {
|
|
processId,
|
|
processUuid,
|
|
instanceUuid
|
|
}) {
|
|
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)
|
|
})
|
|
.catch(error => {
|
|
console.warn(`Error getting print formats: ${error.message}. Code: ${error.code}.`)
|
|
})
|
|
})
|
|
},
|
|
requestReportViews({ commit }, {
|
|
processId,
|
|
processUuid,
|
|
instanceUuid,
|
|
printFormatUuid
|
|
}) {
|
|
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)
|
|
})
|
|
.catch(error => {
|
|
console.warn(`Error getting report views: ${error.message}. Code: ${error.code}.`)
|
|
})
|
|
})
|
|
},
|
|
requestDrillTables({ commit }, {
|
|
processId,
|
|
processUuid,
|
|
instanceUuid,
|
|
printFormatUuid,
|
|
tableName,
|
|
reportViewUuid
|
|
}) {
|
|
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)
|
|
})
|
|
.catch(error => {
|
|
console.warn(`Error getting drill tables: ${error.message}. Code: ${error.code}.`)
|
|
})
|
|
})
|
|
},
|
|
getReportOutputFromServer({ commit, getters, rootGetters }, {
|
|
tableName,
|
|
printFormatUuid,
|
|
reportViewUuid,
|
|
isSummary,
|
|
reportName,
|
|
reportType,
|
|
processUuid,
|
|
processId,
|
|
instanceUuid,
|
|
option
|
|
}) {
|
|
return new Promise(resolve => {
|
|
if (isEmptyValue(printFormatUuid)) {
|
|
printFormatUuid = getters.getDefaultPrintFormat(processUuid).printFormatUuid
|
|
}
|
|
const parametersList = rootGetters.getParametersToServer({ containerUuid: processUuid })
|
|
getReportOutput({
|
|
parametersList,
|
|
printFormatUuid,
|
|
reportViewUuid,
|
|
isSummary,
|
|
reportName,
|
|
reportType,
|
|
tableName
|
|
})
|
|
.then(response => {
|
|
const reportOutput = {
|
|
...response,
|
|
processId,
|
|
processUuid,
|
|
isError: false,
|
|
instanceUuid,
|
|
isReport: true,
|
|
option
|
|
}
|
|
commit('setNewReportOutput', reportOutput)
|
|
|
|
resolve(reportOutput)
|
|
})
|
|
.catch(error => {
|
|
console.warn(`Error getting report output: ${error.message}. Code: ${error.code}.`)
|
|
})
|
|
})
|
|
}
|
|
},
|
|
getters: {
|
|
getPrintFormatList: (state) => (containerUuid) => {
|
|
const printFormatList = state.reportFormatsList.find(list => list.containerUuid === containerUuid)
|
|
if (printFormatList) {
|
|
return printFormatList.printFormatList
|
|
}
|
|
return []
|
|
},
|
|
getDefaultPrintFormat: (state, getters) => (containerUuid) => {
|
|
return getters.getPrintFormatList(containerUuid).find(printFormat => printFormat.isDefault)
|
|
},
|
|
getReportViewList: (state) => (containerUuid) => {
|
|
const reportViewList = state.reportViewsList.find(list => list.containerUuid === containerUuid)
|
|
if (reportViewList) {
|
|
return reportViewList.viewList
|
|
}
|
|
return []
|
|
},
|
|
getDrillTablesList: (state) => (containerUuid) => {
|
|
const drillTablesList = state.drillTablesList.find(list => list.containerUuid === containerUuid)
|
|
if (drillTablesList) {
|
|
return drillTablesList.viewList
|
|
}
|
|
return []
|
|
}
|
|
}
|
|
}
|
|
|
|
export default reportControl
|