This commit is contained in:
fit2-zhao 2021-03-04 10:29:55 +08:00
commit 18d6322636
6 changed files with 21 additions and 25 deletions

View File

@ -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",

View File

@ -133,7 +133,7 @@
<!-- 步骤组件-->
<ms-component-config :type="data.type" :scenario="data" :response="response" :currentScenario="currentScenario"
:currentEnvironmentId="currentEnvironmentId" :node="node" :project-list="projectList" :env-map="projectEnvMap"
@remove="remove" @copyRow="copyRow" @suggestClick="suggestClick" @refReload="reload"/>
@remove="remove" @copyRow="copyRow" @suggestClick="suggestClick" @refReload="refReload"/>
</span>
</el-tree>
</div>
@ -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));
})
}
}
}
</script>

View File

@ -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;
})
})
},

View File

@ -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() {

View File

@ -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) {

View File

@ -1,2 +0,0 @@
import Vue from 'vue';
export const getProject = new Vue();