mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-11 13:39:48 +08:00
parent
182c4c2303
commit
d7aaa4fc00
@ -2,12 +2,12 @@
|
||||
<div class="container-submenu container-context-menu">
|
||||
<el-menu v-shortkey="{f2: ['f2'], f3: ['f3'], f5: ['f5'], f3:['ctrl', 'd']}" :default-active="activeMenu" :router="false" class="el-menu-demo" mode="horizontal" menu-trigger="hover" unique-opened @select="typeFormat" @shortkey.native="actionContextMenu">
|
||||
<template>
|
||||
<el-submenu v-if="relations !== undefined && relations.length" class="el-menu-item" index="1">
|
||||
<el-submenu v-if="relationsList !== undefined && relationsList.length" class="el-menu-item" index="1">
|
||||
<template slot="title">
|
||||
{{ $t('components.contextMenuRelations') }}
|
||||
</template>
|
||||
<el-scrollbar wrap-class="scroll">
|
||||
<item v-for="(relation, index) in relations" :key="index" :item="relation" />
|
||||
<item v-for="(relation, index) in relationsList" :key="index" :item="relation" />
|
||||
</el-scrollbar>
|
||||
</el-submenu>
|
||||
<el-menu-item v-else disabled index="1">
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { showNotification } from '@/utils/ADempiere/notification'
|
||||
import Item from './items'
|
||||
import { convertFieldListToShareLink } from '@/utils/ADempiere/valueUtils'
|
||||
import { convertFieldListToShareLink, recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
|
||||
import { supportedTypes, exportFileFromJson } from '@/utils/ADempiere/exportUtil'
|
||||
import ROUTES from '@/utils/ADempiere/zoomWindow'
|
||||
|
||||
@ -71,17 +71,6 @@ export const contextMixin = {
|
||||
getDataSelection() {
|
||||
return this.$store.getters.getDataRecordSelection(this.containerUuid)
|
||||
},
|
||||
relations() {
|
||||
if (this.$route.params.menuParentUuid !== undefined) {
|
||||
return this.$store.getters.getRelations(this.$route.params.menuParentUuid)
|
||||
} else {
|
||||
return this.$store.getters.getRelations(this.menuParentUuid).filter(relations => {
|
||||
if (!relations.hidden) {
|
||||
return relations
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
getterContextMenu() {
|
||||
return this.$store.getters.getContextMenu(this.containerUuid)
|
||||
},
|
||||
@ -97,6 +86,14 @@ export const contextMixin = {
|
||||
}
|
||||
return []
|
||||
},
|
||||
relationsList() {
|
||||
let menuUuid = this.$route.params.menuParentUuid
|
||||
if (this.isEmptyValue(menuUuid)) {
|
||||
menuUuid = this.menuParentUuid
|
||||
}
|
||||
const relations = this.$store.getters.getRelations(menuUuid)
|
||||
return relations.children
|
||||
},
|
||||
permissionRoutes() {
|
||||
return this.$store.getters.permission_routes
|
||||
},
|
||||
@ -111,7 +108,7 @@ export const contextMixin = {
|
||||
return this.$store.getters.getFieldsListFromPanel(this.containerUuid)
|
||||
},
|
||||
getterFieldListHeader() {
|
||||
var header = this.getterFieldList.filter(fieldItem => {
|
||||
const header = this.getterFieldList.filter(fieldItem => {
|
||||
const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic
|
||||
if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) {
|
||||
return fieldItem.name
|
||||
@ -122,7 +119,7 @@ export const contextMixin = {
|
||||
})
|
||||
},
|
||||
getterFieldListValue() {
|
||||
var value = this.getterFieldList.filter(fieldItem => {
|
||||
const value = this.getterFieldList.filter(fieldItem => {
|
||||
const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic
|
||||
if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) {
|
||||
return fieldItem
|
||||
@ -412,7 +409,7 @@ export const contextMixin = {
|
||||
// run process or report
|
||||
const fieldNotReady = this.$store.getters.isNotReadyForSubmit(this.$route.meta.uuid)
|
||||
if (!fieldNotReady) {
|
||||
var containerParams = this.$route.meta.uuid
|
||||
let containerParams = this.$route.meta.uuid
|
||||
if (this.lastParameter !== undefined) {
|
||||
containerParams = this.lastParameter
|
||||
}
|
||||
@ -429,7 +426,7 @@ export const contextMixin = {
|
||||
href: window.location.href
|
||||
})
|
||||
}
|
||||
var reportFormat = action.reportExportType
|
||||
let reportFormat = action.reportExportType
|
||||
if (this.isEmptyValue(reportFormat)) {
|
||||
if (!this.isEmptyValue(this.$route.query.reportType)) {
|
||||
reportFormat = this.$route.query.reportType
|
||||
@ -445,7 +442,7 @@ export const contextMixin = {
|
||||
containerUuid: containerParams, // EVALUATE IF IS action.uuid
|
||||
panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser)
|
||||
reportFormat: reportFormat, // this.$route.query.reportType ? this.$route.query.reportType : action.reportExportType,
|
||||
menuParentUuid: parentMenu, // to load relations in context menu (report view)
|
||||
menuParentUuid: parentMenu, // to load relationsList in context menu (report view)
|
||||
routeToDelete: this.$route
|
||||
})
|
||||
.catch(error => {
|
||||
@ -493,14 +490,17 @@ export const contextMixin = {
|
||||
})
|
||||
}
|
||||
} else if (action.type === 'reference') {
|
||||
this.$store.dispatch('getWindowByUuid', {
|
||||
routes: this.permissionRoutes,
|
||||
windowUuid: action.windowUuid
|
||||
})
|
||||
if (action.windowUuid && action.recordUuid) {
|
||||
var windowRoute = this.$store.getters.getWindowRoute(action.windowUuid)
|
||||
const viewSearch = recursiveTreeSearch({
|
||||
treeData: this.permissionRoutes,
|
||||
attributeValue: action.windowUuid,
|
||||
attributeName: 'meta',
|
||||
secondAttribute: 'uuid',
|
||||
attributeChilds: 'children'
|
||||
})
|
||||
if (viewSearch) {
|
||||
this.$router.push({
|
||||
name: windowRoute.name,
|
||||
name: viewSearch.name,
|
||||
query: {
|
||||
action: action.type,
|
||||
referenceUuid: action.uuid,
|
||||
@ -510,6 +510,7 @@ export const contextMixin = {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if (action.type === 'updateReport') {
|
||||
var updateReportParams = {
|
||||
instanceUuid: action.instanceUuid,
|
||||
@ -532,12 +533,15 @@ export const contextMixin = {
|
||||
this.$store.dispatch('getReportOutputFromServer', updateReportParams)
|
||||
.then(response => {
|
||||
if (!response.isError) {
|
||||
var link = {
|
||||
let link = {
|
||||
href: undefined,
|
||||
download: undefined
|
||||
}
|
||||
|
||||
const blob = new Blob([response.outputStream], { type: response.mimeType })
|
||||
const blob = new Blob(
|
||||
[response.outputStream],
|
||||
{ type: response.mimeType }
|
||||
)
|
||||
link = document.createElement('a')
|
||||
link.href = window.URL.createObjectURL(blob)
|
||||
link.download = response.fileName
|
||||
@ -554,10 +558,10 @@ export const contextMixin = {
|
||||
}
|
||||
},
|
||||
setShareLink() {
|
||||
var shareLink = this.panelType === 'window' || window.location.href.includes('?') ? `${window.location.href}&` : `${window.location.href}?`
|
||||
let shareLink = this.panelType === 'window' || window.location.href.includes('?') ? `${window.location.href}&` : `${window.location.href}?`
|
||||
if (this.$route.name === 'Report Viewer') {
|
||||
var processParameters = convertFieldListToShareLink(this.processParametersExecuted)
|
||||
var reportFormat = this.$store.getters.getReportType
|
||||
const processParameters = convertFieldListToShareLink(this.processParametersExecuted)
|
||||
const reportFormat = this.$store.getters.getReportType
|
||||
shareLink = this.$store.getters.getTempShareLink
|
||||
if (String(processParameters).length) {
|
||||
shareLink += '?' + processParameters
|
||||
@ -576,20 +580,17 @@ export const contextMixin = {
|
||||
}
|
||||
},
|
||||
fallbackCopyTextToClipboard(text) {
|
||||
var textArea = document.createElement('textarea')
|
||||
const textArea = document.createElement('textarea')
|
||||
textArea.value = text
|
||||
document.body.appendChild(textArea)
|
||||
textArea.focus()
|
||||
textArea.select()
|
||||
try {
|
||||
var successful = document.execCommand('copy')
|
||||
if (successful) {
|
||||
var message = this.$t('notifications.copySuccessful')
|
||||
this.clipboardMessage(message)
|
||||
if (document.execCommand('copy')) {
|
||||
this.clipboardMessage(this.$t('notifications.copySuccessful'))
|
||||
}
|
||||
} catch (err) {
|
||||
message = this.$t('notifications.copyUnsuccessful')
|
||||
this.clipboardMessage(message)
|
||||
this.clipboardMessage(this.$t('notifications.copyUnsuccessful'))
|
||||
}
|
||||
document.body.removeChild(textArea)
|
||||
},
|
||||
@ -600,12 +601,10 @@ export const contextMixin = {
|
||||
}
|
||||
navigator.clipboard.writeText(text)
|
||||
.then(() => {
|
||||
var message = this.$t('notifications.copySuccessful')
|
||||
this.clipboardMessage(message)
|
||||
this.clipboardMessage(this.$t('notifications.copySuccessful'))
|
||||
})
|
||||
.catch(() => {
|
||||
var message = this.$t('notifications.copyUnsuccessful')
|
||||
this.clipboardMessage(message)
|
||||
this.clipboardMessage(this.$t('notifications.copyUnsuccessful'))
|
||||
})
|
||||
navigator.clipboard.writeText(text)
|
||||
},
|
||||
|
@ -8,7 +8,7 @@
|
||||
</template>
|
||||
<el-menu-item-group>
|
||||
<el-scrollbar wrap-class="scroll">
|
||||
<item v-for="(relation, index) in relations" :key="index" :item="relation" />
|
||||
<item v-for="(relation, index) in relationsList" :key="index" :item="relation" />
|
||||
</el-scrollbar>
|
||||
</el-menu-item-group>
|
||||
</el-submenu>
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
<script>
|
||||
import { getPendingDocumentsFromServer } from '@/api/ADempiere/data'
|
||||
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
|
||||
|
||||
export default {
|
||||
name: 'PendingDocuments',
|
||||
@ -83,10 +84,16 @@ export default {
|
||||
})
|
||||
},
|
||||
handleClick(row) {
|
||||
this.$store.dispatch('getWindowByUuid', { routes: this.permissionRoutes, windowUuid: row.windowUuid })
|
||||
var windowRoute = this.$store.getters.getWindowRoute(row.windowUuid)
|
||||
const viewSearch = recursiveTreeSearch({
|
||||
treeData: this.permissionRoutes,
|
||||
attributeValue: row.windowUuid,
|
||||
attributeName: 'meta',
|
||||
secondAttribute: 'uuid',
|
||||
attributeChilds: 'children'
|
||||
})
|
||||
if (viewSearch) {
|
||||
this.$router.push({
|
||||
name: windowRoute.name,
|
||||
name: viewSearch.name,
|
||||
params: {
|
||||
...row.criteria
|
||||
},
|
||||
@ -94,6 +101,7 @@ export default {
|
||||
action: 'criteria'
|
||||
}
|
||||
})
|
||||
}
|
||||
// conditions for the registration amount (operador: row.criteria.whereClause)
|
||||
},
|
||||
filterResult(search) {
|
||||
|
@ -31,6 +31,7 @@
|
||||
<script>
|
||||
import { getRecentItems as getRecentItemsFromServer } from '@/api/ADempiere'
|
||||
import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
|
||||
|
||||
export default {
|
||||
name: 'RecentItems',
|
||||
props: {
|
||||
@ -91,7 +92,13 @@ export default {
|
||||
},
|
||||
handleClick(row) {
|
||||
if (!this.isEmptyValue(row.uuidRecord)) {
|
||||
this.$router.push({ name: row.menuUuid, query: { action: row.uuidRecord, tabParent: 0 }})
|
||||
this.$router.push({
|
||||
name: row.menuUuid,
|
||||
query: {
|
||||
action: row.uuidRecord,
|
||||
tabParent: 0
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$router.push({ name: row.menuUuid })
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { supportedTypes, exportFileFromJson, exportFileZip } from '@/utils/ADempiere/exportUtil'
|
||||
import { showNotification } from '@/utils/ADempiere/notification'
|
||||
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
|
||||
import { FIELDS_QUANTITY } from '@/components/ADempiere/Field/references'
|
||||
|
||||
export const menuTableMixin = {
|
||||
@ -324,23 +325,26 @@ export const menuTableMixin = {
|
||||
},
|
||||
zoomRecord() {
|
||||
const browserMetadata = this.$store.getters.getBrowser(this.$route.meta.uuid)
|
||||
const elementName = browserMetadata.fieldList.find(field => field.columnName === browserMetadata.keyColumn).elementName
|
||||
const { elementName } = browserMetadata.fieldList.find(field => field.columnName === browserMetadata.keyColumn)
|
||||
const records = []
|
||||
this.getDataSelection.forEach(record => {
|
||||
if (!isNaN(record[browserMetadata.keyColumn])) {
|
||||
records.push(Number(record[browserMetadata.keyColumn]))
|
||||
} else {
|
||||
if (isNaN(record[browserMetadata.keyColumn])) {
|
||||
records.push(record[browserMetadata.keyColumn])
|
||||
} else {
|
||||
records.push(Number(record[browserMetadata.keyColumn]))
|
||||
}
|
||||
})
|
||||
|
||||
this.$store.dispatch('getWindowByUuid', {
|
||||
routes: this.permissionRoutes,
|
||||
windowUuid: browserMetadata.window.uuid
|
||||
const viewSearch = recursiveTreeSearch({
|
||||
treeData: this.permissionRoutes,
|
||||
attributeValue: browserMetadata.window.uuid,
|
||||
attributeName: 'meta',
|
||||
secondAttribute: 'uuid',
|
||||
attributeChilds: 'children'
|
||||
})
|
||||
const windowRoute = this.$store.getters.getWindowRoute(browserMetadata.window.uuid)
|
||||
if (viewSearch) {
|
||||
this.$router.push({
|
||||
name: windowRoute.name,
|
||||
name: viewSearch.name,
|
||||
query: {
|
||||
action: 'advancedQuery',
|
||||
[elementName]: records
|
||||
@ -349,3 +353,4 @@ export const menuTableMixin = {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ import { FIELD_ONLY } from '@/components/ADempiere/Field/references'
|
||||
import { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
|
||||
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
||||
import { showMessage } from '@/utils/ADempiere/notification'
|
||||
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
|
||||
|
||||
/**
|
||||
* This is the base component for linking the components according to the
|
||||
@ -340,14 +341,16 @@ export default {
|
||||
}
|
||||
},
|
||||
redirect({ window, columnName, value }) {
|
||||
this.$store.dispatch('getWindowByUuid', {
|
||||
routes: this.permissionRoutes,
|
||||
windowUuid: window.uuid
|
||||
const viewSearch = recursiveTreeSearch({
|
||||
treeData: this.permissionRoutes,
|
||||
attributeValue: window.uuid,
|
||||
attributeName: 'meta',
|
||||
secondAttribute: 'uuid',
|
||||
attributeChilds: 'children'
|
||||
})
|
||||
const windowRoute = this.$store.getters.getWindowRoute(window.uuid)
|
||||
if (windowRoute) {
|
||||
if (viewSearch) {
|
||||
this.$router.push({
|
||||
name: windowRoute.name,
|
||||
name: viewSearch.name,
|
||||
query: {
|
||||
action: 'advancedQuery',
|
||||
tabParent: 0,
|
||||
|
@ -56,9 +56,10 @@ const staticRoutes = [
|
||||
|
||||
// Get Menu from server
|
||||
export function loadMainMenu() {
|
||||
return getMenu(getToken()).then(menu => {
|
||||
return new Promise(resolve => {
|
||||
getMenu(getToken()).then(menuResponse => {
|
||||
const asyncRoutesMap = []
|
||||
menu.childsList.forEach(menu => {
|
||||
menuResponse.childsList.forEach(menu => {
|
||||
const optionMenu = getRouteFromMenuItem(menu)
|
||||
if (menu.isSummary) {
|
||||
menu.childsList.forEach(menu => {
|
||||
@ -76,9 +77,10 @@ export function loadMainMenu() {
|
||||
}
|
||||
asyncRoutesMap.push(optionMenu)
|
||||
})
|
||||
return staticRoutes.concat(asyncRoutesMap)
|
||||
resolve(staticRoutes.concat(asyncRoutesMap))
|
||||
}).catch(error => {
|
||||
console.warn(`Error getting menu: ${error.message}. Code: ${error.code}`)
|
||||
console.warn(`Error getting menu: ${error.message}. Code: ${error.code}.`)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils.js'
|
||||
// Store used for set all related to context menu
|
||||
// for Window, Process, Smart Browser andother customized component
|
||||
// See structure:
|
||||
@ -32,23 +33,17 @@ const contextMenu = {
|
||||
getContextMenu: (state) => (containerUuid) => {
|
||||
return state.contextMenu.find(item => item.containerUuid === containerUuid)
|
||||
},
|
||||
getRelations: (state, getters, rootState) => (containerUuid) => {
|
||||
var menuRelations
|
||||
rootState.permission.addRoutes.forEach(route => {
|
||||
if (route.name === containerUuid) {
|
||||
menuRelations = route.children
|
||||
} else if (route.name !== containerUuid && route.children) {
|
||||
route.children.forEach(child => {
|
||||
if (child.name === containerUuid) {
|
||||
menuRelations = route.children
|
||||
}
|
||||
getRelations: (state, getters, rootState, rootGetters) => (containerUuid) => {
|
||||
const dataTree = rootGetters.permission_routes
|
||||
return recursiveTreeSearch({
|
||||
treeData: dataTree,
|
||||
attributeName: 'name',
|
||||
attributeValue: containerUuid,
|
||||
attributeChilds: 'children'
|
||||
})
|
||||
}
|
||||
})
|
||||
return menuRelations
|
||||
},
|
||||
getActions: (state) => (containerUuid) => {
|
||||
var menu = state.contextMenu.find(
|
||||
const menu = state.contextMenu.find(
|
||||
item => item.containerUuid === containerUuid
|
||||
)
|
||||
if (menu === undefined) {
|
||||
|
@ -9,7 +9,6 @@ const windowControl = {
|
||||
state: {
|
||||
inCreate: [],
|
||||
references: [],
|
||||
windowRoute: {},
|
||||
windowOldRoute: {
|
||||
path: '',
|
||||
fullPath: '',
|
||||
@ -39,9 +38,6 @@ const windowControl = {
|
||||
return true
|
||||
})
|
||||
},
|
||||
addWindowRoute(state, payload) {
|
||||
state.windowRoute = payload
|
||||
},
|
||||
setDataLog(state, payload) {
|
||||
state.dataLog = payload
|
||||
},
|
||||
@ -407,7 +403,7 @@ const windowControl = {
|
||||
})
|
||||
},
|
||||
deleteEntity({ dispatch, rootGetters }, parameters) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise(resolve => {
|
||||
const panel = rootGetters.getPanel(parameters.containerUuid)
|
||||
|
||||
deleteEntity({
|
||||
@ -464,8 +460,7 @@ const windowControl = {
|
||||
message: language.t('data.deleteRecordError'),
|
||||
type: 'error'
|
||||
})
|
||||
console.warn(`Delete Entity - Error ${error.message}, Code: ${error.code}`)
|
||||
reject(error)
|
||||
console.warn(`Delete Entity - Error ${error.message}, Code: ${error.code}.`)
|
||||
})
|
||||
})
|
||||
},
|
||||
@ -547,7 +542,7 @@ const windowControl = {
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
})
|
||||
console.warn(`Rollback Entity error: ${error.message}`)
|
||||
console.warn(`Rollback Entity error: ${error.message}. Code: ${error.code}.`)
|
||||
})
|
||||
},
|
||||
setDataLog({ commit }, parameters) {
|
||||
@ -597,7 +592,7 @@ const windowControl = {
|
||||
|
||||
if (isReference) {
|
||||
if (!isEmptyValue(parsedWhereClause)) {
|
||||
parsedWhereClause += ' AND ' + referenceWhereClause
|
||||
parsedWhereClause += ` AND ${referenceWhereClause}`
|
||||
} else {
|
||||
parsedWhereClause += referenceWhereClause
|
||||
}
|
||||
@ -605,7 +600,7 @@ const windowControl = {
|
||||
|
||||
if (!isEmptyValue(criteria)) {
|
||||
if (!isEmptyValue(parsedWhereClause)) {
|
||||
parsedWhereClause += ' AND ' + criteria.whereClause
|
||||
parsedWhereClause += ` AND ${criteria.whereClause}`
|
||||
} else {
|
||||
parsedWhereClause += criteria.whereClause
|
||||
}
|
||||
@ -744,15 +739,6 @@ const windowControl = {
|
||||
})
|
||||
})
|
||||
},
|
||||
getWindowByUuid({ dispatch, commit }, parameters) {
|
||||
parameters.routes.forEach((routeItem) => {
|
||||
if (routeItem.meta && routeItem.meta.uuid === parameters.windowUuid) {
|
||||
commit('addWindowRoute', routeItem)
|
||||
} else if (routeItem.meta && routeItem.meta.childs && routeItem.meta.childs.length > 0) {
|
||||
dispatch('getWindowByUuid', { routes: routeItem.meta.childs, windowUuid: parameters.windowUuid })
|
||||
}
|
||||
})
|
||||
},
|
||||
setWindowOldRoute({ commit }, oldPath = { path: '', fullPath: '', query: {}}) {
|
||||
commit('setWindowOldRoute', oldPath)
|
||||
},
|
||||
@ -848,11 +834,6 @@ const windowControl = {
|
||||
const references = getters.getReferencesList(windowUuid, recordUuid)
|
||||
return references.referencesList.find(item => item.uuid === referenceUuid)
|
||||
},
|
||||
getWindowRoute: (state) => (windowUuid) => {
|
||||
if (state.windowRoute && state.windowRoute.meta && state.windowRoute.meta.uuid === windowUuid) {
|
||||
return state.windowRoute
|
||||
}
|
||||
},
|
||||
getTabSequenceRecord: (state) => {
|
||||
return state.tabSequenceRecord
|
||||
},
|
||||
|
@ -16,10 +16,10 @@ const mutations = {
|
||||
const actions = {
|
||||
generateRoutes({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
return loadMainMenu().then(menu => {
|
||||
commit('SET_ROUTES', menu)
|
||||
resolve(menu)
|
||||
}).catch(err => console.log(err))
|
||||
loadMainMenu().then(menuResponse => {
|
||||
commit('SET_ROUTES', menuResponse)
|
||||
resolve(menuResponse)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
import { convertValueFromGRPC } from '@/api/ADempiere/data'
|
||||
|
||||
// Decode a HTML text
|
||||
export function decodeHtml(text) {
|
||||
var processMetadata = document.createElement('div')
|
||||
processMetadata.innerHTML = text
|
||||
return processMetadata.childNodes[0].nodeValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if value is empty. Deep-checks arrays and objects
|
||||
* Note: isEmpty([]) == true, isEmpty({}) == true, isEmpty([{0:false},"",0]) == true, isEmpty({0:1}) == false
|
||||
* Note: isEmpty([]) == true, isEmpty({}) == true,
|
||||
* isEmpty([{0: false}, "", 0]) == true, isEmpty({0: 1}) == false
|
||||
* @param {boolean|array|object|number|string} value
|
||||
* @returns {boolean}
|
||||
*/
|
||||
@ -114,28 +108,30 @@ export function clientDateTime(date = null, type = '') {
|
||||
* @param {object} objectToConvert, object to convert
|
||||
* @param {string} nameKey, name from key in pairs
|
||||
* @param {string} nameValue, name from value in pairs
|
||||
* @returns {array} [ { nameKe: key, nameValue: value } ]
|
||||
* @returns {array} [ { nameKey: key, nameValue: value } ]
|
||||
*/
|
||||
export function convertObjectToArrayPairs(objectToConvert, nameKey = 'columnName', nameValue = 'value') {
|
||||
var result = Object.keys(objectToConvert).map(key => {
|
||||
var returnPairs = {}
|
||||
return Object.keys(objectToConvert).map(key => {
|
||||
const returnPairs = {}
|
||||
returnPairs[nameKey] = key
|
||||
returnPairs[nameValue] = objectToConvert[key]
|
||||
return returnPairs
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert array pairs of object to simple object { key:value }
|
||||
* @param {object} objectToConvert, object to convert
|
||||
* @param {array} arrayToConvert, object to convert
|
||||
* @param {string} nameKey, name from key in pairs
|
||||
* @param {string} nameValue, name from value in pairs
|
||||
*/
|
||||
export function convertArrayPairsToObject(arrayToConver, nameKey = 'columnName', nameValue = 'value') {
|
||||
var result = {}
|
||||
arrayToConver.forEach(element => {
|
||||
export function convertArrayPairsToObject({
|
||||
arrayToConvert,
|
||||
nameKey = 'columnName',
|
||||
nameValue = 'value'
|
||||
}) {
|
||||
const result = {}
|
||||
arrayToConvert.forEach(element => {
|
||||
result[element[nameKey]] = element[nameValue]
|
||||
})
|
||||
|
||||
@ -178,7 +174,7 @@ export function convertMapToArrayPairs({
|
||||
}
|
||||
|
||||
export function convertHasMapToObject(hasMapToConvert) {
|
||||
var result = {}
|
||||
const result = {}
|
||||
hasMapToConvert.forEach((value, key) => {
|
||||
result[key] = value
|
||||
})
|
||||
@ -294,3 +290,76 @@ export function parsedValueComponent({ fieldType, value, referenceType, isMandat
|
||||
}
|
||||
return returnValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Find element in an array recursively
|
||||
* @param {object|array} treeData
|
||||
* @param {string} attributeName, key to get value, default id
|
||||
* @param {mixed} attributeValue, value to compare with search
|
||||
* @param {string} attributeChilds, childs list into element
|
||||
*/
|
||||
export const recursiveTreeSearch = ({
|
||||
treeData,
|
||||
attributeValue,
|
||||
attributeName = 'id',
|
||||
secondAttribute = false,
|
||||
attributeChilds = 'childsList',
|
||||
isParent = false
|
||||
}) => {
|
||||
if (Array.isArray(treeData)) {
|
||||
let index = 0
|
||||
const length = treeData.length
|
||||
while (index < length) {
|
||||
// ESTA MIERDA NO SIRVE PORQUE LOS ATRIBTO
|
||||
let value = treeData[index]
|
||||
if (!isEmptyValue(value) && value.hasOwnProperty(attributeName)) {
|
||||
value = value[attributeName]
|
||||
}
|
||||
if (!isEmptyValue(value) && secondAttribute && value.hasOwnProperty(secondAttribute)) {
|
||||
value = value[secondAttribute]
|
||||
}
|
||||
|
||||
// compare item to search
|
||||
if (value === attributeValue) {
|
||||
return treeData[index]
|
||||
}
|
||||
|
||||
if (treeData[index] && treeData[index][attributeChilds]) {
|
||||
const found = recursiveTreeSearch({
|
||||
treeData: treeData[index][attributeChilds],
|
||||
attributeValue,
|
||||
attributeName,
|
||||
secondAttribute,
|
||||
attributeChilds,
|
||||
isParent
|
||||
})
|
||||
if (found) {
|
||||
return found
|
||||
}
|
||||
}
|
||||
index++
|
||||
}
|
||||
} else {
|
||||
let value = treeData
|
||||
if (!isEmptyValue(value) && value.hasOwnProperty(attributeName)) {
|
||||
value = value[attributeName]
|
||||
}
|
||||
if (!isEmptyValue(value) && secondAttribute && value.hasOwnProperty(secondAttribute)) {
|
||||
value = value[secondAttribute]
|
||||
}
|
||||
|
||||
// compare item to search
|
||||
if (value === attributeValue) {
|
||||
return treeData
|
||||
}
|
||||
|
||||
const found = recursiveTreeSearch({
|
||||
treeData: treeData[attributeChilds],
|
||||
attributeValue,
|
||||
attributeName,
|
||||
secondAttribute,
|
||||
attributeChilds
|
||||
})
|
||||
return found
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
|
||||
|
||||
export default {
|
||||
name: 'ProcessActivity',
|
||||
data() {
|
||||
@ -203,11 +205,16 @@ export default {
|
||||
}
|
||||
})
|
||||
} else if (activity.command === 'zoomIn') {
|
||||
this.$store.dispatch('getWindowByUuid', { routes: this.permissionRoutes, windowUuid: activity.uuid })
|
||||
const processRoute = this.$store.getters.getWindowRoute(activity.uuid)
|
||||
if (!this.isEmptyValue(processRoute)) {
|
||||
const viewSearch = recursiveTreeSearch({
|
||||
treeData: this.permissionRoutes,
|
||||
attributeValue: activity.uuid,
|
||||
attributeName: 'meta',
|
||||
secondAttribute: 'uuid',
|
||||
attributeChilds: 'children'
|
||||
})
|
||||
if (viewSearch) {
|
||||
this.$router.push({
|
||||
name: processRoute.name,
|
||||
name: viewSearch.name,
|
||||
query: {
|
||||
...this.$route.query,
|
||||
...activity.parametersList
|
||||
|
@ -353,6 +353,9 @@ export default {
|
||||
this.$store.dispatch('setWindowOldRoute', {
|
||||
path: from.path,
|
||||
fullPath: from.fullPath,
|
||||
params: {
|
||||
...from.params
|
||||
},
|
||||
query: {
|
||||
...from.query
|
||||
}
|
||||
@ -361,7 +364,6 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
defaultPorcentSplitPane() {
|
||||
// isShowedRecordPanel ? (isShowedRecordNavigation ? 100 : 50) : (isShowedRecordNavigation ? 50 : -1)
|
||||
if (this.isShowedRecordPanel) {
|
||||
if (this.isShowedRecordNavigation) {
|
||||
return 100
|
||||
|
Loading…
x
Reference in New Issue
Block a user