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; 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) { editApi(row) {

View File

@ -513,7 +513,7 @@ export default {
// //
if (this.$route.query.caseId) { if (this.$route.query.caseId) {
this.$get('/api/testcase/findById/' + this.$route.query.caseId, (response) => { this.$get('/api/testcase/findById/' + this.$route.query.caseId, (response) => {
if(!response.data){ if (!response.data) {
this.$error(this.$t('api_test.case_jump_message')); this.$error(this.$t('api_test.case_jump_message'));
return; return;
} }
@ -1136,6 +1136,12 @@ export default {
if (dataType === 'apiTestCase') { if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam; this.selectDataRange = routeParam;
} }
} else {
let routeParam = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam;
}
} }
}, },
changeSelectDataRangeAll() { 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() { changeSelectDataRangeAll() {

View File

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

View File

@ -94,8 +94,16 @@ export default {
if (param.protocol === 'dubbo://') { if (param.protocol === 'dubbo://') {
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({ definitionData = this.$router.resolve({
name: 'ApiDefinition', name: 'ApiDefinitionWithQuery',
params: { params: {
redirectID: getUUID(), redirectID: getUUID(),
dataType: "apiTestCase", dataType: "apiTestCase",
@ -112,7 +120,7 @@ export default {
}); });
break; break;
case "scenario": case "scenario":
this.$emit('redirectPage', 'scenario', 'scenario', 'edit:' + param.id); this.$emit('redirectPage', 'scenarioWithQuery', 'scenario', 'edit:' + param.id);
break; break;
} }
} }

View File

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

View File

@ -7,8 +7,9 @@
:data="tableData" :data="tableData"
@refresh="search" @refresh="search"
screen-height="300px"> 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"
<el-table-column prop="name" :label="$t('commons.name')" width="200" > show-overflow-tooltip/>
<el-table-column prop="name" :label="$t('commons.name')" width="200">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<!-- 若为只读用户不可点击之后跳转--> <!-- 若为只读用户不可点击之后跳转-->
<span v-if="isReadOnly"> <span v-if="isReadOnly">
@ -24,12 +25,16 @@
:filters="typeFilters" :filters="typeFilters"
:label="$t('api_test.home_page.running_task_list.table_coloum.task_type')" width="120"> :label="$t('api_test.home_page.running_task_list.table_coloum.task_type')" width="120">
<template v-slot:default="scope"> <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 == 'API_SCENARIO_TEST'" type="success" effect="plain"
<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')"/> :content="$t('api_test.home_page.running_task_list.scenario_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 == '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> </template>
</ms-table-column> </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')"> <el-table-column width="100" :label="$t('api_test.home_page.running_task_list.table_coloum.task_status')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<div> <div>
@ -49,7 +54,8 @@
<span>{{ scope.row.nextExecutionTime | timestampFormatDate }}</span> <span>{{ scope.row.nextExecutionTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </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')"> <el-table-column width="170" :label="$t('api_test.home_page.running_task_list.table_coloum.update_time')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <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 {getCurrentProjectID} from "@/common/js/utils";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn"; import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
export default { export default {
name: "MsApiRunningTaskList", name: "MsApiRunningTaskList",
components: { components: {
@ -84,15 +91,13 @@ export default {
loading: false, loading: false,
typeFilters: [], typeFilters: [],
condition: { condition: {
filters: { filters: {}
}
} }
} }
}, },
computed:{ computed: {
isReadOnly(){ isReadOnly() {
return false; return false;
}, },
projectId() { projectId() {
@ -127,7 +132,7 @@ export default {
} }
}, },
closeTaskConfirm(row){ closeTaskConfirm(row) {
let flag = row.taskStatus; let flag = row.taskStatus;
row.taskStatus = !flag; //switch row.taskStatus = !flag; //switch
this.$confirm(this.$t('api_test.home_page.running_task_list.confirm.close_title'), this.$t('commons.prompt'), { this.$confirm(this.$t('api_test.home_page.running_task_list.confirm.close_title'), this.$t('commons.prompt'), {
@ -140,19 +145,19 @@ export default {
}); });
}, },
updateTask(taskRow){ updateTask(taskRow) {
this.result = this.$post('/api/schedule/updateEnableByPrimyKey/disable', taskRow, response => { this.result = this.$post('/api/schedule/updateEnableByPrimyKey/disable', taskRow, response => {
this.search(); this.search();
}); });
}, },
redirect(param){ redirect(param) {
if(param.taskGroup === 'TEST_PLAN_TEST'){ if (param.taskGroup === 'TEST_PLAN_TEST') {
this.$emit('redirectPage','testPlanEdit','', param.scenarioId); this.$emit('redirectPage', 'testPlanEdit', '', param.scenarioId);
}else if (param.taskGroup === 'API_SCENARIO_TEST') { } 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') { } else if (param.taskGroup === 'SWAGGER_IMPORT') {
this.$emit('redirectPage', 'api', 'api', {param}); this.$emit('redirectPage', 'apiWithQuery', 'api', {param});
} }
} }
}, },
@ -163,14 +168,15 @@ export default {
activated() { activated() {
this.search(); this.search();
}, },
} }
</script> </script>
<style scoped> <style scoped>
.el-table { .el-table {
cursor:pointer; cursor: pointer;
} }
.el-card /deep/ .el-card__header { .el-card /deep/ .el-card__header {
border-bottom: 0px solid #EBEEF5; border-bottom: 0px solid #EBEEF5;
} }

View File

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

View File

@ -32,6 +32,16 @@ export default {
name: "ApiDefinition", name: "ApiDefinition",
component: () => import('@/business/components/api/definition/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", path: "automation",
name: "ApiAutomation", name: "ApiAutomation",

View File

@ -178,6 +178,18 @@ export default {
case "testPlanEdit": case "testPlanEdit":
this.$router.push('/track/plan/view/' + selectType) this.$router.push('/track/plan/view/' + selectType)
break; 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;
} }
} }
} }