This commit is contained in:
wenyann 2021-03-26 19:02:54 +08:00
commit 6fd9b1aaa4
20 changed files with 748 additions and 976 deletions

View File

@ -74,11 +74,21 @@ public class ApiAutomationController {
apiAutomationService.deleteBatch(ids);
}
@PostMapping("/deleteBatchByCondition")
public void deleteBatchByCondition(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.deleteBatchByCondition(request);
}
@PostMapping("/removeToGc")
public void removeToGc(@RequestBody List<String> ids) {
apiAutomationService.removeToGc(ids);
}
@PostMapping("/removeToGcByBatch")
public void removeToGcByBatch(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.removeToGcByBatch(request);
}
@PostMapping("/reduction")
public void reduction(@RequestBody List<String> ids) {
apiAutomationService.reduction(ids);

View File

@ -1001,4 +1001,18 @@ public class ApiAutomationService {
}
});
}
public void removeToGcByBatch(ApiScenarioBatchRequest request) {
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
this.removeToGc(request.getIds());
}
public void deleteBatchByCondition(ApiScenarioBatchRequest request) {
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
this.deleteBatch(request.getIds());
}
}

View File

@ -1,6 +1,7 @@
package io.metersphere.commons.user;
import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.UserDTO;
import lombok.Getter;
import lombok.Setter;
@ -28,7 +29,7 @@ public class SessionUser extends UserDTO implements Serializable {
SessionUser sessionUser = new SessionUser();
BeanUtils.copyProperties(user, sessionUser);
List<String> infos = Arrays.asList(user.getId(), RandomStringUtils.random(6), "" + System.currentTimeMillis());
List<String> infos = Arrays.asList(user.getId(), RandomStringUtils.randomAlphabetic(6), SessionUtils.getSessionId(), "" + System.currentTimeMillis());
sessionUser.csrfToken = CodingUtil.aesEncrypt(StringUtils.join(infos, "|"), secret, iv);
return sessionUser;
}

View File

@ -10,7 +10,6 @@ import org.apache.shiro.subject.support.DefaultSubjectContext;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import static io.metersphere.commons.constants.SessionConstants.ATTR_USER;
@ -32,6 +31,10 @@ public class SessionUtils {
}
}
public static String getSessionId() {
return (String) SecurityUtils.getSubject().getSession().getId();
}
private static Session getSessionByUsername(String username) {
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
Collection<Session> sessions = sessionManager.getSessionDAO().getActiveSessions();

View File

@ -71,11 +71,14 @@ public class CsrfFilter extends AnonymousFilter {
csrfToken = CodingUtil.aesDecrypt(csrfToken, SessionUser.secret, SessionUser.iv);
String[] signatureArray = StringUtils.split(StringUtils.trimToNull(csrfToken), "|");
if (signatureArray.length != 3) {
if (signatureArray.length != 4) {
throw new RuntimeException("invalid token");
}
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
throw new RuntimeException("Please check csrf token.");
}
if (!StringUtils.equals(SessionUtils.getSessionId(), signatureArray[2])) {
throw new RuntimeException("Please check csrf token.");
}
}
}

View File

