This commit is contained in:
chenjianxing 2020-06-02 11:51:05 +08:00
commit 91ffab8c30
15 changed files with 121 additions and 33 deletions

View File

@ -26,6 +26,16 @@
<if test="request.id != null"> <if test="request.id != null">
AND load_test.id = #{request.id} AND load_test.id = #{request.id}
</if> </if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and load_test.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</if>
</foreach>
</if>
</where> </where>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by

View File

@ -31,8 +31,23 @@
<if test="reportRequest.workspaceId != null"> <if test="reportRequest.workspaceId != null">
AND workspace_id = #{reportRequest.workspaceId,jdbcType=VARCHAR} AND workspace_id = #{reportRequest.workspaceId,jdbcType=VARCHAR}
</if> </if>
<if test="reportRequest.filters != null and reportRequest.filters.size() > 0">
<foreach collection="reportRequest.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and ltr.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</if>
</foreach>
</if>
</where> </where>
ORDER BY ltr.update_time DESC <if test="reportRequest.orders != null and reportRequest.orders.size() > 0">
order by
<foreach collection="reportRequest.orders" separator="," item="order">
ltr.${order.name} ${order.type}
</foreach>
</if>
</select> </select>
<select id="getReportTestAndProInfo" resultType="io.metersphere.dto.ReportDTO"> <select id="getReportTestAndProInfo" resultType="io.metersphere.dto.ReportDTO">

View File

@ -1,11 +1,17 @@
package io.metersphere.performance.controller.request; package io.metersphere.performance.controller.request;
import io.metersphere.controller.request.OrderRequest;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter @Getter
@Setter @Setter
public class ReportRequest { public class ReportRequest {
private String name; private String name;
private String workspaceId; private String workspaceId;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
} }

View File

@ -1,6 +1,5 @@
package io.metersphere.performance.service; package io.metersphere.performance.service;
import io.metersphere.api.dto.SaveAPITestRequest;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper; import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
@ -10,6 +9,7 @@ import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.DashboardTestDTO; import io.metersphere.dto.DashboardTestDTO;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
@ -66,6 +66,7 @@ public class PerformanceTestService {
private ReportService reportService; private ReportService reportService;
public List<LoadTestDTO> list(QueryTestPlanRequest request) { public List<LoadTestDTO> list(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
return extLoadTestMapper.list(request); return extLoadTestMapper.list(request);
} }

View File

@ -12,6 +12,7 @@ import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportKeys; import io.metersphere.commons.constants.ReportKeys;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.dto.LogDetailDTO; import io.metersphere.dto.LogDetailDTO;
import io.metersphere.dto.ReportDTO; import io.metersphere.dto.ReportDTO;
import io.metersphere.performance.base.*; import io.metersphere.performance.base.*;
@ -51,6 +52,7 @@ public class ReportService {
} }
public List<ReportDTO> getReportList(ReportRequest request) { public List<ReportDTO> getReportList(ReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
return extLoadTestReportMapper.getReportList(request); return extLoadTestReportMapper.getReportList(request);
} }

View File

@ -5,10 +5,12 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
import java.util.Map;
@Getter @Getter
@Setter @Setter
public class QueryTestPlanRequest extends TestPlanRequest { public class QueryTestPlanRequest extends TestPlanRequest {
private String workspaceId; private String workspaceId;
private List<OrderRequest> orders; private List<OrderRequest> orders;
private Map<String, List<String>> filters;
} }

View File

@ -15,20 +15,25 @@
<el-table-column prop="testName" :label="$t('api_report.test_name')" width="200" show-overflow-tooltip/> <el-table-column prop="testName" :label="$t('api_report.test_name')" width="200" show-overflow-tooltip/>
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip/> <el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip/>
<el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/> <el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/>
<el-table-column width="250" :label="$t('commons.create_time')"> <el-table-column width="250" :label="$t('commons.create_time')" sortable
prop="createTime">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span> <span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="status" :label="$t('commons.status')"> <el-table-column prop="status" :label="$t('commons.status')"
:filter-method="filter"
:filters="statusFilters">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<ms-api-report-status :row="row"/> <ms-api-report-status :row="row"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="150" :label="$t('commons.operating')"> <el-table-column width="150" :label="$t('commons.operating')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-button :is-tester-permission="true" @click="handleView(scope.row)" type="primary" icon="el-icon-s-data" size="mini" circle/> <el-button :is-tester-permission="true" @click="handleView(scope.row)" type="primary"
<el-button :is-tester-permission="true" @click="handleDelete(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/> icon="el-icon-s-data" size="mini" circle/>
<el-button :is-tester-permission="true" @click="handleDelete(scope.row)" type="danger"
icon="el-icon-delete" size="mini" circle/>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -57,7 +62,15 @@
currentPage: 1, currentPage: 1,
pageSize: 5, pageSize: 5,
total: 0, total: 0,
loading: false loading: false,
statusFilters: [
{text: 'Saved', value: 'Saved'},
{text: 'Starting', value: 'Starting'},
{text: 'Running', value: 'Running'},
{text: 'Reporting', value: 'Reporting'},
{text: 'Completed', value: 'Completed'},
{text: 'Error', value: 'Error'}
]
} }
}, },
@ -106,6 +119,9 @@
init() { init() {
this.testId = this.$route.params.testId; this.testId = this.$route.params.testId;
this.search(); this.search();
},
filter(value, row) {
return row.status === value;
} }
}, },

