diff --git a/src/ui/src/components/model-instance/relation/create.vue b/src/ui/src/components/model-instance/relation/create.vue index 171730f71e..dbe944ef8e 100644 --- a/src/ui/src/components/model-instance/relation/create.vue +++ b/src/ui/src/components/model-instance/relation/create.vue @@ -379,6 +379,7 @@ const { isSource } = this return this.searchInstAssociation({ params: { + bk_obj_id: isSource ? this.objId : option.bk_obj_id, condition: { bk_asst_id: option.bk_asst_id, bk_obj_asst_id: option.bk_obj_asst_id, diff --git a/src/ui/src/components/model-instance/relation/list-table.vue b/src/ui/src/components/model-instance/relation/list-table.vue index ef75db8010..f049123a02 100644 --- a/src/ui/src/components/model-instance/relation/list-table.vue +++ b/src/ui/src/components/model-instance/relation/list-table.vue @@ -153,11 +153,10 @@ return this.type === 'source' }, instances() { - return this.allInstances.filter((instance) => { - const sameAsstId = instance.bk_asst_id === this.associationType.bk_asst_id - const sameModelId = this.id === instance[this.isSource ? 'bk_asst_obj_id' : 'bk_obj_id'] - return sameAsstId && sameModelId - }) + const objAsstId = this.isSource + ? `${this.objId}_${this.associationType.bk_asst_id}_${this.id}` + : `${this.id}_${this.associationType.bk_asst_id}_${this.objId}` + return this.allInstances.filter(instance => instance.bk_obj_asst_id === objAsstId) }, instanceIds() { return this.instances.map(instance => (this.isSource ? instance.bk_asst_inst_id : instance.bk_inst_id)) diff --git a/src/ui/src/components/model-instance/relation/list.vue b/src/ui/src/components/model-instance/relation/list.vue index 983315551c..771847599f 100644 --- a/src/ui/src/components/model-instance/relation/list.vue +++ b/src/ui/src/components/model-instance/relation/list.vue @@ -132,11 +132,11 @@ const targetCondition = { bk_asst_obj_id: this.objId, bk_asst_inst_id: this.instId } const [source, target] = await Promise.all([ this.$store.dispatch('objectAssociation/searchInstAssociation', { - params: { condition: sourceCondition }, + params: { condition: sourceCondition, bk_obj_id: this.objId }, config: { requestId: 'getSourceAssociation' } }), this.$store.dispatch('objectAssociation/searchInstAssociation', { - params: { condition: targetCondition }, + params: { condition: targetCondition, bk_obj_id: this.objId }, config: { requestId: 'getTargetAssociation' } }) ]) diff --git a/src/ui/src/views/host-details/children/association-create.vue b/src/ui/src/views/host-details/children/association-create.vue index 2a01d26f40..3f998da5b9 100644 --- a/src/ui/src/views/host-details/children/association-create.vue +++ b/src/ui/src/views/host-details/children/association-create.vue @@ -414,6 +414,7 @@ const { isSource } = this return this.searchInstAssociation({ params: { + bk_obj_id: isSource ? this.objId : option.bk_obj_id, condition: { bk_asst_id: option.bk_asst_id, bk_obj_asst_id: option.bk_obj_asst_id, diff --git a/src/ui/src/views/host-details/children/association-list-table.vue b/src/ui/src/views/host-details/children/association-list-table.vue index bda2b772fa..3dc5ec7171 100644 --- a/src/ui/src/views/host-details/children/association-list-table.vue +++ b/src/ui/src/views/host-details/children/association-list-table.vue @@ -146,11 +146,10 @@ return this.type === 'source' }, instances() { - return this.allInstances.filter((instance) => { - const sameAsstId = instance.bk_asst_id === this.associationType.bk_asst_id - const sameModelId = this.id === instance[this.isSource ? 'bk_asst_obj_id' : 'bk_obj_id'] - return sameAsstId && sameModelId - }) + const objAsstId = this.isSource + ? `host_${this.associationType.bk_asst_id}_${this.id}` + : `${this.id}_${this.associationType.bk_asst_id}_host` + return this.allInstances.filter(instance => instance.bk_obj_asst_id === objAsstId) }, instanceIds() { return this.instances.map(instance => (this.isSource ? instance.bk_asst_inst_id : instance.bk_inst_id)) diff --git a/src/ui/src/views/host-details/children/association-list.vue b/src/ui/src/views/host-details/children/association-list.vue index f6f584fd46..768622ca94 100644 --- a/src/ui/src/views/host-details/children/association-list.vue +++ b/src/ui/src/views/host-details/children/association-list.vue @@ -167,11 +167,11 @@ const targetCondition = { bk_asst_obj_id: 'host', bk_asst_inst_id: this.id } const [source, target] = await Promise.all([ this.$store.dispatch('objectAssociation/searchInstAssociation', { - params: { condition: sourceCondition }, + params: { condition: sourceCondition, bk_obj_id: 'host' }, config: { requestId: 'getSourceAssociation' } }), this.$store.dispatch('objectAssociation/searchInstAssociation', { - params: { condition: targetCondition }, + params: { condition: targetCondition, bk_obj_id: 'host' }, config: { requestId: 'getTargetAssociation' } }) ])