mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 07:04:21 +08:00
Add support to set warehouse and organization for current role (#455)
This commit is contained in:
parent
b6450dc406
commit
a52d2ee0de
@ -45,8 +45,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adempiere/grpc-access-client": "^1.1.8",
|
"@adempiere/grpc-access-client": "^1.1.8",
|
||||||
"@adempiere/grpc-data-client": "^2.2.1",
|
"@adempiere/grpc-data-client": "^2.2.3",
|
||||||
"@adempiere/grpc-pos-client": "^1.0.3",
|
"@adempiere/grpc-pos-client": "^1.0.4",
|
||||||
"@adempiere/grpc-dictionary-client": "^1.3.9",
|
"@adempiere/grpc-dictionary-client": "^1.3.9",
|
||||||
"@adempiere/grpc-enrollment-client": "^1.0.7",
|
"@adempiere/grpc-enrollment-client": "^1.0.7",
|
||||||
"autoprefixer": "^9.5.1",
|
"autoprefixer": "^9.5.1",
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import { getLanguage } from '@/lang/index'
|
import { getLanguage } from '@/lang/index'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth'
|
||||||
import BusinessData from '@adempiere/grpc-data-client'
|
import BusinessData from '@adempiere/grpc-data-client'
|
||||||
import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants'
|
import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants'
|
||||||
|
|
||||||
// Get Instance for connection
|
// Get Instance for connection
|
||||||
function Instance() {
|
function Instance() {
|
||||||
return new BusinessData(
|
return new BusinessData({
|
||||||
BUSINESS_DATA_ADDRESS,
|
host: BUSINESS_DATA_ADDRESS,
|
||||||
getToken(),
|
sessionUuid: getToken(),
|
||||||
getLanguage() || 'en_US'
|
organizationUuid: getCurrentOrganization(),
|
||||||
)
|
warehouseUuid: getCurrentWarehouse(),
|
||||||
|
language: getLanguage() || 'en_US'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,6 +93,36 @@ export function getEntitiesList({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get Organization list from role
|
||||||
|
export function getOrganizationsList({
|
||||||
|
roleUuid,
|
||||||
|
roleId,
|
||||||
|
pageToken,
|
||||||
|
pageSize
|
||||||
|
}) {
|
||||||
|
return Instance.call(this).requestListOrganizations({
|
||||||
|
roleUuid,
|
||||||
|
roleId,
|
||||||
|
pageToken,
|
||||||
|
pageSize
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Warehouses of Organization
|
||||||
|
export function getWarehousesList({
|
||||||
|
organizationUuid,
|
||||||
|
organizationId,
|
||||||
|
pageToken,
|
||||||
|
pageSize
|
||||||
|
}) {
|
||||||
|
return Instance.call(this).requestListWarehouses({
|
||||||
|
organizationUuid,
|
||||||
|
organizationId,
|
||||||
|
pageToken,
|
||||||
|
pageSize
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all operator or get key value type from value
|
* Get all operator or get key value type from value
|
||||||
* @param {number} keyToFind
|
* @param {number} keyToFind
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<transition name="sidebarLogoFade">
|
<transition name="sidebarLogoFade">
|
||||||
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link sidebar-logo-link-close" to="/">
|
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link sidebar-logo-link-close" to="/">
|
||||||
<el-tooltip placement="right">
|
<el-tooltip placement="right">
|
||||||
<div slot="content">{{ getRol.name }} | {{ getRol.clientName }}</div>
|
<div slot="content">{{ getRole.name }} | {{ getRole.clientName }}</div>
|
||||||
<img v-if="logo" :src="logo" class="sidebar-logo">
|
<img v-if="logo" :src="logo" class="sidebar-logo">
|
||||||
<h1 v-else class="sidebar-title">{{ title }} </h1>
|
<h1 v-else class="sidebar-title">{{ title }} </h1>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@ -12,9 +12,9 @@
|
|||||||
<img v-if="logo" :src="logo" class="sidebar-logo" @click="dashboard()">
|
<img v-if="logo" :src="logo" class="sidebar-logo" @click="dashboard()">
|
||||||
<h1 class="sidebar-title" @click="dashboard()">{{ title }}</h1><br>
|
<h1 class="sidebar-title" @click="dashboard()">{{ title }}</h1><br>
|
||||||
<el-tooltip placement="right">
|
<el-tooltip placement="right">
|
||||||
<div slot="content">{{ getRol.name }} | {{ getRol.clientName }}</div>
|
<div slot="content">{{ getRole.name }} | {{ getRole.clientName }}</div>
|
||||||
<p class="sidebar-sub-title" @click="profile()">
|
<p class="sidebar-sub-title" @click="profile()">
|
||||||
{{ getRol.name }} | {{ getRol.clientName }}
|
{{ getRole.name }} | {{ getRole.clientName }}
|
||||||
</p>
|
</p>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
@ -40,8 +40,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getRol() {
|
getRole() {
|
||||||
return this.$store.getters['user/getRol']
|
return this.$store.getters['user/getRole']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -12,7 +12,7 @@ const getters = {
|
|||||||
router: state => state.permission.addRoutes,
|
router: state => state.permission.addRoutes,
|
||||||
introduction: state => state.user.introduction,
|
introduction: state => state.user.introduction,
|
||||||
currentRole: state => state.user.currentRole,
|
currentRole: state => state.user.currentRole,
|
||||||
getRoleUuid: state => state.user.rol.uuid,
|
getRoleUuid: state => state.user.role.uuid,
|
||||||
roles: state => state.user.roles,
|
roles: state => state.user.roles,
|
||||||
permission_routes: state => state.permission.routes,
|
permission_routes: state => state.permission.routes,
|
||||||
errorLogs: state => state.errorLog.logs
|
errorLogs: state => state.errorLog.logs
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
import { login, logout, requestUserInfoFromSession, getSessionInfo, changeRole } from '@/api/user'
|
import { login, logout, requestUserInfoFromSession, getSessionInfo, changeRole } from '@/api/user'
|
||||||
import { getToken, setToken, removeToken, getCurrentRole, setCurrentRole, removeCurrentRole } from '@/utils/auth'
|
import {
|
||||||
|
getToken,
|
||||||
|
setToken,
|
||||||
|
removeToken,
|
||||||
|
getCurrentRole,
|
||||||
|
setCurrentRole,
|
||||||
|
removeCurrentRole,
|
||||||
|
getCurrentOrganization,
|
||||||
|
setCurrentOrganization,
|
||||||
|
getCurrentWarehouse,
|
||||||
|
setCurrentWarehouse,
|
||||||
|
removeCurrentWarehouse,
|
||||||
|
removeCurrentOrganization
|
||||||
|
} from '@/utils/auth'
|
||||||
|
import { getOrganizationsList, getWarehousesList } from '@/api/ADempiere/data'
|
||||||
import router, { resetRouter } from '@/router'
|
import router, { resetRouter } from '@/router'
|
||||||
import { showMessage } from '@/utils/ADempiere/notification'
|
import { showMessage } from '@/utils/ADempiere/notification'
|
||||||
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
||||||
@ -11,9 +25,13 @@ const state = {
|
|||||||
userUuid: '',
|
userUuid: '',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
introduction: '',
|
introduction: '',
|
||||||
rol: {}, // info current rol
|
role: {}, // info current role
|
||||||
rolesList: [],
|
rolesList: [],
|
||||||
roles: [],
|
roles: [],
|
||||||
|
organizationsList: [],
|
||||||
|
organization: {},
|
||||||
|
warehousesList: [],
|
||||||
|
warehouse: {},
|
||||||
isSession: false,
|
isSession: false,
|
||||||
sessionInfo: {}
|
sessionInfo: {}
|
||||||
}
|
}
|
||||||
@ -37,8 +55,20 @@ const mutations = {
|
|||||||
SET_ROLES_LIST: (state, payload) => {
|
SET_ROLES_LIST: (state, payload) => {
|
||||||
state.rolesList = payload
|
state.rolesList = payload
|
||||||
},
|
},
|
||||||
SET_ROL: (state, rol) => {
|
SET_ORGANIZATIONS_LIST: (state, payload) => {
|
||||||
state.rol = rol
|
state.organizationsList = payload
|
||||||
|
},
|
||||||
|
SET_ORGANIZATION: (state, organization) => {
|
||||||
|
state.organization = organization
|
||||||
|
},
|
||||||
|
SET_WAREHOUSES_LIST: (state, payload) => {
|
||||||
|
state.warehousesList = payload
|
||||||
|
},
|
||||||
|
SET_WAREHOUSE: (state, warehouse) => {
|
||||||
|
state.warehouse = warehouse
|
||||||
|
},
|
||||||
|
SET_ROLE: (state, role) => {
|
||||||
|
state.role = role
|
||||||
},
|
},
|
||||||
SET_USER_UUID: (state, payload) => {
|
SET_USER_UUID: (state, payload) => {
|
||||||
state.userUuid = payload
|
state.userUuid = payload
|
||||||
@ -110,9 +140,47 @@ const actions = {
|
|||||||
defaultContext: responseGetInfo.defaultContextMap
|
defaultContext: responseGetInfo.defaultContextMap
|
||||||
}
|
}
|
||||||
|
|
||||||
commit('SET_ROL', role)
|
commit('SET_ROLE', role)
|
||||||
setCurrentRole(role.uuid)
|
setCurrentRole(role.uuid)
|
||||||
|
getOrganizationsList({ roleUuid: role.uuid })
|
||||||
|
.then(response => {
|
||||||
|
commit('SET_ORGANIZATIONS_LIST', response.organizationsList)
|
||||||
|
let organization = response.organizationsList.find(item => item.uuid === getCurrentOrganization())
|
||||||
|
if (isEmptyValue(organization)) {
|
||||||
|
organization = response.organizationsList[0]
|
||||||
|
}
|
||||||
|
if (isEmptyValue(organization)) {
|
||||||
|
removeCurrentOrganization()
|
||||||
|
commit('SET_ORGANIZATION', undefined)
|
||||||
|
} else {
|
||||||
|
setCurrentOrganization(organization.uuid)
|
||||||
|
commit('SET_ORGANIZATION', organization)
|
||||||
|
}
|
||||||
|
getWarehousesList({ organizationUuid: getCurrentOrganization() })
|
||||||
|
.then(response => {
|
||||||
|
commit('SET_WAREHOUSES_LIST', response.warehousesList)
|
||||||
|
let warehouse = response.warehousesList.find(item => item.uuid === getCurrentWarehouse())
|
||||||
|
if (isEmptyValue(warehouse)) {
|
||||||
|
warehouse = response.warehousesList[0]
|
||||||
|
}
|
||||||
|
if (isEmptyValue(warehouse)) {
|
||||||
|
removeCurrentWarehouse()
|
||||||
|
commit('SET_WAREHOUSE', undefined)
|
||||||
|
} else {
|
||||||
|
setCurrentWarehouse(warehouse.uuid)
|
||||||
|
commit('SET_WAREHOUSE', warehouse)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`Error ${error.code} getting user info value: ${error.message}.`)
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`Error ${error.code} getting user info value: ${error.message}.`)
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
//
|
||||||
resolve(sessionResponse)
|
resolve(sessionResponse)
|
||||||
|
|
||||||
dispatch('getUserInfoFromSession', sessionUuid)
|
dispatch('getUserInfoFromSession', sessionUuid)
|
||||||
@ -155,12 +223,12 @@ const actions = {
|
|||||||
})
|
})
|
||||||
commit('SET_ROLES', rolesName)
|
commit('SET_ROLES', rolesName)
|
||||||
|
|
||||||
if (isEmptyValue(state.rol)) {
|
if (isEmptyValue(state.role)) {
|
||||||
const role = responseGetInfo.rolesList.find(itemRole => {
|
const role = responseGetInfo.rolesList.find(itemRole => {
|
||||||
return itemRole.uuid === getCurrentRole()
|
return itemRole.uuid === getCurrentRole()
|
||||||
})
|
})
|
||||||
if (!isEmptyValue(role)) {
|
if (!isEmptyValue(role)) {
|
||||||
commit('SET_ROL', role)
|
commit('SET_ROLE', role)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,9 +279,40 @@ const actions = {
|
|||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
changeOrganization({ commit, dispatch }, {
|
||||||
|
organizationUuid
|
||||||
|
}) {
|
||||||
|
setCurrentOrganization(organizationUuid)
|
||||||
|
getWarehousesList({ organizationUuid: organizationUuid })
|
||||||
|
.then(response => {
|
||||||
|
commit('SET_WAREHOUSES_LIST', response.warehousesList)
|
||||||
|
let warehouse = response.warehousesList.find(item => item.uuid === getCurrentWarehouse())
|
||||||
|
if (isEmptyValue(warehouse)) {
|
||||||
|
warehouse = response.warehousesList[0]
|
||||||
|
}
|
||||||
|
if (isEmptyValue(warehouse)) {
|
||||||
|
removeCurrentWarehouse()
|
||||||
|
commit('SET_WAREHOUSE', undefined)
|
||||||
|
} else {
|
||||||
|
setCurrentWarehouse(warehouse.uuid)
|
||||||
|
commit('SET_WAREHOUSE', warehouse)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`Error ${error.code} getting user info value: ${error.message}.`)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
changeWarehouse({ commit, state }, {
|
||||||
|
warehouseUuid
|
||||||
|
}) {
|
||||||
|
setCurrentWarehouse(warehouseUuid)
|
||||||
|
commit('SET_WAREHOUSE', state.warehousesList.find(warehouse => warehouse.uuid === warehouseUuid))
|
||||||
|
},
|
||||||
// dynamically modify permissions
|
// dynamically modify permissions
|
||||||
changeRoles({ commit, dispatch }, {
|
changeRole({ commit, dispatch }, {
|
||||||
roleUuid,
|
roleUuid,
|
||||||
|
organizationUuid,
|
||||||
|
warehouseUuid,
|
||||||
isCloseAllViews = true
|
isCloseAllViews = true
|
||||||
}) {
|
}) {
|
||||||
const route = router.app._route
|
const route = router.app._route
|
||||||
@ -238,12 +337,12 @@ const actions = {
|
|||||||
return changeRole({
|
return changeRole({
|
||||||
sessionUuid: getToken(),
|
sessionUuid: getToken(),
|
||||||
roleUuid,
|
roleUuid,
|
||||||
organizationUuid: null,
|
organizationUuid,
|
||||||
warehouseUuid: null
|
warehouseUuid
|
||||||
})
|
})
|
||||||
.then(changeRoleResponse => {
|
.then(changeRoleResponse => {
|
||||||
const { role } = changeRoleResponse
|
const { role } = changeRoleResponse
|
||||||
commit('SET_ROL', role)
|
commit('SET_ROLE', role)
|
||||||
setCurrentRole(role.uuid)
|
setCurrentRole(role.uuid)
|
||||||
commit('SET_TOKEN', changeRoleResponse.uuid)
|
commit('SET_TOKEN', changeRoleResponse.uuid)
|
||||||
setToken(changeRoleResponse.uuid)
|
setToken(changeRoleResponse.uuid)
|
||||||
@ -303,9 +402,21 @@ const getters = {
|
|||||||
getRoles: (state) => {
|
getRoles: (state) => {
|
||||||
return state.rolesList
|
return state.rolesList
|
||||||
},
|
},
|
||||||
// current rol info
|
getOrganizations: (state) => {
|
||||||
getRol: (state) => {
|
return state.organizationsList
|
||||||
return state.rol
|
},
|
||||||
|
getWarehouses: (state) => {
|
||||||
|
return state.warehousesList
|
||||||
|
},
|
||||||
|
// current role info
|
||||||
|
getRole: (state) => {
|
||||||
|
return state.role
|
||||||
|
},
|
||||||
|
getOrganization: (state) => {
|
||||||
|
return state.organization
|
||||||
|
},
|
||||||
|
getWarehouse: (state) => {
|
||||||
|
return state.warehouse
|
||||||
},
|
},
|
||||||
getIsSession: (state) => {
|
getIsSession: (state) => {
|
||||||
return state.isSession
|
return state.isSession
|
||||||
@ -314,7 +425,7 @@ const getters = {
|
|||||||
return state.userUuid
|
return state.userUuid
|
||||||
},
|
},
|
||||||
getIsPersonalLock: (state) => {
|
getIsPersonalLock: (state) => {
|
||||||
return state.rol.isPersonalLock
|
return state.role.isPersonalLock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
|
||||||
const roleKey = 'roleUuid'
|
const roleKey = 'roleUuid'
|
||||||
|
const organizationKey = 'organizationUuid'
|
||||||
|
const warehouseKey = 'warehouseUuid'
|
||||||
|
|
||||||
export function setCurrentRole(currentRole) {
|
export function setCurrentRole(currentRole) {
|
||||||
return Cookies.set(roleKey, currentRole)
|
return Cookies.set(roleKey, currentRole)
|
||||||
@ -10,6 +12,30 @@ export function getCurrentRole() {
|
|||||||
return Cookies.get(roleKey)
|
return Cookies.get(roleKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setCurrentOrganization(currentOrganization) {
|
||||||
|
return Cookies.set(organizationKey, currentOrganization)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCurrentOrganization() {
|
||||||
|
return Cookies.get(organizationKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeCurrentOrganization() {
|
||||||
|
return Cookies.remove(organizationKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCurrentWarehouse(currentWarehouse) {
|
||||||
|
return Cookies.set(warehouseKey, currentWarehouse)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCurrentWarehouse() {
|
||||||
|
return Cookies.get(warehouseKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeCurrentWarehouse() {
|
||||||
|
return Cookies.remove(warehouseKey)
|
||||||
|
}
|
||||||
|
|
||||||
export function removeCurrentRole() {
|
export function removeCurrentRole() {
|
||||||
return Cookies.remove(roleKey)
|
return Cookies.remove(roleKey)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export default {
|
|||||||
return this.roles[0]
|
return this.roles[0]
|
||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
this.$store.dispatch('user/changeRoles', val).then(() => {
|
this.$store.dispatch('user/changeRole', val).then(() => {
|
||||||
this.$emit('change')
|
this.$emit('change')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<router-link to="/profile/index">
|
<router-link to="/profile/index">
|
||||||
<img v-if="logo" :src="logo" class="sidebar-logo">
|
<img v-if="logo" :src="logo" class="sidebar-logo">
|
||||||
<p style="float: right;max-width: 150px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;">
|
<p style="float: right;max-width: 150px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;">
|
||||||
{{ getRol.clientName }}
|
{{ getRole.clientName }}
|
||||||
</p>
|
</p>
|
||||||
</router-link>
|
</router-link>
|
||||||
<roles-navbar />
|
<roles-navbar />
|
||||||
@ -33,8 +33,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getRol() {
|
getRole() {
|
||||||
return this.$store.getters['user/getRol']
|
return this.$store.getters['user/getRole']
|
||||||
},
|
},
|
||||||
getRoles() {
|
getRoles() {
|
||||||
return this.$store.getters['user/getRoles']
|
return this.$store.getters['user/getRoles']
|
||||||
|
@ -1,17 +1,45 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form>
|
<el-form>
|
||||||
<el-select
|
<el-select
|
||||||
v-model="value"
|
v-model="roleUuid"
|
||||||
:filterable="!isMobile"
|
:filterable="!isMobile"
|
||||||
value-key="key"
|
value-key="key"
|
||||||
@change="handleChange"
|
@change="changeRole"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(rol, key) in getRolesList"
|
v-for="(role, key) in getRolesList"
|
||||||
:key="key"
|
:key="key"
|
||||||
:label="rol.name"
|
:label="role.name"
|
||||||
:value="rol.uuid"
|
:value="role.uuid"
|
||||||
:disabled="isEmptyValue(rol.uuid)"
|
:disabled="isEmptyValue(role.uuid)"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<el-select
|
||||||
|
v-model="organizationUuid"
|
||||||
|
:filterable="!isMobile"
|
||||||
|
value-key="key"
|
||||||
|
@change="changeOrganization"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(organization, key) in getOrganizationsList"
|
||||||
|
:key="key"
|
||||||
|
:label="organization.name"
|
||||||
|
:value="organization.uuid"
|
||||||
|
:disabled="isEmptyValue(organization.uuid)"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<el-select
|
||||||
|
v-model="warehouseUuid"
|
||||||
|
:filterable="!isMobile"
|
||||||
|
value-key="key"
|
||||||
|
@change="changeWarehouse"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(warehouse, key) in getWarehousesList"
|
||||||
|
:key="key"
|
||||||
|
:label="warehouse.name"
|
||||||
|
:value="warehouse.uuid"
|
||||||
|
:disabled="isEmptyValue(warehouse.uuid)"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -24,17 +52,30 @@ export default {
|
|||||||
name: 'RolesNavbar',
|
name: 'RolesNavbar',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
value: '',
|
roleUuid: '',
|
||||||
options: []
|
organizationUuid: '',
|
||||||
|
warehouseUuid: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getRol() {
|
getRole() {
|
||||||
return this.$store.getters['user/getRol']
|
return this.$store.getters['user/getRole']
|
||||||
|
},
|
||||||
|
getOrganization() {
|
||||||
|
return this.$store.getters['user/getOrganization']
|
||||||
|
},
|
||||||
|
getWarehouse() {
|
||||||
|
return this.$store.getters['user/getWarehouse']
|
||||||
},
|
},
|
||||||
getRolesList() {
|
getRolesList() {
|
||||||
return this.$store.getters['user/getRoles']
|
return this.$store.getters['user/getRoles']
|
||||||
},
|
},
|
||||||
|
getOrganizationsList() {
|
||||||
|
return this.$store.getters['user/getOrganizations']
|
||||||
|
},
|
||||||
|
getWarehousesList() {
|
||||||
|
return this.$store.getters['user/getWarehouses']
|
||||||
|
},
|
||||||
isMobile() {
|
isMobile() {
|
||||||
return this.$store.state.app.device === 'mobile'
|
return this.$store.state.app.device === 'mobile'
|
||||||
},
|
},
|
||||||
@ -42,30 +83,40 @@ export default {
|
|||||||
return this.$store.getters.permission_routes
|
return this.$store.getters.permission_routes
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
'getRol.uuid'(uuidRol) {
|
|
||||||
this.value = uuidRol
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
this.value = this.getRol.uuid
|
this.roleUuid = this.getRole.uuid
|
||||||
|
this.organizationUuid = this.getOrganization.uuid
|
||||||
|
this.warehouseUuid = this.getWarehouse.uuid
|
||||||
this.getLanguageData()
|
this.getLanguageData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showMessage,
|
showMessage,
|
||||||
handleChange(valueSelected) {
|
changeRole(roleUuid) {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('notifications.loading'),
|
message: this.$t('notifications.loading'),
|
||||||
iconClass: 'el-icon-loading'
|
iconClass: 'el-icon-loading'
|
||||||
})
|
})
|
||||||
this.$store.dispatch('user/changeRoles', {
|
this.$store.dispatch('user/changeRole', {
|
||||||
roleUuid: valueSelected
|
roleUuid,
|
||||||
|
organizationUuid: this.organizationUuid,
|
||||||
|
warehouseUuid: this.warehouseUuid
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$store.dispatch('listDashboard', response.uuid)
|
this.$store.dispatch('listDashboard', response.uuid)
|
||||||
})
|
})
|
||||||
this.$router.push({ path: '/' })
|
this.$router.push({ path: '/' })
|
||||||
},
|
},
|
||||||
|
changeOrganization(organizationUuid) {
|
||||||
|
this.$store.dispatch('user/changeOrganization', {
|
||||||
|
organizationUuid
|
||||||
|
})
|
||||||
|
this.warehouseUuid = this.getWarehouse
|
||||||
|
},
|
||||||
|
changeWarehouse(warehouseUuid) {
|
||||||
|
this.$store.dispatch('user/changeWarehouse', {
|
||||||
|
warehouseUuid
|
||||||
|
})
|
||||||
|
},
|
||||||
getLanguageData() {
|
getLanguageData() {
|
||||||
this.$store.dispatch('getLanguagesFromServer')
|
this.$store.dispatch('getLanguagesFromServer')
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
<div class="box-center">
|
<div class="box-center">
|
||||||
<pan-thumb :image="user.avatar" :height="'100px'" :width="'100px'" :hoverable="false">
|
<pan-thumb :image="user.avatar" :height="'100px'" :width="'100px'" :hoverable="false">
|
||||||
<div>Hello</div>
|
<div>Hello</div>
|
||||||
{{ getRol.name }}
|
{{ getRole.name }}
|
||||||
</pan-thumb>
|
</pan-thumb>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-center">
|
<div class="box-center">
|
||||||
<div class="user-name text-center">{{ getRol.name }}</div>
|
<div class="user-name text-center">{{ getRole.name }}</div>
|
||||||
<div class="user-role text-muted">
|
<div class="user-role text-muted">
|
||||||
{{ $t('profile.availableRoles') }}
|
{{ $t('profile.availableRoles') }}
|
||||||
<li v-for="(item, key) in getRoles" :key="key">
|
<li v-for="(item, key) in getRoles" :key="key">
|
||||||
@ -76,8 +76,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getRol() {
|
getRole() {
|
||||||
return this.$store.getters['user/getRol']
|
return this.$store.getters['user/getRole']
|
||||||
},
|
},
|
||||||
getRoles() {
|
getRoles() {
|
||||||
return this.$store.getters['user/getRoles']
|
return this.$store.getters['user/getRoles']
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form>
|
<el-form>
|
||||||
<el-form-item :label="$t('profile.currentRole')">
|
<el-form-item :label="$t('profile.currentRole')">
|
||||||
{{ getRol.name }}
|
{{ getRole.name }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('profile.clientName')">
|
<el-form-item :label="$t('profile.clientName')">
|
||||||
{{ getRol.clientName }}
|
{{ getRole.clientName }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('profile.description')">
|
<el-form-item :label="$t('profile.description')">
|
||||||
{{ getRol.description }}
|
{{ getRole.description }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('profile.changeRole')">
|
<el-form-item :label="$t('profile.changeRole')">
|
||||||
@ -62,8 +62,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getRol() {
|
getRole() {
|
||||||
return this.$store.getters['user/getRol']
|
return this.$store.getters['user/getRole']
|
||||||
},
|
},
|
||||||
getRolesList() {
|
getRolesList() {
|
||||||
return this.$store.getters['user/getRoles']
|
return this.$store.getters['user/getRoles']
|
||||||
@ -79,12 +79,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'getRol.uuid'(uuidRol) {
|
'getRole.uuid'(uuidRol) {
|
||||||
this.valueRol = uuidRol
|
this.valueRol = uuidRol
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.valueRol = this.getRol.uuid
|
this.valueRol = this.getRole.uuid
|
||||||
this.getLanguageData()
|
this.getLanguageData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -94,7 +94,7 @@ export default {
|
|||||||
message: this.$t('notifications.loading'),
|
message: this.$t('notifications.loading'),
|
||||||
iconClass: 'el-icon-loading'
|
iconClass: 'el-icon-loading'
|
||||||
})
|
})
|
||||||
this.$store.dispatch('user/changeRoles', {
|
this.$store.dispatch('user/changeRole', {
|
||||||
roleUuid: valueSelected,
|
roleUuid: valueSelected,
|
||||||
isCloseAllViews: false
|
isCloseAllViews: false
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user