diff --git a/src/views/assets/Platform/AutomationParamsSetting.vue b/src/views/assets/Platform/AutomationParamsSetting.vue index 7665feabe..52434fd90 100644 --- a/src/views/assets/Platform/AutomationParamsSetting.vue +++ b/src/views/assets/Platform/AutomationParamsSetting.vue @@ -122,7 +122,7 @@ export default { }, onCanSetting() { const filterField = Object.keys(this.remoteMeta) - this.canSetting = filterField.includes(this.method) + this.canSetting = filterField.includes(this.method) && this.$hasPerm('assets.change_platform') this.$emit('canSetting', this.canSetting) return this.canSetting }, diff --git a/src/views/assets/Platform/PlatformDetail/Automation.vue b/src/views/assets/Platform/PlatformDetail/Automation.vue index 6df7bda0c..a2e2a61e0 100644 --- a/src/views/assets/Platform/PlatformDetail/Automation.vue +++ b/src/views/assets/Platform/PlatformDetail/Automation.vue @@ -27,6 +27,7 @@ export default { } }, data() { + const canEdit = !this.object['internal'] && this.$hasPerm('assets.change_platform') return { loading: true, initial: { @@ -35,14 +36,14 @@ export default { } }, url: `/api/v1/assets/platforms/`, - disabled: this.object.internal, + disabled: !canEdit, hasReset: false, hasDetailInMsg: false, submitMethod: () => 'patch', fields: [['', ['automation']]], fieldsMeta: platformFieldsMeta(this), onSubmit: this.submit, - canSubmit: !this.object.internal, + canSubmit: canEdit, defaultOptions: {}, afterGetFormValue: (obj) => { updateAutomationParams(this, obj) @@ -65,7 +66,7 @@ export default { }, methods: { submit(validValues) { - if (!this.$hasPerm('assets.change_platform') || !this.isSystemAdmin) { + if (!this.canSubmit || !this.isSystemAdmin) { return this.$message.error(this.$tc('NoPermission')) } this.$axios.patch(`${this.url}${this.object.id}/`, validValues).then(() => { diff --git a/src/views/assets/Platform/PlatformDetail/Detail.vue b/src/views/assets/Platform/PlatformDetail/Detail.vue index 3a98d47e4..313831ff8 100644 --- a/src/views/assets/Platform/PlatformDetail/Detail.vue +++ b/src/views/assets/Platform/PlatformDetail/Detail.vue @@ -10,10 +10,10 @@ v-if="protocolChoices" v-model="object.protocols" :choices="protocolChoices" - :readonly="object['internal']" + :readonly="!canEdit" /> { @@ -120,7 +121,7 @@ export default { type: 'switch', attrs: { model: object['su_enabled'], - disabled: object['internal'] || this.constraints['su_enabled'] === false + disabled: !this.canEdit || this.constraints['su_enabled'] === false }, callbacks: Object.freeze({ change: (val) => { @@ -136,7 +137,8 @@ export default { title: this.$t('SyncProtocolToAsset'), attrs: { type: 'primary', - label: this.$t('Sync') + label: this.$t('Sync'), + disabled: !this.canEdit }, callbacks: Object.freeze({ click: () => {