diff --git a/src/resources/assets/languages/term/en.json b/src/resources/assets/languages/term/en.json index 4e0d9e5a4b87f7cf1522143d77fe624b9d9fb757..5a8ddf1cadb1933d504b3cd4b33c460f5ea425b3 100644 --- a/src/resources/assets/languages/term/en.json +++ b/src/resources/assets/languages/term/en.json @@ -191,7 +191,8 @@ "startci": "Select the starting model first", "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." + "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.", + "subci": "Submodel" }, "process": { "workordercenter": "Work Center", diff --git a/src/resources/assets/languages/term/zh.json b/src/resources/assets/languages/term/zh.json index 172377ef92d38b38a8f650b1208040a841fa7c6a..7f76991e831cdbb8773db6406efea1f09ea117e4 100644 --- a/src/resources/assets/languages/term/zh.json +++ b/src/resources/assets/languages/term/zh.json @@ -191,7 +191,8 @@ "startci": "先选择起始模型", "writeci": "写入模型", "writecitip": "选择常量或通过表单映射的方式,指定数据写入的模型。若父模型为抽象模型,不支持添加配置项,需将数据写入子模型。", - "abstractcireltip": "首先配置父模型,完成父模型中公共属性的映射,并指定数据写入的模型。完成父模型配置后,返回当前界面,才可点击子模型,配置子模型中的非公共(非继承)属性映射。" + "abstractcireltip": "首先配置父模型,完成父模型中公共属性的映射,并指定数据写入的模型。完成父模型配置后,返回当前界面,才可点击子模型,配置子模型中的非公共(非继承)属性映射。", + "subci": "子模型" }, "process": { "workordercenter": "工单中心", diff --git a/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/children-ci.vue b/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/children-ci.vue new file mode 100644 index 0000000000000000000000000000000000000000..de8fa3140c3b052af8cc3f473e0d14c6de7bebca --- /dev/null +++ b/src/views/pages/cmdb/flow/node/nodesetting/cmdbpolicy/children-ci.vue @@ -0,0 +1,163 @@ + + + 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 f30ee0a2d1bbf32bbb26bde1b2ab9183aca5ba70..a22bbffdb73bfca06ca863fa421baacdfbab93cf 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 @@ -75,7 +75,7 @@ > { - if (this.saveCiEntityMap[key].ciId === rootId) { - rootConfig = this.saveCiEntityMap[key]; + //子模型 + if (rel && rel._rootId) { + if (rel.isChildren) { + //初始模型是抽象模型 + let rootConfig = this.ciEntityQueue[0]; + if (rootConfig) { + this.$set(cientity, 'action', rootConfig.action); + this.$set(cientity, 'batchDataSource', rootConfig.batchDataSource); + this.$set(cientity, 'editMode', rootConfig.editMode); + this.$set(cientity, 'createPolicy', rootConfig.createPolicy); + } + this.isInherit = true; + } else if (rel._rootId != cientity.ciId) { + if (this.saveCiEntityMap[rel._rootUuid]) { + let rootConfig = this.saveCiEntityMap[rel._rootUuid]; + this.$set(cientity, 'action', rootConfig.action); + this.$set(cientity, 'batchDataSource', rootConfig.batchDataSource); + this.$set(cientity, 'editMode', rootConfig.editMode); + this.$set(cientity, 'createPolicy', rootConfig.createPolicy); } - }); - if (rootConfig) { - this.$set(cientity, 'action', rootConfig.action); - this.$set(cientity, 'batchDataSource', rootConfig.batchDataSource); - this.$set(cientity, 'editMode', rootConfig.editMode); - this.$set(cientity, 'createPolicy', rootConfig.createPolicy); this.isInherit = true; } } @@ -397,6 +406,9 @@ export default { allAttrEntityData: {}, isAbstract: ci.isAbstract }; + if (ci.isAbstract) { + this.$set(cientity, 'children', []); + } cientity['_elementList'] = this.getElementByCiId(ci); cientity['_uniqueAttrList'] = ci.uniqueAttrIdList; cientity['_description'] = this.descriptionConfig; @@ -444,44 +456,44 @@ export default { }); return elementList; }, - addNewCiEntity(type, item) { + addNewCiEntity(item) { if (!this.valid()) { return; } this.loadingShow = true; - if (type === 'rel') { - const rel = item; - const ciId = rel.ciId; - const relId = rel._relId; - const direction = rel.direction == 'from' ? 'to' : 'from'; //目标关系需要取反 - const uuid = rel.ciEntityUuid || this.$utils.setUuid(); //新的配置项标识 - const rootId = rel._rootId || null; - this.$api.cmdb.ci.getCiForprocessmapping({id: ciId, rootId: rootId}).then(res => { - if (res.Return) { - const ci = res.Return; - //获取当前配置项数据 - const currentCiEntity = this.ciEntityQueue[this.ciEntityQueue.length - 1]; - const newCiEntity = { - uuid: uuid, - _relId: relId, //记录来自哪个关系,自动填上配置项 - _direction: rel.direction, //记录关系方向 - ciId: ciId, - rootCiId: this.propRootCiId, - ciName: ci.name, - ciLabel: ci.label, - ciIcon: ci.icon, - editMode: 'global', - createPolicy: 'single', - batchDataSource: {}, - action: 'append', - relEntityData: {}, - _disableRel: 'rel' + direction + '_' + relId, //标记哪个关系不允许添加或选择 - allAttrEntityData: {}, //所有的属性 - isAbstract: ci.isAbstract - }; - newCiEntity['_elementList'] = this.getElementByCiId(ci); - newCiEntity['_uniqueAttrList'] = ci.uniqueAttrIdList; - newCiEntity['_description'] = this.descriptionConfig; + const rel = item; + const ciId = rel.ciId; + const relId = rel._relId; + const direction = rel.direction == 'from' ? 'to' : 'from'; //目标关系需要取反 + const uuid = rel.ciEntityUuid || this.$utils.setUuid(); //新的配置项标识 + const rootId = rel._rootId || null; + this.$api.cmdb.ci.getCiForprocessmapping({id: ciId, rootId: rootId}).then(res => { + if (res.Return) { + const ci = res.Return; + //获取当前配置项数据 + const currentCiEntity = this.ciEntityQueue[this.ciEntityQueue.length - 1]; + const newCiEntity = { + uuid: uuid, + _relId: relId, //记录来自哪个关系,自动填上配置项 + _direction: rel.direction, //记录关系方向 + ciId: ciId, + ciName: ci.name, + ciLabel: ci.label, + ciIcon: ci.icon, + editMode: 'global', + createPolicy: 'single', + batchDataSource: {}, + action: 'append', + relEntityData: {}, + _disableRel: 'rel' + direction + '_' + relId, //标记哪个关系不允许添加或选择 + allAttrEntityData: {}, //所有的属性 + isAbstract: ci.isAbstract, + isChildren: !!rel.isChildren + }; + newCiEntity['_elementList'] = this.getElementByCiId(ci); + newCiEntity['_uniqueAttrList'] = ci.uniqueAttrIdList; + newCiEntity['_description'] = this.descriptionConfig; + if (!rel.isChildren) { newCiEntity['relEntityData']['rel' + direction + '_' + relId] = { valueList: [ { @@ -492,15 +504,17 @@ export default { } ] }; - this.initValue(newCiEntity, currentCiEntity, rootId, rel.subCiUuidList); - this.ciData = newCiEntity; - this.ciEntityQueue.push(newCiEntity); - this.updateCurrentFormItemList(); } - }).finally(() => { - this.loadingShow = false; - }); - } + this.initValue(newCiEntity, currentCiEntity, rel); + this.ciData = newCiEntity; + this.ciEntityQueue.push(newCiEntity); + if (!rel.isChildren) { + this.updateCurrentFormItemList(rel); + } + } + }).finally(() => { + this.loadingShow = false; + }); }, removeNewCiEntity(item) { if (item._relId) { //关系删除 @@ -543,7 +557,7 @@ export default { this.updateCurrentFormItemList(); } else { //需要通过接口获取数据回显 - this.addNewCiEntity('rel', rel); + this.addNewCiEntity(rel); } } }, @@ -646,6 +660,12 @@ export default { currentCiEntity['relEntityData']['rel' + cientity._direction + '_' + cientity._relId] = { valueList: [] }; } currentCiEntity['relEntityData']['rel' + cientity._direction + '_' + cientity._relId]['valueList'].push(newRelEntity); + } else if (this.currentCiEntity.children) { + currentCiEntity.children.push({ + ciEntityUuid: cientity.uuid, + ciEntityName: cientity.ciLabel, + ciId: cientity.ciId + }); } } //标记为已保存的新配置项,用于点击“取消”后判断是否需要删除数据 @@ -656,6 +676,11 @@ export default { this.updateSubCiData(cientity); } else if (this.ciEntityQueue.length == 1) { const cientity = this.ciEntityQueue[0]; + if (!this.$utils.isEmpty(cientity.children)) { + //初始模型为抽象模型 + this.subCiUuidList = this.$utils.mapArray(cientity.children, 'ciEntityUuid'); + this.updateSubCiData(cientity); + } this.saveCiEntityMap[cientity.uuid] = cientity; const ciEntityList = []; for (let uuid in this.saveCiEntityMap) { @@ -682,6 +707,10 @@ export default { }; if (item.hasOwnProperty('isStart')) { config.isStart = item.isStart; + //抽象模型的子模型 + if (item.hasOwnProperty('children')) { + config.children = item.children; + } } if (item.hasOwnProperty('action')) { config.action = item.action; @@ -726,7 +755,7 @@ export default { if (this.currentCiEntity) { if (this.currentCiEntity.batchDataSource) { if (this.currentCiEntity.batchDataSource.type === 'formTableComponent') { - if (this.preCiEntity && this.preCiEntity.batchDataSource && this.preCiEntity.batchDataSource.attributeUuid) { + if (!this.isInherit && this.preCiEntity && this.preCiEntity.batchDataSource && this.preCiEntity.batchDataSource.attributeUuid) { let findTable = this.allFormitemList.find(item => item.uuid === this.preCiEntity.batchDataSource.attributeUuid); if (findTable && findTable.config && findTable.config.dataConfig) { findTable.config.dataConfig.forEach(d => { 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 006ce14f4d799fac1c23c7747dc1c13dfb9973af..8fa3f0001faa5c545b2f6d2db8ea5489c56edb4c 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 @@ -11,6 +11,21 @@ :tableComponentAttrList="tableComponentAttrList" :subFormComponentList="subFormComponentList" > + +
@@ -283,7 +298,8 @@ export default { TsFormSelect: resolve => require(['@/resources/plugins/TsForm/TsFormSelect'], resolve), AttrInputer: resolve => require(['@/views/pages/cmdb/cientity/attr-inputer.vue'], resolve), TsFormCascader: resolve => require(['@/resources/plugins/TsForm/TsFormCascader.vue'], resolve), - TargetCi: resolve => require(['./target-ci.vue'], resolve) + TargetCi: resolve => require(['./target-ci.vue'], resolve), + ChildrenCi: resolve => require(['./children-ci.vue'], resolve) }, props: { ciData: Object, @@ -295,7 +311,8 @@ export default { } }, subFormComponentList: Array, - tableComponentAttrList: Array + tableComponentAttrList: Array, + saveCiEntityMap: Object }, data() { return { @@ -402,11 +419,15 @@ export default { } //存在抽象模型和子模型的标识 let abstractCiList = this.ciEntityData.relEntityData['rel' + config.direction + '_' + config.id]['valueList'] || []; - if (abstractCiList && abstractCiList.length > 1 && data.ciId === data._rootId) { - let subCiList = abstractCiList.filter((item) => { - return item.ciId !== data._rootId; - }); - data.subCiUuidList = this.$utils.mapArray(subCiList, 'ciEntityUuid'); + if (abstractCiList && abstractCiList.length > 1) { + if (data.ciId === data._rootId) { + let subCiList = abstractCiList.filter((item) => { + return item.ciId !== data._rootId; + }); + data.subCiUuidList = this.$utils.mapArray(subCiList, 'ciEntityUuid'); + } else if (data.ciId != data._rootId) { + data._rootUuid = abstractCiList[0].ciEntityUuid; + } } this.$emit('edit', data); } @@ -456,7 +477,16 @@ export default { } else { rel._rootId = rel.fromCiId; } - this.$emit('new', 'rel', rel); + //存在抽象模型和子模型的标识 + if (this.ciEntityData.relEntityData['rel' + rel.direction + '_' + rel.id]) { + let abstractCiList = this.ciEntityData.relEntityData['rel' + rel.direction + '_' + rel.id]['valueList'] || []; + if (abstractCiList && abstractCiList.length > 0) { + if (ciId != rel._rootId) { + rel._rootUuid = abstractCiList[0].ciEntityUuid; + } + } + } + this.$emit('new', rel); }, //删除选中的属性 deleteAttrEntity(key, attrentity) {