@ -348,6 +348,9 @@
},
watch: {
selectNodeIds() {
this.condition.selectAll = false;
this.condition.unSelectIds = [];
this.selectDataCounts = 0;
this.selectProjectId ? this.search(this.selectProjectId) : this.search();
},
trashEnable() {
@ -357,6 +360,10 @@
} else {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
}
this.condition.selectAll = false;
this.condition.unSelectIds = [];
this.selectDataCounts = 0;
this.search();
},
batchReportId() {
@ -414,9 +421,13 @@
break;
}
this.selection = [];
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
if(!this.condition.selectAll){
this.condition.selectAll = false;
this.condition.unSelectIds = [];
this.selectDataCounts = 0;
}
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
if (this.condition.projectId) {
this.result.loading = true;
@ -430,23 +441,53 @@
}
});
this.result.loading = false;
this.unSelection = data.listObject.map(s => s.id);
if (this.$refs.scenarioTable) {
setTimeout(this.$refs.scenarioTable.doLayout, 200)
}
if(!this.condition.selectAll){
this.condition.unSelectIds = response.data.listObject.map(s => s.id);
}
this.$nextTick(function(){
this.checkTableRowIsSelect();
})
});
}
getLabel(this, API_SCENARIO_LIST);
},
checkTableRowIsSelect(){
//
if(this.condition.selectAll){
let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{
if(unSelectIds.indexOf(row.id)<0){
this.$refs.scenarioTable.toggleRowSelection(row,true);
//selectRows
if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
}else{
//selectRow
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
}
}
})
}
},
handleCommand(cmd) {
let table = this.$refs.scenarioTable;
switch (cmd) {
case "table":
this.selectAll = false;
this.condition.selectAll = false;
table.toggleAllSelection();
break;
case "all":
this.selectAll = true;
this.condition.selectAll = true;
break
}
},
@ -520,11 +561,6 @@
addTestPlan(params) {
let obj = {planIds: params[0], scenarioIds: this.selection};
// obj.projectId = getCurrentProjectID();
// obj.selectAllDate = this.isSelectAllDate;
// obj.unSelectIds = this.unSelection;
// obj = Object.assign(obj, this.condition);
// todo
if (this.isSelectAllDate) {
this.$warning("暂不支持批量添加所有场景到测试计划!");
@ -619,8 +655,10 @@
},
handleDeleteBatch(row) {
if (this.trashEnable) {
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/api/automation/deleteBatch/', ids, () => {
//let ids = Array.from(this.selectRows).map(row => row.id);
let param = {};
this.buildBatchParam(param);
this.$post('/api/automation/deleteBatchByCondition/', param, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
@ -630,8 +668,10 @@
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/api/automation/removeToGc/', ids, () => {
//let ids = Array.from(this.selectRows).map(row => row.id);
let param = {};
this.buildBatchParam(param);
this.$post('/api/automation/removeToGcByBatch/', param, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
@ -686,8 +726,11 @@
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = [row.id];
this.$post('/api/automation/removeToGc/', ids, () => {
// let ids = [row.id];
let param = {};
this.buildBatchParam(param);
this.$post('/api/automation/removeToGcByBatch/', param, () => {
// this.$post('/api/automation/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});

View File

@ -1,9 +1,11 @@
<template>
<div>
<div>
<el-link type="primary" style="float:right;margin-top: 5px" @click="open">{{$t('commons.adv_search.title')}}</el-link>
<el-link type="primary" style="float:right;margin-top: 5px" @click="open">{{ $t('commons.adv_search.title') }}
</el-link>
<el-input :placeholder="$t('commons.search_by_id_name_tag')" @blur="search" @keyup.enter.native="search" class="search-input" size="small"
<el-input :placeholder="$t('commons.search_by_id_name_tag')" @blur="search" @keyup.enter.native="search"
class="search-input" size="small"
v-model="condition.name"/>
<el-table v-loading="result.loading"
@ -60,18 +62,19 @@
</el-table-column>
<el-table-column
v-if="item.id == 'path'"
sortable="custom"
prop="path"
min-width="180px"
:label="$t('api_test.definition.api_path')"
show-overflow-tooltip
:key="index"/>
v-if="item.id == 'path'"
sortable="custom"
prop="path"
min-width="180px"
:label="$t('api_test.definition.api_path')"
show-overflow-tooltip
:key="index"/>
<el-table-column v-if="item.id=='tags'" prop="tags" min-width="120px" :label="$t('commons.tag')"
:key="index">
<template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template>
</el-table-column>
@ -83,12 +86,12 @@
:key="index"/>
<el-table-column
v-if="item.id=='updateTime'"
sortable="updateTime"
min-width="160"
:label="$t('api_test.definition.api_last_time')"
prop="updateTime"
:key="index">
v-if="item.id=='updateTime'"
sortable="updateTime"
min-width="160"
:label="$t('api_test.definition.api_last_time')"
prop="updateTime"
:key="index">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
@ -179,108 +182,117 @@ export default {
ShowMoreBtn,
MsBatchEdit,
MsApiCaseTableExtendBtns,
MsReferenceView,
MsTableAdvSearchBar
MsReferenceView,
MsTableAdvSearchBar
},
data() {
return {
type: API_CASE_LIST,
headerItems: Api_Case_List,
tableLabel: [],
condition: {
components: API_CASE_CONFIGS
},
selectCase: {},
result: {},
moduleId: "",
selectDataRange: "all",
deletePath: "/test/case/delete",
selectRows: new Set(),
clickRow: {},
buttons: [
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
{name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
],
typeArr: [
{id: 'priority', name: this.$t('test_track.case.priority')},
{id: 'method', name: this.$t('api_test.definition.api_type')},
{id: 'path', name: this.$t('api_test.request.path')},
],
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
valueArr: {
priority: CASE_PRIORITY,
method: REQ_METHOD,
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
screenHeight: document.documentElement.clientHeight - 330,//
environmentId: undefined,
selectAll: false,
unSelection: [],
selectDataCounts: 0,
environments: [],
}
},
props: {
currentProtocol: String,
selectNodeIds: Array,
activeDom: String,
visible: {
type: Boolean,
default: false,
},
data() {
return {
type: API_CASE_LIST,
headerItems: Api_Case_List,
tableLabel: [],
condition: {
components: API_CASE_CONFIGS
},
selectCase: {},
result: {},
moduleId: "",
selectDataRange: "all",
deletePath: "/test/case/delete",
selectRows: new Set(),
clickRow: {},
buttons: [
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
{name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
],
typeArr: [
{id: 'priority', name: this.$t('test_track.case.priority')},
{id: 'method', name: this.$t('api_test.definition.api_type')},
{id: 'path', name: this.$t('api_test.request.path')},
],
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
valueArr: {
priority: CASE_PRIORITY,
method: REQ_METHOD,
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
screenHeight: document.documentElement.clientHeight - 330,//
environmentId: undefined,
selectAll: false,
unSelection: [],
selectDataCounts: 0,
environments: [],
trashEnable: {
type: Boolean,
default: false,
},
isReadOnly: {
type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
relevanceProjectId: String,
model: {
type: String,
default() {
'api'
}
},
props: {
currentProtocol: String,
selectNodeIds: Array,
activeDom: String,
visible: {
type: Boolean,
default: false,
},
trashEnable: {
type: Boolean,
default: false,
},
isReadOnly: {
type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
relevanceProjectId: String,
model: {
type: String,
default() {
'api'
}
},
planId: String
},
created: function () {
planId: String
},
created: function () {
this.initTable();
getSystemLabel(this, this.type)
this.$nextTick(() => {
this.$refs.caseTable.bodyWrapper.scrollTop = 5
})
},
watch: {
selectNodeIds() {
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.initTable();
getSystemLabel(this, this.type)
this.$nextTick(() => {
this.$refs.caseTable.bodyWrapper.scrollTop = 5
})
},
watch: {
selectNodeIds() {
this.initTable();
},
currentProtocol() {
this.initTable();
},
trashEnable() {
if (this.trashEnable) {
this.initTable();
}
},
relevanceProjectId() {
currentProtocol() {
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.initTable();
},
trashEnable() {
if (this.trashEnable) {
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.initTable();
}
},
relevanceProjectId() {
this.initTable();
}
},
computed: {
//
isApiModel() {
@ -299,353 +311,385 @@ export default {
this.condition.status = "";
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.status = "Trash";
this.condition.moduleIds = [];
}
this.condition.status = "Trash";
this.condition.moduleIds = [];
}
if(!this.selectAll){
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.condition.projectId = this.projectId;
}
this.condition.projectId = this.projectId;
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
}
//
this.isSelectThissWeekData();
this.condition.selectThisWeedData = false;
this.condition.id = null;
if (this.selectDataRange == 'thisWeekCount') {
this.condition.selectThisWeedData = true;
} else if (this.selectDataRange != null) {
let selectParamArr = this.selectDataRange.split("single:");
if (selectParamArr.length == 2) {
this.condition.id = selectParamArr[1];
}
}
if (this.condition.projectId) {
this.result = this.$post('/api/testcase/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
//
this.isSelectThissWeekData();
this.condition.selectThisWeedData = false;
this.condition.id = null;
if (this.selectDataRange == 'thisWeekCount') {
this.condition.selectThisWeedData = true;
} else if (this.selectDataRange != null) {
let selectParamArr = this.selectDataRange.split("single:");
if (selectParamArr.length == 2) {
this.condition.id = selectParamArr[1];
}
}
if (this.condition.projectId) {
this.result = this.$post('/api/testcase/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
if(!this.selectAll){
this.unSelection = response.data.listObject.map(s => s.id);
}
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
})
if (this.$refs.caseTable) {
setTimeout(this.$refs.caseTable.doLayout, 200)
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
}
getLabel(this, API_CASE_LIST);
},
open() {
this.$refs.searchBar.open();
},
handleSelect(selection, row) {
_handleSelect(this, selection, row, this.selectRows);
this.selectRowsCount(this.selectRows)
},
showExecResult(row) {
this.visible = false;
this.$emit('showExecResult', row);
},
filter(filters) {
_filter(filters, this.condition);
this.initTable();
},
sort(column) {
//
if (this.condition.orders) {
this.condition.orders = [];
}
_sort(column, this.condition);
this.initTable();
},
handleSelectAll(selection) {
_handleSelectAll(this, selection, this.tableData, this.selectRows);
this.selectRowsCount(this.selectRows)
},
search() {
this.changeSelectDataRangeAll();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleTestCase(testCase) {
this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => {
let api = response.data;
let selectApi = api;
let request = {};
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
request = api.request;
} else {
request = JSON.parse(api.request);
}
if (!request.hashTree) {
request.hashTree = [];
}
selectApi.url = request.path;
this.$refs.caseList.open(selectApi, testCase.id);
});
},
reductionApi(row) {
let ids = [row.id];
this.$post('/api/testcase/reduction/', ids, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDeleteBatch() {
// if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let obj = {};
obj.projectId = this.projectId;
obj.selectAllDate = this.isSelectAllDate;
obj.unSelectIds = this.unSelection;
obj.ids = Array.from(this.selectRows).map(row => row.id);
obj = Object.assign(obj, this.condition);
this.$post('/api/testcase/deleteBatchByParam/', obj, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('commons.delete_success'));
});
}
}
});
// } else {
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
// confirmButtonText: this.$t('commons.confirm'),
// callback: (action) => {
// if (action === 'confirm') {
// let ids = Array.from(this.selectRows).map(row => row.id);
// this.$post('/api/testcase/removeToGc/', ids, () => {
// this.selectRows.clear();
// this.initTable();
// this.$success(this.$t('commons.delete_success'));
// });
// }
// }
// });
// }
},
handleEditBatch() {
if (this.currentProtocol == 'HTTP') {
this.valueArr.method = REQ_METHOD;
} else if (this.currentProtocol == 'TCP') {
this.valueArr.method = TCP_METHOD;
} else if (this.currentProtocol == 'SQL') {
this.valueArr.method = SQL_METHOD;
} else if (this.currentProtocol == 'DUBBO') {
this.valueArr.method = DUBBO_METHOD;
}
this.$refs.batchEdit.open();
},
batchEdit(form) {
let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id);
let param = {};
param[form.type] = form.value;
param.ids = ids;
param.projectId = this.projectId;
param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
this.$post('/api/testcase/batch/editByParam', param, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
});
},
handleDelete(apiCase) {
// if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + apiCase.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
this.$get('/api/testcase/delete/' + apiCase.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
});
}
}
});
return;
},
setEnvironment(data) {
this.environmentId = data.id;
},
selectRowsCount(selection) {
let selectedIDs = this.getIds(selection);
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.isSelectAllDate) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = selection.size;
}
},
isSelectDataAll(dataType) {
this.isSelectAllDate = dataType;
this.selectRowsCount(this.selectRows)
//
if (this.selectRows.size != this.tableData.length) {
this.$refs.caseTable.toggleAllSelection(true);
}
},
//
isSelectThissWeekData() {
this.selectDataRange = "all";
let routeParam = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam;
}
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll", "testCase");
},
getIds(rowSets) {
let rowArray = Array.from(rowSets)
let ids = rowArray.map(s => s.id);
return ids;
},
showCaseRef(row) {
let param = {};
Object.assign(param, row);
param.moduleId = undefined;
this.$refs.viewRef.open(param);
},
showEnvironment(row) {
let projectID = this.projectId;
if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
});
});
} else {
this.environment = undefined;
}
this.clickRow = row;
this.$refs.setEnvironment.open(row);
},
headerDragend(newWidth, oldWidth, column, event) {
let finalWidth = newWidth;
if (column.minWidth > finalWidth) {
finalWidth = column.minWidth;
}
column.width = finalWidth;
column.realWidth = finalWidth;
},
createPerformance(row, environment) {
/**
* 思路调用后台创建性能测试的方法把当前案例的hashTree在后台转化为jmx并文件创建性能测试
* 然后跳转到修改性能测试的页面
*
* 性能测试保存地址 performance/save
*
*/
if (!environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
let runData = [];
let singleLoading = true;
row.request = JSON.parse(row.request);
row.request.name = row.id;
row.request.useEnvironment = environment.id;
runData.push(row.request);
/*触发执行操作*/
let testPlan = new TestPlan();
let threadGroup = new ThreadGroup();
threadGroup.hashTree = [];
testPlan.hashTree = [threadGroup];
runData.forEach(item => {
threadGroup.hashTree.push(item);
})
let reqObj = {
id: row.id,
testElement: testPlan,
name: row.name,
projectId: this.projectId,
};
let bodyFiles = getBodyUploadFiles(reqObj, runData);
reqObj.reportId = "run";
let url = "/api/genPerformanceTestXml";
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
let jmxObj = {};
jmxObj.name = response.data.name;
jmxObj.xml = response.data.xml;
jmxObj.attachFiles = response.data.attachFiles;
jmxObj.attachByteFiles = response.data.attachByteFiles;
jmxObj.caseId = reqObj.id;
this.$store.commit('setTest', {
name: row.name,
jmx: jmxObj
})
this.$router.push({
path: "/performance/test/create"
if (this.$refs.caseTable) {
setTimeout(this.$refs.caseTable.doLayout, 200)
}
this.$nextTick(function(){
this.checkTableRowIsSelect();
})
// let performanceId = response.data;
// if(performanceId!=null){
// this.$router.push({
// path: "/performance/test/edit/"+performanceId,
// })
// }
}, erro => {
this.$emit('runRefresh', {});
});
},
}
getLabel(this, API_CASE_LIST);
},
checkTableRowIsSelect(){
//
if(this.selectAll){
let unSelectIds = this.unSelection;
this.tableData.forEach(row=>{
if(unSelectIds.indexOf(row.id)<0){
this.$refs.caseTable.toggleRowSelection(row,true);
//selectRows
if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
}else{
//selectRow
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
}
}
})
}
},
open() {
this.$refs.searchBar.open();
},
handleSelect(selection, row) {
_handleSelect(this, selection, row, this.selectRows);
this.selectRowsCount(this.selectRows)
},
showExecResult(row) {
this.visible = false;
this.$emit('showExecResult', row);
},
filter(filters) {
_filter(filters, this.condition);
this.initTable();
},
sort(column) {
//
if (this.condition.orders) {
this.condition.orders = [];
}
_sort(column, this.condition);
this.initTable();
},
handleSelectAll(selection) {
_handleSelectAll(this, selection, this.tableData, this.selectRows);
this.selectRowsCount(this.selectRows)
},
search() {
this.changeSelectDataRangeAll();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleTestCase(testCase) {
this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => {
let api = response.data;
let selectApi = api;
let request = {};
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
request = api.request;
} else {
request = JSON.parse(api.request);
}
if (!request.hashTree) {
request.hashTree = [];
}
selectApi.url = request.path;
this.$refs.caseList.open(selectApi, testCase.id);
});
},
reductionApi(row) {
let ids = [row.id];
this.$post('/api/testcase/reduction/', ids, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDeleteBatch() {
// if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let obj = {};
obj.projectId = this.projectId;
obj.selectAllDate = this.selectAll;
obj.unSelectIds = this.unSelection;
obj.ids = Array.from(this.selectRows).map(row => row.id);
obj = Object.assign(obj, this.condition);
this.$post('/api/testcase/deleteBatchByParam/', obj, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('commons.delete_success'));
});
}
}
});
// } else {
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
// confirmButtonText: this.$t('commons.confirm'),
// callback: (action) => {
// if (action === 'confirm') {
// let ids = Array.from(this.selectRows).map(row => row.id);
// this.$post('/api/testcase/removeToGc/', ids, () => {
// this.selectRows.clear();
// this.initTable();
// this.$success(this.$t('commons.delete_success'));
// });
// }
// }
// });
// }
},
handleEditBatch() {
if (this.currentProtocol == 'HTTP') {
this.valueArr.method = REQ_METHOD;
} else if (this.currentProtocol == 'TCP') {
this.valueArr.method = TCP_METHOD;
} else if (this.currentProtocol == 'SQL') {
this.valueArr.method = SQL_METHOD;
} else if (this.currentProtocol == 'DUBBO') {
this.valueArr.method = DUBBO_METHOD;
}
this.$refs.batchEdit.open();
},
batchEdit(form) {
let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id);
let param = {};
param[form.type] = form.value;
param.ids = ids;
param.projectId = this.projectId;
param.selectAllDate = this.selectAll;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
this.$post('/api/testcase/batch/editByParam', param, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
});
},
handleDelete(apiCase) {
// if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + apiCase.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
this.$get('/api/testcase/delete/' + apiCase.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
});
}
}
});
return;
},
setEnvironment(data) {
this.environmentId = data.id;
},
selectRowsCount(selection) {
let selectedIDs = this.getIds(selection);
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.selectAll) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = selection.size;
}
},
isSelectDataAll(dataType) {
this.selectAll = dataType;
this.selectRowsCount(this.selectRows)
//
if (this.selectRows.size != this.tableData.length) {
this.$refs.caseTable.toggleAllSelection(true);
}
},
//
isSelectThissWeekData() {
this.selectDataRange = "all";
let routeParam = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam;
}
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll", "testCase");
},
getIds(rowSets) {
let rowArray = Array.from(rowSets)
let ids = rowArray.map(s => s.id);
return ids;
},
showCaseRef(row) {
let param = {};
Object.assign(param, row);
param.moduleId = undefined;
this.$refs.viewRef.open(param);
},
showEnvironment(row) {
let projectID = this.projectId;
if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
});
});
} else {
this.environment = undefined;
}
this.clickRow = row;
this.$refs.setEnvironment.open(row);
},
headerDragend(newWidth, oldWidth, column, event) {
let finalWidth = newWidth;
if (column.minWidth > finalWidth) {
finalWidth = column.minWidth;
}
column.width = finalWidth;
column.realWidth = finalWidth;
},
createPerformance(row, environment) {
/**
* 思路调用后台创建性能测试的方法把当前案例的hashTree在后台转化为jmx并文件创建性能测试
* 然后跳转到修改性能测试的页面
*
* 性能测试保存地址 performance/save
*
*/
if (!environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
let runData = [];
let singleLoading = true;
row.request = JSON.parse(row.request);
row.request.name = row.id;
row.request.useEnvironment = environment.id;
runData.push(row.request);
/*触发执行操作*/
let testPlan = new TestPlan();
let threadGroup = new ThreadGroup();
threadGroup.hashTree = [];
testPlan.hashTree = [threadGroup];
runData.forEach(item => {
threadGroup.hashTree.push(item);
})
let reqObj = {
id: row.id,
testElement: testPlan,
name: row.name,
projectId: this.projectId,
};
let bodyFiles = getBodyUploadFiles(reqObj, runData);
reqObj.reportId = "run";
let url = "/api/genPerformanceTestXml";
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
let jmxObj = {};
jmxObj.name = response.data.name;
jmxObj.xml = response.data.xml;
jmxObj.attachFiles = response.data.attachFiles;
jmxObj.attachByteFiles = response.data.attachByteFiles;
jmxObj.caseId = reqObj.id;
this.$store.commit('setTest', {
name: row.name,
jmx: jmxObj
})
this.$router.push({
path: "/performance/test/create"
})
// let performanceId = response.data;
// if(performanceId!=null){
// this.$router.push({
// path: "/performance/test/edit/"+performanceId,
// })
// }
}, erro => {
this.$emit('runRefresh', {});
});
},
},
}
</script>
<style scoped>
.operate-button > div {
display: inline-block;
margin-left: 10px;
}
.operate-button > div {
display: inline-block;
margin-left: 10px;
}
.request-method {
padding: 0 5px;
color: #1E90FF;
}
.request-method {
padding: 0 5px;
color: #1E90FF;
}
.api-el-tag {
color: white;
}
.api-el-tag {
color: white;
}
.search-input {
float: right;
width: 300px;
/*margin-bottom: 20px;*/
margin-right: 10px;
}
.search-input {
float: right;
width: 300px;
/*margin-bottom: 20px;*/
margin-right: 10px;
}
.ms-select-all >>> th:first-child {
margin-top: 20px;
}
.ms-select-all >>> th:first-child {
margin-top: 20px;
}
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
top: -2px;
}
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
top: -2px;
}
/deep/ .el-table__fixed {
height: 100% !important;
}
/deep/ .el-table__fixed {
height: 100% !important;
}
</style>

