diff --git a/cmdb-ui/src/modules/cmdb/utils/helper.js b/cmdb-ui/src/modules/cmdb/utils/helper.js
index 1ddd76fd..44de91ba 100644
--- a/cmdb-ui/src/modules/cmdb/utils/helper.js
+++ b/cmdb-ui/src/modules/cmdb/utils/helper.js
@@ -1,5 +1,7 @@
/* eslint-disable */
import _ from 'lodash'
+import XLSX from 'xlsx'
+import XLSXS from 'xlsx-js-style'
export function sum(arr) {
if (!arr.length) {
return 0
@@ -149,4 +151,26 @@ export const toThousands = (num = 0) => {
return num.toString().replace(/\d+/, function (n) {
return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
})
-}
\ No newline at end of file
+}
+
+export const downloadExcel = (data, fileName = `${moment().format('YYYY-MM-DD HH:mm:ss')}.xls`) => {
+ // STEP 1: Create a new workbook
+ const wb = XLSXS.utils.book_new()
+ // STEP 2: Create data rows and styles
+ const rowArray = data
+ // STEP 3: Create worksheet with rows; Add worksheet to workbook
+ const ws = XLSXS.utils.aoa_to_sheet(rowArray)
+ XLSXS.utils.book_append_sheet(wb, ws, fileName)
+
+ let maxColumnNumber = 1 // 默认最大列数
+ rowArray.forEach(item => { if (item.length > maxColumnNumber) { maxColumnNumber = item.length } })
+
+ // 添加列宽
+ ws['!cols'] = (rowArray[0].map(item => {
+ return { width: 22 }
+ }))
+ // // 添加行高
+ // ws['!rows'] = [{ 'hpt': 80 }]
+ // STEP 4: Write Excel file to browser #导出
+ XLSXS.writeFile(wb, fileName + '.xlsx')
+}
diff --git a/cmdb-ui/src/modules/cmdb/views/batch/modules/CiTypeChoice.vue b/cmdb-ui/src/modules/cmdb/views/batch/modules/CiTypeChoice.vue
index fe9af41a..49686c7f 100644
--- a/cmdb-ui/src/modules/cmdb/views/batch/modules/CiTypeChoice.vue
+++ b/cmdb-ui/src/modules/cmdb/views/batch/modules/CiTypeChoice.vue
@@ -14,20 +14,83 @@
}}
下载模板
+
+ 模型属性
+
+ 全选
+
+
+
+
+
+
+ {{ item.alias || item.name }}
+ *
+
+
+
+
+
+ 模型关联
+
+
+
+
+ {{ item.alias || item.name }}
+
+
+ {{ attr.alias || attr.name }}
+
+
+
+
+
+
@@ -105,3 +233,15 @@ export default {
}
}
+
+
diff --git a/cmdb-ui/src/modules/cmdb/views/batch/modules/CiUploadTable.vue b/cmdb-ui/src/modules/cmdb/views/batch/modules/CiUploadTable.vue
index 0d3b8aa0..4a97bb1e 100644
--- a/cmdb-ui/src/modules/cmdb/views/batch/modules/CiUploadTable.vue
+++ b/cmdb-ui/src/modules/cmdb/views/batch/modules/CiUploadTable.vue
@@ -40,15 +40,25 @@ export default {
},
computed: {
columns() {
+ const _columns = []
if (this.ciTypeAttrs.attributes) {
- return this.ciTypeAttrs.attributes.map((item) => {
- return {
- title: item.alias || item.name,
- field: item.alias || item.name,
+ _columns.push(
+ ...this.ciTypeAttrs.attributes.map((item) => {
+ return {
+ title: item.alias || item.name,
+ field: item.alias || item.name,
+ }
+ })
+ )
+ }
+ if (this.uploadData && this.uploadData.length) {
+ Object.keys(this.uploadData[0]).forEach((key) => {
+ if (key.startsWith('$')) {
+ _columns.push({ title: key, field: key })
}
})
}
- return []
+ return _columns
},
dataSource() {
return _.cloneDeep(this.uploadData)
diff --git a/cmdb-ui/src/modules/cmdb/views/batch/modules/UploadFileForm.vue b/cmdb-ui/src/modules/cmdb/views/batch/modules/UploadFileForm.vue
index a258f5b6..1898ce04 100644
--- a/cmdb-ui/src/modules/cmdb/views/batch/modules/UploadFileForm.vue
+++ b/cmdb-ui/src/modules/cmdb/views/batch/modules/UploadFileForm.vue
@@ -4,13 +4,13 @@
ref="upload"
:multiple="false"
:customRequest="customRequest"
- accept=".xls"
+ accept=".xls,.xlsx"
:showUploadList="false"
:fileList="fileList"
>
点击或拖拽文件至此上传!
- 支持文件类型:xls
+ 支持文件类型:xls,xlsx
{{ item.name }}
diff --git a/cmdb-ui/src/modules/cmdb/views/ci/index.vue b/cmdb-ui/src/modules/cmdb/views/ci/index.vue
index 20d7ac11..3479214c 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci/index.vue
@@ -209,13 +209,19 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
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 c31aa5df..303cbb43 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci/modules/CiDetail.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/CiDetail.vue
@@ -38,7 +38,7 @@
关系
-
+
@@ -147,8 +147,14 @@ export default {
},
inject: ['reload', 'handleSearch', 'attrList'],
methods: {
- create(ciId) {
+ create(ciId, activeTabKey = 'tab_1', ciDetailRelationKey = '1') {
this.visible = true
+ this.activeTabKey = activeTabKey
+ if (activeTabKey === 'tab_2') {
+ this.$nextTick(() => {
+ this.$refs.ciDetailRelation.activeKey = ciDetailRelationKey
+ })
+ }
this.ciId = ciId
this.getAttributes()
this.getCI()
diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue
index 63f02dc6..bc9750d1 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue
@@ -23,6 +23,30 @@
:attributeList="attributeList"
/>
+
+ 模型关系
+
+
+
+
+
+
+
+ {{ attr.alias || attr.name }}
+
+
+
+
+
+
+
+
+
@@ -110,6 +134,7 @@ import { addCI } from '@/modules/cmdb/api/ci'
import JsonEditor from '../../../components/JsonEditor/jsonEditor.vue'
import { valueTypeMap } from '../../../utils/const'
import CreateInstanceFormByGroup from './createInstanceFormByGroup.vue'
+import { getCITypeParent } from '@/modules/cmdb/api/CITypeRelation'
export default {
name: 'CreateInstanceForm',
@@ -138,6 +163,8 @@ export default {
batchUpdateLists: [],
editAttr: null,
attributesByGroup: [],
+ parentsType: [],
+ parentsForm: {},
}
},
computed: {
@@ -231,6 +258,11 @@ export default {
}
})
values.ci_type = _this.typeId
+ Object.keys(this.parentsForm).forEach((type) => {
+ if (this.parentsForm[type].value) {
+ values[`$${type}.${this.parentsForm[type].attr}`] = this.parentsForm[type].value
+ }
+ })
addCI(values).then((res) => {
_this.$message.success('新增成功!')
_this.visible = false
@@ -249,6 +281,17 @@ export default {
Promise.all([this.getCIType(), this.getAttributeList()]).then(() => {
this.batchUpdateLists = [{ name: this.attributeList[0].name }]
})
+ if (action === 'create') {
+ getCITypeParent(this.typeId).then((res) => {
+ this.parentsType = res.parents
+ const _parentsForm = {}
+ res.parents.forEach((item) => {
+ const _find = item.attributes.find((attr) => attr.id === item.unique_id)
+ _parentsForm[item.name] = { attr: _find.name, value: '' }
+ })
+ this.parentsForm = _parentsForm
+ })
+ }
})
},
getFieldType(name) {
diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue
index a44d7c20..b862510f 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue
@@ -244,14 +244,13 @@ export default {
},
},
mounted() {
- console.log(this.ci)
this.init(true)
},
methods: {
async init(isFirst) {
await Promise.all([this.getParentCITypes(), this.getChildCITypes()])
Promise.all([this.getFirstCIs(), this.getSecondCIs()]).then(() => {
- if (isFirst) {
+ if (isFirst && this.$refs.ciDetailRelationTopo) {
this.$refs.ciDetailRelationTopo.setTopoData(this.topoData)
}
})
@@ -395,12 +394,6 @@ export default {
margin-top: 20px;
margin-bottom: 5px;
color: #303133;
- > a {
- display: none;
- }
- &:hover > a {
- display: inline-block;
- }
}
}
diff --git a/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue b/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue
index 8796295c..1d17eac0 100644
--- a/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue
@@ -243,17 +243,23 @@
/>
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue b/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue
index 6da78c1a..592b5d4b 100644
--- a/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue
@@ -297,17 +297,23 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+