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.selectDataCounts = 0;
|
this.condition.selectAll = false;
|
||||||
|
this.condition.unSelectIds = [];
|
||||||
|
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"
|
||||||
|
@ -60,18 +62,19 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-if="item.id == 'path'"
|
v-if="item.id == 'path'"
|
||||||
sortable="custom"
|
sortable="custom"
|
||||||
prop="path"
|
prop="path"
|
||||||
min-width="180px"
|
min-width="180px"
|
||||||
:label="$t('api_test.definition.api_path')"
|
:label="$t('api_test.definition.api_path')"
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
:key="index"/>
|
:key="index"/>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
|
@ -83,12 +86,12 @@
|
||||||
:key="index"/>
|
:key="index"/>
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-if="item.id=='updateTime'"
|
v-if="item.id=='updateTime'"
|
||||||
sortable="updateTime"
|
sortable="updateTime"
|
||||||
min-width="160"
|
min-width="160"
|
||||||
:label="$t('api_test.definition.api_last_time')"
|
:label="$t('api_test.definition.api_last_time')"
|
||||||
prop="updateTime"
|
prop="updateTime"
|
||||||
:key="index">
|
:key="index">
|
||||||
<template v-slot:default="scope">
|
<template v-slot:default="scope">
|
||||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -179,108 +182,117 @@ export default {
|
||||||
ShowMoreBtn,
|
ShowMoreBtn,
|
||||||
MsBatchEdit,
|
MsBatchEdit,
|
||||||
MsApiCaseTableExtendBtns,
|
MsApiCaseTableExtendBtns,
|
||||||
MsReferenceView,
|
MsReferenceView,
|
||||||
MsTableAdvSearchBar
|
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() {
|
trashEnable: {
|
||||||
return {
|
type: Boolean,
|
||||||
type: API_CASE_LIST,
|
default: false,
|
||||||
headerItems: Api_Case_List,
|
},
|
||||||
tableLabel: [],
|
isReadOnly: {
|
||||||
condition: {
|
type: Boolean,
|
||||||
components: API_CASE_CONFIGS
|
default: false
|
||||||
},
|
},
|
||||||
selectCase: {},
|
isCaseRelevance: {
|
||||||
result: {},
|
type: Boolean,
|
||||||
moduleId: "",
|
default: false,
|
||||||
selectDataRange: "all",
|
},
|
||||||
deletePath: "/test/case/delete",
|
relevanceProjectId: String,
|
||||||
selectRows: new Set(),
|
model: {
|
||||||
clickRow: {},
|
type: String,
|
||||||
buttons: [
|
default() {
|
||||||
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
|
'api'
|
||||||
{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: {
|
planId: String
|
||||||
currentProtocol: String,
|
},
|
||||||
selectNodeIds: Array,
|
created: function () {
|
||||||
activeDom: String,
|
this.initTable();
|
||||||
visible: {
|
getSystemLabel(this, this.type)
|
||||||
type: Boolean,
|
this.$nextTick(() => {
|
||||||
default: false,
|
this.$refs.caseTable.bodyWrapper.scrollTop = 5
|
||||||
},
|
})
|
||||||
trashEnable: {
|
},
|
||||||
type: Boolean,
|
watch: {
|
||||||
default: false,
|
selectNodeIds() {
|
||||||
},
|
this.selectAll = false;
|
||||||
isReadOnly: {
|
this.unSelection = [];
|
||||||
type: Boolean,
|
this.selectDataCounts = 0;
|
||||||
default: false
|
|
||||||
},
|
|
||||||
isCaseRelevance: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
relevanceProjectId: String,
|
|
||||||
model: {
|
|
||||||
type: String,
|
|
||||||
default() {
|
|
||||||
'api'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
planId: String
|
|
||||||
},
|
|
||||||
created: function () {
|
|
||||||
this.initTable();
|
this.initTable();
|
||||||
getSystemLabel(this, this.type)
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.caseTable.bodyWrapper.scrollTop = 5
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
watch: {
|
currentProtocol() {
|
||||||
selectNodeIds() {
|
this.selectAll = false;
|
||||||
this.initTable();
|
this.unSelection = [];
|
||||||
},
|
this.selectDataCounts = 0;
|
||||||
currentProtocol() {
|
this.initTable();
|
||||||
this.initTable();
|
},
|
||||||
},
|
trashEnable() {
|
||||||
trashEnable() {
|
if (this.trashEnable) {
|
||||||
if (this.trashEnable) {
|
this.selectAll = false;
|
||||||
this.initTable();
|
this.unSelection = [];
|
||||||
}
|
this.selectDataCounts = 0;
|
||||||
},
|
|
||||||
relevanceProjectId() {
|
|
||||||
this.initTable();
|
this.initTable();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
relevanceProjectId() {
|
||||||
|
this.initTable();
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
// 接口定义用例列表
|
// 接口定义用例列表
|
||||||
isApiModel() {
|
isApiModel() {
|
||||||
|
@ -299,353 +311,385 @@ export default {
|
||||||
this.condition.status = "";
|
this.condition.status = "";
|
||||||
this.condition.moduleIds = this.selectNodeIds;
|
this.condition.moduleIds = this.selectNodeIds;
|
||||||
if (this.trashEnable) {
|
if (this.trashEnable) {
|
||||||
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) {
|
||||||
this.condition.protocol = this.currentProtocol;
|
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;
|
||||||
|
|
||||||
//检查是否只查询本周数据
|
if(!this.selectAll){
|
||||||
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.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) {
|
||||||
item.tags = JSON.parse(item.tags);
|
item.tags = JSON.parse(item.tags);
|
||||||
}
|
|
||||||
})
|
|
||||||
if (this.$refs.caseTable) {
|
|
||||||
setTimeout(this.$refs.caseTable.doLayout, 200)
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
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({
|
if (this.$refs.caseTable) {
|
||||||
path: "/performance/test/create"
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.operate-button > div {
|
.operate-button > div {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.request-method {
|
.request-method {
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
color: #1E90FF;
|
color: #1E90FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.api-el-tag {
|
.api-el-tag {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input {
|
.search-input {
|
||||||
float: right;
|
float: right;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
/*margin-bottom: 20px;*/
|
/*margin-bottom: 20px;*/
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-select-all >>> th:first-child {
|
.ms-select-all >>> th:first-child {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
|
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
|
||||||
top: -2px;
|
top: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-table__fixed {
|
/deep/ .el-table__fixed {
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -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,23 +5,20 @@
|
||||||
: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">
|
||||||
|
|
||||||
<el-table-column type="selection"/>
|
<el-table-column type="selection"/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
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"
|
||||||
:label="$t('report.user_name')"
|
:label="$t('report.user_name')"
|
||||||
show-overflow-tooltip>
|
show-overflow-tooltip>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="triggerMode"
|
<el-table-column prop="triggerMode"
|
||||||
:label="$t('test_track.report.list.trigger_mode')">
|
:label="$t('test_track.report.list.trigger_mode')">
|
||||||
|
@ -30,7 +27,7 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
:label="$t('commons.create_time')">
|
:label="$t('commons.create_time')">
|
||||||
<template v-slot:default="scope">
|
<template v-slot:default="scope">
|
||||||
<i class="el-icon-time"/>
|
<i class="el-icon-time"/>
|
||||||
<span class="last-modified">{{ scope.row.createTime | timestampFormatDate }}</span>
|
<span class="last-modified">{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||||
|
@ -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,9 +101,11 @@ export function _sort(column, condition) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initCondition(condition) {
|
export function initCondition(condition,isSelectAll) {
|
||||||
condition.selectAll = false;
|
if(!isSelectAll){
|
||||||
condition.unSelectIds = [];
|
condition.selectAll = false;
|
||||||
|
condition.unSelectIds = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLabel(vueObj, type) {
|
export function getLabel(vueObj, type) {
|
||||||
|
|
Loading…
Reference in New Issue