View File

@ -386,9 +386,11 @@
},
watch: {
selectNodeIds() {
initCondition(this.condition,false);
this.initTable();
},
currentProtocol() {
initCondition(this.condition,false);
this.initTable();
},
trashEnable() {
@ -398,6 +400,7 @@
} else {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
}
initCondition(this.condition,false);
this.initTable();
}
},
@ -419,7 +422,7 @@
},
initTable() {
this.selectRows = new Set();
initCondition(this.condition);
initCondition(this.condition,this.condition.selectAll);
this.selectDataCounts = 0;
this.condition.moduleIds = this.selectNodeIds;
this.condition.projectId = this.projectId;
@ -464,11 +467,37 @@
if (this.$refs.apiDefinitionTable) {
setTimeout(this.$refs.apiDefinitionTable.doLayout, 200)
}
// nexttick:
this.$nextTick(function(){
this.checkTableRowIsSelect();
})
});
}
getLabel(this, API_LIST);
},
checkTableRowIsSelect(){
//
if(this.condition.selectAll){
let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{
if(unSelectIds.indexOf(row.id)<0){
this.$refs.apiDefinitionTable.toggleRowSelection(row,true);
//selectRows
if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
}else{
//selectRow
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
}
}
})
}
},
genProtocalFilter(protocalType) {
if (protocalType === "HTTP") {
this.methodFilters = [

View File

@ -1,21 +1,9 @@
<template>
<ms-container>
<ms-main-container>
<el-row :gutter="20">
<el-col :span="24">
<overview-compare-card ref="overviewCard"/>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<load-compare-card ref="loadCard"/>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<response-time-compare-card ref="responseTimeCard"/>
</el-col>
</el-row>
<el-card>
</el-card>
</ms-main-container>
</ms-container>
</template>
@ -24,16 +12,15 @@
import MsContainer from "@/business/components/common/components/MsContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
import OverviewCompareCard from "@/business/components/performance/report/components/OverviewCompareCard";
import MsChart from "@/business/components/common/chart/MsChart";
import LoadCompareCard from "@/business/components/performance/report/components/LoadCompareCard";
import ResponseTimeCompareCard from "@/business/components/performance/report/components/ResponseTimeCompareCard";
export default {
name: "PerformanceReportCompare",
components: {ResponseTimeCompareCard, LoadCompareCard, MsChart, OverviewCompareCard, MsMainContainer, MsContainer},
components: {MsMainContainer, MsContainer},
mounted() {
this.init();
let reportId = this.$route.path.split('/')[4];
console.log(reportId);
let items = localStorage.getItem("compareReportIds");
console.log(JSON.parse(items));
},
computed: {
isReadOnly() {
@ -43,28 +30,11 @@ export default {
data() {
return {}
},
methods: {
init() {
this.$refs.overviewCard.initTable();
this.$refs.loadCard.initCard();
this.$refs.responseTimeCard.initCard();
}
},
watch: {
'$route'(to) {
if (to.name !== "ReportCompare") {
return;
}
methods: {}
this.init();
}
}
}
</script>
<style scoped>
.el-row {
padding-bottom: 20px;
}
</style>

View File

@ -25,9 +25,6 @@
<el-button :disabled="isReadOnly" type="info" plain size="mini" @click="handleExport(reportName)">
{{ $t('test_track.plan_view.export_report') }}
</el-button>
<el-button :disabled="isReadOnly || report.status !== 'Completed'" type="default" plain size="mini" @click="compareReports()">
{{ $t('report.compare') }}
</el-button>
<el-button :disabled="isReadOnly" type="warning" plain size="mini" @click="downloadJtl()">
{{ $t('report.downloadJtl') }}
</el-button>
@ -332,8 +329,6 @@ export default {
this.$set(this.report, "id", this.reportId);
this.$set(this.report, "status", data.status);
this.$set(this.report, "testId", data.testId);
this.$set(this.report, "name", data.name);
this.$set(this.report, "createTime", data.createTime);
this.$set(this.report, "loadConfiguration", data.loadConfiguration);
this.checkReportStatus(data.status);
if (this.status === "Completed" || this.status === "Running") {

View File

@ -71,8 +71,6 @@
<template v-slot:default="scope">
<ms-table-operator-button :tip="$t('api_report.detail')" icon="el-icon-s-data"
@exec="handleEdit(scope.row)" type="primary"/>
<ms-table-operator-button :tip="$t('load_test.report.diff')" icon="el-icon-s-operation"
@exec="handleDiff(scope.row)" type="warning"/>
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_report.delete')"
icon="el-icon-delete" @exec="handleDelete(scope.row)" type="danger"/>
</template>

View File

@ -1,182 +0,0 @@
<template>
<el-card>
<template v-slot:header>
<span class="title">Load</span>
</template>
<div v-for="(option, index) in loadList" :key="index">
<ms-chart ref="chart1" :options="option" :autoresize="true"></ms-chart>
</div>
</el-card>
</template>
<script>
import MsChart from "@/business/components/common/chart/MsChart";
export default {
name: "LoadCompareCard",
components: {MsChart},
data() {
return {
loadList: []
}
},
methods: {
initCard() {
this.loadList = [];
this.reportId = this.$route.path.split('/')[4];
this.compareReports = JSON.parse(localStorage.getItem("compareReports"));
this.compareReports.forEach(report => {
this.initOverview(report);
})
},
initOverview(report) {
this.$get("/performance/report/content/load_chart/" + report.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxis2ListMax = this._getChartMax(yAxis2List);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let loadOption = {
title: {
text: report.name + " " + this.$options.filters['timestampFormatDate'](report.createTime),
left: 'center',
top: 20,
textStyle: {
color: '#65A2FF'
},
},
tooltip: {
show: true,
trigger: 'axis',
// extraCssText: 'z-index: 999;',
confine: true,
},
legend: {},
xAxis: {},
yAxis: [{
name: 'User',
type: 'value',
min: 0,
max: yAxisListMax,
splitNumber: 5,
interval: yAxisListMax / 5
},
{
name: 'Transactions/s',
type: 'value',
splitNumber: 5,
min: 0,
max: yAxis2ListMax,
interval: yAxis2ListMax / 5
}
],
series: []
};
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
},
{
name: 'hits',
yAxisIndex: '1',
color: '#65A2FF',
},
{
name: 'errors',
yAxisIndex: '1',
color: '#E6113C',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
})
this.loadList.push(this.generateOption(loadOption, data, setting));
}).catch(() => {
this.loadList = [];
})
},
generateOption(option, data, setting) {
let chartData = data;
let seriesArray = [];
for (let set in setting) {
if (set === "series") {
seriesArray = setting[set];
continue;
}
this.$set(option, set, setting[set]);
}
let legend = [], series = {}, xAxis = [], seriesData = [];
chartData.forEach(item => {
if (!xAxis.includes(item.xAxis)) {
xAxis.push(item.xAxis);
}
xAxis.sort()
let name = item.groupName
if (!legend.includes(name)) {
legend.push(name)
series[name] = []
}
if (item.yAxis === -1) {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis2.toFixed(2)]);
} else {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]);
}
})
this.$set(option.legend, "data", legend);
this.$set(option.legend, "type", "scroll");
this.$set(option.legend, "bottom", "10px");
this.$set(option.xAxis, "data", xAxis);
for (let name in series) {
let d = series[name];
d.sort((a, b) => a[0].localeCompare(b[0]));
let items = {
name: name,
type: 'line',
data: d,
smooth: true
};
let seriesArrayNames = seriesArray.map(m => m.name);
if (seriesArrayNames.includes(name)) {
for (let j = 0; j < seriesArray.length; j++) {
let seriesObj = seriesArray[j];
if (seriesObj['name'] === name) {
Object.assign(items, seriesObj);
}
}
}
seriesData.push(items);
}
this.$set(option, "series", seriesData);
return option;
},
_getChartMax(arr) {
const max = Math.max(...arr);
return Math.ceil(max / 4.5) * 5;
},
_unique(arr) {
return Array.from(new Set(arr));
}
}
}
</script>
<style scoped>
.echarts {
width: 100%;
height: 300px;
}
</style>

View File

@ -1,67 +0,0 @@
<template>
<el-card class="table-card">
<template v-slot:header>
<span class="title">Overview</span>
</template>
<el-table border :data="overviewList" class="adjust-table test-content">
<el-table-column prop="name" :label="$t('commons.name')"/>
<el-table-column prop="createTime" :label="$t('commons.create_time')">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="maxUsers" label="Max Users"/>
<el-table-column prop="avgTransactions" label="Avg.Transactions"/>
<el-table-column prop="errors" label="Errors"/>
<el-table-column prop="avgResponseTime" label="Avg.Response Time"/>
<el-table-column prop="responseTime90" label="90% Response Time"/>
<el-table-column prop="avgBandwidth" label="Avg.Bandwidth"/>
</el-table>
</el-card>
</template>
<script>
export default {
name: "OverviewCompareCard",
data() {
return {
reportId: null,
compareReports: [],
overviewList: [],
};
},
methods: {
initTable() {
this.overviewList = [];
this.reportId = this.$route.path.split('/')[4];
this.compareReports = JSON.parse(localStorage.getItem("compareReports"));
this.compareReports.forEach(report => {
this.initOverview(report);
})
},
initOverview(report) {
this.$get("/performance/report/content/testoverview/" + report.id).then(res => {
let data = res.data.data;
this.overviewList.push({
name: report.name,
createTime: report.createTime,
maxUsers: data.maxUsers,
avgThroughput: data.avgThroughput,
avgTransactions: data.avgTransactions,
errors: data.errors,
avgResponseTime: data.avgResponseTime,
responseTime90: data.responseTime90,
avgBandwidth: data.avgBandwidth,
})
}).catch(() => {
})
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,188 +0,0 @@
<template>
<el-card>
<template v-slot:header>
<span class="title">Response Time</span>
</template>
<div v-for="(option, index) in responseTimeList" :key="index">
<ms-chart ref="chart1" :options="option" :autoresize="true"></ms-chart>
</div>
</el-card>
</template>
<script>
import MsChart from "@/business/components/common/chart/MsChart";
export default {
name: "ResponseTimeCompareCard",
components: {MsChart},
data() {
return {
responseTimeList: []
}
},
methods: {
initCard() {
this.responseTimeList = [];
this.reportId = this.$route.path.split('/')[4];
this.compareReports = JSON.parse(localStorage.getItem("compareReports"));
this.compareReports.forEach(report => {
this.initOverview(report);
})
},
initOverview(report) {
this.$get("/performance/report/content/res_chart/" + report.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxis2ListMax = this._getChartMax(yAxis2List);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let resOption = {
title: {
text: report.name + " " + this.$options.filters['timestampFormatDate'](report.createTime),
left: 'center',
top: 20,
textStyle: {
color: '#99743C'
},
},
tooltip: {
show: true,
trigger: 'axis',
// extraCssText: 'z-index: 999;',
confine: true,
formatter: function (params, ticket, callback) {
let result = "";
let name = params[0].name;
result += name + "<br/>";
for (let i = 0; i < params.length; i++) {
let seriesName = params[i].seriesName;
if (seriesName.length > 100) {
seriesName = seriesName.substring(0, 100);
}
let value = params[i].value;
let marker = params[i].marker;
result += marker + seriesName + ": " + value[1] + "<br/>";
}
return result;
}
},
legend: {},
xAxis: {},
yAxis: [{
name: 'User',
type: 'value',
min: 0,
max: yAxisListMax,
interval: yAxisListMax / 5
},
{
name: 'Response Time',
type: 'value',
min: 0,
max: yAxis2ListMax,
interval: yAxis2ListMax / 5
}
],
series: []
}
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
})
this.responseTimeList.push(this.generateOption(resOption, data, setting));
}).catch(() => {
this.responseTimeList = [];
})
},
generateOption(option, data, setting) {
let chartData = data;
let seriesArray = [];
for (let set in setting) {
if (set === "series") {
seriesArray = setting[set];
continue;
}
this.$set(option, set, setting[set]);
}
let legend = [], series = {}, xAxis = [], seriesData = [];
chartData.forEach(item => {
if (!xAxis.includes(item.xAxis)) {
xAxis.push(item.xAxis);
}
xAxis.sort()
let name = item.groupName
if (!legend.includes(name)) {
legend.push(name)
series[name] = []
}
if (item.yAxis === -1) {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis2.toFixed(2)]);
} else {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]);
}
})
this.$set(option.legend, "data", legend);
this.$set(option.legend, "type", "scroll");
this.$set(option.legend, "bottom", "10px");
this.$set(option.xAxis, "data", xAxis);
for (let name in series) {
let d = series[name];
d.sort((a, b) => a[0].localeCompare(b[0]));
let items = {
name: name,
type: 'line',
data: d,
smooth: true
};
let seriesArrayNames = seriesArray.map(m => m.name);
if (seriesArrayNames.includes(name)) {
for (let j = 0; j < seriesArray.length; j++) {
let seriesObj = seriesArray[j];
if (seriesObj['name'] === name) {
Object.assign(items, seriesObj);
}
}
}
seriesData.push(items);
}
this.$set(option, "series", seriesData);
return option;
},
_getChartMax(arr) {
const max = Math.max(...arr);
return Math.ceil(max / 4.5) * 5;
},
_unique(arr) {
return Array.from(new Set(arr));
}
}
}
</script>
<style scoped>
.echarts {
width: 100%;
height: 300px;
}
</style>

