fix(接口定义,接口自动化): 点击树节点 ,右侧Tab恢复到列表页面

This commit is contained in:
fit2-zhao 2021-03-23 19:37:48 +08:00
parent 41c46740b3
commit c02b8dff1b
2 changed files with 142 additions and 136 deletions

View File

@ -133,6 +133,9 @@
}); });
} }
} }
},
selectNodeIds() {
this.activeName = "default";
} }
}, },
methods: { methods: {

View File

@ -1,152 +1,152 @@
<template> <template>
<div> <div>
<ms-container v-if="renderComponent"> <ms-container v-if="renderComponent">
<ms-aside-container> <ms-aside-container>
<ms-api-module <ms-api-module
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@protocolChange="handleProtocolChange" @protocolChange="handleProtocolChange"
@refreshTable="refresh" @refreshTable="refresh"
@exportAPI="exportAPI" @exportAPI="exportAPI"
@debug="debug" @debug="debug"
@saveAsEdit="editApi" @saveAsEdit="editApi"
@setModuleOptions="setModuleOptions" @setModuleOptions="setModuleOptions"
@setNodeTree="setNodeTree" @setNodeTree="setNodeTree"
@enableTrash="enableTrash" @enableTrash="enableTrash"
:type="'edit'" :type="'edit'"
ref="nodeTree"/> ref="nodeTree"/>
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
<!-- 主框架列表 --> <!-- 主框架列表 -->
<el-tabs v-model="apiDefaultTab" @edit="handleTabRemove" @tab-click="addTab"> <el-tabs v-model="apiDefaultTab" @edit="handleTabRemove" @tab-click="addTab">
<el-tab-pane v-for="(item) in apiTabs" <el-tab-pane v-for="(item) in apiTabs"
:key="item.name" :key="item.name"
:label="item.title" :label="item.title"
:closable="item.closable" :closable="item.closable"
:name="item.name"> :name="item.name">
<ms-tab-button <ms-tab-button
v-if="item.type === 'list'" v-if="item.type === 'list'"
:active-dom.sync="activeDom" :active-dom.sync="activeDom"
:left-tip="$t('api_test.definition.api_title')" :left-tip="$t('api_test.definition.api_title')"
:right-tip="$t('api_test.definition.doc_title')" :right-tip="$t('api_test.definition.doc_title')"
:middle-tip="$t('api_test.definition.case_title')" :middle-tip="$t('api_test.definition.case_title')"
left-content="API" left-content="API"
middle-content="CASE" middle-content="CASE"
:right-content="$t('api_test.definition.doc_title')"> :right-content="$t('api_test.definition.doc_title')">
<!-- 列表集合 --> <!-- 列表集合 -->
<ms-api-list <ms-api-list
v-if="activeDom==='left'" v-if="activeDom==='left'"
@runTest="runTest" @runTest="runTest"
:module-tree="nodeTree" :module-tree="nodeTree"
:module-options="moduleOptions" :module-options="moduleOptions"
:current-protocol="currentProtocol" :current-protocol="currentProtocol"
:visible="visible" :visible="visible"
:currentRow="currentRow" :currentRow="currentRow"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:trash-enable="trashEnable" :trash-enable="trashEnable"
:queryDataType="queryDataType" :queryDataType="queryDataType"
:selectDataRange="selectDataRange" :selectDataRange="selectDataRange"
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
@changeSelectDataRangeAll="changeSelectDataRangeAll" @changeSelectDataRangeAll="changeSelectDataRangeAll"
@editApi="editApi" @editApi="editApi"
@handleCase="handleCase" @handleCase="handleCase"
@showExecResult="showExecResult" @showExecResult="showExecResult"
ref="apiList"/> ref="apiList"/>
<!--测试用例列表--> <!--测试用例列表-->
<api-case-simple-list <api-case-simple-list
v-if="activeDom==='middle'" v-if="activeDom==='middle'"
:current-protocol="currentProtocol" :current-protocol="currentProtocol"
:visible="visible" :visible="visible"
:currentRow="currentRow" :currentRow="currentRow"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:trash-enable="trashEnable" :trash-enable="trashEnable"
:queryDataType="queryDataType" :queryDataType="queryDataType"
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
@changeSelectDataRangeAll="changeSelectDataRangeAll" @changeSelectDataRangeAll="changeSelectDataRangeAll"
@handleCase="handleCase" @handleCase="handleCase"
@showExecResult="showExecResult" @showExecResult="showExecResult"
ref="apiList"/> ref="apiList"/>
<api-documents-page class="api-doc-page" <api-documents-page class="api-doc-page"
v-if="activeDom==='right'" v-if="activeDom==='right'"
:project-id="projectId" :project-id="projectId"
:module-ids="selectNodeIds"/> :module-ids="selectNodeIds"/>
</ms-tab-button> </ms-tab-button>
<!-- 添加/编辑测试窗口--> <!-- 添加/编辑测试窗口-->
<div v-if="item.type=== 'ADD'" class="ms-api-div"> <div v-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" :project-id="projectId"
:currentProtocol="currentProtocol" :currentProtocol="currentProtocol"
:moduleOptions="moduleOptions"/> :moduleOptions="moduleOptions"/>
</div> </div>
<!-- 快捷调试 --> <!-- 快捷调试 -->
<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" :testCase="item.api" @saveAs="editApi" <ms-debug-http-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
v-if="currentProtocol==='HTTP'"/> v-if="currentProtocol==='HTTP'"/>
<ms-debug-jdbc-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" <ms-debug-jdbc-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
v-if="currentProtocol==='SQL'"/> v-if="currentProtocol==='SQL'"/>
<ms-debug-tcp-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" <ms-debug-tcp-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
v-if="currentProtocol==='TCP'"/> v-if="currentProtocol==='TCP'"/>
<ms-debug-dubbo-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" <ms-debug-dubbo-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
v-if="currentProtocol==='DUBBO'"/> 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 :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId" <ms-run-test-http-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @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" :project-id="projectId" <ms-run-test-tcp-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @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" :project-id="projectId" <ms-run-test-sql-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @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" :project-id="projectId" <ms-run-test-dubbo-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" :project-id="projectId"
@saveAsApi="editApi" @refresh="refresh" v-if="currentProtocol==='DUBBO'"/> @saveAsApi="editApi" @refresh="refresh" v-if="currentProtocol==='DUBBO'"/>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="add"> <el-tab-pane name="add">
<template v-slot:label> <template v-slot:label>
<el-dropdown @command="handleCommand" v-tester> <el-dropdown @command="handleCommand" v-tester>
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/> <el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="debug">{{ $t('api_test.definition.request.fast_debug') }}</el-dropdown-item> <el-dropdown-item command="debug">{{ $t('api_test.definition.request.fast_debug') }}</el-dropdown-item>
<el-dropdown-item command="ADD">{{ $t('api_test.definition.request.title') }}</el-dropdown-item> <el-dropdown-item command="ADD">{{ $t('api_test.definition.request.title') }}</el-dropdown-item>
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }} <el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</template> </template>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</ms-main-container> </ms-main-container>
</ms-container> </ms-container>
</div> </div>
</template> </template>
<script> <script>
import MsApiList from './components/list/ApiList'; import MsApiList from './components/list/ApiList';
import MsContainer from "../../common/components/MsContainer"; import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import MsAsideContainer from "../../common/components/MsAsideContainer"; import MsAsideContainer from "../../common/components/MsAsideContainer";
import MsApiConfig from "./components/ApiConfig"; import MsApiConfig from "./components/ApiConfig";
import MsDebugHttpPage from "./components/debug/DebugHttpPage"; import MsDebugHttpPage from "./components/debug/DebugHttpPage";
import MsDebugJdbcPage from "./components/debug/DebugJdbcPage"; import MsDebugJdbcPage from "./components/debug/DebugJdbcPage";
import MsDebugTcpPage from "./components/debug/DebugTcpPage"; import MsDebugTcpPage from "./components/debug/DebugTcpPage";
import MsDebugDubboPage from "./components/debug/DebugDubboPage"; import MsDebugDubboPage from "./components/debug/DebugDubboPage";
import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage"; import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
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 {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils";
import MsApiModule from "./components/module/ApiModule"; import MsApiModule from "./components/module/ApiModule";
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList"; import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
import ApiDocumentsPage from "@/business/components/api/definition/components/list/ApiDocumentsPage"; import ApiDocumentsPage from "@/business/components/api/definition/components/list/ApiDocumentsPage";
import MsTableButton from "@/business/components/common/components/MsTableButton"; import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsTabButton from "@/business/components/common/components/MsTabButton"; import MsTabButton from "@/business/components/common/components/MsTabButton";
export default { export default {
name: "ApiDefinition", name: "ApiDefinition",
@ -157,7 +157,7 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
this.changeRedirectParam(redirectIDParam); this.changeRedirectParam(redirectIDParam);
return routeParam; return routeParam;
}, },
isReadOnly(){ isReadOnly() {
return !checkoutTestManagerOrTestUser(); return !checkoutTestManagerOrTestUser();
}, },
projectId() { projectId() {
@ -221,6 +221,9 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
currentProtocol() { currentProtocol() {
this.handleCommand("CLOSE_ALL"); this.handleCommand("CLOSE_ALL");
}, },
selectNodeIds() {
this.apiDefaultTab = "default";
},
redirectID() { redirectID() {
this.renderComponent = false; this.renderComponent = false;
this.$nextTick(() => { this.$nextTick(() => {