refactor(接口测试): 完善接口测试首页的跳转

--story=1007743 --user=宋天阳 接口测试首页数据统计优化
https://www.tapd.cn/55049933/s/1194610
This commit is contained in:
song-tianyang 2022-07-05 14:09:44 +08:00 committed by TIanyang
parent d6587265cf
commit fefd3017a3
10 changed files with 288 additions and 189 deletions

View File

@ -378,7 +378,25 @@ export default {
this.param = item;
}
}
}
} else {
let dataType = this.$route.params.dataType;
if (dataType) {
if (dataType === "api") {
this.activeDom = 'left';
} else {
this.activeDom = 'middle';
}
}
if (this.$route.params.dataSelectRange) {
let item = JSON.parse(JSON.stringify(this.$route.params.dataSelectRange)).param;
if (item !== undefined) {
let type = item.taskGroup.toString();
if (type === "SWAGGER_IMPORT") {
this.handleTabsEdit(this.$t('api_test.api_import.timing_synchronization'), 'SCHEDULE');
this.param = item;
}
}
}
}
},
@ -726,6 +744,20 @@ export default {
}
}
}
} else {
let dataRange = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataRange) {
let selectParamArr = dataRange.split("edit:");
if (selectParamArr.length === 2) {
let scenarioId = selectParamArr[1];
if (dataType === 'api') {
this.$get('/api/definition/get/' + scenarioId, (response) => {
this.editApi(response.data);
});
}
}
}
}
},
editApi(row) {

View File

@ -1136,6 +1136,12 @@ export default {
if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam;
}
} else {
let routeParam = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam;
}
}
},
changeSelectDataRangeAll() {

View File

@ -914,6 +914,20 @@ export default {
}
}
}
} else {
let dataRange = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
this.selectDataRange = dataType === 'api' ? dataRange : "all";
if (this.selectDataRange &&
Object.prototype.toString.call(this.selectDataRange).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object'
&& this.selectDataRange.indexOf(":") !== -1) {
let selectParamArr = this.selectDataRange.split(":");
if (selectParamArr.length === 2) {
if (selectParamArr[0] === "apiList") {
this.condition.name = selectParamArr[1];
}
}
}
}
},
changeSelectDataRangeAll() {

View File

@ -283,7 +283,6 @@ export default {
});
},
redirectPage(page, dataType, selectType, title) {
//api
//UUID
let uuid = getUUID();
let redirectObj = {
@ -296,12 +295,24 @@ export default {
params: {paramObj: redirectObj}
});
break;
case "apiWithQuery":
this.$router.push({
name: 'ApiDefinitionWithQuery',
params: {redirectID: uuid, dataType: dataType, dataSelectRange: selectType}
});
break;
case "scenario":
this.$router.push({
name: 'ApiAutomation',
params: {paramObj: redirectObj}
});
break;
case "scenarioWithQuery":
this.$router.push({
name: 'ApiAutomationWithQuery',
params: {redirectID: uuid, dataType: dataType, dataSelectRange: selectType}
});
break;
case "testPlanEdit":
this.$router.push('/track/plan/view/' + selectType)
break;

View File

@ -94,8 +94,16 @@ export default {
if (param.protocol === 'dubbo://') {
param.protocol = 'DUBBO'
}
let paramObj = {
redirectID: getUUID(),
dataType: "apiTestCase",
dataSelectRange: 'single:' + param.id,
projectId: getCurrentProjectID(),
type: api.protocol,
workspaceId: getCurrentWorkspaceId(),
};
definitionData = this.$router.resolve({
name: 'ApiDefinition',
name: 'ApiDefinitionWithQuery',
params: {
redirectID: getUUID(),
dataType: "apiTestCase",
@ -112,7 +120,7 @@ export default {
});
break;
case "scenario":
this.$emit('redirectPage', 'scenario', 'scenario', 'edit:' + param.id);
this.$emit('redirectPage', 'scenarioWithQuery', 'scenario', 'edit:' + param.id);
break;
}
}

View File

@ -204,7 +204,7 @@ export default {
switch (pageType) {
case "api":
resolve = this.$router.resolve({
name: 'ApiDefinition',
name: 'ApiDefinitionWithQuery',
params: {
redirectID: getUUID(),
dataType: "api",

View File

@ -7,7 +7,8 @@
:data="tableData"
@refresh="search"
screen-height="300px">
<el-table-column prop="index" :label="$t('api_test.home_page.running_task_list.table_coloum.index')" width="80" show-overflow-tooltip/>
<el-table-column prop="index" :label="$t('api_test.home_page.running_task_list.table_coloum.index')" width="80"
show-overflow-tooltip/>
<el-table-column prop="name" :label="$t('commons.name')" width="200">
<template v-slot:default="{row}">
<!-- 若为只读用户不可点击之后跳转-->
@ -24,12 +25,16 @@
:filters="typeFilters"
:label="$t('api_test.home_page.running_task_list.table_coloum.task_type')" width="120">
<template v-slot:default="scope">
<ms-tag v-if="scope.row.taskGroup == 'API_SCENARIO_TEST'" type="success" effect="plain" :content="$t('api_test.home_page.running_task_list.scenario_schedule')"/>
<ms-tag v-if="scope.row.taskGroup == 'TEST_PLAN_TEST'" type="warning" effect="plain" :content="$t('api_test.home_page.running_task_list.test_plan_schedule')"/>
<ms-tag v-if="scope.row.taskGroup == 'SWAGGER_IMPORT'" type="danger" effect="plain" :content="$t('api_test.home_page.running_task_list.swagger_schedule')"/>
<ms-tag v-if="scope.row.taskGroup == 'API_SCENARIO_TEST'" type="success" effect="plain"
:content="$t('api_test.home_page.running_task_list.scenario_schedule')"/>
<ms-tag v-if="scope.row.taskGroup == 'TEST_PLAN_TEST'" type="warning" effect="plain"
:content="$t('api_test.home_page.running_task_list.test_plan_schedule')"/>
<ms-tag v-if="scope.row.taskGroup == 'SWAGGER_IMPORT'" type="danger" effect="plain"
:content="$t('api_test.home_page.running_task_list.swagger_schedule')"/>
</template>
</ms-table-column>
<el-table-column prop="rule" :label="$t('api_test.home_page.running_task_list.table_coloum.run_rule')" width="120" show-overflow-tooltip/>
<el-table-column prop="rule" :label="$t('api_test.home_page.running_task_list.table_coloum.run_rule')" width="120"
show-overflow-tooltip/>
<el-table-column width="100" :label="$t('api_test.home_page.running_task_list.table_coloum.task_status')">
<template v-slot:default="scope">
<div>
@ -49,7 +54,8 @@
<span>{{ scope.row.nextExecutionTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="creator" :label="$t('api_test.home_page.running_task_list.table_coloum.create_user')" width="100" show-overflow-tooltip/>
<el-table-column prop="creator" :label="$t('api_test.home_page.running_task_list.table_coloum.create_user')"
width="100" show-overflow-tooltip/>
<el-table-column width="170" :label="$t('api_test.home_page.running_task_list.table_coloum.update_time')">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -65,6 +71,7 @@ import MsTag from "@/business/components/common/components/MsTag";
import {getCurrentProjectID} from "@/common/js/utils";
import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
export default {
name: "MsApiRunningTaskList",
components: {
@ -84,9 +91,7 @@ export default {
loading: false,
typeFilters: [],
condition: {
filters: {
}
filters: {}
}
}
},
@ -150,9 +155,9 @@ export default {
if (param.taskGroup === 'TEST_PLAN_TEST') {
this.$emit('redirectPage', 'testPlanEdit', '', param.scenarioId);
} else if (param.taskGroup === 'API_SCENARIO_TEST') {
this.$emit('redirectPage', 'scenario', 'scenario', 'edit:' + param.scenarioId);
this.$emit('redirectPage', 'scenarioWithQuery', 'scenario', 'edit:' + param.scenarioId);
} else if (param.taskGroup === 'SWAGGER_IMPORT') {
this.$emit('redirectPage', 'api', 'api', {param});
this.$emit('redirectPage', 'apiWithQuery', 'api', {param});
}
}
},
@ -171,6 +176,7 @@ export default {
.el-table {
cursor: pointer;
}
.el-card /deep/ .el-card__header {
border-bottom: 0px solid #EBEEF5;
}

View File

@ -92,7 +92,7 @@ export default {
this.$emit('redirectPage', 'api', 'apiTestCase', 'single:' + param);
break;
case "scenario":
this.$emit('redirectPage', 'scenario', 'scenario', 'edit:' + param);
this.$emit('redirectPage', 'scenarioWithQuery', 'scenario', 'edit:' + param);
break;
}
}

View File

@ -32,6 +32,16 @@ export default {
name: "ApiDefinition",
component: () => import('@/business/components/api/definition/ApiDefinition'),
},
{
path: "definition/:redirectID?/:dataType?/:dataSelectRange?/:projectId?/:type?/:workspaceId?",
name: "ApiDefinitionWithQuery",
component: () => import('@/business/components/api/definition/ApiDefinition'),
},
{
path: "automation/:redirectID?/:dataType?/:dataSelectRange?/:projectId?/:workspaceId?",
name: "ApiAutomationWithQuery",
component: () => import('@/business/components/api/automation/ApiAutomation'),
},
{
path: "automation",
name: "ApiAutomation",

View File

@ -178,6 +178,18 @@ export default {
case "testPlanEdit":
this.$router.push('/track/plan/view/' + selectType)
break;
case "scenarioWithQuery":
this.$router.push({
name: 'ApiAutomationWithQuery',
params: {redirectID: uuid, dataType: dataType, dataSelectRange: selectType}
});
break;
case "api":
this.$router.push({
name: 'ApiDefinition',
params: {paramObj: redirectObj}
});
break;
}
}
}