View File

@ -5,23 +5,20 @@
:visible.sync="loadReportVisible">
<el-table v-loading="reportLoadingResult.loading"
class="basic-config"
:data="tableData"
:data="compareReports"
@select-all="handleSelectAll"
@select="handleSelectionChange">
<el-table-column type="selection"/>
<el-table-column
prop="name"
:label="$t('commons.name')"
show-overflow-tooltip>
<template v-slot:default="scope">
<i v-if="scope.row.id === report.id" class="el-icon-star-on"></i> {{ scope.row.name }}
</template>
prop="name"
:label="$t('commons.name')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="userName"
:label="$t('report.user_name')"
show-overflow-tooltip>
prop="userName"
:label="$t('report.user_name')"
show-overflow-tooltip>
</el-table-column>
<el-table-column prop="triggerMode"
:label="$t('test_track.report.list.trigger_mode')">
@ -30,7 +27,7 @@
</template>
</el-table-column>
<el-table-column
:label="$t('commons.create_time')">
:label="$t('commons.create_time')">
<template v-slot:default="scope">
<i class="el-icon-time"/>
<span class="last-modified">{{ scope.row.createTime | timestampFormatDate }}</span>
@ -58,56 +55,46 @@ export default {
return {
loadReportVisible: false,
reportLoadingResult: {},
tableData: [],
compareReports: [],
currentPage: 1,
pageSize: 10,
total: 0,
selectIds: new Set,
report: {},
compareReports: [],
}
},
methods: {
open(report) {
this.report = report;
this.getCompareReports(report);
this.compareReports.push(report);
this.getCompareReports(report.testId);
this.loadReportVisible = true;
},
close() {
this.loadReportVisible = false;
},
getCompareReports(report) {
getCompareReports(testId) {
let condition = {
testId: report.testId,
testId: testId,
filters: {status: ["Completed"]}
};
this.reportLoadingResult = this.$post('/performance/report/list/all/' + this.currentPage + "/" + this.pageSize, condition, res => {
let data = res.data;
this.total = data.itemCount;
this.tableData = data.listObject;
this.compareReports = data.listObject;
})
},
handleCompare() {
let reportIds = [...this.selectIds];
this.tableData
.filter(r => reportIds.indexOf(r.id) > -1 && this.report.id !== r.id)
.forEach(r => this.compareReports.push(r));
localStorage.setItem("compareReports", JSON.stringify(this.compareReports));
localStorage.setItem("compareReportIds", JSON.stringify(reportIds));
this.close();
this.$router.push({path: '/performance/report/compare/' + reportIds[0]});
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.tableData.forEach(item => {
this.compareReports.forEach(item => {
this.selectIds.add(item.id);
});
} else {
this.tableData.forEach(item => {
this.compareReports.forEach(item => {
if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id);
}

View File

@ -216,8 +216,36 @@
})
}
this.total = data.itemCount;
this.$nextTick(function(){
this.checkTableRowIsSelect();
});
})
},
checkTableRowIsSelect(){
//
if(this.condition.selectAll){
let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{
if(unSelectIds.indexOf(row.id)<0){
this.$refs.userTable.toggleRowSelection(row,true);
//selectRows
if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
}else{
//selectRow
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
}
}
})
}
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},

