Merge branch 'v1.8' of https://github.com/metersphere/metersphere into v1.8
This commit is contained in:
commit
6fd9b1aaa4
|
@ -74,11 +74,21 @@ public class ApiAutomationController {
|
||||||
apiAutomationService.deleteBatch(ids);
|
apiAutomationService.deleteBatch(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteBatchByCondition")
|
||||||
|
public void deleteBatchByCondition(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
|
apiAutomationService.deleteBatchByCondition(request);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/removeToGc")
|
@PostMapping("/removeToGc")
|
||||||
public void removeToGc(@RequestBody List<String> ids) {
|
public void removeToGc(@RequestBody List<String> ids) {
|
||||||
apiAutomationService.removeToGc(ids);
|
apiAutomationService.removeToGc(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/removeToGcByBatch")
|
||||||
|
public void removeToGcByBatch(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
|
apiAutomationService.removeToGcByBatch(request);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/reduction")
|
@PostMapping("/reduction")
|
||||||
public void reduction(@RequestBody List<String> ids) {
|
public void reduction(@RequestBody List<String> ids) {
|
||||||
apiAutomationService.reduction(ids);
|
apiAutomationService.reduction(ids);
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.commons.user;
|
package io.metersphere.commons.user;
|
||||||
|
|
||||||
import io.metersphere.commons.utils.CodingUtil;
|
import io.metersphere.commons.utils.CodingUtil;
|
||||||
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.dto.UserDTO;
|
import io.metersphere.dto.UserDTO;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -28,7 +29,7 @@ public class SessionUser extends UserDTO implements Serializable {
|
||||||
SessionUser sessionUser = new SessionUser();
|
SessionUser sessionUser = new SessionUser();
|
||||||
BeanUtils.copyProperties(user, 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);
|
sessionUser.csrfToken = CodingUtil.aesEncrypt(StringUtils.join(infos, "|"), secret, iv);
|
||||||
return sessionUser;
|
return sessionUser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.apache.shiro.subject.support.DefaultSubjectContext;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static io.metersphere.commons.constants.SessionConstants.ATTR_USER;
|
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) {
|
private static Session getSessionByUsername(String username) {
|
||||||
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
|
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
|
||||||
Collection<Session> sessions = sessionManager.getSessionDAO().getActiveSessions();
|
Collection<Session> sessions = sessionManager.getSessionDAO().getActiveSessions();
|
||||||
|
|
|
@ -71,11 +71,14 @@ public class CsrfFilter extends AnonymousFilter {
|
||||||
csrfToken = CodingUtil.aesDecrypt(csrfToken, SessionUser.secret, SessionUser.iv);
|
csrfToken = CodingUtil.aesDecrypt(csrfToken, SessionUser.secret, SessionUser.iv);
|
||||||
|
|
||||||
String[] signatureArray = StringUtils.split(StringUtils.trimToNull(csrfToken), "|");
|
String[] signatureArray = StringUtils.split(StringUtils.trimToNull(csrfToken), "|");
|
||||||
if (signatureArray.length != 3) {
|
if (signatureArray.length != 4) {
|
||||||
throw new RuntimeException("invalid token");
|
throw new RuntimeException("invalid token");
|
||||||
}
|
}
|
||||||
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
|
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
|
||||||
throw new RuntimeException("Please check csrf token.");
|
throw new RuntimeException("Please check csrf token.");
|
||||||
}
|
}
|
||||||
|
if (!StringUtils.equals(SessionUtils.getSessionId(), signatureArray[2])) {
|
||||||
|
throw new RuntimeException("Please check csrf token.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,6 +348,9 @@
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selectNodeIds() {
|
selectNodeIds() {
|
||||||
|
this.condition.selectAll = false;
|
||||||
|
this.condition.unSelectIds = [];
|
||||||
|
this.selectDataCounts = 0;
|
||||||
this.selectProjectId ? this.search(this.selectProjectId) : this.search();
|
this.selectProjectId ? this.search(this.selectProjectId) : this.search();
|
||||||
},
|
},
|
||||||
trashEnable() {
|
trashEnable() {
|
||||||
|
@ -357,6 +360,10 @@
|
||||||
} else {
|
} else {
|
||||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||||
}
|
}
|
||||||
|
this.condition.selectAll = false;
|
||||||
|
this.condition.unSelectIds = [];
|
||||||
|
this.selectDataCounts = 0;
|
||||||
|
|
||||||
this.search();
|
this.search();
|
||||||
},
|
},
|
||||||
batchReportId() {
|
batchReportId() {
|
||||||
|
@ -414,9 +421,13 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.selection = [];
|
this.selection = [];
|
||||||
this.selectAll = false;
|
|
||||||
this.unSelection = [];
|
if(!this.condition.selectAll){
|
||||||
|
this.condition.selectAll = false;
|
||||||
|
this.condition.unSelectIds = [];
|
||||||
this.selectDataCounts = 0;
|
this.selectDataCounts = 0;
|
||||||
|
}
|
||||||
|
|
||||||
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
|
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
|
||||||
if (this.condition.projectId) {
|
if (this.condition.projectId) {
|
||||||
this.result.loading = true;
|
this.result.loading = true;
|
||||||
|
@ -430,23 +441,53 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.result.loading = false;
|
this.result.loading = false;
|
||||||
this.unSelection = data.listObject.map(s => s.id);
|
|
||||||
if (this.$refs.scenarioTable) {
|
if (this.$refs.scenarioTable) {
|
||||||
setTimeout(this.$refs.scenarioTable.doLayout, 200)
|
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);
|
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) {
|
handleCommand(cmd) {
|
||||||
let table = this.$refs.scenarioTable;
|
let table = this.$refs.scenarioTable;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "table":
|
case "table":
|
||||||
this.selectAll = false;
|
this.condition.selectAll = false;
|
||||||
table.toggleAllSelection();
|
table.toggleAllSelection();
|
||||||
break;
|
break;
|
||||||
case "all":
|
case "all":
|
||||||
this.selectAll = true;
|
this.condition.selectAll = true;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -520,11 +561,6 @@
|
||||||
addTestPlan(params) {
|
addTestPlan(params) {
|
||||||
let obj = {planIds: params[0], scenarioIds: this.selection};
|
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 选取全部数据
|
// todo 选取全部数据
|
||||||
if (this.isSelectAllDate) {
|
if (this.isSelectAllDate) {
|
||||||
this.$warning("暂不支持批量添加所有场景到测试计划!");
|
this.$warning("暂不支持批量添加所有场景到测试计划!");
|
||||||
|
@ -619,8 +655,10 @@
|
||||||
},
|
},
|
||||||
handleDeleteBatch(row) {
|
handleDeleteBatch(row) {
|
||||||
if (this.trashEnable) {
|
if (this.trashEnable) {
|
||||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
//let ids = Array.from(this.selectRows).map(row => row.id);
|
||||||
this.$post('/api/automation/deleteBatch/', ids, () => {
|
let param = {};
|
||||||
|
this.buildBatchParam(param);
|
||||||
|
this.$post('/api/automation/deleteBatchByCondition/', param, () => {
|
||||||
this.$success(this.$t('commons.delete_success'));
|
this.$success(this.$t('commons.delete_success'));
|
||||||
this.search();
|
this.search();
|
||||||
});
|
});
|
||||||
|
@ -630,8 +668,10 @@
|
||||||
confirmButtonText: this.$t('commons.confirm'),
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
callback: (action) => {
|
callback: (action) => {
|
||||||
if (action === 'confirm') {
|
if (action === 'confirm') {
|
||||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
//let ids = Array.from(this.selectRows).map(row => row.id);
|
||||||
this.$post('/api/automation/removeToGc/', ids, () => {
|
let param = {};
|
||||||
|
this.buildBatchParam(param);
|
||||||
|
this.$post('/api/automation/removeToGcByBatch/', param, () => {
|
||||||
this.$success(this.$t('commons.delete_success'));
|
this.$success(this.$t('commons.delete_success'));
|
||||||
this.search();
|
this.search();
|
||||||
});
|
});
|
||||||
|
@ -686,8 +726,11 @@
|
||||||
confirmButtonText: this.$t('commons.confirm'),
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
callback: (action) => {
|
callback: (action) => {
|
||||||
if (action === 'confirm') {
|
if (action === 'confirm') {
|
||||||
let ids = [row.id];
|
// let ids = [row.id];
|
||||||
this.$post('/api/automation/removeToGc/', ids, () => {
|
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.$success(this.$t('commons.delete_success'));
|
||||||
this.search();
|
this.search();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<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"/>
|
v-model="condition.name"/>
|
||||||
|
|
||||||
<el-table v-loading="result.loading"
|
<el-table v-loading="result.loading"
|
||||||
|
@ -71,7 +73,8 @@
|
||||||
<el-table-column v-if="item.id=='tags'" prop="tags" min-width="120px" :label="$t('commons.tag')"
|
<el-table-column v-if="item.id=='tags'" prop="tags" min-width="120px" :label="$t('commons.tag')"
|
||||||
:key="index">
|
:key="index">
|
||||||
<template v-slot:default="scope">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
@ -267,13 +270,22 @@ export default {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selectNodeIds() {
|
selectNodeIds() {
|
||||||
|
this.selectAll = false;
|
||||||
|
this.unSelection = [];
|
||||||
|
this.selectDataCounts = 0;
|
||||||
this.initTable();
|
this.initTable();
|
||||||
},
|
},
|
||||||
currentProtocol() {
|
currentProtocol() {
|
||||||
|
this.selectAll = false;
|
||||||
|
this.unSelection = [];
|
||||||
|
this.selectDataCounts = 0;
|
||||||
this.initTable();
|
this.initTable();
|
||||||
},
|
},
|
||||||
trashEnable() {
|
trashEnable() {
|
||||||
if (this.trashEnable) {
|
if (this.trashEnable) {
|
||||||
|
this.selectAll = false;
|
||||||
|
this.unSelection = [];
|
||||||
|
this.selectDataCounts = 0;
|
||||||
this.initTable();
|
this.initTable();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -302,9 +314,11 @@ export default {
|
||||||
this.condition.status = "Trash";
|
this.condition.status = "Trash";
|
||||||
this.condition.moduleIds = [];
|
this.condition.moduleIds = [];
|
||||||
}
|
}
|
||||||
|
if(!this.selectAll){
|
||||||
this.selectAll = false;
|
this.selectAll = false;
|
||||||
this.unSelection = [];
|
this.unSelection = [];
|
||||||
this.selectDataCounts = 0;
|
this.selectDataCounts = 0;
|
||||||
|
}
|
||||||
this.condition.projectId = this.projectId;
|
this.condition.projectId = this.projectId;
|
||||||
|
|
||||||
if (this.currentProtocol != null) {
|
if (this.currentProtocol != null) {
|
||||||
|
@ -328,7 +342,10 @@ export default {
|
||||||
this.result = this.$post('/api/testcase/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => {
|
this.result = this.$post('/api/testcase/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => {
|
||||||
this.total = response.data.itemCount;
|
this.total = response.data.itemCount;
|
||||||
this.tableData = response.data.listObject;
|
this.tableData = response.data.listObject;
|
||||||
|
|
||||||
|
if(!this.selectAll){
|
||||||
this.unSelection = response.data.listObject.map(s => s.id);
|
this.unSelection = response.data.listObject.map(s => s.id);
|
||||||
|
}
|
||||||
|
|
||||||
this.tableData.forEach(item => {
|
this.tableData.forEach(item => {
|
||||||
if (item.tags && item.tags.length > 0) {
|
if (item.tags && item.tags.length > 0) {
|
||||||
|
@ -338,11 +355,38 @@ export default {
|
||||||
if (this.$refs.caseTable) {
|
if (this.$refs.caseTable) {
|
||||||
setTimeout(this.$refs.caseTable.doLayout, 200)
|
setTimeout(this.$refs.caseTable.doLayout, 200)
|
||||||
}
|
}
|
||||||
|
this.$nextTick(function(){
|
||||||
|
this.checkTableRowIsSelect();
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getLabel(this, API_CASE_LIST);
|
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() {
|
open() {
|
||||||
this.$refs.searchBar.open();
|
this.$refs.searchBar.open();
|
||||||
},
|
},
|
||||||
|
@ -410,7 +454,7 @@ export default {
|
||||||
if (action === 'confirm') {
|
if (action === 'confirm') {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
obj.projectId = this.projectId;
|
obj.projectId = this.projectId;
|
||||||
obj.selectAllDate = this.isSelectAllDate;
|
obj.selectAllDate = this.selectAll;
|
||||||
obj.unSelectIds = this.unSelection;
|
obj.unSelectIds = this.unSelection;
|
||||||
obj.ids = Array.from(this.selectRows).map(row => row.id);
|
obj.ids = Array.from(this.selectRows).map(row => row.id);
|
||||||
obj = Object.assign(obj, this.condition);
|
obj = Object.assign(obj, this.condition);
|
||||||
|
@ -457,7 +501,7 @@ export default {
|
||||||
param[form.type] = form.value;
|
param[form.type] = form.value;
|
||||||
param.ids = ids;
|
param.ids = ids;
|
||||||
param.projectId = this.projectId;
|
param.projectId = this.projectId;
|
||||||
param.selectAllDate = this.isSelectAllDate;
|
param.selectAllDate = this.selectAll;
|
||||||
param.unSelectIds = this.unSelection;
|
param.unSelectIds = this.unSelection;
|
||||||
param = Object.assign(param, this.condition);
|
param = Object.assign(param, this.condition);
|
||||||
this.$post('/api/testcase/batch/editByParam', param, () => {
|
this.$post('/api/testcase/batch/editByParam', param, () => {
|
||||||
|
@ -489,14 +533,14 @@ export default {
|
||||||
this.unSelection = allIDs.filter(function (val) {
|
this.unSelection = allIDs.filter(function (val) {
|
||||||
return selectedIDs.indexOf(val) === -1
|
return selectedIDs.indexOf(val) === -1
|
||||||
});
|
});
|
||||||
if (this.isSelectAllDate) {
|
if (this.selectAll) {
|
||||||
this.selectDataCounts = this.total - this.unSelection.length;
|
this.selectDataCounts = this.total - this.unSelection.length;
|
||||||
} else {
|
} else {
|
||||||
this.selectDataCounts = selection.size;
|
this.selectDataCounts = selection.size;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isSelectDataAll(dataType) {
|
isSelectDataAll(dataType) {
|
||||||
this.isSelectAllDate = dataType;
|
this.selectAll = dataType;
|
||||||
this.selectRowsCount(this.selectRows)
|
this.selectRowsCount(this.selectRows)
|
||||||
//如果已经全选,不需要再操作了
|
//如果已经全选,不需要再操作了
|
||||||
if (this.selectRows.size != this.tableData.length) {
|
if (this.selectRows.size != this.tableData.length) {
|
||||||
|
|
|
@ -386,9 +386,11 @@
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selectNodeIds() {
|
selectNodeIds() {
|
||||||
|
initCondition(this.condition,false);
|
||||||
this.initTable();
|
this.initTable();
|
||||||
},
|
},
|
||||||
currentProtocol() {
|
currentProtocol() {
|
||||||
|
initCondition(this.condition,false);
|
||||||
this.initTable();
|
this.initTable();
|
||||||
},
|
},
|
||||||
trashEnable() {
|
trashEnable() {
|
||||||
|
@ -398,6 +400,7 @@
|
||||||
} else {
|
} else {
|
||||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||||
}
|
}
|
||||||
|
initCondition(this.condition,false);
|
||||||
this.initTable();
|
this.initTable();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -419,7 +422,7 @@
|
||||||
},
|
},
|
||||||
initTable() {
|
initTable() {
|
||||||
this.selectRows = new Set();
|
this.selectRows = new Set();
|
||||||
initCondition(this.condition);
|
initCondition(this.condition,this.condition.selectAll);
|
||||||
this.selectDataCounts = 0;
|
this.selectDataCounts = 0;
|
||||||
this.condition.moduleIds = this.selectNodeIds;
|
this.condition.moduleIds = this.selectNodeIds;
|
||||||
this.condition.projectId = this.projectId;
|
this.condition.projectId = this.projectId;
|
||||||
|
@ -464,11 +467,37 @@
|
||||||
if (this.$refs.apiDefinitionTable) {
|
if (this.$refs.apiDefinitionTable) {
|
||||||
setTimeout(this.$refs.apiDefinitionTable.doLayout, 200)
|
setTimeout(this.$refs.apiDefinitionTable.doLayout, 200)
|
||||||
}
|
}
|
||||||
|
// nexttick:表格加载完成之后触发。判断是否需要勾选行
|
||||||
|
this.$nextTick(function(){
|
||||||
|
this.checkTableRowIsSelect();
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getLabel(this, API_LIST);
|
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) {
|
genProtocalFilter(protocalType) {
|
||||||
if (protocalType === "HTTP") {
|
if (protocalType === "HTTP") {
|
||||||
this.methodFilters = [
|
this.methodFilters = [
|
||||||
|
|
|
@ -1,21 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<ms-container>
|
<ms-container>
|
||||||
<ms-main-container>
|
<ms-main-container>
|
||||||
<el-row :gutter="20">
|
<el-card>
|
||||||
<el-col :span="24">
|
|
||||||
<overview-compare-card ref="overviewCard"/>
|
</el-card>
|
||||||
</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>
|
|
||||||
</ms-main-container>
|
</ms-main-container>
|
||||||
</ms-container>
|
</ms-container>
|
||||||
</template>
|
</template>
|
||||||
|
@ -24,16 +12,15 @@
|
||||||
import MsContainer from "@/business/components/common/components/MsContainer";
|
import MsContainer from "@/business/components/common/components/MsContainer";
|
||||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||||
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
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 {
|
export default {
|
||||||
name: "PerformanceReportCompare",
|
name: "PerformanceReportCompare",
|
||||||
components: {ResponseTimeCompareCard, LoadCompareCard, MsChart, OverviewCompareCard, MsMainContainer, MsContainer},
|
components: {MsMainContainer, MsContainer},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init();
|
let reportId = this.$route.path.split('/')[4];
|
||||||
|
console.log(reportId);
|
||||||
|
let items = localStorage.getItem("compareReportIds");
|
||||||
|
console.log(JSON.parse(items));
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isReadOnly() {
|
isReadOnly() {
|
||||||
|
@ -43,28 +30,11 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {}
|
||||||
init() {
|
|
||||||
this.$refs.overviewCard.initTable();
|
|
||||||
this.$refs.loadCard.initCard();
|
|
||||||
this.$refs.responseTimeCard.initCard();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'$route'(to) {
|
|
||||||
if (to.name !== "ReportCompare") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.el-row {
|
|
||||||
padding-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
<el-button :disabled="isReadOnly" type="info" plain size="mini" @click="handleExport(reportName)">
|
<el-button :disabled="isReadOnly" type="info" plain size="mini" @click="handleExport(reportName)">
|
||||||
{{ $t('test_track.plan_view.export_report') }}
|
{{ $t('test_track.plan_view.export_report') }}
|
||||||
</el-button>
|
</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()">
|
<el-button :disabled="isReadOnly" type="warning" plain size="mini" @click="downloadJtl()">
|
||||||
{{ $t('report.downloadJtl') }}
|
{{ $t('report.downloadJtl') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
@ -332,8 +329,6 @@ export default {
|
||||||
this.$set(this.report, "id", this.reportId);
|
this.$set(this.report, "id", this.reportId);
|
||||||
this.$set(this.report, "status", data.status);
|
this.$set(this.report, "status", data.status);
|
||||||
this.$set(this.report, "testId", data.testId);
|
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.$set(this.report, "loadConfiguration", data.loadConfiguration);
|
||||||
this.checkReportStatus(data.status);
|
this.checkReportStatus(data.status);
|
||||||
if (this.status === "Completed" || this.status === "Running") {
|
if (this.status === "Completed" || this.status === "Running") {
|
||||||
|
|
|
@ -71,8 +71,6 @@
|
||||||
<template v-slot:default="scope">
|
<template v-slot:default="scope">
|
||||||
<ms-table-operator-button :tip="$t('api_report.detail')" icon="el-icon-s-data"
|
<ms-table-operator-button :tip="$t('api_report.detail')" icon="el-icon-s-data"
|
||||||
@exec="handleEdit(scope.row)" type="primary"/>
|
@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')"
|
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_report.delete')"
|
||||||
icon="el-icon-delete" @exec="handleDelete(scope.row)" type="danger"/>
|
icon="el-icon-delete" @exec="handleDelete(scope.row)" type="danger"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -5,7 +5,7 @@
|
||||||
:visible.sync="loadReportVisible">
|
:visible.sync="loadReportVisible">
|
||||||
<el-table v-loading="reportLoadingResult.loading"
|
<el-table v-loading="reportLoadingResult.loading"
|
||||||
class="basic-config"
|
class="basic-config"
|
||||||
:data="tableData"
|
:data="compareReports"
|
||||||
@select-all="handleSelectAll"
|
@select-all="handleSelectAll"
|
||||||
@select="handleSelectionChange">
|
@select="handleSelectionChange">
|
||||||
|
|
||||||
|
@ -14,9 +14,6 @@
|
||||||
prop="name"
|
prop="name"
|
||||||
:label="$t('commons.name')"
|
:label="$t('commons.name')"
|
||||||
show-overflow-tooltip>
|
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>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="userName"
|
prop="userName"
|
||||||
|
@ -58,56 +55,46 @@ export default {
|
||||||
return {
|
return {
|
||||||
loadReportVisible: false,
|
loadReportVisible: false,
|
||||||
reportLoadingResult: {},
|
reportLoadingResult: {},
|
||||||
tableData: [],
|
compareReports: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
selectIds: new Set,
|
selectIds: new Set,
|
||||||
report: {},
|
|
||||||
compareReports: [],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
open(report) {
|
open(report) {
|
||||||
this.report = report;
|
this.getCompareReports(report.testId);
|
||||||
this.getCompareReports(report);
|
|
||||||
|
|
||||||
this.compareReports.push(report);
|
|
||||||
|
|
||||||
this.loadReportVisible = true;
|
this.loadReportVisible = true;
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.loadReportVisible = false;
|
this.loadReportVisible = false;
|
||||||
},
|
},
|
||||||
getCompareReports(report) {
|
getCompareReports(testId) {
|
||||||
|
|
||||||
let condition = {
|
let condition = {
|
||||||
testId: report.testId,
|
testId: testId,
|
||||||
filters: {status: ["Completed"]}
|
filters: {status: ["Completed"]}
|
||||||
};
|
};
|
||||||
this.reportLoadingResult = this.$post('/performance/report/list/all/' + this.currentPage + "/" + this.pageSize, condition, res => {
|
this.reportLoadingResult = this.$post('/performance/report/list/all/' + this.currentPage + "/" + this.pageSize, condition, res => {
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
this.total = data.itemCount;
|
this.total = data.itemCount;
|
||||||
this.tableData = data.listObject;
|
this.compareReports = data.listObject;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleCompare() {
|
handleCompare() {
|
||||||
let reportIds = [...this.selectIds];
|
let reportIds = [...this.selectIds];
|
||||||
this.tableData
|
localStorage.setItem("compareReportIds", JSON.stringify(reportIds));
|
||||||
.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));
|
|
||||||
this.close();
|
this.close();
|
||||||
this.$router.push({path: '/performance/report/compare/' + reportIds[0]});
|
this.$router.push({path: '/performance/report/compare/' + reportIds[0]});
|
||||||
},
|
},
|
||||||
handleSelectAll(selection) {
|
handleSelectAll(selection) {
|
||||||
if (selection.length > 0) {
|
if (selection.length > 0) {
|
||||||
this.tableData.forEach(item => {
|
this.compareReports.forEach(item => {
|
||||||
this.selectIds.add(item.id);
|
this.selectIds.add(item.id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.tableData.forEach(item => {
|
this.compareReports.forEach(item => {
|
||||||
if (this.selectIds.has(item.id)) {
|
if (this.selectIds.has(item.id)) {
|
||||||
this.selectIds.delete(item.id);
|
this.selectIds.delete(item.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,8 +216,36 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.total = data.itemCount;
|
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) {
|
buildPagePath(path) {
|
||||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||||
},
|
},
|
||||||
|
|
|
@ -598,7 +598,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.selectRows = new Set();
|
this.selectRows = new Set();
|
||||||
this.condition.selectAll = false;
|
// this.condition.selectAll = false;
|
||||||
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
|
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
|
||||||
let data = response.data;
|
let data = response.data;
|
||||||
this.total = data.itemCount;
|
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() {
|
handleClose() {
|
||||||
this.form = {roles: [{id: ''}]};
|
this.form = {roles: [{id: ''}]};
|
||||||
this.btnAddRole = false;
|
this.btnAddRole = false;
|
||||||
|
|
|
@ -208,8 +208,33 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.total = data.itemCount;
|
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) {
|
buildPagePath(path) {
|
||||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||||
|
|
|
@ -314,6 +314,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
selectNodeIds() {
|
selectNodeIds() {
|
||||||
this.currentPage = 1;
|
this.currentPage = 1;
|
||||||
|
initCondition(this.condition,false);
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
},
|
},
|
||||||
condition() {
|
condition() {
|
||||||
|
@ -332,7 +333,8 @@ export default {
|
||||||
initTableData() {
|
initTableData() {
|
||||||
this.condition.planId = "";
|
this.condition.planId = "";
|
||||||
this.condition.nodeIds = [];
|
this.condition.nodeIds = [];
|
||||||
initCondition(this.condition);
|
//initCondition(this.condition);
|
||||||
|
initCondition(this.condition,this.condition.selectAll);
|
||||||
this.selectDataCounts = 0;
|
this.selectDataCounts = 0;
|
||||||
if (this.planId) {
|
if (this.planId) {
|
||||||
// param.planId = this.planId;
|
// param.planId = this.planId;
|
||||||
|
@ -394,9 +396,35 @@ export default {
|
||||||
setTimeout(this.$refs.table.doLayout, 200)
|
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() {
|
search() {
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
},
|
},
|
||||||
|
|
|
@ -43,7 +43,6 @@ export function setUnSelectIds(tableData, condition, selectRows) {
|
||||||
condition.unSelectIds = allIDs.filter(function (val) {
|
condition.unSelectIds = allIDs.filter(function (val) {
|
||||||
return ids.indexOf(val) === -1
|
return ids.indexOf(val) === -1
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSelectDataCounts(condition, total, selectRows) {
|
export function getSelectDataCounts(condition, total, selectRows) {
|
||||||
|
@ -102,10 +101,12 @@ export function _sort(column, condition) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initCondition(condition) {
|
export function initCondition(condition,isSelectAll) {
|
||||||
|
if(!isSelectAll){
|
||||||
condition.selectAll = false;
|
condition.selectAll = false;
|
||||||
condition.unSelectIds = [];
|
condition.unSelectIds = [];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getLabel(vueObj, type) {
|
export function getLabel(vueObj, type) {
|
||||||
let param = {}
|
let param = {}
|
||||||
|
|
Loading…
Reference in New Issue