feat(接口定义): 统一项目获取方式
This commit is contained in:
parent
61f78bb4d0
commit
8bfcf45844
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<ms-container>
|
<ms-container>
|
||||||
<ms-aside-container>
|
<ms-aside-container>
|
||||||
<ms-node-tree @selectModule="selectModule" @getApiModuleTree="initTree" @changeProject="changeProject" @changeProtocol="changeProtocol"
|
<ms-node-tree @selectModule="selectModule" @getApiModuleTree="initTree" @changeProtocol="changeProtocol"
|
||||||
@refresh="refresh" @saveAsEdit="editApi" @debug="debug" @exportAPI="exportAPI"/>
|
@refresh="refresh" @saveAsEdit="editApi" @debug="debug" @exportAPI="exportAPI"/>
|
||||||
</ms-aside-container>
|
</ms-aside-container>
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
||||||
<!-- 列表集合 -->
|
<!-- 列表集合 -->
|
||||||
<ms-api-list
|
<ms-api-list
|
||||||
v-if="item.type === 'list'"
|
v-if="item.type === 'list'"
|
||||||
:current-project="currentProject"
|
|
||||||
:current-protocol="currentProtocol"
|
:current-protocol="currentProtocol"
|
||||||
:current-module="currentModule"
|
:current-module="currentModule"
|
||||||
@editApi="editApi"
|
@editApi="editApi"
|
||||||
|
@ -38,7 +37,6 @@
|
||||||
<!-- 添加测试窗口-->
|
<!-- 添加测试窗口-->
|
||||||
<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 @runTest="runTest" @saveApi="saveApi" :current-api="currentApi"
|
<ms-api-config @runTest="runTest" @saveApi="saveApi" :current-api="currentApi"
|
||||||
:currentProject="currentProject"
|
|
||||||
:currentProtocol="currentProtocol"
|
:currentProtocol="currentProtocol"
|
||||||
:moduleOptions="moduleOptions" ref="apiConfig"/>
|
:moduleOptions="moduleOptions" ref="apiConfig"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,17 +44,17 @@
|
||||||
<!-- 快捷调试 -->
|
<!-- 快捷调试 -->
|
||||||
<div v-else-if="item.type=== 'debug'" class="ms-api-div">
|
<div v-else-if="item.type=== 'debug'" class="ms-api-div">
|
||||||
<ms-debug-http-page :currentProtocol="currentProtocol" @saveAs="editApi" v-if="currentProtocol==='HTTP'"/>
|
<ms-debug-http-page :currentProtocol="currentProtocol" @saveAs="editApi" v-if="currentProtocol==='HTTP'"/>
|
||||||
<ms-debug-jdbc-page :currentProtocol="currentProtocol" :currentProject="currentProject" @saveAs="editApi" v-if="currentProtocol==='SQL'"/>
|
<ms-debug-jdbc-page :currentProtocol="currentProtocol" @saveAs="editApi" v-if="currentProtocol==='SQL'"/>
|
||||||
<ms-debug-tcp-page :currentProtocol="currentProtocol" :currentProject="currentProject" @saveAs="editApi" v-if="currentProtocol==='TCP'"/>
|
<ms-debug-tcp-page :currentProtocol="currentProtocol" @saveAs="editApi" v-if="currentProtocol==='TCP'"/>
|
||||||
<ms-debug-dubbo-page :currentProtocol="currentProtocol" :currentProject="currentProject" @saveAs="editApi" v-if="currentProtocol==='DUBBO'"/>
|
<ms-debug-dubbo-page :currentProtocol="currentProtocol" @saveAs="editApi" v-if="currentProtocol==='DUBBO'"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 测试-->
|
<!-- 测试-->
|
||||||
<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 :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" :currentProject="currentProject" v-if="currentProtocol==='HTTP'"/>
|
<ms-run-test-http-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='HTTP'"/>
|
||||||
<ms-run-test-tcp-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" :currentProject="currentProject" v-if="currentProtocol==='TCP'"/>
|
<ms-run-test-tcp-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='TCP'"/>
|
||||||
<ms-run-test-sql-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" :currentProject="currentProject" v-if="currentProtocol==='SQL'"/>
|
<ms-run-test-sql-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='SQL'"/>
|
||||||
<ms-run-test-dubbo-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" :currentProject="currentProject" v-if="currentProtocol==='DUBBO'"/>
|
<ms-run-test-dubbo-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='DUBBO'"/>
|
||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
|
@ -84,8 +82,7 @@
|
||||||
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
|
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
|
||||||
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
|
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
|
||||||
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
|
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
|
||||||
|
import {downloadFile, getCurrentUser, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import {downloadFile, getCurrentUser, getUUID} from "@/common/js/utils";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiDefinition",
|
name: "ApiDefinition",
|
||||||
|
@ -118,7 +115,6 @@
|
||||||
return {
|
return {
|
||||||
isHide: true,
|
isHide: true,
|
||||||
apiDefaultTab: 'default',
|
apiDefaultTab: 'default',
|
||||||
currentProject: null,
|
|
||||||
currentProtocol: null,
|
currentProtocol: null,
|
||||||
currentModule: null,
|
currentModule: null,
|
||||||
currentApi: {},
|
currentApi: {},
|
||||||
|
@ -209,7 +205,7 @@
|
||||||
if (!this.$refs.apiList[0].tableData) {
|
if (!this.$refs.apiList[0].tableData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let obj = {projectName: this.currentProject.name, protocol: this.currentProtocol, data: this.$refs.apiList[0].tableData}
|
let obj = {projectName: getCurrentProjectID(), protocol: this.currentProtocol, data: this.$refs.apiList[0].tableData}
|
||||||
downloadFile("导出API.json", JSON.stringify(obj));
|
downloadFile("导出API.json", JSON.stringify(obj));
|
||||||
},
|
},
|
||||||
refresh(data) {
|
refresh(data) {
|
||||||
|
@ -236,9 +232,6 @@
|
||||||
initTree(data) {
|
initTree(data) {
|
||||||
this.moduleOptions = data;
|
this.moduleOptions = data;
|
||||||
},
|
},
|
||||||
changeProject(data) {
|
|
||||||
this.currentProject = data;
|
|
||||||
},
|
|
||||||
changeProtocol(data) {
|
changeProtocol(data) {
|
||||||
this.currentProtocol = data;
|
this.currentProtocol = data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,9 +142,9 @@
|
||||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||||
|
|
||||||
<ms-api-request-form :is-read-only="isReadOnly" :headers="item.request.headers " :request="item.request" v-if="api.protocol==='HTTP'"/>
|
<ms-api-request-form :is-read-only="isReadOnly" :headers="item.request.headers " :request="item.request" v-if="api.protocol==='HTTP'"/>
|
||||||
<ms-tcp-basis-parameters :request="item.request" :currentProject="currentProject" v-if="api.protocol==='TCP'"/>
|
<ms-tcp-basis-parameters :request="item.request" v-if="api.protocol==='TCP'"/>
|
||||||
<ms-sql-basis-parameters :request="item.request" :currentProject="currentProject" v-if="api.protocol==='SQL'"/>
|
<ms-sql-basis-parameters :request="item.request" v-if="api.protocol==='SQL'"/>
|
||||||
<ms-dubbo-basis-parameters :request="item.request" :currentProject="currentProject" v-if="api.protocol==='DUBBO'"/>
|
<ms-dubbo-basis-parameters :request="item.request" v-if="api.protocol==='DUBBO'"/>
|
||||||
<!-- 保存操作 -->
|
<!-- 保存操作 -->
|
||||||
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)">
|
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)">
|
||||||
{{$t('commons.save')}}
|
{{$t('commons.save')}}
|
||||||
|
@ -168,7 +168,7 @@
|
||||||
import MsTag from "../../../common/components/MsTag";
|
import MsTag from "../../../common/components/MsTag";
|
||||||
import MsTipButton from "../../../common/components/MsTipButton";
|
import MsTipButton from "../../../common/components/MsTipButton";
|
||||||
import MsApiRequestForm from "./request/http/ApiRequestForm";
|
import MsApiRequestForm from "./request/http/ApiRequestForm";
|
||||||
import {downloadFile, getUUID} from "@/common/js/utils";
|
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import {parseEnvironment} from "../model/EnvironmentModel";
|
import {parseEnvironment} from "../model/EnvironmentModel";
|
||||||
import ApiEnvironmentConfig from "./environment/ApiEnvironmentConfig";
|
import ApiEnvironmentConfig from "./environment/ApiEnvironmentConfig";
|
||||||
import {PRIORITY, RESULT_MAP} from "../model/JsonData";
|
import {PRIORITY, RESULT_MAP} from "../model/JsonData";
|
||||||
|
@ -203,7 +203,6 @@
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
loaded: Boolean,
|
loaded: Boolean,
|
||||||
currentProject: {},
|
|
||||||
refreshSign: String,
|
refreshSign: String,
|
||||||
currentRow: Object,
|
currentRow: Object,
|
||||||
},
|
},
|
||||||
|
@ -221,6 +220,7 @@
|
||||||
loading: false,
|
loading: false,
|
||||||
runData: [],
|
runData: [],
|
||||||
reportId: "",
|
reportId: "",
|
||||||
|
projectId: "",
|
||||||
checkedCases: new Set(),
|
checkedCases: new Set(),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -233,12 +233,6 @@
|
||||||
}
|
}
|
||||||
this.getApiTest();
|
this.getApiTest();
|
||||||
},
|
},
|
||||||
currentProject() {
|
|
||||||
if (this.currentRow) {
|
|
||||||
this.currentRow.cases = [];
|
|
||||||
}
|
|
||||||
this.getEnvironments();
|
|
||||||
},
|
|
||||||
refreshSign() {
|
refreshSign() {
|
||||||
if (this.currentRow) {
|
if (this.currentRow) {
|
||||||
this.currentRow.cases = [];
|
this.currentRow.cases = [];
|
||||||
|
@ -250,6 +244,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.projectId = getCurrentProjectID();
|
||||||
this.getEnvironments();
|
this.getEnvironments();
|
||||||
if (this.createCase) {
|
if (this.createCase) {
|
||||||
this.sysAddition();
|
this.sysAddition();
|
||||||
|
@ -438,8 +433,8 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
if (this.currentProject) {
|
if (this.projectId) {
|
||||||
this.$get('/api/environment/list/' + this.currentProject.id, 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);
|
||||||
|
@ -460,11 +455,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
if (!this.currentProject) {
|
if (!this.projectId) {
|
||||||
this.$error(this.$t('api_test.select_project'));
|
this.$error(this.$t('api_test.select_project'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$refs.environmentConfig.open(this.currentProject.id);
|
this.$refs.environmentConfig.open(this.projectId);
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
|
|
@ -3,17 +3,16 @@
|
||||||
<div class="card-container">
|
<div class="card-container">
|
||||||
<!-- HTTP 请求参数 -->
|
<!-- HTTP 请求参数 -->
|
||||||
<ms-edit-complete-http-api @runTest="runTest" @saveApi="saveApi" :request="request" :response="response"
|
<ms-edit-complete-http-api @runTest="runTest" @saveApi="saveApi" :request="request" :response="response"
|
||||||
:basisData="currentApi" :moduleOptions="moduleOptions" :currentProject="currentProject" v-if="currentProtocol === 'HTTP'"/>
|
:basisData="currentApi" :moduleOptions="moduleOptions" v-if="currentProtocol === 'HTTP'"/>
|
||||||
<!-- TCP -->
|
<!-- TCP -->
|
||||||
<ms-edit-complete-tcp-api :request="request" @runTest="runTest" @saveApi="saveApi" :currentProject="currentProject" :basisData="currentApi"
|
<ms-edit-complete-tcp-api :request="request" @runTest="runTest" @saveApi="saveApi" :basisData="currentApi"
|
||||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'TCP'"/>
|
:moduleOptions="moduleOptions" v-if="currentProtocol === 'TCP'"/>
|
||||||
<!--DUBBO-->
|
<!--DUBBO-->
|
||||||
<ms-edit-complete-dubbo-api :request="request" @runTest="runTest" @saveApi="saveApi" :currentProject="currentProject" :basisData="currentApi"
|
<ms-edit-complete-dubbo-api :request="request" @runTest="runTest" @saveApi="saveApi" :basisData="currentApi"
|
||||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'DUBBO'"/>
|
:moduleOptions="moduleOptions" v-if="currentProtocol === 'DUBBO'"/>
|
||||||
<!--SQL-->
|
<!--SQL-->
|
||||||
<ms-edit-complete-sql-api :request="request" @runTest="runTest" @saveApi="saveApi" :currentProject="currentProject" :basisData="currentApi"
|
<ms-edit-complete-sql-api :request="request" @runTest="runTest" @saveApi="saveApi" :basisData="currentApi"
|
||||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'SQL'"/>
|
:moduleOptions="moduleOptions" v-if="currentProtocol === 'SQL'"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
import MsEditCompleteSqlApi from "./complete/EditCompleteSQLApi";
|
import MsEditCompleteSqlApi from "./complete/EditCompleteSQLApi";
|
||||||
|
|
||||||
import {ResponseFactory, Body} from "../model/ApiTestModel";
|
import {ResponseFactory, Body} from "../model/ApiTestModel";
|
||||||
import {getUUID} from "@/common/js/utils";
|
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import {createComponent, Request} from "./jmeter/components";
|
import {createComponent, Request} from "./jmeter/components";
|
||||||
import Sampler from "./jmeter/components/sampler/sampler";
|
import Sampler from "./jmeter/components/sampler/sampler";
|
||||||
import {WORKSPACE_ID} from '@/common/js/constants';
|
import {WORKSPACE_ID} from '@/common/js/constants';
|
||||||
|
@ -38,16 +37,17 @@
|
||||||
request: Sampler,
|
request: Sampler,
|
||||||
config: {},
|
config: {},
|
||||||
response: {},
|
response: {},
|
||||||
|
projectId: "",
|
||||||
maintainerOptions: [],
|
maintainerOptions: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
currentApi: {},
|
currentApi: {},
|
||||||
moduleOptions: {},
|
moduleOptions: {},
|
||||||
currentProject: {},
|
|
||||||
currentProtocol: String,
|
currentProtocol: String,
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.projectId = getCurrentProjectID();
|
||||||
this.getMaintainerOptions();
|
this.getMaintainerOptions();
|
||||||
switch (this.currentProtocol) {
|
switch (this.currentProtocol) {
|
||||||
case Request.TYPES.SQL:
|
case Request.TYPES.SQL:
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setParameters(data) {
|
setParameters(data) {
|
||||||
data.projectId = this.currentProject.id;
|
data.projectId = this.projectId;
|
||||||
this.request.name = this.currentApi.name;
|
this.request.name = this.currentApi.name;
|
||||||
data.protocol = this.currentProtocol;
|
data.protocol = this.currentProtocol;
|
||||||
data.request = this.request;
|
data.request = this.request;
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
<div id="svgResize"/>
|
<div id="svgResize"/>
|
||||||
<div id="svgDown">
|
<div id="svgDown">
|
||||||
<ms-bottom-container v-bind:enableAsideHidden="isHide">
|
<ms-bottom-container v-bind:enableAsideHidden="isHide">
|
||||||
<ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="initApiTable" :visible="visible" :currentRow="currentRow" :api="selectApi" :current-project="currentProject"/>
|
<ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="initApiTable" :visible="visible" :currentRow="currentRow" :api="selectApi"/>
|
||||||
</ms-bottom-container>
|
</ms-bottom-container>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -112,7 +112,8 @@
|
||||||
import MsContainer from "../../../common/components/MsContainer";
|
import MsContainer from "../../../common/components/MsContainer";
|
||||||
import MsBottomContainer from "./BottomContainer";
|
import MsBottomContainer from "./BottomContainer";
|
||||||
import ShowMoreBtn from "../../../../components/track/case/components/ShowMoreBtn";
|
import ShowMoreBtn from "../../../../components/track/case/components/ShowMoreBtn";
|
||||||
import {API_METHOD_COLOUR, FILTER_MAP_1, FILTER_MAP_2} from "../model/JsonData";
|
import {API_METHOD_COLOUR} from "../model/JsonData";
|
||||||
|
import {getCurrentProjectID} from "@/common/js/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiList",
|
name: "ApiList",
|
||||||
|
@ -142,11 +143,11 @@
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
|
projectId: "",
|
||||||
screenHeight: document.documentElement.clientHeight - 330,//屏幕高度
|
screenHeight: document.documentElement.clientHeight - 330,//屏幕高度
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
currentProject: Object,
|
|
||||||
currentProtocol: String,
|
currentProtocol: String,
|
||||||
currentModule: Object,
|
currentModule: Object,
|
||||||
visible: {
|
visible: {
|
||||||
|
@ -158,16 +159,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
this.projectId = getCurrentProjectID();
|
||||||
this.initApiTable();
|
this.initApiTable();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.dragControllerDiv();
|
this.dragControllerDiv();
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentProject() {
|
|
||||||
this.initApiTable();
|
|
||||||
this.apiCaseClose();
|
|
||||||
},
|
|
||||||
currentModule() {
|
currentModule() {
|
||||||
this.initApiTable();
|
this.initApiTable();
|
||||||
this.apiCaseClose();
|
this.apiCaseClose();
|
||||||
|
@ -191,8 +189,8 @@
|
||||||
this.condition.moduleIds = this.currentModule.ids;
|
this.condition.moduleIds = this.currentModule.ids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.currentProject != null) {
|
if (this.projectId != null) {
|
||||||
this.condition.projectId = this.currentProject.id;
|
this.condition.projectId = this.projectId;
|
||||||
}
|
}
|
||||||
if (this.currentProtocol != null) {
|
if (this.currentProtocol != null) {
|
||||||
this.condition.protocol = this.currentProtocol;
|
this.condition.protocol = this.currentProtocol;
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-loading="result.loading">
|
<div v-loading="result.loading">
|
||||||
<select-menu
|
|
||||||
:data="projects"
|
|
||||||
:current-data="currentProject"
|
|
||||||
:title="$t('test_track.project')"
|
|
||||||
@dataChange="changeProject" style="margin-bottom: 20px"/>
|
|
||||||
|
|
||||||
<el-select style="width: 100px ;height: 30px" size="small" v-model="protocol" @change="changeProtocol">
|
<el-select style="width: 100px ;height: 30px" size="small" v-model="protocol" @change="changeProtocol">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in options"
|
v-for="item in options"
|
||||||
|
@ -95,7 +89,7 @@
|
||||||
</el-tree>
|
</el-tree>
|
||||||
|
|
||||||
<ms-add-basis-api :current-protocol="protocol" ref="basisApi"></ms-add-basis-api>
|
<ms-add-basis-api :current-protocol="protocol" ref="basisApi"></ms-add-basis-api>
|
||||||
<api-import ref="apiImport" :project-id="currentProject.id" @refresh="refresh"/>
|
<api-import ref="apiImport" :project-id="projectId" @refresh="refresh"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -106,6 +100,7 @@
|
||||||
import SelectMenu from "../../../track/common/SelectMenu";
|
import SelectMenu from "../../../track/common/SelectMenu";
|
||||||
import {OPTIONS, DEFAULT_DATA} from "../model/JsonData";
|
import {OPTIONS, DEFAULT_DATA} from "../model/JsonData";
|
||||||
import ApiImport from "./import/ApiImport";
|
import ApiImport from "./import/ApiImport";
|
||||||
|
import {getCurrentProjectID} from "@/common/js/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MsApiModule',
|
name: 'MsApiModule',
|
||||||
|
@ -123,43 +118,36 @@
|
||||||
expandedNode: [],
|
expandedNode: [],
|
||||||
filterText: "",
|
filterText: "",
|
||||||
nextFlag: true,
|
nextFlag: true,
|
||||||
currentProject: {},
|
projectId: "",
|
||||||
projects: [],
|
|
||||||
data: DEFAULT_DATA,
|
data: DEFAULT_DATA,
|
||||||
currentModule: {},
|
currentModule: {},
|
||||||
newLabel: ""
|
newLabel: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getProjects();
|
this.projectId = getCurrentProjectID();
|
||||||
this.changeProtocol();
|
this.changeProtocol();
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentProject() {
|
|
||||||
this.getApiModuleTree();
|
|
||||||
this.$emit('changeProject', this.currentProject);
|
|
||||||
},
|
|
||||||
filterText(val) {
|
filterText(val) {
|
||||||
this.$refs.tree.filter(val);
|
this.$refs.tree.filter(val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getApiModuleTree() {
|
getApiModuleTree() {
|
||||||
if (this.currentProject) {
|
if (this.expandedNode.length === 0) {
|
||||||
if (this.expandedNode.length === 0) {
|
this.expandedNode.push("root");
|
||||||
this.expandedNode.push("root");
|
|
||||||
}
|
|
||||||
this.result = this.$get("/api/module/list/" + this.currentProject.id + "/" + this.protocol, response => {
|
|
||||||
if (response.data != undefined && response.data != null) {
|
|
||||||
this.data[1].children = response.data;
|
|
||||||
let moduleOptions = [];
|
|
||||||
this.data[1].children.forEach(node => {
|
|
||||||
this.buildNodePath(node, {path: ''}, moduleOptions);
|
|
||||||
});
|
|
||||||
this.$emit('getApiModuleTree', moduleOptions);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
this.result = this.$get("/api/module/list/" + this.projectId + "/" + this.protocol, response => {
|
||||||
|
if (response.data != undefined && response.data != null) {
|
||||||
|
this.data[1].children = response.data;
|
||||||
|
let moduleOptions = [];
|
||||||
|
this.data[1].children.forEach(node => {
|
||||||
|
this.buildNodePath(node, {path: ''}, moduleOptions);
|
||||||
|
});
|
||||||
|
this.$emit('getApiModuleTree', moduleOptions);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
handleCommand(e) {
|
handleCommand(e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
|
@ -364,7 +352,7 @@
|
||||||
},
|
},
|
||||||
// 保存或修改
|
// 保存或修改
|
||||||
editApiModule(node, data) {
|
editApiModule(node, data) {
|
||||||
if (!this.currentProject) {
|
if (!this.projectId) {
|
||||||
this.$error("$t('api_test.select_project')");
|
this.$error("$t('api_test.select_project')");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +371,7 @@
|
||||||
data.nodeIds = ids;
|
data.nodeIds = ids;
|
||||||
}
|
}
|
||||||
data.protocol = this.protocol;
|
data.protocol = this.protocol;
|
||||||
data.projectId = this.currentProject.id;
|
data.projectId = this.projectId;
|
||||||
this.$post(url, data, () => {
|
this.$post(url, data, () => {
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
this.getApiModuleTree();
|
this.getApiModuleTree();
|
||||||
|
@ -420,20 +408,7 @@
|
||||||
return data.name.indexOf(value) !== -1;
|
return data.name.indexOf(value) !== -1;
|
||||||
},
|
},
|
||||||
addApi() {
|
addApi() {
|
||||||
this.$refs.basisApi.open(this.currentModule, this.currentProject.id);
|
this.$refs.basisApi.open(this.currentModule, this.projectId);
|
||||||
},
|
|
||||||
// 项目相关方法
|
|
||||||
changeProject(project) {
|
|
||||||
this.currentProject = project;
|
|
||||||
},
|
|
||||||
getProjects() {
|
|
||||||
let projectId;
|
|
||||||
this.$get("/project/listAll", (response) => {
|
|
||||||
this.projects = response.data;
|
|
||||||
if (this.projects.length > 0) {
|
|
||||||
this.currentProject = this.projects[0];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
nodeExpand(data) {
|
nodeExpand(data) {
|
||||||
if (data.id) {
|
if (data.id) {
|
||||||
|
|
|
@ -80,7 +80,6 @@
|
||||||
basicForm: {},
|
basicForm: {},
|
||||||
httpVisible: false,
|
httpVisible: false,
|
||||||
currentModule: {},
|
currentModule: {},
|
||||||
projectId: "",
|
|
||||||
maintainerOptions: [],
|
maintainerOptions: [],
|
||||||
rule: {
|
rule: {
|
||||||
name: [
|
name: [
|
||||||
|
|
|
@ -22,10 +22,9 @@
|
||||||
|
|
||||||
<!-- 请求参数 -->
|
<!-- 请求参数 -->
|
||||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||||
<ms-basis-parameters :request="request" :currentProject="currentProject"/>
|
<ms-basis-parameters :request="request"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -40,7 +39,6 @@
|
||||||
props: {
|
props: {
|
||||||
request: {},
|
request: {},
|
||||||
basisData: {},
|
basisData: {},
|
||||||
currentProject: {},
|
|
||||||
moduleOptions: Array,
|
moduleOptions: Array,
|
||||||
isReadOnly: {
|
isReadOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -57,10 +55,6 @@
|
||||||
validateApi() {
|
validateApi() {
|
||||||
this.validated = false;
|
this.validated = false;
|
||||||
this.basisData.method = this.request.protocol;
|
this.basisData.method = this.request.protocol;
|
||||||
if (this.currentProject === null) {
|
|
||||||
this.$error(this.$t('api_test.select_project'), 2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs['basicForm'].validate();
|
this.$refs['basicForm'].validate();
|
||||||
},
|
},
|
||||||
saveApi() {
|
saveApi() {
|
||||||
|
|
|
@ -103,13 +103,9 @@
|
||||||
options: API_STATUS,
|
options: API_STATUS,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {moduleOptions: {}, currentProject: {}, request: {}, response: {}, basisData: {}},
|
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}},
|
||||||
methods: {
|
methods: {
|
||||||
runTest() {
|
runTest() {
|
||||||
if (this.currentProject === null) {
|
|
||||||
this.$error(this.$t('api_test.select_project'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs['httpForm'].validate((valid) => {
|
this.$refs['httpForm'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.setParameter();
|
this.setParameter();
|
||||||
|
@ -132,10 +128,6 @@
|
||||||
this.httpForm.request.useEnvironment = undefined;
|
this.httpForm.request.useEnvironment = undefined;
|
||||||
},
|
},
|
||||||
saveApi() {
|
saveApi() {
|
||||||
if (this.currentProject === null) {
|
|
||||||
this.$error(this.$t('api_test.select_project'), 2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs['httpForm'].validate((valid) => {
|
this.$refs['httpForm'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.setParameter();
|
this.setParameter();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<!-- 请求参数 -->
|
<!-- 请求参数 -->
|
||||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||||
<ms-basis-parameters :request="request" :currentProject="currentProject"/>
|
<ms-basis-parameters :request="request"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -38,7 +38,6 @@
|
||||||
props: {
|
props: {
|
||||||
request: {},
|
request: {},
|
||||||
basisData: {},
|
basisData: {},
|
||||||
currentProject: {},
|
|
||||||
moduleOptions: Array,
|
moduleOptions: Array,
|
||||||
isReadOnly: {
|
isReadOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -55,10 +54,6 @@
|
||||||
},
|
},
|
||||||
validateApi() {
|
validateApi() {
|
||||||
this.validated = false;
|
this.validated = false;
|
||||||
if (this.currentProject === null) {
|
|
||||||
this.$error(this.$t('api_test.select_project'), 2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs['basicForm'].validate();
|
this.$refs['basicForm'].validate();
|
||||||
},
|
},
|
||||||
saveApi() {
|
saveApi() {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<!-- 请求参数 -->
|
<!-- 请求参数 -->
|
||||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||||
<ms-basis-parameters :request="request" :currentProject="currentProject"/>
|
<ms-basis-parameters :request="request"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@
|
||||||
props: {
|
props: {
|
||||||
request: {},
|
request: {},
|
||||||
basisData: {},
|
basisData: {},
|
||||||
currentProject: {},
|
|
||||||
moduleOptions: Array,
|
moduleOptions: Array,
|
||||||
isReadOnly: {
|
isReadOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -57,10 +56,6 @@
|
||||||
validateApi() {
|
validateApi() {
|
||||||
this.validated = false;
|
this.validated = false;
|
||||||
this.basisData.method = "TCP";
|
this.basisData.method = "TCP";
|
||||||
if (this.currentProject === null) {
|
|
||||||
this.$error(this.$t('api_test.select_project'), 2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs['basicForm'].validate();
|
this.$refs['basicForm'].validate();
|
||||||
},
|
},
|
||||||
saveApi() {
|
saveApi() {
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
import {Assertions, Extract} from "../../../model/ApiTestModel";
|
import {Assertions, Extract} from "../../../model/ApiTestModel";
|
||||||
import {parseEnvironment} from "../../../model/EnvironmentModel";
|
import {parseEnvironment} from "../../../model/EnvironmentModel";
|
||||||
import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig";
|
import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig";
|
||||||
|
import {getCurrentProjectID} from "@/common/js/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsDatabaseConfig",
|
name: "MsDatabaseConfig",
|
||||||
|
@ -171,10 +172,6 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
validate() {
|
validate() {
|
||||||
if (this.currentProject === null) {
|
|
||||||
this.$error(this.$t('api_test.select_project'), 2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs['request'].validate((valid) => {
|
this.$refs['request'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$emit('callback');
|
this.$emit('callback');
|
||||||
|
@ -190,23 +187,17 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
if (this.currentProject) {
|
this.environments = [];
|
||||||
this.environments = [];
|
this.$get('/api/environment/list/' + getCurrentProjectID(), response => {
|
||||||
this.$get('/api/environment/list/' + this.currentProject.id, response => {
|
this.environments = response.data;
|
||||||
this.environments = response.data;
|
this.environments.forEach(environment => {
|
||||||
this.environments.forEach(environment => {
|
parseEnvironment(environment);
|
||||||
parseEnvironment(environment);
|
|
||||||
});
|
|
||||||
this.initDataSource();
|
|
||||||
});
|
});
|
||||||
}
|
this.initDataSource();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
if (!this.currentProject) {
|
this.$refs.environmentConfig.open(getCurrentProjectID());
|
||||||
this.$error(this.$t('api_test.select_project'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.environmentConfig.open(this.currentProject.id);
|
|
||||||
},
|
},
|
||||||
initDataSource() {
|
initDataSource() {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||||
<!-- TCP 请求参数 -->
|
<!-- TCP 请求参数 -->
|
||||||
<ms-basis-parameters :request="api.request" :currentProject="currentProject" ref="requestForm"/>
|
<ms-basis-parameters :request="api.request" ref="requestForm"/>
|
||||||
|
|
||||||
<!--返回结果-->
|
<!--返回结果-->
|
||||||
<!-- HTTP 请求返回数据 -->
|
<!-- HTTP 请求返回数据 -->
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
<!-- 加载用例 -->
|
<!-- 加载用例 -->
|
||||||
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%">
|
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%">
|
||||||
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api"
|
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api"
|
||||||
:currentProject="currentProject" :loaded="loaded" :refreshSign="refreshSign" :createCase="createCase"
|
:loaded="loaded" :refreshSign="refreshSign" :createCase="createCase"
|
||||||
ref="caseList"/>
|
ref="caseList"/>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
>
|
>
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
||||||
import {downloadFile, getUUID} from "@/common/js/utils";
|
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import MsApiCaseList from "../ApiCaseList";
|
import MsApiCaseList from "../ApiCaseList";
|
||||||
import MsContainer from "../../../../common/components/MsContainer";
|
import MsContainer from "../../../../common/components/MsContainer";
|
||||||
import MsBottomContainer from "../BottomContainer";
|
import MsBottomContainer from "../BottomContainer";
|
||||||
|
@ -56,7 +56,6 @@
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import MsRun from "../Run";
|
import MsRun from "../Run";
|
||||||
import MsBasisParameters from "../request/dubbo/BasisParameters";
|
import MsBasisParameters from "../request/dubbo/BasisParameters";
|
||||||
|
|
||||||
import {REQ_METHOD} from "../../model/JsonData";
|
import {REQ_METHOD} from "../../model/JsonData";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -92,7 +91,7 @@
|
||||||
reportId: "",
|
reportId: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {apiData: {}, currentProject: {}, currentProtocol: String,},
|
props: {apiData: {}, currentProtocol: String,},
|
||||||
methods: {
|
methods: {
|
||||||
handleCommand(e) {
|
handleCommand(e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
|
@ -184,36 +183,27 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
if (this.currentProject) {
|
this.$get('/api/environment/list/' + getCurrentProjectID(), response => {
|
||||||
this.$get('/api/environment/list/' + this.currentProject.id, response => {
|
this.environments = response.data;
|
||||||
this.environments = response.data;
|
this.environments.forEach(environment => {
|
||||||
this.environments.forEach(environment => {
|
parseEnvironment(environment);
|
||||||
parseEnvironment(environment);
|
|
||||||
});
|
|
||||||
let hasEnvironment = false;
|
|
||||||
for (let i in this.environments) {
|
|
||||||
if (this.environments[i].id === this.api.environmentId) {
|
|
||||||
this.api.environment = this.environments[i];
|
|
||||||
hasEnvironment = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hasEnvironment) {
|
|
||||||
this.api.environmentId = '';
|
|
||||||
this.api.environment = undefined;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
let hasEnvironment = false;
|
||||||
this.api.environmentId = '';
|
for (let i in this.environments) {
|
||||||
this.api.environment = undefined;
|
if (this.environments[i].id === this.api.environmentId) {
|
||||||
}
|
this.api.environment = this.environments[i];
|
||||||
|
hasEnvironment = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasEnvironment) {
|
||||||
|
this.api.environmentId = '';
|
||||||
|
this.api.environment = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
if (!this.currentProject) {
|
this.$refs.environmentConfig.open(getCurrentProjectID());
|
||||||
this.$error(this.$t('api_test.select_project'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.environmentConfig.open(this.currentProject.id);
|
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
<!-- 加载用例 -->
|
<!-- 加载用例 -->
|
||||||
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%" ref="drawer">
|
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%" ref="drawer">
|
||||||
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api" :refreshSign="refreshSign"
|
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api" :refreshSign="refreshSign"
|
||||||
:currentProject="currentProject" :loaded="loaded" :createCase="createCase"
|
:loaded="loaded" :createCase="createCase"
|
||||||
ref="caseList"/>
|
ref="caseList"/>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
|
||||||
|
@ -87,14 +87,13 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
||||||
import {downloadFile, getUUID} from "@/common/js/utils";
|
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import MsApiCaseList from "../ApiCaseList";
|
import MsApiCaseList from "../ApiCaseList";
|
||||||
import MsContainer from "../../../../common/components/MsContainer";
|
import MsContainer from "../../../../common/components/MsContainer";
|
||||||
import {parseEnvironment} from "../../model/EnvironmentModel";
|
import {parseEnvironment} from "../../model/EnvironmentModel";
|
||||||
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
|
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import MsRun from "../Run";
|
import MsRun from "../Run";
|
||||||
|
|
||||||
import {REQ_METHOD} from "../../model/JsonData";
|
import {REQ_METHOD} from "../../model/JsonData";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -126,9 +125,10 @@
|
||||||
},
|
},
|
||||||
runData: [],
|
runData: [],
|
||||||
reportId: "",
|
reportId: "",
|
||||||
|
projectId: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {apiData: {}, currentProject: {}, currentProtocol: String,},
|
props: {apiData: {}, currentProtocol: String,},
|
||||||
methods: {
|
methods: {
|
||||||
handleCommand(e) {
|
handleCommand(e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
|
@ -226,8 +226,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
if (this.currentProject) {
|
if (this.projectId) {
|
||||||
this.$get('/api/environment/list/' + this.currentProject.id, 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);
|
||||||
|
@ -251,11 +251,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
if (!this.currentProject) {
|
if (!this.projectId) {
|
||||||
this.$error(this.$t('api_test.select_project'));
|
this.$error(this.$t('api_test.select_project'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$refs.environmentConfig.open(this.currentProject.id);
|
this.$refs.environmentConfig.open(this.projectId);
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
@ -279,6 +279,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.projectId = getCurrentProjectID();
|
||||||
this.api = this.apiData;
|
this.api = this.apiData;
|
||||||
this.api.protocol = this.currentProtocol;
|
this.api.protocol = this.currentProtocol;
|
||||||
this.currentRequest = this.api.request;
|
this.currentRequest = this.api.request;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||||
<!-- TCP 请求参数 -->
|
<!-- TCP 请求参数 -->
|
||||||
<ms-basis-parameters :request="api.request" @callback="runTest" :currentProject="currentProject" ref="requestForm"/>
|
<ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm"/>
|
||||||
|
|
||||||
<!--返回结果-->
|
<!--返回结果-->
|
||||||
<!-- HTTP 请求返回数据 -->
|
<!-- HTTP 请求返回数据 -->
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<!-- 加载用例 -->
|
<!-- 加载用例 -->
|
||||||
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%">
|
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%">
|
||||||
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api" :refreshSign="refreshSign"
|
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api" :refreshSign="refreshSign"
|
||||||
:currentProject="currentProject" :loaded="loaded" :createCase="createCase"
|
:loaded="loaded" :createCase="createCase"
|
||||||
ref="caseList"/>
|
ref="caseList"/>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
>
|
>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
||||||
import {downloadFile, getUUID} from "@/common/js/utils";
|
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import MsApiCaseList from "../ApiCaseList";
|
import MsApiCaseList from "../ApiCaseList";
|
||||||
import MsContainer from "../../../../common/components/MsContainer";
|
import MsContainer from "../../../../common/components/MsContainer";
|
||||||
import MsBottomContainer from "../BottomContainer";
|
import MsBottomContainer from "../BottomContainer";
|
||||||
|
@ -55,7 +55,6 @@
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import MsRun from "../Run";
|
import MsRun from "../Run";
|
||||||
import MsBasisParameters from "../request/database/BasisParameters";
|
import MsBasisParameters from "../request/database/BasisParameters";
|
||||||
|
|
||||||
import {REQ_METHOD} from "../../model/JsonData";
|
import {REQ_METHOD} from "../../model/JsonData";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -91,7 +90,7 @@
|
||||||
reportId: "",
|
reportId: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {apiData: {}, currentProject: {}, currentProtocol: String,},
|
props: {apiData: {}, currentProtocol: String,},
|
||||||
methods: {
|
methods: {
|
||||||
handleCommand(e) {
|
handleCommand(e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
|
@ -182,36 +181,27 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
if (this.currentProject) {
|
this.$get('/api/environment/list/' + getCurrentProjectID(), response => {
|
||||||
this.$get('/api/environment/list/' + this.currentProject.id, response => {
|
this.environments = response.data;
|
||||||
this.environments = response.data;
|
this.environments.forEach(environment => {
|
||||||
this.environments.forEach(environment => {
|
parseEnvironment(environment);
|
||||||
parseEnvironment(environment);
|
|
||||||
});
|
|
||||||
let hasEnvironment = false;
|
|
||||||
for (let i in this.environments) {
|
|
||||||
if (this.environments[i].id === this.api.environmentId) {
|
|
||||||
this.api.environment = this.environments[i];
|
|
||||||
hasEnvironment = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hasEnvironment) {
|
|
||||||
this.api.environmentId = '';
|
|
||||||
this.api.environment = undefined;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
let hasEnvironment = false;
|
||||||
this.api.environmentId = '';
|
for (let i in this.environments) {
|
||||||
this.api.environment = undefined;
|
if (this.environments[i].id === this.api.environmentId) {
|
||||||
}
|
this.api.environment = this.environments[i];
|
||||||
|
hasEnvironment = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasEnvironment) {
|
||||||
|
this.api.environmentId = '';
|
||||||
|
this.api.environment = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
if (!this.currentProject) {
|
this.$refs.environmentConfig.open(getCurrentProjectID());
|
||||||
this.$error(this.$t('api_test.select_project'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.environmentConfig.open(this.currentProject.id);
|
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||||
<!-- TCP 请求参数 -->
|
<!-- TCP 请求参数 -->
|
||||||
<ms-basis-parameters :request="api.request" @callback="runTest" :currentProject="currentProject" ref="requestForm"/>
|
<ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm"/>
|
||||||
|
|
||||||
<!--返回结果-->
|
<!--返回结果-->
|
||||||
<!-- HTTP 请求返回数据 -->
|
<!-- HTTP 请求返回数据 -->
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
<!-- 加载用例 -->
|
<!-- 加载用例 -->
|
||||||
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%">
|
<el-drawer :visible.sync="visible" direction="btt" :with-header="false" :modal="false" size="50%">
|
||||||
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api" :refreshSign="refreshSign"
|
<ms-api-case-list @apiCaseClose="apiCaseClose" @selectTestCase="selectTestCase" :api="api" :refreshSign="refreshSign"
|
||||||
:currentProject="currentProject" :loaded="loaded" :createCase="createCase"
|
:loaded="loaded" :createCase="createCase"
|
||||||
ref="caseList"/>
|
ref="caseList"/>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<!-- 环境 -->
|
<!-- 环境 -->
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
import MsApiRequestForm from "../request/http/ApiRequestForm";
|
||||||
import {downloadFile, getUUID} from "@/common/js/utils";
|
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import MsApiCaseList from "../ApiCaseList";
|
import MsApiCaseList from "../ApiCaseList";
|
||||||
import MsContainer from "../../../../common/components/MsContainer";
|
import MsContainer from "../../../../common/components/MsContainer";
|
||||||
import MsBottomContainer from "../BottomContainer";
|
import MsBottomContainer from "../BottomContainer";
|
||||||
|
@ -54,7 +54,6 @@
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import MsRun from "../Run";
|
import MsRun from "../Run";
|
||||||
import MsBasisParameters from "../request/tcp/BasisParameters";
|
import MsBasisParameters from "../request/tcp/BasisParameters";
|
||||||
|
|
||||||
import {REQ_METHOD} from "../../model/JsonData";
|
import {REQ_METHOD} from "../../model/JsonData";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -90,7 +89,7 @@
|
||||||
reportId: "",
|
reportId: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {apiData: {}, currentProject: {}, currentProtocol: String,},
|
props: {apiData: {}, currentProtocol: String,},
|
||||||
methods: {
|
methods: {
|
||||||
handleCommand(e) {
|
handleCommand(e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
|
@ -181,36 +180,27 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
if (this.currentProject) {
|
this.$get('/api/environment/list/' + getCurrentProjectID(), response => {
|
||||||
this.$get('/api/environment/list/' + this.currentProject.id, response => {
|
this.environments = response.data;
|
||||||
this.environments = response.data;
|
this.environments.forEach(environment => {
|
||||||
this.environments.forEach(environment => {
|
parseEnvironment(environment);
|
||||||
parseEnvironment(environment);
|
|
||||||
});
|
|
||||||
let hasEnvironment = false;
|
|
||||||
for (let i in this.environments) {
|
|
||||||
if (this.environments[i].id === this.api.environmentId) {
|
|
||||||
this.api.environment = this.environments[i];
|
|
||||||
hasEnvironment = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hasEnvironment) {
|
|
||||||
this.api.environmentId = '';
|
|
||||||
this.api.environment = undefined;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
let hasEnvironment = false;
|
||||||
this.api.environmentId = '';
|
for (let i in this.environments) {
|
||||||
this.api.environment = undefined;
|
if (this.environments[i].id === this.api.environmentId) {
|
||||||
}
|
this.api.environment = this.environments[i];
|
||||||
|
hasEnvironment = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasEnvironment) {
|
||||||
|
this.api.environmentId = '';
|
||||||
|
this.api.environment = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
if (!this.currentProject) {
|
this.$refs.environmentConfig.open(getCurrentProjectID());
|
||||||
this.$error(this.$t('api_test.select_project'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.environmentConfig.open(this.currentProject.id);
|
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
|
Loading…
Reference in New Issue