diff --git a/src/components/AutoDataZTree/index.vue b/src/components/AutoDataZTree/index.vue index 88fe39457..140ea396b 100644 --- a/src/components/AutoDataZTree/index.vue +++ b/src/components/AutoDataZTree/index.vue @@ -209,6 +209,7 @@ export default { if (!parentNode) { return } + this.zTree.expandNode(parentNode, true, false, true, false) // http://localhost/api/v1/assets/nodes/85aa4ee2-0bd9-41db-9079-aa3646448d0c/children/ const url = `${this.treeSetting.nodeUrl}${parentNode.meta.node.id}/children/` this.$axios.post(url, {}).then(data => { diff --git a/src/components/ListTable/formatters/DeleteActionFormatter.vue b/src/components/ListTable/formatters/DeleteActionFormatter.vue index cbc5c310c..de2f61ad3 100644 --- a/src/components/ListTable/formatters/DeleteActionFormatter.vue +++ b/src/components/ListTable/formatters/DeleteActionFormatter.vue @@ -16,7 +16,7 @@ export default { } }, methods: { - onDelete(col, row, cellValue, reload) { + defaultOnDelete(col, row, cellValue, reload) { const url = col.deleteUrl + cellValue this.$axios.delete(url).then(res => { this.$message.success(this.$t('common.deleteSuccessMsg')) @@ -25,6 +25,13 @@ export default { this.$message.error(this.$t('common.deleteErrorMsg' + ' ' + error)) }) }, + onDelete(col, row, cellValue, reload) { + if (col.onDelete && typeof col.onDelete === 'function') { + col.onDelete(col, row, cellValue, reload) + } else { + this.defaultOnDelete(col, row, cellValue, reload) + } + }, iCanDelete() { return this.col.objects.indexOf(this.cellValue) === -1 } diff --git a/src/views/assets/Asset/AssetDetail/Detail.vue b/src/views/assets/Asset/AssetDetail/Detail.vue index f01a9c76b..7c524d3e6 100644 --- a/src/views/assets/Asset/AssetDetail/Detail.vue +++ b/src/views/assets/Asset/AssetDetail/Detail.vue @@ -130,11 +130,7 @@ export default { items.map(v => { newData.push(v.value) }) - return this.$axios.patch(relationUrl, { nodes: newData }).then(res => { - this.$message.success(this.$t('common.updateSuccessMsg')) - }).catch(err => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err)) - }) + return this.$axios.patch(relationUrl, { nodes: newData }) }, performDelete: (item) => { const itemId = item.value @@ -146,11 +142,7 @@ export default { } }) const relationUrl = `/api/v1/assets/assets/${this.object.id}/` - return this.$axios.patch(relationUrl, { nodes: newData }).then(res => { - this.$message.success(this.$t('common.updateSuccessMsg')) - }).catch(err => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err)) - }) + return this.$axios.patch(relationUrl, { nodes: newData }) } }, labelConfig: { diff --git a/src/views/assets/CommandFilter/CommandFilterDetail/Detail.vue b/src/views/assets/CommandFilter/CommandFilterDetail/Detail.vue index bf94e403c..a35d80e03 100644 --- a/src/views/assets/CommandFilter/CommandFilterDetail/Detail.vue +++ b/src/views/assets/CommandFilter/CommandFilterDetail/Detail.vue @@ -55,11 +55,7 @@ export default { items.map(v => { newData.push(v.value) }) - return this.$axios.patch(relationUrl, { system_users: newData }).then(res => { - this.$message.success(this.$t('common.updateSuccessMsg')) - }).catch(err => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err)) - }) + return this.$axios.patch(relationUrl, { system_users: newData }) }, performDelete: (item) => { const itemId = item.value @@ -71,11 +67,7 @@ export default { } }) const relationUrl = `/api/v1/assets/cmd-filters/${this.object.id}/` - return this.$axios.patch(relationUrl, { system_users: newData }).then(res => { - this.$message.success(this.$t('common.deleteSuccessMsg')) - }).catch(err => { - this.$message.error(this.$t('common.deleteErrorMsg' + ' ' + err)) - }) + return this.$axios.patch(relationUrl, { system_users: newData }) } } } diff --git a/src/views/assets/SystemUser/SystemUserDetail/AssetList.vue b/src/views/assets/SystemUser/SystemUserDetail/AssetList.vue index 2c8fcb332..62a34f0d7 100644 --- a/src/views/assets/SystemUser/SystemUserDetail/AssetList.vue +++ b/src/views/assets/SystemUser/SystemUserDetail/AssetList.vue @@ -127,21 +127,13 @@ export default { node: v.value } }) - return this.$axios.post(relationUrl, data).then(res => { - this.$message.success(this.$t('common.updateSuccessMsg')) - }).catch(err => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err)) - }) + return this.$axios.post(relationUrl, data) }, performDelete: (item) => { const itemId = item.value const objectId = this.object.id const relationUrl = `/api/v1/assets/system-users-nodes-relations/?systemuser=${objectId}&node=${itemId}` - return this.$axios.delete(relationUrl).then(res => { - this.$message.success(this.$t('common.updateSuccessMsg')) - }).catch(err => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err)) - }) + return this.$axios.delete(relationUrl) } } } diff --git a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanDetail/ChangeAuthPlanAsset/index.vue b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanDetail/ChangeAuthPlanAsset/index.vue index 463abb90f..d2627aee2 100644 --- a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanDetail/ChangeAuthPlanAsset/index.vue +++ b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanDetail/ChangeAuthPlanAsset/index.vue @@ -14,6 +14,7 @@ import ListTable from '@/components/ListTable/index' import RelationCard from '@/components/RelationCard/index' import AssetRelationCard from '@/components/AssetRelationCard' +import { DeleteActionFormatter } from '@/components/ListTable/formatters' export default { name: 'ChangeAuthPlanAsset', @@ -32,8 +33,29 @@ export default { tableConfig: { url: `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/assets/`, columns: [ - 'hostname', 'ip' + 'hostname', 'ip', 'delete_action' ], + columnsMeta: { + delete_action: { + prop: 'id', + label: this.$t('common.Actions'), + align: 'center', + width: 150, + objects: this.object.assets, + formatter: DeleteActionFormatter, + onDelete: function(col, row, cellValue, reload) { + this.$axios.patch( + `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/asset/remove/`, + { assets: [row.id] } + ).then(res => { + this.$message.success(this.$t('common.deleteSuccessMsg')) + reload() + }).catch(error => { + this.$message.error(this.$t('common.deleteErrorMsg' + ' ' + error)) + }) + }.bind(this) + } + }, tableAttrs: { border: false } diff --git a/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue b/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue index c0fd2e521..f9e11d288 100644 --- a/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue +++ b/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue @@ -20,6 +20,16 @@ export default { ], url: '/api/v1/xpack/cloud/accounts/', fieldsMeta: { + access_key_id: { + rules: [ + { required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError') } + ] + }, + access_key_secret: { + rules: [ + { required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError') } + ] + } }, updateSuccessNextRoute: { name: 'CloudCenter' }, createSuccessNextRoute: { name: 'CloudCenter' }