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

View File

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

View File

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

View File

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

View File

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

View File

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