mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 20:39:48 +08:00
Support to Private Access (#860)
Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
parent
09c9bea77d
commit
426e8e78ea
@ -35,8 +35,9 @@ export function getPrivateAccess({
|
|||||||
.then(responsePrivateAccess => {
|
.then(responsePrivateAccess => {
|
||||||
return {
|
return {
|
||||||
tableName: responsePrivateAccess.table_name,
|
tableName: responsePrivateAccess.table_name,
|
||||||
recordId: responsePrivateAccess.record_id,
|
recordId: responsePrivateAccess.id,
|
||||||
recordUuid: responsePrivateAccess.record_uuid
|
recordUuid: responsePrivateAccess.uuid,
|
||||||
|
isLocked: responsePrivateAccess.is_locked
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
<span v-if="key === 0" slot="label">
|
<span v-if="key === 0" slot="label">
|
||||||
<el-tooltip v-if="key === 0" :content="lock ? $t('data.lockRecord') : $t('data.unlockRecord')" placement="top">
|
<el-tooltip v-if="key === 0" :content="lock ? $t('data.lockRecord') : $t('data.unlockRecord')" placement="top">
|
||||||
<el-button type="text" @click="lockRecord()">
|
<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-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<span :style="lock ? 'color: #1890ff;': 'color: red;'">
|
<span :style="!lock ? 'color: #1890ff;': 'color: red;'">
|
||||||
{{ tabAttributes.name }}
|
{{ tabAttributes.name }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
@ -129,14 +129,13 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
lockRecord() {
|
lockRecord() {
|
||||||
const tableName = this.windowMetadata.firstTab.tableName
|
const tableName = this.windowMetadata.firstTab.tableName
|
||||||
const action = this.lock ? 'lockRecord' : 'unlockRecord'
|
const action = this.lock ? 'unlockRecord' : 'lockRecord'
|
||||||
this.$store.dispatch(action, {
|
this.$store.dispatch(action, {
|
||||||
tableName,
|
tableName,
|
||||||
recordId: this.record[tableName + '_ID'],
|
recordId: this.record[tableName + '_ID'],
|
||||||
recordUuid: this.record.UUID
|
recordUuid: this.record.UUID
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.lock = !this.lock
|
|
||||||
this.$message({
|
this.$message({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: this.$t('data.notification.' + action),
|
message: this.$t('data.notification.' + action),
|
||||||
@ -144,13 +143,22 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.lock = !this.lock
|
|
||||||
this.$message({
|
this.$message({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: this.$t('data.isError') + this.$t('data.' + action),
|
message: this.$t('data.isError') + this.$t('data.' + action),
|
||||||
showClose: true
|
showClose: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.$store.dispatch('getPrivateAccessFromServer', {
|
||||||
|
tableName,
|
||||||
|
recordId: this.record[tableName + '_ID'],
|
||||||
|
recordUuid: this.record.UUID
|
||||||
|
})
|
||||||
|
.then(privateAccessResponse => {
|
||||||
|
this.lock = privateAccessResponse.isLocked
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
setCurrentTab() {
|
setCurrentTab() {
|
||||||
this.$store.dispatch('setCurrentTab', {
|
this.$store.dispatch('setCurrentTab', {
|
||||||
|
@ -765,18 +765,8 @@ const actions = {
|
|||||||
recordUuid
|
recordUuid
|
||||||
})
|
})
|
||||||
.then(privateAccessResponse => {
|
.then(privateAccessResponse => {
|
||||||
// TODO: Evaluate uuid record
|
|
||||||
if (!isEmptyValue(privateAccessResponse.tableName)) {
|
|
||||||
return {
|
|
||||||
isLocked: false,
|
|
||||||
tableName,
|
|
||||||
recordId,
|
|
||||||
recordUuid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
...privateAccessResponse,
|
...privateAccessResponse
|
||||||
isLocked: true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user