diff --git a/frontend/package.json b/frontend/package.json index 9b89c5a842..a63cffc926 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -48,7 +48,8 @@ "vuedraggable": "^2.24.3", "vuex": "^3.1.2", "xml-js": "^1.6.11", - "yan-progress": "^1.0.3" + "yan-progress": "^1.0.3", + "jsonpath": "^1.1.0" }, "devDependencies": { "@vue/cli-plugin-babel": "^4.1.0", diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index ac270ddc2a..61df42bba3 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -133,7 +133,7 @@ + @remove="remove" @copyRow="copyRow" @suggestClick="suggestClick" @refReload="refReload"/> @@ -215,8 +215,8 @@ import ScenarioRelevance from "./api/ScenarioRelevance"; import MsComponentConfig from "./component/ComponentConfig"; import {handleCtrlSEvent} from "../../../../../common/js/utils"; - import {getProject} from "@/business/components/api/automation/scenario/event"; import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover"; + let jsonPath = require('jsonpath'); export default { name: "EditApiScenario", props: { @@ -295,12 +295,6 @@ this.getApiScenario(); this.addListener(); // 添加 ctrl s 监听 }, - mounted() { - getProject.$on('addProjectEnv', (projectId, projectEnv) => { - this.projectIds.add(projectId); - // this.projectEnvMap.set(projectId, projectEnv); - }) - }, directives: {OutsideClick}, computed: { buttons() { @@ -583,6 +577,7 @@ } this.sort(); this.reload(); + this.initProjectIds(); this.scenarioVisible = false; }, setApiParameter(item, refType, referenced) { @@ -624,6 +619,7 @@ }); this.sort(); this.reload(); + this.initProjectIds(); }, getMaintainerOptions() { let workspaceId = localStorage.getItem(WORKSPACE_ID); @@ -647,15 +643,10 @@ const parent = node.parent const hashTree = parent.data.hashTree || parent.data; const index = hashTree.findIndex(d => d.resourceId != undefined && row.resourceId != undefined && d.resourceId === row.resourceId) - if (hashTree[index] && hashTree[index].projectId) { - this.projectIds.delete(hashTree[index].projectId); - if (this.projectEnvMap.has(hashTree[index].projectId)) { - this.projectEnvMap.delete(hashTree[index].projectId); - } - } hashTree.splice(index, 1); this.sort(); this.reload(); + this.initProjectIds(); } } }); @@ -992,9 +983,6 @@ } return size; }, - beforeDestroy() { - getProject.$off('addProjectEnv'); - }, handleEnv() { this.$refs.apiScenarioEnv.open(); }, @@ -1006,6 +994,17 @@ this.projectList = res.data; }) }, + refReload() { + this.initProjectIds(); + this.reload(); + }, + initProjectIds() { + this.projectIds.clear(); + this.scenarioDefinition.forEach(data=>{ + let arr = jsonPath.query(data, "$..projectId"); + arr.forEach(a => this.projectIds.add(a)); + }) + } } } diff --git a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue index 93d437382e..281c466aea 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue @@ -62,7 +62,9 @@ export default { // 固定环境列表渲染顺序 let temp = this.data.find(dt => dt.id === id); temp.envs = envs; - temp.selectEnv = this.envMap.get(id); + let envId = this.envMap.get(id); + // 选中环境是否存在 + temp.selectEnv = envs.filter(e =>e.id === envId).length === 0 ? null : envId; }) }) }, diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 40189f0feb..1f48fe7912 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -71,7 +71,6 @@ import ApiBaseComponent from "../common/ApiBaseComponent"; import ApiResponseComponent from "./ApiResponseComponent"; import CustomizeReqInfo from "@/business/components/api/automation/scenario/common/CustomizeReqInfo"; - import {getProject} from "@/business/components/api/automation/scenario/event"; export default { name: "MsApiComponent", @@ -123,7 +122,6 @@ } } } - getProject.$emit('addProjectEnv', this.request.projectId, this.currentEnvironmentId); }, computed: { displayColor() { diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue index 9658c5a521..a0b2873f78 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -29,7 +29,6 @@ import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters"; import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm"; import ApiBaseComponent from "../common/ApiBaseComponent"; - import {getProject} from "@/business/components/api/automation/scenario/event"; import {getCurrentProjectID} from "@/common/js/utils"; export default { @@ -49,7 +48,6 @@ if (!this.scenario.projectId) { this.scenario.projectId = getCurrentProjectID(); } - getProject.$emit('addProjectEnv', this.scenario.projectId, this.currentEnvironmentId); if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) { this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => { if (response.data) { diff --git a/frontend/src/business/components/api/automation/scenario/event.js b/frontend/src/business/components/api/automation/scenario/event.js deleted file mode 100644 index 858344afcd..0000000000 --- a/frontend/src/business/components/api/automation/scenario/event.js +++ /dev/null @@ -1,2 +0,0 @@ -import Vue from 'vue'; -export const getProject = new Vue();