From 13122b07d4bf7a8cc141eedcc8bb63d4a94931ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Tue, 25 Oct 2022 16:42:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=88=9B=E5=BB=BA=E3=80=81=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AccountListTable/AddAccount.vue | 5 +++-- src/components/AccountListTable/index.vue | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/AccountListTable/AddAccount.vue b/src/components/AccountListTable/AddAccount.vue index 48d01773b..f91d263d9 100644 --- a/src/components/AccountListTable/AddAccount.vue +++ b/src/components/AccountListTable/AddAccount.vue @@ -72,10 +72,11 @@ export default { }, methods: { async getPlatform() { - this.platform = await this.$axios.get(`/api/v1/assets/platforms/${this.asset?.platform?.id}/`) + const platformId = this.asset?.platform?.id || this.asset?.platform_id + this.platform = await this.$axios.get(`/api/v1/assets/platforms/${platformId}/`) }, addAccount(form) { - const data = { asset: this.asset.id, ...form } + const data = { asset: this.asset?.id || '', ...form } this.$axios.post(`/api/v1/assets/accounts/`, data).then(() => { this.iVisible = false this.$emit('add', true) diff --git a/src/components/AccountListTable/index.vue b/src/components/AccountListTable/index.vue index 971ee4d44..aab19a2bf 100644 --- a/src/components/AccountListTable/index.vue +++ b/src/components/AccountListTable/index.vue @@ -68,7 +68,7 @@ export default { }, asset: { type: Object, - default: null + default: () => ({}) }, columns: { type: Array, @@ -179,6 +179,7 @@ export default { can: this.$hasPerm('assets.change_account') && !this.$store.getters.currentOrgIsRoot, callback: ({ row }) => { vm.account = row + vm.$set(this.iAsset, 'platform_id', row.asset.platform_id) vm.showAddDialog = false setTimeout(() => { vm.showAddDialog = true @@ -252,8 +253,6 @@ export default { actionColumn.formatterArgs.extraActions.push(item) } } - - console.log('Has perm: ', this.$hasPerm('assets.change_account')) }, methods: { onUpdateAuthDone(account) { @@ -262,11 +261,15 @@ export default { addAccountSuccess() { this.$refs.ListTable.reloadTable() }, + async getAssetDetail() { + const { query: { assets }} = this.$route + this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${assets}/`) + }, hasAccountPermission() { - const { path, query } = this.$route + const { path, query: { assets }} = this.$route if (!hasUUID(path)) { - const hasPerm = this.$hasPerm('assets.add_account') && !!query.assets - this.iAsset = { id: query.assets } + if (assets) this.getAssetDetail() + const hasPerm = this.$hasPerm('assets.add_account') && !!assets this.$set(this.headerActions.extraActions[0], 'can', hasPerm) } }