From 855cb91b31321be8acaa5c94e9f8e599ce97ac22 Mon Sep 17 00:00:00 2001
From: wang-liang0615 <53748875+wang-liang0615@users.noreply.github.com>
Date: Fri, 22 Dec 2023 15:42:20 +0800
Subject: [PATCH] =?UTF-8?q?feat(cmdb-ui):ci=20type=20import&export?=
=?UTF-8?q?=EF=BC=8Cpref(cmdb-ui):download=20ci=20xlsx=20name=EF=BC=8C=20p?=
=?UTF-8?q?ref(cmdb-ui):ci=20detail=20history=20merge=20row=20method=20(#3?=
=?UTF-8?q?31)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* pref(cmdb-ui):download ci xlsx name
* pref(cmdb-ui):ci detail history merge row method
* feat(cmdb-ui):ci type import&export
---
.../batchDownload/batchDownload.vue | 6 ++-
.../src/modules/cmdb/views/batch/index.vue | 1 -
cmdb-ui/src/modules/cmdb/views/ci/index.vue | 5 +-
.../cmdb/views/ci/modules/CiDetail.vue | 9 ++--
.../modules/cmdb/views/ci_types/attrAD.vue | 4 +-
.../src/modules/cmdb/views/ci_types/index.vue | 47 ++++++++++++++++---
.../cmdb/views/relation_views/index.vue | 29 +++++++++---
.../relation_views/modules/AddTableModal.vue | 27 ++++++-----
.../modules/cmdb/views/tree_views/index.vue | 13 +++--
9 files changed, 102 insertions(+), 39 deletions(-)
diff --git a/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue b/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue
index 429d6ce..6cfecf6 100644
--- a/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue
+++ b/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue
@@ -111,12 +111,14 @@ export default {
},
methods: {
...mapMutations('cmdbStore', ['SET_IS_TABLE_LOADING']),
- open({ preferenceAttrList }) {
+ open({ preferenceAttrList, ciTypeName = undefined }) {
this.preferenceAttrList = preferenceAttrList
this.visible = true
this.$nextTick((res) => {
this.form.setFieldsValue({
- filename: `cmdb-${moment().format('YYYYMMDDHHmmss')}`,
+ filename: ciTypeName
+ ? `cmdb-${ciTypeName}-${moment().format('YYYYMMDDHHmmss')}`
+ : `cmdb-${moment().format('YYYYMMDDHHmmss')}`,
})
if (this.treeType === 'tree') {
const _check = ['ci_type_alias']
diff --git a/cmdb-ui/src/modules/cmdb/views/batch/index.vue b/cmdb-ui/src/modules/cmdb/views/batch/index.vue
index c6c8420..d9f8a4a 100644
--- a/cmdb-ui/src/modules/cmdb/views/batch/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/batch/index.vue
@@ -106,7 +106,6 @@ export default {
this.uploadData = _uploadData.slice(1)
this.hasError = false
this.isUploading = false
- this.$refs.uploadResult.visible = false
},
handleUpload() {
if (!this.ciType) {
diff --git a/cmdb-ui/src/modules/cmdb/views/ci/index.vue b/cmdb-ui/src/modules/cmdb/views/ci/index.vue
index 64019af..8a484a5 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci/index.vue
@@ -576,7 +576,10 @@ export default {
},
async openBatchDownload() {
- this.$refs.batchDownload.open({ preferenceAttrList: this.preferenceAttrList })
+ this.$refs.batchDownload.open({
+ preferenceAttrList: this.preferenceAttrList,
+ ciTypeName: this.$route.meta.title || this.$route.meta.name,
+ })
},
batchDownload({ filename, type, checkedKeys }) {
const jsonAttrList = []
diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/CiDetail.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/CiDetail.vue
index 84af7f3..c9abc1f 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci/modules/CiDetail.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/CiDetail.vue
@@ -276,15 +276,16 @@ export default {
},
mergeRowMethod({ row, _rowIndex, column, visibleData }) {
const fields = ['created_at', 'username']
- const cellValue = row[column.property]
- if (cellValue && fields.includes(column.property)) {
+ const cellValue1 = row['created_at']
+ const cellValue2 = row['username']
+ if (cellValue1 && cellValue2 && fields.includes(column.property)) {
const prevRow = visibleData[_rowIndex - 1]
let nextRow = visibleData[_rowIndex + 1]
- if (prevRow && prevRow[column.property] === cellValue) {
+ if (prevRow && prevRow['created_at'] === cellValue1 && prevRow['username'] === cellValue2) {
return { rowspan: 0, colspan: 0 }
} else {
let countRowspan = 1
- while (nextRow && nextRow[column.property] === cellValue) {
+ while (nextRow && nextRow['created_at'] === cellValue1 && nextRow['username'] === cellValue2) {
nextRow = visibleData[++countRowspan + _rowIndex]
}
if (countRowspan > 1) {
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 d04f138..1e705ac 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/attrAD.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attrAD.vue
@@ -136,8 +136,8 @@ export default {
async getCITypeDiscovery(currentTab) {
await getCITypeDiscovery(this.CITypeId).then((res) => {
this.adCITypeList = res.filter((item) => item.adr_id)
- if (res && res.length && !this.currentTab) {
- this.currentTab = res[0].id
+ if (this.adCITypeList && this.adCITypeList.length && !this.currentTab) {
+ this.currentTab = this.adCITypeList[0].id
}
if (currentTab) {
this.currentTab = currentTab
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue
index 18b7cd1..c54faad 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue
@@ -40,20 +40,18 @@