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 1/2] =?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) } } From da4cc3de20c2e0e4b2b00863b9fd54fa9a3f9798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Thu, 27 Oct 2022 15:03:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96ZTree=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E9=80=89=E6=8B=A9=E5=AE=8C=E5=B7=A6=E4=BE=A7=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E5=90=8E=E8=BF=9B=E5=85=A5=E8=B5=84=E4=BA=A7=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E5=9C=A8=E8=BF=94=E5=9B=9E=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=BF=98=E4=BF=9D=E6=8C=81=E4=B9=8B=E5=89=8D=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AccountListTable/index.vue | 12 ++++++------ src/components/TreeTable/index.vue | 10 ++++++++++ src/views/accounts/AssetAccount/AssetAccountList.vue | 8 ++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/components/AccountListTable/index.vue b/src/components/AccountListTable/index.vue index aab19a2bf..73f5b53f8 100644 --- a/src/components/AccountListTable/index.vue +++ b/src/components/AccountListTable/index.vue @@ -236,7 +236,7 @@ export default { this.$set(this.tableConfig, 'url', iNew) this.$set(this.headerActions.exportOptions, 'url', iNew.replace('/accounts/', '/account-secrets/')) }, - '$route.query.assets': { + '$route.query.asset': { immediate: true, handler() { this.hasAccountPermission() @@ -262,14 +262,14 @@ export default { this.$refs.ListTable.reloadTable() }, async getAssetDetail() { - const { query: { assets }} = this.$route - this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${assets}/`) + const { query: { asset }} = this.$route + this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${asset}/`) }, hasAccountPermission() { - const { path, query: { assets }} = this.$route + const { path, query: { asset }} = this.$route if (!hasUUID(path)) { - if (assets) this.getAssetDetail() - const hasPerm = this.$hasPerm('assets.add_account') && !!assets + if (asset) this.getAssetDetail() + const hasPerm = this.$hasPerm('assets.add_account') && !!asset this.$set(this.headerActions.extraActions[0], 'can', hasPerm) } } diff --git a/src/components/TreeTable/index.vue b/src/components/TreeTable/index.vue index 25194cdaa..54efaac96 100644 --- a/src/components/TreeTable/index.vue +++ b/src/components/TreeTable/index.vue @@ -44,6 +44,8 @@ import AutoDataZTree from '../AutoDataZTree' import Dialog from '@/components/Dialog' import ListTable from '../ListTable' import IBox from '../IBox' +import { setUrlParam } from '@/utils/common' + export default { name: 'TreeTable', components: { @@ -88,8 +90,16 @@ export default { }, mounted() { // debug(this.treeSetting) + this.initSetTableUrl() }, methods: { + initSetTableUrl() { + const { asset = '', node = '' } = this.$route.query || {} + let url = this.iTableConfig.url + url = setUrlParam(url, 'asset', asset) + url = setUrlParam(url, 'node', node) + this.$set(this.iTableConfig, 'url', url) + }, handleUrlChange(url) { this.$set(this.iTableConfig, 'url', url) this.$emit('urlChange', url) diff --git a/src/views/accounts/AssetAccount/AssetAccountList.vue b/src/views/accounts/AssetAccount/AssetAccountList.vue index fac6f2eec..a456b156f 100644 --- a/src/views/accounts/AssetAccount/AssetAccountList.vue +++ b/src/views/accounts/AssetAccount/AssetAccountList.vue @@ -42,12 +42,12 @@ export default { let url = '/api/v1/assets/accounts/' if (treeNode.meta.type === 'node') { const nodeId = treeNode.meta.data.id - url = setUrlParam(url, 'assets', '') - url = setUrlParam(url, 'nodes', nodeId) + url = setUrlParam(url, 'asset', '') + url = setUrlParam(url, 'node', nodeId) } else if (treeNode.meta.type === 'asset') { const assetId = treeNode.meta.data.id - url = setUrlParam(url, 'nodes', '') - url = setUrlParam(url, 'assets', assetId) + url = setUrlParam(url, 'node', '') + url = setUrlParam(url, 'asset', assetId) } this.$set(this.tableConfig, 'url', url)