1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-07 18:25:45 +08:00

Support to Private Access (#860)

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-05-20 10:24:48 -04:00 committed by GitHub
parent 09c9bea77d
commit 426e8e78ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 18 deletions

View File

@ -35,8 +35,9 @@ export function getPrivateAccess({
.then(responsePrivateAccess => {
return {
tableName: responsePrivateAccess.table_name,
recordId: responsePrivateAccess.record_id,
recordUuid: responsePrivateAccess.record_uuid
recordId: responsePrivateAccess.id,
recordUuid: responsePrivateAccess.uuid,
isLocked: responsePrivateAccess.is_locked
}
})
}

View File

@ -31,10 +31,10 @@
<span v-if="key === 0" slot="label">
<el-tooltip v-if="key === 0" :content="lock ? $t('data.lockRecord') : $t('data.unlockRecord')" placement="top">
<el-button type="text" @click="lockRecord()">
<i :class="lock ? 'el-icon-unlock' : 'el-icon-lock'" style="font-size: 15px;color: black;" />
<i :class="!lock ? 'el-icon-unlock' : 'el-icon-lock'" style="font-size: 15px;color: black;" />
</el-button>
</el-tooltip>
<span :style="lock ? 'color: #1890ff;': 'color: red;'">
<span :style="!lock ? 'color: #1890ff;': 'color: red;'">
{{ tabAttributes.name }}
</span>
</span>
@ -129,14 +129,13 @@ export default {
methods: {
lockRecord() {
const tableName = this.windowMetadata.firstTab.tableName
const action = this.lock ? 'lockRecord' : 'unlockRecord'
const action = this.lock ? 'unlockRecord' : 'lockRecord'
this.$store.dispatch(action, {
tableName,
recordId: this.record[tableName + '_ID'],
recordUuid: this.record.UUID
})
.then(() => {
this.lock = !this.lock
this.$message({
type: 'success',
message: this.$t('data.notification.' + action),
@ -144,13 +143,22 @@ export default {
})
})
.catch(() => {
this.lock = !this.lock
this.$message({
type: 'error',
message: this.$t('data.isError') + this.$t('data.' + action),
showClose: true
})
})
.finally(() => {
this.$store.dispatch('getPrivateAccessFromServer', {
tableName,
recordId: this.record[tableName + '_ID'],
recordUuid: this.record.UUID
})
.then(privateAccessResponse => {
this.lock = privateAccessResponse.isLocked
})
})
},
setCurrentTab() {
this.$store.dispatch('setCurrentTab', {

View File

@ -765,18 +765,8 @@ const actions = {
recordUuid
})
.then(privateAccessResponse => {
// TODO: Evaluate uuid record
if (!isEmptyValue(privateAccessResponse.tableName)) {
return {
isLocked: false,
tableName,
recordId,
recordUuid
}
}
return {
...privateAccessResponse,
isLocked: true
...privateAccessResponse
}
})
.catch(error => {