fixed: Fixed an issue where clicking the user/group field in the authorization rule of the user detail page would jump to an error

This commit is contained in:
zhaojisen
2024-06-25 17:06:52 +08:00
parent 1b7ffaeda3
commit 3f42ad7d18
4 changed files with 31 additions and 8 deletions

View File

@@ -176,6 +176,7 @@ export class FormFieldGenerator {
const helpTextWordLength = helpText.split(' ').length const helpTextWordLength = helpText.split(' ').length
const placeholderType = ['input', 'select', 'm2m_related_field'] const placeholderType = ['input', 'select', 'm2m_related_field']
const placeholderComponent = [ObjectSelect2] const placeholderComponent = [ObjectSelect2]
if (helpTextAsPlaceholder !== undefined) { if (helpTextAsPlaceholder !== undefined) {
helpTextAsPlaceholder = !!helpTextAsPlaceholder helpTextAsPlaceholder = !!helpTextAsPlaceholder
} else if (placeholderType.indexOf(field.type) === -1 && placeholderComponent.indexOf(field.component) === -1) { } else if (placeholderType.indexOf(field.type) === -1 && placeholderComponent.indexOf(field.component) === -1) {

View File

@@ -28,11 +28,9 @@ export default {
} }
}, },
data() { data() {
const id = this.object.id
const url = id ? `/api/v1/perms/asset-permissions/${id}/users/all/` : ''
return { return {
tableConfig: { tableConfig: {
url: url, url: '',
id: 'user', id: 'user',
columnsExclude: ['user'], columnsExclude: ['user'],
columnsExtra: ['delete_action'], columnsExtra: ['delete_action'],
@@ -104,7 +102,6 @@ export default {
this.$log.debug('Select value', that.select2.value) this.$log.debug('Select value', that.select2.value)
that.iHasObjects = [...that.iHasObjects, ...objects] that.iHasObjects = [...that.iHasObjects, ...objects]
this.$store.commit('common/reload') this.$store.commit('common/reload')
// this.$refs.ListTable.reloadTable()
} }
}, },
groupRelationConfig: { groupRelationConfig: {
@@ -150,6 +147,26 @@ export default {
} }
} }
} }
},
watch: {
object: {
handler(newVal) {
this.updateTableConfigUrl(newVal.id)
},
immediate: true,
deep: true
}
},
mounted() {
this.updateTableConfigUrl(this.$route.params.id)
},
methods: {
// 对于 url 中的 id 值有可能会捕获到上一个页面路由对象中的 id 值,因此会导致权限报错
updateTableConfigUrl(id) {
if (id) {
this.tableConfig.url = `/api/v1/perms/asset-permissions/${id}/users/all/`
}
}
} }
} }
</script> </script>

View File

@@ -31,9 +31,14 @@ export default {
data() { data() {
return { return {
AssetPermission: { AssetPermission: {
name: '', users_amount: 0, user_groups_amount: 0, assets_amount: 0, name: '',
nodes_amount: 0, system_users_amount: 0, users_amount: 0,
date_start: '', date_expired: '' user_groups_amount: 0,
assets_amount: 0,
nodes_amount: 0,
system_users_amount: 0,
date_start: '',
date_expired: ''
}, },
config: { config: {
activeMenu: 'AssetPermissionDetail', activeMenu: 'AssetPermissionDetail',

View File

@@ -67,7 +67,7 @@ export default {
}, },
'resource_statistics.asset_perms_amount': { 'resource_statistics.asset_perms_amount': {
label: this.$t('AssetPermsAmount'), label: this.$t('AssetPermsAmount'),
width: '150px' width: '200px'
}, },
actions: { actions: {
prop: 'id', prop: 'id',