From b37ef2d144cf2aed2de3154aaf5cbd7baf9e8722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Wed, 1 Feb 2023 16:32:33 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B9=B3=E5=8F=B0=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=BA=E7=BD=91=E7=BB=9C=E8=AE=BE=E5=A4=87=E6=97=B6=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E8=B4=A6=E5=8F=B7=E4=B8=8D=E5=8F=AF=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/Platform/PlatformDetail/Detail.vue | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/views/assets/Platform/PlatformDetail/Detail.vue b/src/views/assets/Platform/PlatformDetail/Detail.vue index 555a960cb..e95a281aa 100644 --- a/src/views/assets/Platform/PlatformDetail/Detail.vue +++ b/src/views/assets/Platform/PlatformDetail/Detail.vue @@ -34,14 +34,10 @@ export default { } }, data() { - const myFields = { - AccountEnabled: ['su_enabled', 'su_method'], - ProtocolsEnabled: ['protocols'] - } return { visible: false, fields: ['domain_enabled'], - quickActions: this.setQuickActions(myFields), + quickActions: this.setQuickActions(), url: `/api/v1/assets/platforms/${this.object.id}`, detailFields: [ 'name', 'charset', @@ -56,7 +52,7 @@ export default { computed: { }, methods: { - setQuickActions(fields = []) { + setQuickActions() { const vm = this const { object } = this const quickActions = [ @@ -72,17 +68,30 @@ export default { change: (val) => { const data = { domain_enabled: val } this.$axios.patch( - `/api/v1/assets/platforms/${this.object.id}/`, data).then(res => { + `/api/v1/assets/platforms/${object.id}/`, data).then(res => { this.$message.success(this.$tc('common.updateSuccessMsg')) }) } }) - } - ] - - for (const [key, value] of Object.entries(fields)) { - const option = { - title: this.$t(`assets.${key}`), + }, + { + title: this.$t(`assets.AccountEnabled`), + attrs: { + type: 'primary', + label: this.$t('common.Update'), + disabled: ( + object.category.value === 'device' || object.internal || !vm.$hasPerm('assets.change_platform') + ) + }, + callbacks: Object.freeze({ + click: () => { + this.fields = ['su_enabled', 'su_method'] + this.visible = !this.visible + } + }) + }, + { + title: this.$t(`assets.ProtocolsEnabled`), attrs: { type: 'primary', label: this.$t('common.Update'), @@ -90,13 +99,12 @@ export default { }, callbacks: Object.freeze({ click: () => { - this.fields = value + this.fields = ['protocols'] this.visible = !this.visible } }) } - quickActions.push(option) - } + ] return quickActions }