View File

@ -15,17 +15,21 @@
</el-table-column> </el-table-column>
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="200" show-overflow-tooltip/> <el-table-column prop="projectName" :label="$t('load_test.project_name')" width="200" show-overflow-tooltip/>
<el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/> <el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/>
<el-table-column width="250" :label="$t('commons.create_time')"> <el-table-column width="250" :label="$t('commons.create_time')" sortable
prop="createTime">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span> <span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="250" :label="$t('commons.update_time')"> <el-table-column width="250" :label="$t('commons.update_time')" sortable
prop="updateTime">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="status" :label="$t('commons.status')"> <el-table-column prop="status" :label="$t('commons.status')"
:filter-method="filter"
:filters="statusFilters">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<ms-api-test-status :row="row"/> <ms-api-test-status :row="row"/>
</template> </template>
@ -79,6 +83,14 @@
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger", tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
exec: this.handleDelete exec: this.handleDelete
} }
],
statusFilters: [
{text: 'Saved', value: 'Saved'},
{text: 'Starting', value: 'Starting'},
{text: 'Running', value: 'Running'},
{text: 'Reporting', value: 'Reporting'},
{text: 'Completed', value: 'Completed'},
{text: 'Error', value: 'Error'}
] ]
} }
}, },
@ -137,11 +149,15 @@
init() { init() {
this.projectId = this.$route.params.projectId; this.projectId = this.$route.params.projectId;
this.search(); this.search();
},
filter(value, row) {
return row.status === value;
} }
}, },
created() { created() {
this.init(); this.init();
} }
} }
</script> </script>

View File

@ -10,14 +10,15 @@
<el-input type="text" size="small" :placeholder="$t('report.search_by_name')" <el-input type="text" size="small" :placeholder="$t('report.search_by_name')"
prefix-icon="el-icon-search" prefix-icon="el-icon-search"
maxlength="60" maxlength="60"
v-model="condition" @change="search" clearable/> v-model="condition.name" @change="search" clearable/>
</span> </span>
</el-row> </el-row>
</div> </div>
</template> </template>
<el-table :data="tableData" class="test-content" <el-table :data="tableData" class="test-content"
:default-sort="{prop: 'createTime', order: 'descending'}" @sort-change="sort"
@filter-change="filter"
> >
<el-table-column <el-table-column
prop="name" prop="name"
@ -47,6 +48,8 @@
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column--> <!-- <el-table-column-->
<!-- prop="updateTime"-->
<!-- sortable-->
<!-- width="250"--> <!-- width="250"-->
<!-- :label="$t('commons.update_time')">--> <!-- :label="$t('commons.update_time')">-->
<!-- <template v-slot:default="scope">--> <!-- <template v-slot:default="scope">-->
@ -55,7 +58,7 @@
<!-- </el-table-column>--> <!-- </el-table-column>-->
<el-table-column <el-table-column
prop="status" prop="status"
:filter-method="filter" column-key="status"
:filters="statusFilters" :filters="statusFilters"
:label="$t('commons.status')"> :label="$t('commons.status')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
@ -83,6 +86,7 @@
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 MsPerformanceReportStatus from "./PerformanceReportStatus"; import MsPerformanceReportStatus from "./PerformanceReportStatus";
import {_filter, _sort} from "../../../../common/js/utils";
export default { export default {
name: "PerformanceTestReport", name: "PerformanceTestReport",
@ -95,7 +99,7 @@
result: {}, result: {},
queryPath: "/performance/report/list/all", queryPath: "/performance/report/list/all",
deletePath: "/performance/report/delete/", deletePath: "/performance/report/delete/",
condition: "", condition: {},
projectId: null, projectId: null,
tableData: [], tableData: [],
multipleSelection: [], multipleSelection: [],
@ -115,10 +119,7 @@
}, },
methods: { methods: {
initTableData() { initTableData() {
let param = { this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
name: this.condition,
};
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
@ -161,8 +162,13 @@
this.initTableData(); this.initTableData();
}); });
}, },
filter(value, row) { sort(column) {
return row.status === value; _sort(column, this.condition);
this.initTableData();
},
filter(filters) {
_filter(filters, this.condition);
this.initTableData();
}, },
} }
} }

