From 6e9ce08e2c3c60214a291be3bfdee6521c83b26d Mon Sep 17 00:00:00 2001 From: wang-liang0615 <53748875+wang-liang0615@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:07:52 +0800 Subject: [PATCH] pref(cmdb-ui):change adt key & add adt alias (#314) --- .../modules/cmdb/views/ci_types/adModal.vue | 4 +-- .../modules/cmdb/views/ci_types/attrAD.vue | 32 +++++++++++-------- .../cmdb/views/ci_types/attrADTabpane.vue | 23 +++++++++---- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/adModal.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/adModal.vue index e3f39b1..0f071fc 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/adModal.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/adModal.vue @@ -53,8 +53,8 @@ export default { return postCITypeDiscovery(this.CITypeId, { adr_id: id, interval: type === 'agent' ? 300 : 3600 }) }) await Promise.all(promises) - .then(() => { - this.getCITypeDiscovery(this.selectedIds[0].id) + .then((res) => { + this.getCITypeDiscovery(res[0].id) this.$message.success('添加成功') }) .catch(() => { diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attrAD.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attrAD.vue index 349e170..d04f138 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/attrAD.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attrAD.vue @@ -2,20 +2,22 @@
- + - {{ getADCITypeParam(item.adr_id) }} + {{ item.extra_option.alias }} + {{ getADCITypeParam(item.adr_id) }} { this.adCITypeList = res.filter((item) => item.adr_id) if (res && res.length && !this.currentTab) { - this.currentTab = res[0].adr_id + this.currentTab = res[0].id } if (currentTab) { this.currentTab = currentTab @@ -156,7 +158,7 @@ export default { e.stopPropagation() const that = this this.$confirm({ - title: `确认删除 【${this.getADCITypeParam(item.adr_id)}】`, + title: `确认删除 【${item?.extra_option?.alias || this.getADCITypeParam(item.adr_id)}】`, content: (h) => (
删除插件 @@ -164,18 +166,22 @@ export default { ), onOk() { deleteCITypeDiscovery(item.id).then(async () => { - if (that.currentTab === item.adr_id) { + if (that.currentTab === item.id) { that.currentTab = '' } - that.deletePlugin = false that.$message.success('删除成功!') that.getCITypeDiscovery() if (that.deletePlugin) { - await deleteDiscovery(item.adr_id) + await deleteDiscovery(item.adr_id).finally(() => { + that.deletePlugin = false + }) } + that.deletePlugin = false }) }, - onCancel() {}, + onCancel() { + that.deletePlugin = false + }, }) }, openEditDrawer(data, type, adType) { @@ -183,12 +189,12 @@ export default { }, async updateNotInner(adr) { const _idx = this.adCITypeList.findIndex((item) => item.adr_id === adr.id) + let res if (_idx < 0) { - await postCITypeDiscovery(this.CITypeId, { adr_id: adr.id, interval: 300 }) + res = await postCITypeDiscovery(this.CITypeId, { adr_id: adr.id, interval: 300 }) } await this.getDiscovery() - await this.getCITypeDiscovery() - this.currentTab = adr.id + await this.getCITypeDiscovery(res?.id ?? undefined) this.$nextTick(() => { this.$refs[`attrAdTabpane_${this.currentTab}`][0].init() }) diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue index 268cde8..7a2659c 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue @@ -14,6 +14,7 @@ 编辑 +
别名:
字段映射
Number(item.id) === Number(this.currentTab)) - const _findADT = this.adCITypeList.find((item) => Number(item.adr_id) === Number(this.currentTab)) + const _find = this.adrList.find((item) => Number(item.id) === Number(this.adr_id)) + const _findADT = this.adCITypeList.find((item) => Number(item.id) === Number(this.currentAdt.id)) + this.alias = _findADT?.extra_option?.alias ?? '' if (this.adrType === 'http') { const { category = undefined, key = '', secret = '' } = _findADT?.extra_option ?? {} this.form2 = { @@ -294,7 +297,7 @@ export default { this.cron = cron }, handleSave() { - const { currentAdt } = this + const { currentAdt, alias } = this let params if (this.adrType === 'http') { params = { @@ -360,9 +363,15 @@ export default { return } } - + if (params.extra_option) { + params.extra_option.alias = alias + } else { + params.extra_option = {} + params.extra_option.alias = alias + } putCITypeDiscovery(currentAdt.id, params).then((res) => { this.$message.success('保存成功') + this.$emit('handleSave') }) }, handleOpenCmdb() {