mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 23:20:12 +08:00
Bugfix/validate private access (#655)
* fix private acces * Fixes: # 156 Fix Private Access Co-authored-by: Elsio Sanchez <elsiosanche@gmail.com>
This commit is contained in:
parent
c440cbdae8
commit
b87826415d
@ -196,6 +196,24 @@ export default {
|
|||||||
deleteRecord2: ['ctrl', 'd'],
|
deleteRecord2: ['ctrl', 'd'],
|
||||||
refreshData: ['f5']
|
refreshData: ['f5']
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
getCurrentRecord() {
|
||||||
|
const record = this.getAllDataRecords.record.find(fieldItem => {
|
||||||
|
if (this.recordUuid === fieldItem.UUID) {
|
||||||
|
return fieldItem
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!this.isEmptyValue(record)) {
|
||||||
|
return record
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
tableNameCurrentTab() {
|
||||||
|
const current = this.$store.getters.getWindow(this.getterContextMenu.actions[0].uuidParent).tabs[0]
|
||||||
|
if (!this.isEmptyValue(current)) {
|
||||||
|
return current.tableName
|
||||||
|
}
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -354,17 +372,14 @@ export default {
|
|||||||
let isChangePrivateAccess = true
|
let isChangePrivateAccess = true
|
||||||
if (this.isReferecesContent) {
|
if (this.isReferecesContent) {
|
||||||
isChangePrivateAccess = false
|
isChangePrivateAccess = false
|
||||||
if (!this.isEmptyValue(this.$route.params.tableName)) {
|
if (!this.isEmptyValue(this.$route.params.tableName) || (!this.isEmptyValue(this.getCurrentRecord) && !this.isEmptyValue(this.tableNameCurrentTab))) {
|
||||||
this.$store.dispatch('getPrivateAccessFromServer', {
|
this.$store.dispatch('getPrivateAccessFromServer', {
|
||||||
tableName: this.$route.params.tableName,
|
tableName: this.$route.params.tableName,
|
||||||
recordId: this.$route.params.recordId
|
recordId: this.getCurrentRecord[this.tableNameCurrentTab + '_ID'],
|
||||||
|
recordUuid: this.$route.query.action
|
||||||
})
|
})
|
||||||
.then(privateAccessResponse => {
|
.then(privateAccessResponse => {
|
||||||
if (!this.isEmptyValue(privateAccessResponse)) {
|
this.validatePrivateAccess(privateAccessResponse)
|
||||||
this.$nextTick(() => {
|
|
||||||
this.validatePrivateAccess(privateAccessResponse)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,14 +478,26 @@ export default {
|
|||||||
recordUuid: this.recordUuid,
|
recordUuid: this.recordUuid,
|
||||||
panelType: this.panelType,
|
panelType: this.panelType,
|
||||||
isNewRecord: action.action === 'setDefaultValues',
|
isNewRecord: action.action === 'setDefaultValues',
|
||||||
tableName: action.tableName,
|
tableName: this.$route.params.tableName,
|
||||||
recordId: action.recordId
|
recordId: this.getCurrentRecord[this.tableNameCurrentTab + '_ID']
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: this.$t('data.lockRecord'),
|
||||||
|
showClose: true
|
||||||
|
})
|
||||||
if (response && response.isPrivateAccess) {
|
if (response && response.isPrivateAccess) {
|
||||||
this.validatePrivateAccess(response)
|
this.validatePrivateAccess(response)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.$message({
|
||||||
|
type: 'error',
|
||||||
|
message: this.$t('notifications.error') + error.message,
|
||||||
|
showClose: true
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else if (action.type === 'updateReport') {
|
} else if (action.type === 'updateReport') {
|
||||||
this.updateReport(action)
|
this.updateReport(action)
|
||||||
@ -679,12 +706,11 @@ export default {
|
|||||||
}, () => {})
|
}, () => {})
|
||||||
},
|
},
|
||||||
validatePrivateAccess({ isLocked, tableName, recordId }) {
|
validatePrivateAccess({ isLocked, tableName, recordId }) {
|
||||||
if (this.isPersonalLock) {
|
if (!this.isPersonalLock) {
|
||||||
let isHiddenLock = false
|
let isHiddenLock = false
|
||||||
if (isLocked) {
|
if (isLocked) {
|
||||||
isHiddenLock = true
|
isHiddenLock = true
|
||||||
}
|
}
|
||||||
|
|
||||||
this.actions = this.actions.map(actionItem => {
|
this.actions = this.actions.map(actionItem => {
|
||||||
if (actionItem.action === 'lockRecord') {
|
if (actionItem.action === 'lockRecord') {
|
||||||
return {
|
return {
|
||||||
|
@ -764,8 +764,7 @@ const actions = {
|
|||||||
})
|
})
|
||||||
.then(privateAccessResponse => {
|
.then(privateAccessResponse => {
|
||||||
// TODO: Evaluate uuid record
|
// TODO: Evaluate uuid record
|
||||||
if (isEmptyValue(privateAccessResponse.recordId) ||
|
if (!isEmptyValue(privateAccessResponse.tableName)) {
|
||||||
privateAccessResponse.recordId !== recordId) {
|
|
||||||
return {
|
return {
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
tableName,
|
tableName,
|
||||||
@ -810,7 +809,7 @@ const actions = {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
showMessage({
|
showMessage({
|
||||||
title: language.t('notifications.error'),
|
title: language.t('notifications.error'),
|
||||||
message: language.t('login.unexpectedError'),
|
message: language.t('login.unexpectedError') + error.message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
console.warn(`Error lock private access: ${error.message}. Code: ${error.code}.`)
|
console.warn(`Error lock private access: ${error.message}. Code: ${error.code}.`)
|
||||||
@ -844,7 +843,7 @@ const actions = {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
showMessage({
|
showMessage({
|
||||||
title: language.t('notifications.error'),
|
title: language.t('notifications.error'),
|
||||||
message: language.t('login.unexpectedError'),
|
message: language.t('login.unexpectedError') + error.message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
console.warn(`Error unlock private access: ${error.message}. Code: ${error.code}.`)
|
console.warn(`Error unlock private access: ${error.message}. Code: ${error.code}.`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user