fix: 部分页面开启两个不项目窗口不同projectId问题

This commit is contained in:
chenjianxing 2021-01-28 15:30:44 +08:00
parent bacfd8fc64
commit 48e4b0806e
6 changed files with 28 additions and 28 deletions

View File

@ -59,6 +59,7 @@
<div v-else-if="item.type=== 'ADD'" class="ms-api-div">
<ms-api-config :syncTabs="syncTabs" @runTest="runTest" @saveApi="saveApi" @createRootModel="createRootModel" ref="apiConfig"
:current-api="item.api"
:project-id="projectId"
:currentProtocol="currentProtocol"
:moduleOptions="moduleOptions"/>
</div>
@ -76,14 +77,14 @@
<!-- 测试-->
<div v-else-if="item.type=== 'TEST'" class="ms-api-div">
<ms-run-test-http-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
@refresh="refresh" v-if="currentProtocol==='HTTP'"/>
<ms-run-test-tcp-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
@refresh="refresh" v-if="currentProtocol==='TCP'"/>
<ms-run-test-sql-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
@refresh="refresh" v-if="currentProtocol==='SQL'"/>
<ms-run-test-dubbo-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
@refresh="refresh" v-if="currentProtocol==='DUBBO'"/>
<ms-run-test-http-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @refresh="refresh" v-if="currentProtocol==='HTTP'"/>
<ms-run-test-tcp-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @refresh="refresh" v-if="currentProtocol==='TCP'"/>
<ms-run-test-sql-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @refresh="refresh" v-if="currentProtocol==='SQL'"/>
<ms-run-test-dubbo-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @refresh="refresh" v-if="currentProtocol==='DUBBO'"/>
</div>
</el-tab-pane>
@ -186,8 +187,12 @@
}],
isApiListEnable: true,
syncTabs: [],
projectId: ""
}
},
mounted() {
this.projectId = getCurrentProjectID();
},
watch: {
currentProtocol() {
this.handleCommand("CLOSE_ALL");
@ -248,7 +253,7 @@
}
},
handleTabAdd(e) {
if (!getCurrentProjectID()) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
@ -286,7 +291,7 @@
this.$refs.nodeTree.createRootModel();
},
handleTabsEdit(targetName, action, api) {
if (!getCurrentProjectID()) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
@ -325,7 +330,7 @@
this.$warning('用例列表暂不支持导出,请切换成接口列表');
return;
}
let obj = {projectName: getCurrentProjectID(), protocol: this.currentProtocol}
let obj = {projectName: this.projectId, protocol: this.currentProtocol}
if (this.$refs.apiList[0].selectRows && this.$refs.apiList[0].selectRows.size > 0) {
let arr = Array.from(this.$refs.apiList[0].selectRows);
obj.data = arr;
@ -339,7 +344,7 @@
["status", ["Prepare", "Underway", "Completed"]],
]
);
condition.projectId = getCurrentProjectID();
condition.projectId = this.projectId;
this.$post(url, condition, response => {
obj.data = response.data;
this.buildApiPath(obj.data);

View File

@ -38,7 +38,6 @@
request: Sampler,
config: {},
response: {},
projectId: "",
maintainerOptions: [],
}
},
@ -47,9 +46,9 @@
moduleOptions: {},
currentProtocol: String,
syncTabs: Array,
projectId: String
},
created() {
this.projectId = getCurrentProjectID();
this.getMaintainerOptions();
switch (this.currentProtocol) {
case Request.TYPES.SQL:

View File

@ -44,7 +44,7 @@
</template>
<script>
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import {downloadFile, getUUID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer";
import MsBottomContainer from "../BottomContainer";
@ -89,7 +89,7 @@
reportId: "",
}
},
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
methods: {
handleCommand(e) {
switch (e) {
@ -187,7 +187,7 @@
}
},
getEnvironments() {
this.$get('/api/environment/list/' + getCurrentProjectID(), response => {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
@ -207,7 +207,7 @@
});
},
openEnvironmentConfig() {
this.$refs.environmentConfig.open(getCurrentProjectID());
this.$refs.environmentConfig.open(this.projectId);
},
environmentChange(value) {
for (let i in this.environments) {

View File

@ -110,10 +110,9 @@
},
runData: [],
reportId: "",
projectId: "",
}
},
props: {apiData: {}, currentProtocol: String, syncTabs: Array},
props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
methods: {
handleCommand(e) {
switch (e) {
@ -232,7 +231,6 @@
}
},
created() {
this.projectId = getCurrentProjectID();
//
this.api = JSON.parse(JSON.stringify(this.apiData));
this.api.protocol = this.currentProtocol;

View File

@ -44,7 +44,7 @@
</template>
<script>
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import {downloadFile, getUUID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer";
import MsBottomContainer from "../BottomContainer";
@ -89,7 +89,7 @@
reportId: "",
}
},
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
methods: {
handleCommand(e) {
switch (e) {
@ -186,7 +186,7 @@
}
},
getEnvironments() {
this.$get('/api/environment/list/' + getCurrentProjectID(), response => {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
@ -206,7 +206,7 @@
});
},
openEnvironmentConfig() {
this.$refs.environmentConfig.open(getCurrentProjectID());
this.$refs.environmentConfig.open(this.projectId);
},
environmentChange(value) {
for (let i in this.environments) {

View File

@ -96,10 +96,9 @@
},
runData: [],
reportId: "",
projectId: ""
}
},
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
methods: {
handleCommand(e) {
switch (e) {
@ -214,7 +213,6 @@
this.api = JSON.parse(JSON.stringify(this.apiData));
this.api.protocol = this.currentProtocol;
this.currentRequest = this.api.request;
this.projectId = getCurrentProjectID();
this.getResult();
}
}