View File

@ -4,7 +4,9 @@
<el-card v-loading="result.loading"> <el-card v-loading="result.loading">
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
<el-input :placeholder="$t('load_test.input_name')" v-model="testPlan.name" class="input-with-select"> <el-input :placeholder="$t('load_test.input_name')" v-model="testPlan.name" class="input-with-select"
maxlength="30"
>
<template v-slot:prepend> <template v-slot:prepend>
<el-select v-model="testPlan.projectId" :placeholder="$t('load_test.select_project')"> <el-select v-model="testPlan.projectId" :placeholder="$t('load_test.select_project')">
<el-option <el-option
@ -208,9 +210,13 @@
this.$router.push({path: '/performance/test/all'}) this.$router.push({path: '/performance/test/all'})
}, },
validTestPlan() { validTestPlan() {
let reg = /^[\u4e00-\u9fa5_a-zA-Z0-9\s.·-]+$/;
if (!this.testPlan.name) { if (!this.testPlan.name) {
this.$error(this.$t('load_test.test_name_is_null')); this.$error(this.$t('load_test.test_name_is_null'));
return false; return false;
} else if (!reg.test(this.testPlan.name)) {
this.$error(this.$t('load_test.special_characters_are_not_supported'));
return false;
} }
if (!this.testPlan.projectId) { if (!this.testPlan.projectId) {

View File

@ -16,9 +16,9 @@
</div> </div>
</template> </template>
<!-- @sort-change="sort"-->
<el-table :data="tableData" class="test-content" <el-table :data="tableData" class="test-content"
:default-sort="{prop: 'createTime', order: 'descending'}" @sort-change="sort"
@filter-change="filter"
> >
<el-table-column <el-table-column
prop="name" prop="name"
@ -61,7 +61,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="status" prop="status"
:filter-method="filter" column-key="status"
:filters="statusFilters" :filters="statusFilters"
:label="$t('commons.status')"> :label="$t('commons.status')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
@ -200,12 +200,13 @@
this.initTableData(); this.initTableData();
}); });
}, },
// sort(column) { sort(column) {
// _sort(column, this.condition); _sort(column, this.condition);
// this.initTableData(); this.initTableData();
// }, },
filter(value, row) { filter(filters) {
return row.status === value; _filter(filters, this.condition);
this.initTableData();
}, },
link(row) { link(row) {
this.$router.push({ this.$router.push({

View File

@ -223,6 +223,10 @@
this.$router.push({ this.$router.push({
path: '/performance/test/' + row.id, path: '/performance/test/' + row.id,
}) })
} else if (this.$route.name === 'fucProject') {
this.$router.push({
path: '/api/test/list/' + row.id
})
} }
} }
} }

View File

@ -254,7 +254,8 @@ export default {
'select_resource_pool': 'Please Select Resource Pool', 'select_resource_pool': 'Please Select Resource Pool',
'resource_pool_is_null': 'Resource Pool is empty', 'resource_pool_is_null': 'Resource Pool is empty',
'download_log_file': 'Download', 'download_log_file': 'Download',
'user_name': 'Creator' 'user_name': 'Creator',
'special_characters_are_not_supported': 'Test name does not support special characters',
}, },
api_test: { api_test: {
creator: "Creator", creator: "Creator",

View File

@ -252,7 +252,8 @@ export default {
'resource_pool_is_null': '资源池为空', 'resource_pool_is_null': '资源池为空',
'download_log_file': '下载完整日志文件', 'download_log_file': '下载完整日志文件',
'pressure_prediction_chart': '压力预估图', 'pressure_prediction_chart': '压力预估图',
'user_name': '创建人' 'user_name': '创建人',
'special_characters_are_not_supported': '测试名称不支持特殊字符',
}, },
api_test: { api_test: {
creator: "创建人", creator: "创建人",

View File

@ -253,7 +253,8 @@ export default {
'resource_pool_is_null': '資源池為空', 'resource_pool_is_null': '資源池為空',
'download_log_file': '下載完整日誌文件', 'download_log_file': '下載完整日誌文件',
'pressure_prediction_chart': '壓力預估圖', 'pressure_prediction_chart': '壓力預估圖',
'user_name': '創建人' 'user_name': '創建人',
'special_characters_are_not_supported': '測試名稱不支持特殊字符',
}, },
api_test: { api_test: {
title: "測試", title: "測試",