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

fix: Run process SB record selection. (#588)

* fix: Run process SB record selection.

* Update package.json

Co-authored-by: EdwinBetanc0urt <EdwinBetanco0urt@outlook.com>
This commit is contained in:
Edwin Betancourt 2021-02-25 14:00:45 -04:00 committed by GitHub
parent a7d2b63d44
commit b41ec22883
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 38 deletions

View File

@ -50,42 +50,52 @@ const getters = {
* selectionValues: [{ columnName, value }]
* }]
*/
getSelectionToServer: (state, getters, rootState, rootGetters) => ({ containerUuid, selection = [] }) => {
getSelectionToServer: (state, getters, rootState, rootGetters) => ({
containerUuid,
selection = []
}) => {
const selectionToServer = []
const withOut = ['isEdit', 'isSendToServer']
if (selection.length <= 0) {
if (isEmptyValue(selection)) {
selection = getters.getDataRecordSelection(containerUuid)
}
if (selection.length) {
const { fieldsList, keyColumn } = rootGetters.getPanel(containerUuid)
// reduce list
const fieldsListSelection = fieldsList.filter(itemField => {
if (isEmptyValue(selection)) {
return selectionToServer
}
const { fieldsList, keyColumn } = rootGetters.getPanel(containerUuid)
// reduce list
const fieldsListSelection = fieldsList
.filter(itemField => {
return itemField.isIdentifier || itemField.isUpdateable
})
selection.forEach(itemRow => {
const records = []
Object.keys(itemRow).forEach(key => {
if (!key.includes('DisplayColumn') && !withOut.includes(key)) {
// evaluate metadata attributes before to convert
const field = fieldsListSelection.find(itemField => itemField.columnName === key)
if (field) {
records.push({
columnName: key,
value: itemRow[key]
})
}
}
})
selectionToServer.push({
selectionId: itemRow[keyColumn],
selectionValues: records
})
.map(itemField => {
return itemField.columnName
})
}
selection.forEach(itemRow => {
const records = []
Object.keys(itemRow).forEach(key => {
if (!key.includes('DisplayColumn') && !withOut.includes(key)) {
// evaluate metadata attributes before to convert
if (fieldsListSelection.includes(key)) {
records.push({
columnName: key,
value: itemRow[key]
})
}
}
})
selectionToServer.push({
selectionId: itemRow[keyColumn],
selectionValues: records
})
})
return selectionToServer
},
getContextInfoField: (state) => (contextInfoUuid, sqlStatement) => {

View File

@ -47,17 +47,17 @@ export default {
// }
// additional attributes to send server, selection to browser, or table name and record id to window
let selection = []
let selectionsList = []
let allData = {}
let tab, tableName, recordId
if (panelType) {
if (panelType === 'browser') {
allData = getters.getDataRecordAndSelection(containerUuid)
selection = rootGetters.getSelectionToServer({
selectionsList = rootGetters.getSelectionToServer({
containerUuid,
selection: allData.selection
})
if (selection.length < 1) {
if (isEmptyValue(selectionsList)) {
showNotification({
title: language.t('data.selectionRequired'),
type: 'warning'
@ -89,7 +89,10 @@ export default {
}
}
// get info metadata process
const processDefinition = !isEmptyValue(isActionDocument) ? action : rootGetters.getProcess(action.uuid)
const processDefinition = !isEmptyValue(isActionDocument)
? action
: rootGetters.getProcess(action.uuid)
let reportType = reportFormat
if (isEmptyValue(parametersList)) {
@ -193,22 +196,22 @@ export default {
}
if (isProcessTableSelection) {
const windowSelectionProcess = getters.getProcessSelect
windowSelectionProcess.selection.forEach(selection => {
windowSelectionProcess.selection.forEach(selectionWindow => {
Object.assign(processResult, {
selection: selection.UUID,
record: selection[windowSelectionProcess.tableName]
selection: selectionWindow.UUID,
record: selectionWindow[windowSelectionProcess.tableName]
})
const countRequest = state.totalRequest + 1
commit('setTotalRequest', countRequest)
if (!windowSelectionProcess.finish) {
// TODO: Add backend support to selectionsList records in window
requestRunProcess({
uuid: processDefinition.uuid,
id: processDefinition.id,
reportType,
parametersList,
selectionsList: selection,
tableName: windowSelectionProcess.tableName,
recordId: selection[windowSelectionProcess.tableName]
recordId: selectionWindow[windowSelectionProcess.tableName]
})
.then(runProcessResponse => {
const { instanceUuid, output } = runProcessResponse
@ -394,7 +397,7 @@ export default {
id: processDefinition.id,
reportType,
parametersList,
selectionsList: selection,
selectionsList,
tableName,
recordId
})