mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 20:39:48 +08:00
Support Private Access (#671)
* #667 Support Private Access * fix bottons * change lang * rename service * rename service
This commit is contained in:
parent
56716e0647
commit
ca2f9bed3c
@ -64,3 +64,53 @@ export function requestUnlockPrivateAccess({
|
||||
return convertPrivateAccess(responsePrivateAccess)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* List Rol Access Record
|
||||
* @param {string} tableName
|
||||
* @param {number} recordId
|
||||
* @param {string} recordUuid
|
||||
* @param {string} sessionUuid
|
||||
*/
|
||||
export function getAccessList({
|
||||
tableName,
|
||||
recordId,
|
||||
recordUuid,
|
||||
sessionUuid
|
||||
}) {
|
||||
return requestRest({
|
||||
url: '/ui/update-access-record',
|
||||
params: {
|
||||
table_name: tableName,
|
||||
id: recordId,
|
||||
uuid: recordUuid,
|
||||
token: sessionUuid
|
||||
}
|
||||
})
|
||||
.then(evaluateResponse)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Access Record
|
||||
* @param {string} tableName
|
||||
* @param {number} recordId
|
||||
* @param {string} recordUuid
|
||||
* @param {array} listRol
|
||||
*/
|
||||
export function updateAccessRecord({
|
||||
tableName,
|
||||
recordId,
|
||||
recordUuid,
|
||||
listRecord
|
||||
}) {
|
||||
return requestRest({
|
||||
url: '/ui/update-access-record',
|
||||
params: {
|
||||
table_name: tableName,
|
||||
id: recordId,
|
||||
uuid: recordUuid,
|
||||
list_rol: listRecord
|
||||
}
|
||||
})
|
||||
.then(evaluateResponse)
|
||||
}
|
||||
|
@ -214,6 +214,20 @@ export default {
|
||||
return current.tableName
|
||||
}
|
||||
return ''
|
||||
},
|
||||
isLockRecord() {
|
||||
return this.$store.getters['user/getRole'].isPersonalLock
|
||||
},
|
||||
recordAccess() {
|
||||
return {
|
||||
action: 'recordAccess',
|
||||
disabled: false,
|
||||
hidden: false,
|
||||
isSortTab: true,
|
||||
name: this.$t('data.recordAccess.actions'),
|
||||
type: 'dataAction',
|
||||
tableName: this.tableNameCurrentTab
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -377,14 +391,14 @@ export default {
|
||||
// TODO: Add store attribute to avoid making repeated requests
|
||||
let isChangePrivateAccess = true
|
||||
if (this.isReferecesContent) {
|
||||
isChangePrivateAccess = false
|
||||
if (!this.isEmptyValue(this.$route.params.tableName) || (!this.isEmptyValue(this.getCurrentRecord) && !this.isEmptyValue(this.tableNameCurrentTab))) {
|
||||
if ((!this.isEmptyValue(this.getCurrentRecord) && !this.isEmptyValue(this.tableNameCurrentTab))) {
|
||||
this.$store.dispatch('getPrivateAccessFromServer', {
|
||||
tableName: this.$route.params.tableName,
|
||||
tableName: this.tableNameCurrentTab,
|
||||
recordId: this.getCurrentRecord[this.tableNameCurrentTab + '_ID'],
|
||||
recordUuid: this.$route.query.action
|
||||
})
|
||||
.then(privateAccessResponse => {
|
||||
isChangePrivateAccess = false
|
||||
this.validatePrivateAccess(privateAccessResponse)
|
||||
})
|
||||
}
|
||||
@ -397,6 +411,14 @@ export default {
|
||||
})
|
||||
this.$store.dispatch('setOrder', processAction)
|
||||
}
|
||||
if (this.panelType === 'window' && this.isEmptyValue(this.actions.find(element => element.action === 'recordAccess'))) {
|
||||
this.$store.dispatch('addAttribute', {
|
||||
tableName: this.tableNameCurrentTab,
|
||||
recordId: this.getCurrentRecord[this.tableNameCurrentTab + '_ID'],
|
||||
recordUuid: this.$route.query.action
|
||||
})
|
||||
this.actions.push(this.recordAccess)
|
||||
}
|
||||
|
||||
if (this.actions && this.actions.length) {
|
||||
this.actions.forEach(itemAction => {
|
||||
@ -413,11 +435,11 @@ export default {
|
||||
}
|
||||
|
||||
if (this.$route.meta.type === 'window') {
|
||||
if (isChangePrivateAccess) {
|
||||
if (this.isLockRecord) {
|
||||
if (action === 'lockRecord') {
|
||||
itemAction.hidden = false
|
||||
itemAction.hidden = isChangePrivateAccess
|
||||
} else if (action === 'unlockRecord') {
|
||||
itemAction.hidden = true
|
||||
itemAction.hidden = !isChangePrivateAccess
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,7 +495,12 @@ export default {
|
||||
...this.getOldRouteOfWindow.query
|
||||
}
|
||||
}, () => {})
|
||||
} else {
|
||||
} else if (action.action === 'recordAccess') {
|
||||
this.$store.dispatch('setShowDialog', {
|
||||
type: this.panelType,
|
||||
action: action
|
||||
})
|
||||
} else if (action.action !== 'undoModifyData') {
|
||||
if (action.action === 'setDefaultValues' && this.$route.query.action === 'create-new') {
|
||||
return
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
<div
|
||||
v-if="panelType !== 'From'"
|
||||
>
|
||||
<record-access />
|
||||
<sequence-order
|
||||
v-if="modalMetadata.isSortTab"
|
||||
key="order"
|
||||
@ -36,16 +37,15 @@
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-close"
|
||||
@click="closeDialog"
|
||||
>
|
||||
{{ $t('components.dialogCancelButton') }}
|
||||
</el-button>
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-check"
|
||||
@click="runAction(modalMetadata)"
|
||||
>
|
||||
{{ $t('components.dialogConfirmButton') }}
|
||||
</el-button>
|
||||
/>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@ -53,13 +53,17 @@
|
||||
<script>
|
||||
import MainPanel from '@/components/ADempiere/Panel'
|
||||
import SequenceOrder from '@/components/ADempiere/SequenceOrder'
|
||||
import RecordAccess from '@/components/ADempiere/recordAccess'
|
||||
import { showNotification } from '@/utils/ADempiere/notification'
|
||||
|
||||
import {
|
||||
updateAccessRecord
|
||||
} from '@/api/ADempiere/private-access'
|
||||
export default {
|
||||
name: 'ModalProcess',
|
||||
components: {
|
||||
MainPanel,
|
||||
SequenceOrder
|
||||
SequenceOrder,
|
||||
RecordAccess
|
||||
},
|
||||
props: {
|
||||
parentUuid: {
|
||||
@ -202,6 +206,10 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (action.action === undefined) {
|
||||
const list = this.$store.getters.getListRecordAcces
|
||||
updateAccessRecord(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
261
src/components/ADempiere/recordAccess/index.vue
Normal file
261
src/components/ADempiere/recordAccess/index.vue
Normal file
@ -0,0 +1,261 @@
|
||||
<template>
|
||||
<div class="board">
|
||||
<div
|
||||
:key="1"
|
||||
class="kanban todo"
|
||||
header-text="Todo"
|
||||
>
|
||||
<div class="board-column">
|
||||
<div class="board-column-header">
|
||||
{{ $t('data.recordAccess.hideRecord') }} ({{ getterListExclude.length }})
|
||||
</div>
|
||||
<draggable
|
||||
v-model="getterListExclude"
|
||||
:group="group"
|
||||
v-bind="$attrs"
|
||||
class="board-column-content"
|
||||
>
|
||||
<div
|
||||
v-for="element in getterListExclude"
|
||||
:key="element.UUID"
|
||||
class="board-item"
|
||||
>
|
||||
{{ element.clientName }}
|
||||
</div>
|
||||
|
||||
</draggable>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
:key="2"
|
||||
class="kanban working"
|
||||
header-text="Working"
|
||||
>
|
||||
<div class="board-column">
|
||||
<div class="board-column-header">
|
||||
{{ $t('data.recordAccess.recordDisplay') }} {{ getterListInclude.length }}
|
||||
</div>
|
||||
<draggable
|
||||
v-model="getterListInclude"
|
||||
:group="group"
|
||||
v-bind="$attrs"
|
||||
class="board-column-content"
|
||||
@change="handleChange"
|
||||
>
|
||||
<div
|
||||
v-for="element in getterListInclude"
|
||||
:key="element.UUID"
|
||||
class="board-item"
|
||||
>
|
||||
{{ element.name }}
|
||||
<el-divider direction="vertical" />
|
||||
{{ $t('data.recordAccess.isReadonly') }} <el-checkbox v-model="isReadonly" />
|
||||
<el-divider direction="vertical" />
|
||||
{{ $t('data.recordAccess.isDependentEntities') }} <el-checkbox v-model="isDependentEntities" />
|
||||
</div>
|
||||
</draggable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import draggable from 'vuedraggable'
|
||||
|
||||
export default {
|
||||
name: 'RecordAccess',
|
||||
components: {
|
||||
draggable
|
||||
},
|
||||
props: {
|
||||
parentUuid: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
containerUuid: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
order: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
included: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
keyColumn: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
identifiersList: {
|
||||
type: Array,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
group: 'sequence',
|
||||
isReadonly: false,
|
||||
isDependentEntities: true,
|
||||
getterDataRecords: this.$store.getters['user/getRoles']
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getterListExclude: {
|
||||
get() {
|
||||
return this.getterDataRecords.filter(item => item.isPersonalLock === false)
|
||||
},
|
||||
set(value) {
|
||||
}
|
||||
},
|
||||
getterListInclude: {
|
||||
get() {
|
||||
return this.getterDataRecords.filter(item => item.isPersonalLock === true)
|
||||
},
|
||||
set(value) {
|
||||
}
|
||||
},
|
||||
getIdentifiersList() {
|
||||
return this.identifiersList
|
||||
.filter(item => item.componentPath !== 'FieldSelect')
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const record = this.getterDataRecords.map(record => {
|
||||
return {
|
||||
id: record.id,
|
||||
uuid: record.uuid,
|
||||
IsExclude: record.isPersonalLock,
|
||||
isDependentEntities: this.isDependentEntities,
|
||||
isReadonly: this.isReadonly
|
||||
}
|
||||
})
|
||||
this.$store.dispatch('changeList', record)
|
||||
},
|
||||
methods: {
|
||||
handleChange(value) {
|
||||
const action = Object.keys(value)[0] // get property
|
||||
const element = value.[action].element
|
||||
const index = this.getterDataRecords.findIndex(role => role.id === element.id)
|
||||
switch (action) {
|
||||
case 'added':
|
||||
this.addItem({
|
||||
index,
|
||||
element
|
||||
})
|
||||
break
|
||||
case 'removed':
|
||||
this.deleteItem({
|
||||
index,
|
||||
element
|
||||
})
|
||||
break
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {number} index: the index of the added element
|
||||
* @param {object} element: the added element
|
||||
*/
|
||||
addItem({
|
||||
index,
|
||||
element
|
||||
}) {
|
||||
this.getterDataRecords[index].isPersonalLock = !element.isPersonalLock
|
||||
},
|
||||
/**
|
||||
* @param {number} index: the index of the element before remove
|
||||
* @param {object} element: the removed element
|
||||
*/
|
||||
deleteItem({
|
||||
index,
|
||||
element
|
||||
}) {
|
||||
this.getterDataRecords[index].isPersonalLock = !element.isPersonalLock
|
||||
const record = this.getterDataRecords.map(record => {
|
||||
return {
|
||||
id: record.id,
|
||||
uuid: record.uuid,
|
||||
IsExclude: record.isPersonalLock,
|
||||
isDependentEntities: this.isDependentEntities,
|
||||
isReadonly: this.isReadonly
|
||||
}
|
||||
})
|
||||
this.$store.dispatch('changeList', record)
|
||||
},
|
||||
getOrder(arrayToSort, orderBy = this.order) {
|
||||
return arrayToSort.sort((itemA, itemB) => {
|
||||
return itemA[orderBy] - itemB[orderBy]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.board-column {
|
||||
min-width: 250px;
|
||||
min-height: 70px;
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
background: #f0f0f0;
|
||||
border-radius: 3px;
|
||||
|
||||
.board-column-header {
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
overflow: hidden;
|
||||
padding: 0 20px;
|
||||
text-align: center;
|
||||
background: #333;
|
||||
color: #fff;
|
||||
border-radius: 3px 3px 0 0;
|
||||
}
|
||||
|
||||
.board-column-content {
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
border: 10px solid transparent;
|
||||
min-height: 60px;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.board-item {
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
margin: 5px 0;
|
||||
background-color: #fff;
|
||||
text-align: left;
|
||||
line-height: 30px;
|
||||
padding: 0px 10px;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0px 1px 3px 0 rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="scss">
|
||||
.board {
|
||||
width: 100%;
|
||||
margin-left: 20px;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.kanban {
|
||||
&.todo {
|
||||
.board-column-header {
|
||||
background: #f9944a;
|
||||
}
|
||||
}
|
||||
&.working {
|
||||
.board-column-header {
|
||||
background: #4A9FF9;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@ -309,6 +309,13 @@ export default {
|
||||
deleteRecordError: 'Error deleting record',
|
||||
exportRecord: 'Export Record',
|
||||
lockRecord: 'Lock Record',
|
||||
recordAccess: {
|
||||
actions: 'Record Access',
|
||||
hideRecord: 'Hide Record',
|
||||
recordDisplay: 'Allow Record Display',
|
||||
isReadonly: 'Reading Only',
|
||||
isDependentEntities: 'Dependent Entities'
|
||||
},
|
||||
selectionRequired: 'You must select a record',
|
||||
undo: 'Undo',
|
||||
unlockRecord: 'Unlock Record'
|
||||
|
@ -284,6 +284,13 @@ export default {
|
||||
deleteRecordError: 'Error al eliminar el regitro',
|
||||
exportRecord: 'Exportar Registro',
|
||||
lockRecord: 'Bloquear Registro',
|
||||
recordAccess: {
|
||||
actions: 'Acceso a registros',
|
||||
hideRecord: 'Ocultar Registro',
|
||||
recordDisplay: 'Permitir Visualización del Registro',
|
||||
isReadonly: 'Solo Lectura',
|
||||
isDependentEntities: 'Entidades Dependientes'
|
||||
},
|
||||
selectionRequired: 'Debe seleccionar un registro',
|
||||
undo: 'Deshacer',
|
||||
unlockRecord: 'Desbloquear Registro'
|
||||
|
38
src/store/modules/ADempiere/accessRecord.js
Normal file
38
src/store/modules/ADempiere/accessRecord.js
Normal file
@ -0,0 +1,38 @@
|
||||
const initStateUtils = {
|
||||
listRecordAcces: [],
|
||||
attribute: {}
|
||||
}
|
||||
|
||||
export default {
|
||||
state: initStateUtils,
|
||||
mutations: {
|
||||
setListRecordAcces(state, listRecordAcces) {
|
||||
state.listRecordAcces = listRecordAcces
|
||||
},
|
||||
setAttribute(state, attribute) {
|
||||
state.attribute = attribute
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
changeList({ commit, state }, listRecord) {
|
||||
const recordAccess = {
|
||||
recordId: state.attribute.recordId,
|
||||
recordUuid: state.attribute.recordUuid,
|
||||
tableName: state.attribute.tableName,
|
||||
listRecord
|
||||
}
|
||||
commit('setListRecordAcces', recordAccess)
|
||||
},
|
||||
addAttribute({ commit }, params) {
|
||||
commit('setAttribute', params)
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getListRecordAcces: (state) => {
|
||||
return state.listRecordAcces
|
||||
},
|
||||
getAttribute: (state) => {
|
||||
return state.attribute
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user