diff --git a/cmdb-ui/src/modules/cmdb/components/ciIcon/index.vue b/cmdb-ui/src/modules/cmdb/components/ciIcon/index.vue index d7e6d4a..740018c 100644 --- a/cmdb-ui/src/modules/cmdb/components/ciIcon/index.vue +++ b/cmdb-ui/src/modules/cmdb/components/ciIcon/index.vue @@ -21,7 +21,7 @@ {{ title[0].toUpperCase() }} diff --git a/cmdb-ui/src/modules/cmdb/lang/en.js b/cmdb-ui/src/modules/cmdb/lang/en.js index e6fadc5..ac46e80 100644 --- a/cmdb-ui/src/modules/cmdb/lang/en.js +++ b/cmdb-ui/src/modules/cmdb/lang/en.js @@ -721,6 +721,7 @@ if __name__ == "__main__": batchRollbacking: 'Deleting {total} items in total, {successNum} items successful, {errorNum} items failed', baselineTips: 'Changes at this point in time will also be rollbacked, Unique ID, password and dynamic attributes do not support', cover: 'Cover', + detail: 'Detail' }, serviceTree: { remove: 'Remove', diff --git a/cmdb-ui/src/modules/cmdb/lang/zh.js b/cmdb-ui/src/modules/cmdb/lang/zh.js index 83574e1..114997d 100644 --- a/cmdb-ui/src/modules/cmdb/lang/zh.js +++ b/cmdb-ui/src/modules/cmdb/lang/zh.js @@ -720,6 +720,7 @@ if __name__ == "__main__": batchRollbacking: '正在回滚,共{total}个,成功{successNum}个,失败{errorNum}个', baselineTips: '该时间点的变更也会被回滚, 唯一标识、密码属性、动态属性不支持回滚', cover: '覆盖', + detail: '详情' }, serviceTree: { remove: '移除', diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciDetailTableTitle.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciDetailTableTitle.vue new file mode 100644 index 0000000..9f4f431 --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciDetailTableTitle.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciDetailTitle.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciDetailTitle.vue new file mode 100644 index 0000000..e58ce80 --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciDetailTitle.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciRelationTable.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciRelationTable.vue new file mode 100644 index 0000000..6162a10 --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailComponent/ciRelationTable.vue @@ -0,0 +1,614 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailMixin/relationMixin.js b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailMixin/relationMixin.js new file mode 100644 index 0000000..2b7326e --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailMixin/relationMixin.js @@ -0,0 +1,95 @@ +import { getCITypeChildren, getCITypeParent } from '@/modules/cmdb/api/CITypeRelation' +import { searchCIRelation } from '@/modules/cmdb/api/CIRelation' + +const RelationMixin = { + data() { + return { + relationData: { + parentCITypeList: [], + childCITypeList: [], + parentCIList: [], + childCIList: [] + } + } + }, + + methods: { + async initRelationData(typeId, ciId) { + const { + parentCITypeList, + childCITypeList + } = await this.getRelationCITypeList(typeId) + const { + parentCIList, + childCIList + } = await this.getRelationCIList(ciId) + this.relationData = { + parentCITypeList, + childCITypeList, + parentCIList, + childCIList + } + }, + + async getRelationCITypeList(typeId) { + let parentCITypeList = [] + let childCITypeList = [] + + if (typeId) { + parentCITypeList = await this.getParentCITypeList(typeId) + childCITypeList = await this.getChildCITypeList(typeId) + } + + return { + parentCITypeList, + childCITypeList + } + }, + + async getRelationCIList(ciId) { + let parentCIList = [] + let childCIList = [] + + if (ciId) { + parentCIList = await this.getParentCIList(ciId) + childCIList = await this.getChildCIList(ciId) + } + + return { + parentCIList, + childCIList + } + }, + + async refreshRelationCI(ciId) { + const { + parentCIList, + childCIList + } = await this.getRelationCIList(ciId) + this.relationData.parentCIList = parentCIList + this.relationData.childCIList = childCIList + }, + + async getParentCITypeList(typeId) { + const res = await getCITypeParent(typeId) + return res?.parents || [] + }, + + async getChildCITypeList(typeId) { + const res = await getCITypeChildren(typeId) + return res.children || [] + }, + + async getParentCIList(ciId) { + const res = await searchCIRelation(`root_id=${ciId}&level=1&reverse=1&count=10000`) + return res?.result || [] + }, + + async getChildCIList(ciId) { + const res = await searchCIRelation(`root_id=${ciId}&level=1&reverse=0&count=10000`) + return res?.result || [] + } + } +} + +export default RelationMixin 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 9e6bd0d..41ea9df 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue @@ -1,146 +1,16 @@