From 4324333755ccfef72b4a7071deb244a66679a28c Mon Sep 17 00:00:00 2001 From: dengbf Date: Wed, 3 Jan 2024 15:56:43 +0800 Subject: [PATCH 1/5] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=20ITSM-CMDB?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=8A=82=E7=82=B9-=E6=8A=BD=E8=B1=A1?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=98=A0=E5=B0=84=E5=A4=84=E7=90=86=20=20=20?= =?UTF-8?q?-=20[=E5=85=B3=E8=81=94]=20#[1056558484520960]ITSM-CMDB?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=8A=82=E7=82=B9-=E6=8A=BD=E8=B1=A1?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=98=A0=E5=B0=84=E5=A4=84=E7=90=86=20http:/?= =?UTF-8?q?/192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/?= =?UTF-8?q?939050947543042/1056558484520960?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/api/cmdb/ci/ci.js | 3 + src/resources/assets/languages/term/en.json | 5 +- src/resources/assets/languages/term/zh.json | 5 +- .../cmdbpolicy/cmdbsync-dialog.vue | 116 ++-- .../nodesetting/cmdbpolicy/cmdbsync-edit.vue | 555 ++++++++++-------- .../node/nodesetting/cmdbpolicy/target-ci.vue | 215 +++++++ 6 files changed, 582 insertions(+), 317 deletions(-) create mode 100644 src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/target-ci.vue diff --git a/src/resources/api/cmdb/ci/ci.js b/src/resources/api/cmdb/ci/ci.js index bae135c2..d6ef40a6 100644 --- a/src/resources/api/cmdb/ci/ci.js +++ b/src/resources/api/cmdb/ci/ci.js @@ -165,6 +165,9 @@ const ci = { }, saveCiTreeItem(params) { return axios.post('/api/rest/cmdb/ci/tree/save', params); + }, + getCiForprocessmapping(params) { //获取模型信息(流程图cmdb节点关系映射专用) + return axios.post('/api/rest/cmdb/ci/get/forprocessmapping', params); } }; diff --git a/src/resources/assets/languages/term/en.json b/src/resources/assets/languages/term/en.json index e08de467..aa6f713d 100644 --- a/src/resources/assets/languages/term/en.json +++ b/src/resources/assets/languages/term/en.json @@ -187,7 +187,10 @@ "asyncpolicy": "Synchronization strategy", "globaleditmodetip": "Global mode, do not delete attribute representatives", "partialeditmodetip": "Local mode, do not change if attribute is not given", - "treedraginfo": "Dragging a model can change the order and affiliation of the model, and cannot be dragged when in search mode" + "treedraginfo": "Dragging a model can change the order and affiliation of the model, and cannot be dragged when in search mode", + "writeci": "Write model", + "writecitip": "Select constants or specify the model for data writing through form mapping. If the parent model is an abstract model and does not support adding configuration items, data needs to be written into the child model.", + "abstractcireltip": "Firstly, configure the parent model, complete the mapping of common attributes in the parent model, and specify the model for data writing. After completing the configuration of the parent model, return to the current interface before clicking on the sub model to configure the mapping of non-public (non inherited) attributes in the sub model." }, "process": { "workordercenter": "Work Center", diff --git a/src/resources/assets/languages/term/zh.json b/src/resources/assets/languages/term/zh.json index 1cdc944a..d9674bd8 100644 --- a/src/resources/assets/languages/term/zh.json +++ b/src/resources/assets/languages/term/zh.json @@ -187,7 +187,10 @@ "asyncpolicy": "同步策略", "globaleditmodetip": "全局模式,不给属性代表删除", "partialeditmodetip": "局部模式,不给属性则不改", - "treedraginfo": "拖动模型可以改变模型的顺序和从属关系,处于搜索状态时不可拖动" + "treedraginfo": "拖动模型可以改变模型的顺序和从属关系,处于搜索状态时不可拖动", + "writeci": "写入模型", + "writecitip": "选择常量或通过表单映射的方式,指定数据写入的模型。若父模型为抽象模型,不支持添加配置项,需将数据写入子模型。", + "abstractcireltip": "首先配置父模型,完成父模型中公共属性的映射,并指定数据写入的模型。完成父模型配置后,返回当前界面,才可点击子模型,配置子模型中的非公共(非继承)属性映射。" }, "process": { "workordercenter": "工单中心", diff --git a/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-dialog.vue b/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-dialog.vue index 18d20d53..18aa52e7 100644 --- a/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-dialog.vue +++ b/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-dialog.vue @@ -129,22 +129,18 @@ > - -
- -
-
+ @@ -197,7 +193,6 @@ export default { url: 'api/rest/cmdb/ci/list', search: true, params: { - isAbstract: 0, isVirtual: 0 }, validateList: ['required'], @@ -320,6 +315,8 @@ export default { } } }); + //标记为已保存的,用于点击“取消”后判断是否需要删除数据 + cientity._isnew = true; } if (preCiEntity && preCiEntity.batchDataSource && preCiEntity.batchDataSource.type && cientity.batchDataSource && cientity.batchDataSource.type && @@ -358,10 +355,10 @@ export default { }, getCiEntityById() { this.loadingShow = true; - this.$api.cmdb.ci.getCiById(this.ciData.ciId, true).then(async res => { + this.$api.cmdb.ci.getCiForprocessmapping({id: this.ciData.ciId}).then(res => { if (res.Return) { const ci = res.Return; - if (ci.isVirtual == 0 && ci.isAbstract == 0) { + if (ci.isVirtual == 0) { const cientity = { isStart: 1, uuid: this.ciData.uuid || this.$utils.setUuid(), @@ -369,14 +366,15 @@ export default { ciName: ci.name, ciLabel: ci.label, ciIcon: ci.icon, - editMode: this.ciData.editMode || '', + editMode: this.ciData.editMode || 'global', createPolicy: 'single', batchDataSource: {}, relEntityData: {}, - allAttrEntityData: {} + allAttrEntityData: {}, + isAbstract: ci.isAbstract }; - cientity['_elementList'] = await this.getElementByCiId(this.ciData.ciId); - cientity['_uniqueAttrList'] = await this.getCiUniqueByCiId(this.ciData.ciId); + cientity['_elementList'] = this.getElementByCiId(ci); + cientity['_uniqueAttrList'] = ci.uniqueAttrIdList; cientity['_description'] = this.descriptionConfig; this.initValue(cientity); this.ciEntityQueue = [cientity]; @@ -384,8 +382,6 @@ export default { } else { if (ci.isVirtual == 1) { this.error = this.$t('message.cmdb.virtualmodel'); - } else if (ci.isAbstract == 1) { - this.error = this.$t('message.cmdb.abstractmodel'); } } } @@ -393,18 +389,11 @@ export default { this.loadingShow = false; }); }, - async getCiUniqueByCiId(ciId) { - let uniqueList = []; - await this.$api.cmdb.ci.getCiUniqueByCiId(ciId).then(res => { - uniqueList = res.Return; - }); - return uniqueList; - }, - async getElementByCiId(ciId) { - const attrList = await this.getAttrByCiId(ciId); - const relList = await this.getRelByCiId(ciId); - const globalAttrList = await this.getGlobalAttr(); - const ciViewList = await this.getCiViewByCiId(ciId); + getElementByCiId(data) { + const attrList = data.attrList || []; + const relList = data.relList || []; + const globalAttrList = data.globalAttrList || []; + const ciViewList = data.viewList || []; const elementList = []; ciViewList.forEach((e, index) => { if (e.type === 'attr') { @@ -431,41 +420,6 @@ export default { }); return elementList; }, - async getGlobalAttr() { - let globalAttrList; - await this.$api.cmdb.globalattr.searchGlobalAttr({isActive: 1}).then(res => { - globalAttrList = res.Return.tbodyList; - }); - return globalAttrList; - }, - async getAttrByCiId(ciId) { - if (ciId) { - let attrList; - let allowEdit = 1; - await this.$api.cmdb.ci.getAttrByCiId(ciId, { allowEdit: allowEdit }).then(res => { - attrList = res.Return; - }); - return attrList; - } - }, - async getRelByCiId(ciId) { - if (ciId) { - let relList; - await this.$api.cmdb.ci.getRelByCiId(ciId, {needAction: true, allowEdit: 1}).then(res => { - relList = res.Return; - }); - return relList; - } - }, - async getCiViewByCiId(ciId) { - if (ciId) { - let ciViewList; - await this.$api.cmdb.ci.getCiViewByCiId(ciId).then(res => { - ciViewList = res.Return; - }); - return ciViewList; - } - }, addNewCiEntity(type, item) { if (!this.valid()) { return; @@ -477,7 +431,8 @@ export default { const relId = rel._relId; const direction = rel.direction == 'from' ? 'to' : 'from'; //目标关系需要取反 const uuid = rel.ciEntityUuid || this.$utils.setUuid(); //新的配置项标识 - this.$api.cmdb.ci.getCiById(ciId).then(async res => { + const rootId = rel._rootId || null; + this.$api.cmdb.ci.getCiForprocessmapping({id: ciId, rootId: rootId}).then(res => { if (res.Return) { const ci = res.Return; //获取当前配置项数据 @@ -491,22 +446,23 @@ export default { ciName: ci.name, ciLabel: ci.label, ciIcon: ci.icon, - editMode: '', + editMode: 'global', createPolicy: 'single', batchDataSource: {}, action: 'append', relEntityData: {}, _disableRel: 'rel' + direction + '_' + relId, //标记哪个关系不允许添加或选择 - allAttrEntityData: {} //所有的属性 + allAttrEntityData: {}, //所有的属性 + isAbstract: ci.isAbstract }; - newCiEntity['_elementList'] = await this.getElementByCiId(ciId); - newCiEntity['_uniqueAttrList'] = await this.getCiUniqueByCiId(ciId); + newCiEntity['_elementList'] = this.getElementByCiId(ci); + newCiEntity['_uniqueAttrList'] = ci.uniqueAttrIdList; newCiEntity['_description'] = this.descriptionConfig; newCiEntity['relEntityData']['rel' + direction + '_' + relId] = { valueList: [ { ciEntityUuid: currentCiEntity.uuid, - ciEntityName: this.$t('term.cmdb.fromcientity'), + ciEntityName: currentCiEntity.ciLabel, ciId: ciId, type: 'from' } @@ -549,7 +505,7 @@ export default { editNewCiEntity(rel) { let uuid = rel.ciEntityUuid; if (this.saveCiEntityMap[uuid]) { - this.tmpCiEntityData = JSON.parse(JSON.stringify(this.saveCiEntityMap[uuid])); + this.tmpCiEntityData = this.$utils.deepClone((this.saveCiEntityMap[uuid])); let index = -1; for (let i = 0; i < this.ciEntityQueue.length; i++) { if (this.ciEntityQueue[i].uuid == uuid) { @@ -653,7 +609,7 @@ export default { const newRelEntity = { _relId: cientity['_relId'], ciEntityUuid: cientity.uuid, - ciEntityName: this.$t('term.cmdb.newcientity'), + ciEntityName: cientity.ciLabel, ciId: cientity.ciId, type: 'new' }; diff --git a/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-edit.vue b/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-edit.vue index cbcb581d..f21356dd 100644 --- a/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-edit.vue +++ b/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/cmdbsync-edit.vue @@ -1,250 +1,274 @@