mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 20:39:48 +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'],
|
||||
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: {
|
||||
@ -354,17 +372,14 @@ export default {
|
||||
let isChangePrivateAccess = true
|
||||
if (this.isReferecesContent) {
|
||||
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', {
|
||||
tableName: this.$route.params.tableName,
|
||||
recordId: this.$route.params.recordId
|
||||
recordId: this.getCurrentRecord[this.tableNameCurrentTab + '_ID'],
|
||||
recordUuid: this.$route.query.action
|
||||
})
|
||||
.then(privateAccessResponse => {
|
||||
if (!this.isEmptyValue(privateAccessResponse)) {
|
||||
this.$nextTick(() => {
|
||||
this.validatePrivateAccess(privateAccessResponse)
|
||||
})
|
||||
}
|
||||
this.validatePrivateAccess(privateAccessResponse)
|
||||
})
|
||||
}
|
||||
|
||||
@ -463,14 +478,26 @@ export default {
|
||||
recordUuid: this.recordUuid,
|
||||
panelType: this.panelType,
|
||||
isNewRecord: action.action === 'setDefaultValues',
|
||||
tableName: action.tableName,
|
||||
recordId: action.recordId
|
||||
tableName: this.$route.params.tableName,
|
||||
recordId: this.getCurrentRecord[this.tableNameCurrentTab + '_ID']
|
||||
})
|
||||
.then(response => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: this.$t('data.lockRecord'),
|
||||
showClose: true
|
||||
})
|
||||
if (response && response.isPrivateAccess) {
|
||||
this.validatePrivateAccess(response)
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: this.$t('notifications.error') + error.message,
|
||||
showClose: true
|
||||
})
|
||||
})
|
||||
}
|
||||
} else if (action.type === 'updateReport') {
|
||||
this.updateReport(action)
|
||||
@ -679,12 +706,11 @@ export default {
|
||||
}, () => {})
|
||||
},
|
||||
validatePrivateAccess({ isLocked, tableName, recordId }) {
|
||||
if (this.isPersonalLock) {
|
||||
if (!this.isPersonalLock) {
|
||||
let isHiddenLock = false
|
||||
if (isLocked) {
|
||||
isHiddenLock = true
|
||||
}
|
||||
|
||||
this.actions = this.actions.map(actionItem => {
|
||||
if (actionItem.action === 'lockRecord') {
|
||||
return {
|
||||
|
@ -764,8 +764,7 @@ const actions = {
|
||||
})
|
||||
.then(privateAccessResponse => {
|
||||
// TODO: Evaluate uuid record
|
||||
if (isEmptyValue(privateAccessResponse.recordId) ||
|
||||
privateAccessResponse.recordId !== recordId) {
|
||||
if (!isEmptyValue(privateAccessResponse.tableName)) {
|
||||
return {
|
||||
isLocked: false,
|
||||
tableName,
|
||||
@ -810,7 +809,7 @@ const actions = {
|
||||
.catch(error => {
|
||||
showMessage({
|
||||
title: language.t('notifications.error'),
|
||||
message: language.t('login.unexpectedError'),
|
||||
message: language.t('login.unexpectedError') + error.message,
|
||||
type: 'error'
|
||||
})
|
||||
console.warn(`Error lock private access: ${error.message}. Code: ${error.code}.`)
|
||||
@ -844,7 +843,7 @@ const actions = {
|
||||
.catch(error => {
|
||||
showMessage({
|
||||
title: language.t('notifications.error'),
|
||||
message: language.t('login.unexpectedError'),
|
||||
message: language.t('login.unexpectedError') + error.message,
|
||||
type: 'error'
|
||||
})
|
||||
console.warn(`Error unlock private access: ${error.message}. Code: ${error.code}.`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user