perf: 优化资产授权用户、资产选择之后下拉菜单选项还能继续选择问题

This commit is contained in:
“huailei000”
2023-08-21 14:51:14 +08:00
committed by huailei
parent b18c045a1b
commit a0a7590769
2 changed files with 15 additions and 9 deletions

View File

@@ -78,7 +78,7 @@ export default {
assetRelationConfig: {
icon: 'fa-edit',
title: this.$t('perms.addAssetToThisPermission'),
hasObjectsId: this.object.assets,
hasObjectsId: this.object.assets?.map(i => i.id) || [],
disabled: this.$store.getters.currentOrgIsRoot,
canSelect: (row, index) => {
return this.object.assets.indexOf(row.id) === -1
@@ -97,7 +97,7 @@ export default {
onAddSuccess: (items, that) => {
this.$log.debug('AssetSelect value', that.assets)
this.$message.success(this.$tc('common.updateSuccessMsg'))
window.location.reload()
this.$store.commit('common/reload')
}
},
nodeRelationConfig: {
@@ -109,7 +109,7 @@ export default {
return { label: item.full_value, value: item.id }
}
},
hasObjectsId: this.object.nodes,
hasObjectsId: this.object.nodes?.map(i => i.id) || [],
performAdd: (items) => {
const relationUrl = `/api/v1/perms/asset-permissions-nodes-relations/`
const objectId = this.object.id

View File

@@ -50,7 +50,15 @@ export default {
width: 150,
objects: this.object.users,
formatter: DeleteActionFormatter,
deleteUrl: `/api/v1/perms/asset-permissions-users-relations/?assetpermission=${this.object.id}&user=`
onDelete: function(col, row, cellValue, reload) {
const url = `/api/v1/perms/asset-permissions-users-relations/?assetpermission=${this.object.id}&user=${cellValue}`
this.$axios.delete(url).then(res => {
this.$message.success(this.$tc('common.deleteSuccessMsg'))
this.$store.commit('common/reload')
}).catch(error => {
this.$message.error(this.$tc('common.deleteErrorMsg') + ' ' + error)
})
}.bind(this)
},
actions: {
has: false
@@ -78,7 +86,7 @@ export default {
}
},
showHasMore: false,
hasObjectsId: this.object.users,
hasObjectsId: this.object.users?.map(i => i.id) || [],
showHasObjects: false,
performAdd: (items) => {
const relationUrl = `/api/v1/perms/asset-permissions-users-relations/`
@@ -94,8 +102,7 @@ export default {
onAddSuccess: (objects, that) => {
this.$log.debug('Select value', that.select2.value)
that.iHasObjects = [...that.iHasObjects, ...objects]
this.$message.success(this.$tc('common.updateSuccessMsg'))
window.location.reload()
this.$store.commit('common/reload')
}
},
groupRelationConfig: {
@@ -104,7 +111,7 @@ export default {
objectsAjax: {
url: '/api/v1/users/groups/'
},
hasObjectsId: this.object.user_groups,
hasObjectsId: this.object.user_groups?.map(i => i.id) || [],
performAdd: (items) => {
const relationUrl = `/api/v1/perms/asset-permissions-user-groups-relations/`
const objectId = this.object.id
@@ -123,7 +130,6 @@ export default {
return this.$axios.delete(relationUrl)
},
onAddSuccess: (objects, that) => {
this.$log.debug('Select value', that.select2.value)
that.iHasObjects = [...that.iHasObjects, ...objects]
that.$refs.select2.clearSelected()
this.$message.success(this.$tc('common.updateSuccessMsg'))