View File

@ -598,7 +598,7 @@ export default {
return;
}
this.selectRows = new Set();
this.condition.selectAll = false;
// this.condition.selectAll = false;
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
let data = response.data;
this.total = data.itemCount;
@ -615,8 +615,38 @@ export default {
});
}
}
this.$nextTick(function(){
this.checkTableRowIsSelect();
});
})
},
checkTableRowIsSelect(){
//
if(this.condition.selectAll){
let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{
if(unSelectIds.indexOf(row.id)<0){
this.$refs.userTable.toggleRowSelection(row,true);
//selectRows
if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
}else{
//selectRow
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
}
}
})
}
},
handleClose() {
this.form = {roles: [{id: ''}]};
this.btnAddRole = false;

View File

@ -208,8 +208,33 @@
})
}
this.total = data.itemCount;
this.$nextTick(function(){
this.checkTableRowIsSelect();
});
})
},
checkTableRowIsSelect(){
//
if(this.condition.selectAll){
let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{
if(unSelectIds.indexOf(row.id)<0){
this.$refs.userTable.toggleRowSelection(row,true);
//selectRows
if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
}else{
//selectRow
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
}
}
})
}
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;

View File

@ -314,6 +314,7 @@ export default {
watch: {
selectNodeIds() {
this.currentPage = 1;
initCondition(this.condition,false);
this.initTableData();
},
condition() {
@ -332,7 +333,8 @@ export default {
initTableData() {
this.condition.planId = "";
this.condition.nodeIds = [];
initCondition(this.condition);
//initCondition(this.condition);
initCondition(this.condition,this.condition.selectAll);
this.selectDataCounts = 0;
if (this.planId) {
// param.planId = this.planId;
@ -394,9 +396,35 @@ export default {
setTimeout(this.$refs.table.doLayout, 200)
}
this.$nextTick(function(){
this.checkTableRowIsSelect();
})
});
}
},
checkTableRowIsSelect(){
//
if(this.condition.selectAll){
let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{
if(unSelectIds.indexOf(row.id)<0){
this.$refs.table.toggleRowSelection(row,true);
//selectRows
if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
}else{
//selectRow
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
}
}
})
}
},
search() {
this.initTableData();
},

View File

@ -43,7 +43,6 @@ export function setUnSelectIds(tableData, condition, selectRows) {
condition.unSelectIds = allIDs.filter(function (val) {
return ids.indexOf(val) === -1
});
}
export function getSelectDataCounts(condition, total, selectRows) {
@ -102,9 +101,11 @@ export function _sort(column, condition) {
}
}
export function initCondition(condition) {
condition.selectAll = false;
condition.unSelectIds = [];
export function initCondition(condition,isSelectAll) {
if(!isSelectAll){
condition.selectAll = false;
condition.unSelectIds = [];
}
}
export function getLabel(vueObj, type) {