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