fix: 修改场景引入操作时接口/案例/场景的弹窗内容:接口/案例/场景的表头与相关页面一致并增加批量操作
修改场景引入操作时接口/案例/场景的弹窗内容:接口/案例/场景的表头与相关页面一致并增加批量操作
This commit is contained in:
parent
fdce9e4268
commit
06513085aa
|
@ -48,6 +48,18 @@ public class ApiAutomationController {
|
|||
return PageUtils.setPageInfo(page, apiAutomationService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping("/list/all")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||
public List<ApiScenarioWithBLOBs> listAll(@RequestBody ApiScenarioBatchRequest request) {
|
||||
return apiAutomationService.listAll(request);
|
||||
}
|
||||
|
||||
@PostMapping("/id/all")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||
public List<String> idAll(@RequestBody ApiScenarioBatchRequest request) {
|
||||
return apiAutomationService.idAll(request);
|
||||
}
|
||||
|
||||
@GetMapping("/list/{projectId}")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||
public List<ApiScenarioDTO> list(@PathVariable String projectId) {
|
||||
|
|
|
@ -85,6 +85,12 @@ public class ApiDefinitionController {
|
|||
return apiDefinitionService.list(request);
|
||||
}
|
||||
|
||||
@PostMapping("/list/batch")
|
||||
public List<ApiDefinitionResult> listBatch(@RequestBody ApiBatchRequest request) {
|
||||
return apiDefinitionService.listBatch(request);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
||||
public void create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
|
|
|
@ -77,6 +77,14 @@ public class ApiTestCaseController {
|
|||
return apiTestCaseService.getRequest(request);
|
||||
}
|
||||
|
||||
@PostMapping("/get/caseBLOBs/request")
|
||||
public List<ApiTestCaseInfo> getCaseBLOBs(@RequestBody ApiTestCaseRequest request) {
|
||||
|
||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||
List<ApiTestCaseInfo> returnList = apiTestCaseService.findApiTestCaseBLOBs(request);
|
||||
return returnList;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
||||
public ApiTestCase create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
return apiTestCaseService.create(request, bodyFiles);
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs {
|
|||
* unSelectIds:是否在页面上有未勾选的数据,有的话他们的ID是哪些。
|
||||
* filters/name/moduleIds/unSeelctIds 只在isSelectAllDate为true时需要。为了让程序能明确批量的范围。
|
||||
*/
|
||||
private boolean isSelectAllDate;
|
||||
private boolean isSelectAll;
|
||||
|
||||
private Map<String, List<String>> filters;
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiTestCaseBLOBsDTO extends ApiTestCaseWithBLOBs {
|
||||
private String moduleId;
|
||||
private String path;
|
||||
private String protocol;
|
||||
private String casePath;
|
||||
private String updateUser;
|
||||
private String createUser;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiTestCaseBatchRequest {
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.controller.request.BaseQueryRequest;
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -9,7 +10,7 @@ import java.util.Map;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiTestCaseRequest {
|
||||
public class ApiTestCaseRequest extends BaseQueryRequest {
|
||||
private String id;
|
||||
private List<String> ids;
|
||||
private String planId;
|
||||
|
|
|
@ -123,6 +123,19 @@ public class ApiAutomationService {
|
|||
return list;
|
||||
}
|
||||
|
||||
public List<ApiScenarioWithBLOBs> listAll(ApiScenarioBatchRequest request) {
|
||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
|
||||
List<ApiScenarioWithBLOBs> list = extApiScenarioMapper.selectIds(request.getIds());
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> idAll(ApiScenarioBatchRequest request) {
|
||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
|
||||
return request.getIds();
|
||||
}
|
||||
|
||||
public List<ApiScenarioDTO> listReview(ApiScenarioRequest request) {
|
||||
request = this.initRequest(request, true, true);
|
||||
List<ApiScenarioDTO> list = extApiScenarioMapper.listReview(request);
|
||||
|
|
|
@ -108,6 +108,15 @@ public class ApiDefinitionService {
|
|||
return resList;
|
||||
}
|
||||
|
||||
public List<ApiDefinitionResult> listBatch(ApiBatchRequest request) {
|
||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||
(query) -> extApiDefinitionMapper.selectIds(query));
|
||||
List<ApiDefinitionResult> resList = extApiDefinitionMapper.listByIds(request.getIds());
|
||||
calculateResult(resList);
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化部分参数
|
||||
*
|
||||
|
|
|
@ -110,6 +110,13 @@ public class ApiTestCaseService {
|
|||
return apiTestCases;
|
||||
}
|
||||
|
||||
public List<String> idSimple(ApiTestCaseRequest request) {
|
||||
request = this.initRequest(request, true, true);
|
||||
|
||||
List<String> ids = extApiTestCaseMapper.idSimple(request);
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化部分参数
|
||||
*
|
||||
|
@ -478,7 +485,7 @@ public class ApiTestCaseService {
|
|||
|
||||
public void deleteBatchByParam(ApiTestBatchRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
if (request.isSelectAll()) {
|
||||
ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus());
|
||||
}
|
||||
this.deleteBatch(ids);
|
||||
|
@ -486,7 +493,7 @@ public class ApiTestCaseService {
|
|||
|
||||
public void editApiBathByParam(ApiTestBatchRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
if (request.isSelectAll()) {
|
||||
ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus());
|
||||
}
|
||||
ApiTestCaseExample apiDefinitionExample = new ApiTestCaseExample();
|
||||
|
@ -664,11 +671,29 @@ public class ApiTestCaseService {
|
|||
String status = apiDefinitionExecResultMapper.selectExecResult(id);
|
||||
return status;
|
||||
}
|
||||
public ApiDefinitionExecResult getInfo(String id){
|
||||
|
||||
public ApiDefinitionExecResult getInfo(String id) {
|
||||
return apiDefinitionExecResultMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<ApiTestCase> selectEffectiveTestCaseByProjectId(String projectId) {
|
||||
return extApiTestCaseMapper.selectEffectiveTestCaseByProjectId(projectId);
|
||||
}
|
||||
|
||||
public List<ApiTestCaseInfo> findApiTestCaseBLOBs(ApiTestCaseRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if (request.isSelectAll()) {
|
||||
ids = this.idSimple(request);
|
||||
ids.removeAll(request.getUnSelectIds());
|
||||
request.setIds(ids);
|
||||
}
|
||||
List<ApiTestCaseInfo> list = extApiTestCaseMapper.getCaseInfo(request);
|
||||
for (ApiTestCaseInfo model : list) {
|
||||
if (StringUtils.equalsIgnoreCase(model.getApiMethod(), "esb")) {
|
||||
esbApiParamService.handleApiEsbParams(model);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ public class ApiTestEnvironmentService {
|
|||
// httpConfig.put("port", portStr);
|
||||
// }
|
||||
httpConfig.put("socket", null);
|
||||
httpConfig.put("isMock", true);
|
||||
httpConfig.put("domain", null);
|
||||
JSONArray httpVariablesArr = new JSONArray();
|
||||
Map<String, Object> httpMap = new HashMap<>();
|
||||
|
|
|
@ -35,9 +35,13 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
ApiDefinition getNextNum(@Param("projectId") String projectId);
|
||||
|
||||
List<ApiDefinitionResult> listRelevance(@Param("request")ApiDefinitionRequest request);
|
||||
List<ApiDefinitionResult> listRelevanceReview(@Param("request")ApiDefinitionRequest request);
|
||||
List<ApiDefinitionResult> listRelevance(@Param("request") ApiDefinitionRequest request);
|
||||
|
||||
List<ApiDefinitionResult> listRelevanceReview(@Param("request") ApiDefinitionRequest request);
|
||||
|
||||
List<String> selectIds(@Param("request") BaseQueryRequest query);
|
||||
|
||||
List<ApiDefinition> selectEffectiveIdByProjectId(String projectId);
|
||||
|
||||
List<ApiDefinitionResult> listByIds(@Param("ids") List<String> ids);
|
||||
}
|
|
@ -233,6 +233,21 @@
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="listByIds" resultType="io.metersphere.api.dto.definition.ApiDefinitionResult">
|
||||
select api_definition.id, api_definition.project_id, api_definition.num, api_definition.tags,
|
||||
api_definition.name,api_definition.protocol,api_definition.path,api_definition.module_id,api_definition.module_path,api_definition.method,
|
||||
api_definition.description,api_definition.request,api_definition.response,api_definition.environment_id,
|
||||
api_definition.status, api_definition.user_id, api_definition.create_time, api_definition.update_time,
|
||||
project.name as
|
||||
project_name, user.name as user_name
|
||||
from api_definition
|
||||
left join project on api_definition.project_id = project.id
|
||||
left join user on api_definition.user_id = user.id
|
||||
WHERE api_definition.id IN
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</select>
|
||||
<update id="removeToGc">
|
||||
update api_definition
|
||||
set original_state=status,
|
||||
|
|
|
@ -31,4 +31,8 @@ public interface ExtApiTestCaseMapper {
|
|||
ApiTestCaseInfo selectApiCaseInfoByPrimaryKey(String id);
|
||||
|
||||
List<ApiTestCase> selectEffectiveTestCaseByProjectId(String projectId);
|
||||
|
||||
List<String> idSimple(@Param("request") ApiTestCaseRequest request);
|
||||
|
||||
List<ApiTestCaseInfo> getCaseInfo(@Param("request") ApiTestCaseRequest request);
|
||||
}
|
||||
|
|
|
@ -340,11 +340,88 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="idSimple" resultType="java.lang.String">
|
||||
select
|
||||
t1.id
|
||||
from
|
||||
api_test_case t1
|
||||
inner join api_definition a on t1.api_definition_id = a.id
|
||||
<if test="request.protocol != null and request.protocol!=''">
|
||||
and a.protocol = #{request.protocol}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="request.status == 'Trash'">
|
||||
and a.status = 'Trash'
|
||||
</when>
|
||||
<otherwise>
|
||||
and a.status != 'Trash'
|
||||
</otherwise>
|
||||
</choose>
|
||||
<where>
|
||||
<if test="request.combine != null">
|
||||
<include refid="combine">
|
||||
<property name="condition" value="request.combine"/>
|
||||
<property name="name" value="request.name"/>
|
||||
<property name="objectKey" value="request.combine.tags"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and t1.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.id != null and request.id!=''">
|
||||
and t1.id = #{request.id}
|
||||
</if>
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and
|
||||
</if>
|
||||
t1.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.name != null and request.name!=''">
|
||||
and (t1.name like CONCAT('%', #{request.name},'%')
|
||||
or t1.tags like CONCAT('%', #{request.name},'%')
|
||||
or t1.num like CONCAT('%', #{request.name},'%'))
|
||||
</if>
|
||||
<if test="request.createTime > 0">
|
||||
and t1.create_time >= #{request.createTime}
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
and a.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key == 'priority'">
|
||||
and t1.priority in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
${order.name} ${order.type}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectIdsNotExistsInPlan" resultType="java.lang.String">
|
||||
select c.id
|
||||
from api_test_case c
|
||||
where c.project_id = #{projectId} and c.id not in (
|
||||
select pc.api_case_id
|
||||
where c.project_id = #{projectId}
|
||||
and c.id not in (
|
||||
select pc.api_case_id
|
||||
from test_plan_api_case pc
|
||||
where pc.test_plan_id = #{planId}
|
||||
)
|
||||
|
@ -369,14 +446,29 @@
|
|||
<select id="countByProjectIDAndCreateInThisWeek" resultType="java.lang.Long">
|
||||
SELECT count(testCase.id) AS countNumber FROM api_test_case testCase
|
||||
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
||||
WHERE testCase.project_id = #{projectId} AND apiDef.status != "Trash"
|
||||
AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
|
||||
WHERE testCase.project_id = #{projectId}AND apiDef.status != "Trash"
|
||||
AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
|
||||
</select>
|
||||
|
||||
<select id="getRequest" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
||||
select t1.id, t1.request,a.method AS apiMethod
|
||||
from api_test_case t1
|
||||
inner join api_definition a on t1.api_definition_id = a.id
|
||||
inner join api_definition a on t1.api_definition_id = a.id
|
||||
where 1
|
||||
<if test="request.id != null and request.id!=''">
|
||||
and t1.id = #{request.id}
|
||||
</if>
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
and t1.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getCaseInfo" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
||||
select t1.*,a.method AS apiMethod
|
||||
from api_test_case t1
|
||||
inner join api_definition a on t1.api_definition_id = a.id
|
||||
where 1
|
||||
<if test="request.id != null and request.id!=''">
|
||||
and t1.id = #{request.id}
|
||||
|
@ -389,7 +481,11 @@
|
|||
</if>
|
||||
</select>
|
||||
<select id="getNextNum" resultType="io.metersphere.base.domain.ApiTestCase">
|
||||
SELECT * FROM api_test_case WHERE api_test_case.api_definition_id = #{definitionId} ORDER BY num DESC LIMIT 1;
|
||||
SELECT *
|
||||
FROM api_test_case
|
||||
WHERE api_test_case.api_definition_id = #{definitionId}
|
||||
ORDER BY num DESC
|
||||
LIMIT 1;
|
||||
</select>
|
||||
<select id="selectEffectiveTestCaseByProjectId" resultType="io.metersphere.base.domain.ApiTestCase">
|
||||
select id,api_definition_id from api_test_case where project_id = #{projectId}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-card class="table-card" v-loading="result.loading">
|
||||
<template v-slot:header>
|
||||
<ms-table-header :condition.sync="condition" @search="selectByParam" title=""
|
||||
:show-create="false" :tip="$t('commons.search_by_id_name_tag')"/>
|
||||
</template>
|
||||
<el-card class="table-card-nopadding" v-loading="result.loading">
|
||||
<!-- <template v-slot:header>-->
|
||||
<ms-table-header :condition.sync="condition" @search="selectByParam" title=""
|
||||
:show-create="false" :tip="$t('commons.search_by_id_name_tag')"/>
|
||||
<!-- </template>-->
|
||||
|
||||
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table ms-select-all-fixed"
|
||||
@sort-change="sort"
|
||||
|
@ -800,6 +800,9 @@
|
|||
});
|
||||
});
|
||||
},
|
||||
getConditions() {
|
||||
return this.condition;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -88,40 +88,18 @@ export default {
|
|||
let apis = this.$refs.apiList.selectRows;
|
||||
apis.forEach(api => {
|
||||
api.projectId = this.projectId;
|
||||
})
|
||||
this.$emit('save', this.$refs.apiList.selectRows, 'API', reference);
|
||||
this.$refs.baseRelevance.close();
|
||||
});
|
||||
let params = this.$refs.apiList.getConditions();
|
||||
this.result = this.$post("/api/definition/list/batch", params, (response) => {
|
||||
let apis = response.data;
|
||||
this.$emit('save', apis, 'API', reference);
|
||||
this.$refs.baseRelevance.close();
|
||||
});
|
||||
|
||||
} else {
|
||||
let apiCases = this.$refs.apiCaseList.selectRows;
|
||||
let ids = Array.from(apiCases).map(row => row.id);
|
||||
this.result = this.$post("/api/testcase/get/request", {ids: ids}, (response) => {
|
||||
apiCases.forEach((item) => {
|
||||
item.request = response.data[item.id];
|
||||
item.projectId = this.projectId;
|
||||
|
||||
let requestObj = JSON.parse(item.request);
|
||||
if(requestObj.esbDataStruct != null ){
|
||||
// //ESB接口
|
||||
// let param = {};
|
||||
// param.request = requestObj;
|
||||
// param.method = "ESB";
|
||||
// param.esbDataStruct = JSON.stringify(requestObj.esbDataStruct);
|
||||
// if(requestObj.backEsbDataStruct != null){
|
||||
// param.backEsbDataStruct = JSON.stringify(requestObj.backEsbDataStruct);
|
||||
// }else{
|
||||
// param.backEsbDataStruct = "";
|
||||
// }
|
||||
|
||||
// this.$post("/api/definition/updateEsbRequest", param, response => {
|
||||
// if(response.data!=null){
|
||||
// if(response.data.request!=null){
|
||||
// item.request = JSON.stringify(response.data.request);
|
||||
// param.method = "TCP";
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
});
|
||||
let params = this.$refs.apiCaseList.getConditions();
|
||||
this.result = this.$post("/api/testcase/get/caseBLOBs/request", params, (response) => {
|
||||
let apiCases = response.data;
|
||||
this.$emit('save', apiCases, 'CASE', reference);
|
||||
this.$refs.baseRelevance.close();
|
||||
});
|
||||
|
|
|
@ -4,69 +4,207 @@
|
|||
:is-api-list-enable="isApiListEnable"
|
||||
@isApiListEnableChange="isApiListEnableChange">
|
||||
|
||||
<ms-environment-select :project-id="projectId" v-if="isTestPlan" :is-read-only="isReadOnly" @setEnvironment="setEnvironment"/>
|
||||
<ms-environment-select :project-id="projectId" v-if="isTestPlan" :is-read-only="isReadOnly"
|
||||
@setEnvironment="setEnvironment"/>
|
||||
|
||||
<el-input :placeholder="$t('api_test.definition.request.select_api')" @blur="initTable" class="search-input" size="small" @keyup.enter.native="initTable" v-model="condition.name"/>
|
||||
<el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable" class="search-input" size="small"
|
||||
@keyup.enter.native="initTable" v-model="condition.name"/>
|
||||
|
||||
<el-table v-loading="result.loading"
|
||||
border
|
||||
:data="tableData" row-key="id" class="test-content adjust-table"
|
||||
@select-all="handleSelectAll"
|
||||
@select="handleSelect" ref="table">
|
||||
<el-table-column reserve-selection type="selection"/>
|
||||
<ms-table :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize"
|
||||
:total="total" enableSelection
|
||||
:screenHeight="screenHeight"
|
||||
operator-width="170px"
|
||||
ref="apitable">
|
||||
<template v-for="(item, index) in tableLabel">
|
||||
<ms-table-column
|
||||
v-if="item.id == 'num'"
|
||||
prop="num"
|
||||
label="ID"
|
||||
show-overflow-tooltip
|
||||
min-width="80px"
|
||||
sortable=true
|
||||
:key="index">
|
||||
<template slot-scope="scope">
|
||||
<!-- 判断为只读用户的话不可点击ID进行编辑操作 -->
|
||||
<span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>
|
||||
<el-tooltip v-else content="编辑">
|
||||
<a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'name'"
|
||||
prop="name"
|
||||
:label="$t('api_test.definition.api_name')"
|
||||
show-overflow-tooltip
|
||||
sortable="custom"
|
||||
width="120px"
|
||||
:key="index"/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'status'"
|
||||
prop="status"
|
||||
column-key="status"
|
||||
sortable="custom"
|
||||
:filters="statusFilters"
|
||||
:label="$t('api_test.definition.api_status')"
|
||||
width="120px"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<span class="el-dropdown-link">
|
||||
<api-status :value="scope.row.status"/>
|
||||
</span>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'method'"
|
||||
prop="method"
|
||||
sortable="custom"
|
||||
column-key="method"
|
||||
:filters="methodFilters"
|
||||
:label="$t('api_test.definition.api_type')"
|
||||
show-overflow-tooltip
|
||||
width="120px"
|
||||
:key="index">
|
||||
<template v-slot:default="scope" class="request-method">
|
||||
<el-tag size="mini"
|
||||
:style="{'background-color': getColor(true, scope.row.method), border: getColor(true, scope.row.method)}"
|
||||
class="api-el-tag">
|
||||
{{ scope.row.method }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="status"
|
||||
column-key="api_status"
|
||||
:label="$t('api_test.definition.api_status')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<ms-tag v-if="scope.row.status == 'Prepare'" type="info" effect="plain" :content="$t('test_track.plan.plan_status_prepare')"/>
|
||||
<ms-tag v-if="scope.row.status == 'Underway'" type="warning" effect="plain" :content="$t('test_track.plan.plan_status_running')"/>
|
||||
<ms-tag v-if="scope.row.status == 'Completed'" type="success" effect="plain" :content="$t('test_track.plan.plan_status_completed')"/>
|
||||
<ms-tag v-if="scope.row.status == 'Trash'" type="danger" effect="plain" :content="$t('test_track.plan.plan_status_trash')"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'userName'"
|
||||
prop="userName"
|
||||
sortable="custom"
|
||||
:filters="userFilters"
|
||||
column-key="user_id"
|
||||
:label="$t('api_test.definition.api_principal')"
|
||||
show-overflow-tooltip
|
||||
width="100px"
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column
|
||||
prop="method"
|
||||
:label="$t('api_test.definition.api_type')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope" class="request-method">
|
||||
<el-tag size="mini" :style="{'background-color': getColor(scope.row.method), border: getColor(true, scope.row.method)}" class="api-el-tag">
|
||||
{{ scope.row.method }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'path'"
|
||||
prop="path"
|
||||
width="120px"
|
||||
:label="$t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column
|
||||
prop="path"
|
||||
:label="$t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'tags'"
|
||||
prop="tags"
|
||||
:label="$t('commons.tag')"
|
||||
width="120px"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
|
||||
:show-tooltip="true" :content="itemName"
|
||||
style="margin-left: 0px; margin-right: 2px"/>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column width="160" :label="$t('api_test.definition.api_last_time')" prop="updateTime">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'updateTime'"
|
||||
width="160"
|
||||
:label="$t('api_test.definition.api_last_time')"
|
||||
sortable="custom"
|
||||
prop="updateTime"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="caseTotal"
|
||||
:label="$t('api_test.definition.api_case_number')"
|
||||
show-overflow-tooltip/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'caseTotal'"
|
||||
prop="caseTotal"
|
||||
width="80px"
|
||||
:label="$t('api_test.definition.api_case_number')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column
|
||||
prop="caseStatus"
|
||||
:label="$t('api_test.definition.api_case_status')"
|
||||
show-overflow-tooltip/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'caseStatus'"
|
||||
prop="caseStatus"
|
||||
width="80px"
|
||||
:label="$t('api_test.definition.api_case_status')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column
|
||||
prop="casePassingRate"
|
||||
:label="$t('api_test.definition.api_case_passing_rate')"
|
||||
show-overflow-tooltip/>
|
||||
</el-table>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'casePassingRate'"
|
||||
width="100px"
|
||||
prop="casePassingRate"
|
||||
:label="$t('api_test.definition.api_case_passing_rate')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
</template>
|
||||
|
||||
|
||||
</ms-table>
|
||||
<!-- <el-table v-loading="result.loading"-->
|
||||
<!-- border-->
|
||||
<!-- :data="tableData" row-key="id" class="test-content adjust-table"-->
|
||||
<!-- @select-all="handleSelectAll"-->
|
||||
<!-- @select="handleSelect" ref="table">-->
|
||||
<!-- <el-table-column reserve-selection type="selection"/>-->
|
||||
|
||||
<!-- <el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="status"-->
|
||||
<!-- column-key="api_status"-->
|
||||
<!-- :label="$t('api_test.definition.api_status')"-->
|
||||
<!-- show-overflow-tooltip>-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <ms-tag v-if="scope.row.status == 'Prepare'" type="info" effect="plain" :content="$t('test_track.plan.plan_status_prepare')"/>-->
|
||||
<!-- <ms-tag v-if="scope.row.status == 'Underway'" type="warning" effect="plain" :content="$t('test_track.plan.plan_status_running')"/>-->
|
||||
<!-- <ms-tag v-if="scope.row.status == 'Completed'" type="success" effect="plain" :content="$t('test_track.plan.plan_status_completed')"/>-->
|
||||
<!-- <ms-tag v-if="scope.row.status == 'Trash'" type="danger" effect="plain" :content="$t('test_track.plan.plan_status_trash')"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="method"-->
|
||||
<!-- :label="$t('api_test.definition.api_type')"-->
|
||||
<!-- show-overflow-tooltip>-->
|
||||
<!-- <template v-slot:default="scope" class="request-method">-->
|
||||
<!-- <el-tag size="mini" :style="{'background-color': getColor(scope.row.method), border: getColor(true, scope.row.method)}" class="api-el-tag">-->
|
||||
<!-- {{ scope.row.method }}-->
|
||||
<!-- </el-tag>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="path"-->
|
||||
<!-- :label="$t('api_test.definition.api_path')"-->
|
||||
<!-- show-overflow-tooltip/>-->
|
||||
|
||||
<!-- <el-table-column width="160" :label="$t('api_test.definition.api_last_time')" prop="updateTime">-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <span>{{ scope.row.updateTime | timestampFormatDate }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="caseTotal"-->
|
||||
<!-- :label="$t('api_test.definition.api_case_number')"-->
|
||||
<!-- show-overflow-tooltip/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="caseStatus"-->
|
||||
<!-- :label="$t('api_test.definition.api_case_status')"-->
|
||||
<!-- show-overflow-tooltip/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="casePassingRate"-->
|
||||
<!-- :label="$t('api_test.definition.api_case_passing_rate')"-->
|
||||
<!-- show-overflow-tooltip/>-->
|
||||
<!-- </el-table>-->
|
||||
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
</api-list-container>
|
||||
|
@ -77,6 +215,8 @@
|
|||
|
||||
<script>
|
||||
|
||||
import MsTable from "@/business/components/common/components/table/MsTable";
|
||||
import MsTableColumn from "@/business/components/common/components/table/Ms-table-column";
|
||||
import MsTableOperator from "../../../../common/components/MsTableOperator";
|
||||
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
|
||||
import MsTablePagination from "../../../../common/pagination/TablePagination";
|
||||
|
@ -90,7 +230,8 @@ import ApiListContainer from "../../../definition/components/list/ApiListContain
|
|||
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
|
||||
import MsEnvironmentSelect from "../../../definition/components/case/MsEnvironmentSelect";
|
||||
import TableSelectCountBar from "./TableSelectCountBar";
|
||||
import {_filter, _handleSelect, _handleSelectAll, _sort,} from "@/common/js/tableUtils";
|
||||
import {_filter, _handleSelect, _handleSelectAll, _sort, buildBatchParam, getLabel,} from "@/common/js/tableUtils";
|
||||
import {API_LIST, WORKSPACE_ID} from "@/common/js/constants";
|
||||
|
||||
export default {
|
||||
name: "RelevanceApiList",
|
||||
|
@ -105,16 +246,19 @@ export default {
|
|||
MsTag,
|
||||
MsBottomContainer,
|
||||
ShowMoreBtn,
|
||||
MsBatchEdit
|
||||
MsBatchEdit,
|
||||
MsTable,
|
||||
MsTableColumn
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
condition: {},
|
||||
selectCase: {},
|
||||
tableLabel: [],
|
||||
result: {},
|
||||
moduleId: "",
|
||||
deletePath: "/test/case/delete",
|
||||
selectRows: new Set(),
|
||||
screenHeight: document.documentElement.clientHeight - 310,//屏幕高度,
|
||||
typeArr: [
|
||||
{id: 'priority', name: this.$t('test_track.case.priority')},
|
||||
],
|
||||
|
@ -132,7 +276,22 @@ export default {
|
|||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
environmentId: ""
|
||||
environmentId: "",
|
||||
methodFilters: [
|
||||
{text: 'GET', value: 'GET'},
|
||||
{text: 'POST', value: 'POST'},
|
||||
{text: 'PUT', value: 'PUT'},
|
||||
{text: 'PATCH', value: 'PATCH'},
|
||||
{text: 'DELETE', value: 'DELETE'},
|
||||
{text: 'OPTIONS', value: 'OPTIONS'},
|
||||
{text: 'HEAD', value: 'HEAD'},
|
||||
{text: 'CONNECT', value: 'CONNECT'},
|
||||
{text: 'DUBBO', value: 'DUBBO'},
|
||||
{text: 'dubbo://', value: 'dubbo://'},
|
||||
{text: 'SQL', value: 'SQL'},
|
||||
{text: 'TCP', value: 'TCP'},
|
||||
],
|
||||
userFilters: [],
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -159,8 +318,11 @@ export default {
|
|||
isTestPlan: Boolean
|
||||
},
|
||||
created: function () {
|
||||
this.selectRows = new Set();
|
||||
if (this.$refs.apitable) {
|
||||
this.$refs.apitable.clearSelectRows();
|
||||
}
|
||||
this.initTable();
|
||||
this.getMaintainerOptions();
|
||||
},
|
||||
watch: {
|
||||
selectNodeIds() {
|
||||
|
@ -173,7 +335,15 @@ export default {
|
|||
this.initTable();
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
computed: {
|
||||
selectRows() {
|
||||
if (this.$refs.apitable) {
|
||||
return this.$refs.apitable.getSelectRows();
|
||||
} else {
|
||||
return new Set();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isApiListEnableChange(data) {
|
||||
this.$emit('isApiListEnableChange', data);
|
||||
|
@ -205,12 +375,17 @@ export default {
|
|||
this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => {
|
||||
this.total = response.data.itemCount;
|
||||
this.tableData = response.data.listObject;
|
||||
this.genProtocalFilter(this.condition.protocol);
|
||||
this.$nextTick(function () {
|
||||
if (this.$refs.apitable) {
|
||||
this.$refs.apitable.checkTableRowIsSelect();
|
||||
}
|
||||
});
|
||||
});
|
||||
//添加自定义列的查询
|
||||
getLabel(this, API_LIST);
|
||||
},
|
||||
|
||||
handleSelect(selection, row) {
|
||||
_handleSelect(this, selection, row, this.selectRows);
|
||||
},
|
||||
showExecResult(row) {
|
||||
this.visible = false;
|
||||
this.$emit('showExecResult', row);
|
||||
|
@ -227,9 +402,6 @@ export default {
|
|||
_sort(column, this.condition);
|
||||
this.initTable();
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
_handleSelectAll(this, selection, this.tableData, this.selectRows);
|
||||
},
|
||||
buildPagePath(path) {
|
||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||
},
|
||||
|
@ -240,10 +412,67 @@ export default {
|
|||
this.environmentId = data.id;
|
||||
},
|
||||
clearSelection() {
|
||||
this.selectRows = new Set();
|
||||
if (this.$refs.table) {
|
||||
this.$refs.table.clearSelection();
|
||||
if (this.$refs.apitable) {
|
||||
this.$refs.apitable.clearSelectRows();
|
||||
this.$refs.apitable.clearSelection();
|
||||
}
|
||||
},
|
||||
genProtocalFilter(protocalType) {
|
||||
if (protocalType === "HTTP") {
|
||||
this.methodFilters = [
|
||||
{text: 'GET', value: 'GET'},
|
||||
{text: 'POST', value: 'POST'},
|
||||
{text: 'PUT', value: 'PUT'},
|
||||
{text: 'PATCH', value: 'PATCH'},
|
||||
{text: 'DELETE', value: 'DELETE'},
|
||||
{text: 'OPTIONS', value: 'OPTIONS'},
|
||||
{text: 'HEAD', value: 'HEAD'},
|
||||
{text: 'CONNECT', value: 'CONNECT'},
|
||||
];
|
||||
} else if (protocalType === "TCP") {
|
||||
this.methodFilters = [
|
||||
{text: 'TCP', value: 'TCP'},
|
||||
];
|
||||
} else if (protocalType === "SQL") {
|
||||
this.methodFilters = [
|
||||
{text: 'SQL', value: 'SQL'},
|
||||
];
|
||||
} else if (protocalType === "DUBBO") {
|
||||
this.methodFilters = [
|
||||
{text: 'DUBBO', value: 'DUBBO'},
|
||||
{text: 'dubbo://', value: 'dubbo://'},
|
||||
];
|
||||
} else {
|
||||
this.methodFilters = [
|
||||
{text: 'GET', value: 'GET'},
|
||||
{text: 'POST', value: 'POST'},
|
||||
{text: 'PUT', value: 'PUT'},
|
||||
{text: 'PATCH', value: 'PATCH'},
|
||||
{text: 'DELETE', value: 'DELETE'},
|
||||
{text: 'OPTIONS', value: 'OPTIONS'},
|
||||
{text: 'HEAD', value: 'HEAD'},
|
||||
{text: 'CONNECT', value: 'CONNECT'},
|
||||
{text: 'DUBBO', value: 'DUBBO'},
|
||||
{text: 'dubbo://', value: 'dubbo://'},
|
||||
{text: 'SQL', value: 'SQL'},
|
||||
{text: 'TCP', value: 'TCP'},
|
||||
];
|
||||
}
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||
this.valueArr.userId = response.data;
|
||||
this.userFilters = response.data.map(u => {
|
||||
return {text: u.name, value: u.id};
|
||||
});
|
||||
});
|
||||
},
|
||||
getConditions() {
|
||||
let sampleSelectRows = this.$refs.apitable.getSelectRows();
|
||||
let param = buildBatchParam(this);
|
||||
param.ids = Array.from(sampleSelectRows).map(row => row.id);
|
||||
return param;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,56 +4,145 @@
|
|||
:is-api-list-enable="isApiListEnable"
|
||||
@isApiListEnableChange="isApiListEnableChange">
|
||||
|
||||
<ms-environment-select :project-id="projectId" v-if="isTestPlan" :is-read-only="isReadOnly" @setEnvironment="setEnvironment"/>
|
||||
<ms-environment-select :project-id="projectId" v-if="isTestPlan" :is-read-only="isReadOnly"
|
||||
@setEnvironment="setEnvironment"/>
|
||||
|
||||
<el-input :placeholder="$t('api_test.definition.request.select_case')" @blur="initTable"
|
||||
<el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable"
|
||||
@keyup.enter.native="initTable" class="search-input" size="small" v-model="condition.name"/>
|
||||
|
||||
<el-table v-loading="result.loading"
|
||||
border
|
||||
:data="tableData"
|
||||
row-key="id"
|
||||
class="test-content adjust-table"
|
||||
@select-all="handleSelectAll"
|
||||
@filter-change="filter"
|
||||
@sort-change="sort"
|
||||
@select="handleSelect" ref="table">
|
||||
<el-table-column reserve-selection type="selection"/>
|
||||
<ms-table :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize"
|
||||
:total="total" enableSelection
|
||||
:screenHeight="screenHeight"
|
||||
operator-width="170px"
|
||||
ref="table"
|
||||
>
|
||||
<template v-for="(item, index) in tableLabel">
|
||||
|
||||
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'num'"
|
||||
prop="num"
|
||||
label="ID"
|
||||
show-overflow-tooltip
|
||||
width="80px"
|
||||
sortable=true
|
||||
:key="index">
|
||||
<template slot-scope="scope">
|
||||
<!-- 判断为只读用户的话不可点击ID进行编辑操作 -->
|
||||
<span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>
|
||||
<el-tooltip v-else content="编辑">
|
||||
<a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="priority"
|
||||
:filters="priorityFilters"
|
||||
column-key="priority"
|
||||
:label="$t('test_track.case.priority')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<priority-table-item :value="scope.row.priority"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<ms-table-column v-if="item.id == 'name'" prop="name" width="160px" :label="$t('test_track.case.name')"
|
||||
show-overflow-tooltip :key="index"/>
|
||||
|
||||
<el-table-column
|
||||
prop="path"
|
||||
:label="$t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'priority'"
|
||||
prop="priority"
|
||||
:filters="priorityFilters"
|
||||
column-key="priority"
|
||||
width="120px"
|
||||
:label="$t('test_track.case.priority')"
|
||||
show-overflow-tooltip
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<priority-table-item :value="scope.row.priority"/>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="createUser"
|
||||
:label="'创建人'"
|
||||
show-overflow-tooltip/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'path'"
|
||||
sortable="custom"
|
||||
prop="path"
|
||||
width="180px"
|
||||
:label="'API'+ $t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column
|
||||
sortable="custom"
|
||||
width="160"
|
||||
:label="$t('api_test.definition.api_last_time')"
|
||||
prop="updateTime">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'casePath'"
|
||||
sortable="custom"
|
||||
prop="casePath"
|
||||
width="180px"
|
||||
:label="$t('api_test.definition.request.case')+ $t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
</el-table>
|
||||
<ms-table-column v-if="item.id=='tags'" prop="tags" width="120px" :label="$t('commons.tag')"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
|
||||
:content="itemName" style="margin-left: 0px; margin-right: 2px"/>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
<ms-table-column
|
||||
v-if="item.id=='createUser'"
|
||||
prop="createUser"
|
||||
:label="'创建人'"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<ms-table-column
|
||||
v-if="item.id=='updateTime'"
|
||||
sortable="updateTime"
|
||||
width="160px"
|
||||
:label="$t('api_test.definition.api_last_time')"
|
||||
prop="updateTime"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
</template>
|
||||
</ms-table>
|
||||
<!-- <el-table v-loading="result.loading"-->
|
||||
<!-- border-->
|
||||
<!-- :data="tableData"-->
|
||||
<!-- row-key="id"-->
|
||||
<!-- class="test-content adjust-table"-->
|
||||
<!-- @select-all="handleSelectAll"-->
|
||||
<!-- @filter-change="filter"-->
|
||||
<!-- @sort-change="sort"-->
|
||||
<!-- @select="handleSelect" ref="table">-->
|
||||
<!-- <el-table-column reserve-selection type="selection"/>-->
|
||||
|
||||
<!-- <el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="priority"-->
|
||||
<!-- :filters="priorityFilters"-->
|
||||
<!-- column-key="priority"-->
|
||||
<!-- :label="$t('test_track.case.priority')"-->
|
||||
<!-- show-overflow-tooltip>-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <priority-table-item :value="scope.row.priority"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="path"-->
|
||||
<!-- :label="$t('api_test.definition.api_path')"-->
|
||||
<!-- show-overflow-tooltip/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="createUser"-->
|
||||
<!-- :label="'创建人'"-->
|
||||
<!-- show-overflow-tooltip/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- sortable="custom"-->
|
||||
<!-- width="160"-->
|
||||
<!-- :label="$t('api_test.definition.api_last_time')"-->
|
||||
<!-- prop="updateTime">-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <span>{{ scope.row.updateTime | timestampFormatDate }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- </el-table>-->
|
||||
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
</api-list-container>
|
||||
|
@ -66,6 +155,8 @@
|
|||
|
||||
<script>
|
||||
|
||||
import MsTable from "@/business/components/common/components/table/MsTable";
|
||||
import MsTableColumn from "@/business/components/common/components/table/Ms-table-column";
|
||||
import MsTableOperator from "../../../../common/components/MsTableOperator";
|
||||
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
|
||||
import MsTablePagination from "../../../../common/pagination/TablePagination";
|
||||
|
@ -79,7 +170,8 @@ import ApiListContainer from "../../../definition/components/list/ApiListContain
|
|||
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
|
||||
import MsEnvironmentSelect from "../../../definition/components/case/MsEnvironmentSelect";
|
||||
import TableSelectCountBar from "./TableSelectCountBar";
|
||||
import {_filter, _handleSelect, _handleSelectAll, _sort} from "@/common/js/tableUtils";
|
||||
import {_filter, _handleSelect, _handleSelectAll, _sort, buildBatchParam, getLabel} from "@/common/js/tableUtils";
|
||||
import {API_CASE_LIST} from "@/common/js/constants";
|
||||
|
||||
export default {
|
||||
name: "RelevanceCaseList",
|
||||
|
@ -92,17 +184,19 @@ export default {
|
|||
MsTableOperator,
|
||||
MsTablePagination,
|
||||
MsTag,
|
||||
MsBottomContainer,
|
||||
ShowMoreBtn,
|
||||
MsBatchEdit
|
||||
},
|
||||
MsBottomContainer,
|
||||
ShowMoreBtn,
|
||||
MsBatchEdit,
|
||||
MsTable,
|
||||
MsTableColumn
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
condition: {},
|
||||
selectCase: {},
|
||||
result: {},
|
||||
moduleId: "",
|
||||
selectRows: new Set(),
|
||||
tableLabel: [],
|
||||
typeArr: [
|
||||
{id: 'priority', name: this.$t('test_track.case.priority')},
|
||||
],
|
||||
|
@ -116,6 +210,7 @@ export default {
|
|||
priority: CASE_PRIORITY,
|
||||
},
|
||||
methodColorMap: new Map(API_METHOD_COLOUR),
|
||||
screenHeight: document.documentElement.clientHeight - 330,//屏幕高度
|
||||
tableData: [],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
|
@ -160,16 +255,25 @@ export default {
|
|||
this.initTable();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isApiListEnableChange(data) {
|
||||
this.$emit('isApiListEnableChange', data);
|
||||
},
|
||||
initTable(projectId) {
|
||||
this.condition.status = "";
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
if (projectId != null && typeof projectId === 'string') {
|
||||
this.condition.projectId = projectId;
|
||||
} else if (this.projectId != null) {
|
||||
computed: {
|
||||
selectRows() {
|
||||
if (this.$refs.table) {
|
||||
return this.$refs.table.getSelectRows();
|
||||
} else {
|
||||
return new Set();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isApiListEnableChange(data) {
|
||||
this.$emit('isApiListEnableChange', data);
|
||||
},
|
||||
initTable(projectId) {
|
||||
this.condition.status = "";
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
if (projectId != null && typeof projectId === 'string') {
|
||||
this.condition.projectId = projectId;
|
||||
} else if (this.projectId != null) {
|
||||
this.condition.projectId = this.projectId;
|
||||
}
|
||||
if (this.currentProtocol != null) {
|
||||
|
@ -181,15 +285,19 @@ export default {
|
|||
this.condition.planId = this.planId;
|
||||
}
|
||||
|
||||
this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => {
|
||||
this.total = response.data.itemCount;
|
||||
this.tableData = response.data.listObject;
|
||||
this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => {
|
||||
this.total = response.data.itemCount;
|
||||
this.tableData = response.data.listObject;
|
||||
|
||||
this.$nextTick(function () {
|
||||
if (this.$refs.table) {
|
||||
this.$refs.table.checkTableRowIsSelect();
|
||||
}
|
||||
});
|
||||
});
|
||||
getLabel(this, API_CASE_LIST);
|
||||
},
|
||||
|
||||
handleSelect(selection, row) {
|
||||
_handleSelect(this, selection, row, this.selectRows);
|
||||
},
|
||||
showExecResult(row) {
|
||||
this.visible = false;
|
||||
this.$emit('showExecResult', row);
|
||||
|
@ -206,9 +314,6 @@ export default {
|
|||
_sort(column, this.condition);
|
||||
this.initTable();
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
_handleSelectAll(this, selection, this.tableData, this.selectRows);
|
||||
},
|
||||
buildPagePath(path) {
|
||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||
},
|
||||
|
@ -229,16 +334,22 @@ export default {
|
|||
this.$refs.caseList.open(selectApi, testCase.id);
|
||||
});
|
||||
},
|
||||
setEnvironment(data) {
|
||||
this.environmentId = data.id;
|
||||
},
|
||||
clearSelection() {
|
||||
this.selectRows = new Set();
|
||||
if (this.$refs.table) {
|
||||
this.$refs.table.clearSelection();
|
||||
}
|
||||
setEnvironment(data) {
|
||||
this.environmentId = data.id;
|
||||
},
|
||||
clearSelection() {
|
||||
if (this.$refs.table) {
|
||||
this.$refs.table.clearSelectRows();
|
||||
this.$refs.table.clearSelection();
|
||||
}
|
||||
},
|
||||
getConditions() {
|
||||
let sampleSelectRows = this.$refs.table.getSelectRows();
|
||||
let param = buildBatchParam(this);
|
||||
param.ids = Array.from(sampleSelectRows).map(row => row.id);
|
||||
return param;
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -69,39 +69,121 @@
|
|||
methods: {
|
||||
reference() {
|
||||
let scenarios = [];
|
||||
if (!this.currentScenario || this.currentScenario.length < 1) {
|
||||
this.$emit('请选择场景');
|
||||
return;
|
||||
}
|
||||
this.currentScenario.forEach(item => {
|
||||
let obj = {id: item.id, name: item.name, type: "scenario", referenced: 'REF', resourceId: getUUID(), projectId: item.projectId};
|
||||
scenarios.push(obj);
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
},
|
||||
copy() {
|
||||
let scenarios = [];
|
||||
if (!this.currentScenarioIds || this.currentScenarioIds.length < 1) {
|
||||
this.$warning('请选择场景');
|
||||
return;
|
||||
}
|
||||
this.result = this.$post("/api/automation/getApiScenarios/", this.currentScenarioIds, response => {
|
||||
if (response.data) {
|
||||
response.data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id, name: item.name, type: "scenario", headers: scenarioDefinition.headers, variables: scenarioDefinition.variables, environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: 'Copy', resourceId: getUUID(), hashTree: scenarioDefinition.hashTree, projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
}
|
||||
let conditions = this.getConditions();
|
||||
if (conditions.selectAll) {
|
||||
let params = {};
|
||||
params.ids = this.currentScenarioIds;
|
||||
params.condition = conditions;
|
||||
let url = "/api/automation/list/all/";
|
||||
this.result = this.$post(url, params, (response) => {
|
||||
this.currentScenario = response.data;
|
||||
if (!this.currentScenario || this.currentScenario.length < 1) {
|
||||
this.$emit('请选择场景');
|
||||
return;
|
||||
}
|
||||
this.currentScenario.forEach(item => {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
referenced: 'REF',
|
||||
resourceId: getUUID(),
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
});
|
||||
} else {
|
||||
if (!this.currentScenario || this.currentScenario.length < 1) {
|
||||
this.$emit('请选择场景');
|
||||
return;
|
||||
}
|
||||
})
|
||||
this.currentScenario.forEach(item => {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
referenced: 'REF',
|
||||
resourceId: getUUID(),
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
}
|
||||
},
|
||||
copy() {
|
||||
let scenarios = [];
|
||||
let conditions = this.getConditions();
|
||||
if (conditions.selectAll) {
|
||||
let url = "/api/automation/id/all/";
|
||||
let params = {};
|
||||
params.ids = this.currentScenarioIds;
|
||||
params.condition = conditions;
|
||||
this.result = this.$post(url, params, (response) => {
|
||||
this.currentScenarioIds = response.data;
|
||||
if (!this.currentScenarioIds || this.currentScenarioIds.length < 1) {
|
||||
this.$warning('请选择场景');
|
||||
return;
|
||||
}
|
||||
this.result = this.$post("/api/automation/getApiScenarios/", this.currentScenarioIds, response => {
|
||||
if (response.data) {
|
||||
response.data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
headers: scenarioDefinition.headers,
|
||||
variables: scenarioDefinition.variables,
|
||||
environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: 'Copy',
|
||||
resourceId: getUUID(),
|
||||
hashTree: scenarioDefinition.hashTree,
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
}
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (!this.currentScenarioIds || this.currentScenarioIds.length < 1) {
|
||||
this.$warning('请选择场景');
|
||||
return;
|
||||
}
|
||||
this.result = this.$post("/api/automation/getApiScenarios/", this.currentScenarioIds, response => {
|
||||
if (response.data) {
|
||||
response.data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
headers: scenarioDefinition.headers,
|
||||
variables: scenarioDefinition.variables,
|
||||
environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: 'Copy',
|
||||
resourceId: getUUID(),
|
||||
hashTree: scenarioDefinition.hashTree,
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
}
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
|
@ -134,6 +216,9 @@
|
|||
this.projectId = projectId;
|
||||
this.selectNodeIds = [];
|
||||
},
|
||||
getConditions() {
|
||||
return this.$refs.apiScenarioList.getConditions();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -8,104 +8,92 @@
|
|||
class="search-input" size="small"
|
||||
v-model="condition.name"/>
|
||||
|
||||
<el-table v-loading="result.loading"
|
||||
<ms-table :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize"
|
||||
:total="total" enableSelection
|
||||
:batch-operators="buttons" :screenHeight="screenHeight"
|
||||
operator-width="170px"
|
||||
ref="caseTable"
|
||||
border
|
||||
:data="tableData" row-key="id" class="test-content adjust-table ms-select-all-fixed"
|
||||
@select-all="handleSelectAll"
|
||||
@filter-change="filter"
|
||||
@sort-change="sort"
|
||||
@header-dragend="headerDragend"
|
||||
@select="handleSelect" :height="screenHeight">
|
||||
|
||||
<el-table-column type="selection" width="50"/>
|
||||
|
||||
<ms-table-header-select-popover v-show="total>0"
|
||||
:page-size="pageSize>total?total:pageSize"
|
||||
:total="total"
|
||||
:select-data-counts="selectDataCounts"
|
||||
@selectPageAll="isSelectDataAll(false)"
|
||||
@selectAll="isSelectDataAll(true)"/>
|
||||
|
||||
<el-table-column width="30" :resizable="false" min-width="30px" align="center">
|
||||
<template v-slot:default="scope">
|
||||
<!-- 选中后浮现提供批量操作的按钮-->
|
||||
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts" v-tester/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
>
|
||||
<template v-for="(item, index) in tableLabel">
|
||||
<el-table-column v-if="item.id == 'num'" prop="num" label="ID" min-width="120px" show-overflow-tooltip
|
||||
:key="index">
|
||||
|
||||
<ms-table-column
|
||||
v-if="item.id == 'num'"
|
||||
prop="num"
|
||||
label="ID"
|
||||
show-overflow-tooltip
|
||||
width="80px"
|
||||
sortable=true
|
||||
:key="index">
|
||||
<template slot-scope="scope">
|
||||
<!-- 为只读用户的话不能编辑 -->
|
||||
<!-- 判断为只读用户的话不可点击ID进行编辑操作 -->
|
||||
<span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>
|
||||
<el-tooltip :content="$t('commons.edit')" v-else>
|
||||
<a style="cursor:pointer" @click="handleTestCase(scope.row)"> {{ scope.row.num }} </a>
|
||||
<el-tooltip v-else content="编辑">
|
||||
<a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column v-if="item.id == 'name'" prop="name" min-width="160px" :label="$t('test_track.case.name')"
|
||||
<ms-table-column v-if="item.id == 'name'" prop="name" width="160px" :label="$t('test_track.case.name')"
|
||||
show-overflow-tooltip :key="index"/>
|
||||
|
||||
<el-table-column
|
||||
v-if="item.id == 'priority'"
|
||||
prop="priority"
|
||||
:filters="priorityFilters"
|
||||
column-key="priority"
|
||||
min-width="120px"
|
||||
:label="$t('test_track.case.priority')"
|
||||
show-overflow-tooltip
|
||||
:key="index">
|
||||
<ms-table-column
|
||||
v-if="item.id == 'priority'"
|
||||
prop="priority"
|
||||
:filters="priorityFilters"
|
||||
column-key="priority"
|
||||
width="120px"
|
||||
:label="$t('test_track.case.priority')"
|
||||
show-overflow-tooltip
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<priority-table-item :value="scope.row.priority"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column
|
||||
v-if="item.id == 'path'"
|
||||
sortable="custom"
|
||||
prop="path"
|
||||
min-width="180px"
|
||||
:label="'API'+ $t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'path'"
|
||||
sortable="custom"
|
||||
prop="path"
|
||||
width="180px"
|
||||
:label="'API'+ $t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column
|
||||
v-if="item.id == 'casePath'"
|
||||
sortable="custom"
|
||||
prop="casePath"
|
||||
min-width="180px"
|
||||
:label="$t('api_test.definition.request.case')+ $t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
<ms-table-column
|
||||
v-if="item.id == 'casePath'"
|
||||
sortable="custom"
|
||||
prop="casePath"
|
||||
width="180px"
|
||||
:label="$t('api_test.definition.request.case')+ $t('api_test.definition.api_path')"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column v-if="item.id=='tags'" prop="tags" min-width="120px" :label="$t('commons.tag')"
|
||||
<ms-table-column v-if="item.id=='tags'" prop="tags" width="120px" :label="$t('commons.tag')"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
|
||||
:content="itemName" style="margin-left: 0px; margin-right: 2px"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ms-table-column>
|
||||
|
||||
<el-table-column
|
||||
v-if="item.id=='createUser'"
|
||||
prop="createUser"
|
||||
:label="'创建人'"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
<ms-table-column
|
||||
v-if="item.id=='createUser'"
|
||||
prop="createUser"
|
||||
:label="'创建人'"
|
||||
show-overflow-tooltip
|
||||
:key="index"/>
|
||||
|
||||
<el-table-column
|
||||
v-if="item.id=='updateTime'"
|
||||
sortable="updateTime"
|
||||
min-width="160"
|
||||
:label="$t('api_test.definition.api_last_time')"
|
||||
prop="updateTime"
|
||||
:key="index">
|
||||
<ms-table-column
|
||||
v-if="item.id=='updateTime'"
|
||||
sortable="updateTime"
|
||||
width="160px"
|
||||
:label="$t('api_test.definition.api_last_time')"
|
||||
prop="updateTime"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ms-table-column>
|
||||
</template>
|
||||
<el-table-column fixed="right" v-if="!isReadOnly" :label="$t('commons.operating')" min-width="160"
|
||||
align="center">
|
||||
|
@ -125,7 +113,9 @@
|
|||
@createPerformance="createPerformance" :row="scope.row" v-tester/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
</ms-table>
|
||||
|
||||
<header-custom ref="headerCustom" :initTableData="initTable" :optionalFields=headerItems
|
||||
:type=type></header-custom>
|
||||
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
|
@ -148,6 +138,8 @@
|
|||
|
||||
<script>
|
||||
|
||||
import MsTable from "@/business/components/common/components/table/MsTable";
|
||||
import MsTableColumn from "@/business/components/common/components/table/Ms-table-column";
|
||||
import MsTableOperator from "../../../../common/components/MsTableOperator";
|
||||
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
|
||||
import MsTablePagination from "../../../../common/pagination/TablePagination";
|
||||
|
@ -197,7 +189,9 @@ export default {
|
|||
MsBatchEdit,
|
||||
MsApiCaseTableExtendBtns,
|
||||
MsReferenceView,
|
||||
MsTableAdvSearchBar
|
||||
MsTableAdvSearchBar,
|
||||
MsTable,
|
||||
MsTableColumn
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -212,7 +206,6 @@ export default {
|
|||
moduleId: "",
|
||||
selectDataRange: "all",
|
||||
deletePath: "/test/case/delete",
|
||||
selectRows: new Set(),
|
||||
clickRow: {},
|
||||
buttons: [
|
||||
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
|
||||
|
@ -277,9 +270,9 @@ export default {
|
|||
},
|
||||
created: function () {
|
||||
this.initTable();
|
||||
this.$nextTick(() => {
|
||||
this.$refs.caseTable.bodyWrapper.scrollTop = 5
|
||||
})
|
||||
// this.$nextTick(() => {
|
||||
// this.$refs.caseTable.bodyWrapper.scrollTop = 5
|
||||
// })
|
||||
},
|
||||
watch: {
|
||||
selectNodeIds() {
|
||||
|
@ -309,18 +302,23 @@ export default {
|
|||
computed: {
|
||||
// 接口定义用例列表
|
||||
isApiModel() {
|
||||
return this.model === 'api'
|
||||
return this.model === 'api';
|
||||
},
|
||||
projectId() {
|
||||
return this.$store.state.projectId
|
||||
return this.$store.state.projectId;
|
||||
},
|
||||
selectRows() {
|
||||
return this.$refs.caseTable.getSelectRows();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
customHeader() {
|
||||
this.$refs.headerCustom.open(this.tableLabel)
|
||||
},
|
||||
initTable() {
|
||||
this.selectRows = new Set();
|
||||
if (this.$refs.caseTable) {
|
||||
this.$refs.caseTable.clearSelectRows();
|
||||
}
|
||||
this.condition.status = "";
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
if (this.trashEnable) {
|
||||
|
@ -369,45 +367,18 @@ export default {
|
|||
this.$nextTick(function () {
|
||||
if (this.$refs.caseTable) {
|
||||
setTimeout(this.$refs.caseTable.doLayout, 200);
|
||||
this.$refs.caseTable.checkTableRowIsSelect();
|
||||
}
|
||||
this.checkTableRowIsSelect();
|
||||
})
|
||||
});
|
||||
}
|
||||
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);
|
||||
|
@ -424,10 +395,6 @@ export default {
|
|||
_sort(column, this.condition);
|
||||
this.initTable();
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
_handleSelectAll(this, selection, this.tableData, this.selectRows);
|
||||
this.selectRowsCount(this.selectRows);
|
||||
},
|
||||
search() {
|
||||
this.changeSelectDataRangeAll();
|
||||
this.initTable();
|
||||
|
@ -489,28 +456,13 @@ export default {
|
|||
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.$refs.caseTable.clearSelectRows();
|
||||
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') {
|
||||
|
@ -569,14 +521,6 @@ export default {
|
|||
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";
|
||||
|
|
|
@ -146,196 +146,6 @@
|
|||
|
||||
</ms-table>
|
||||
|
||||
<!-- <el-table v-loading="result.loading"-->
|
||||
<!-- ref="apiDefinitionTable"-->
|
||||
<!-- border-->
|
||||
<!-- @sort-change="sort"-->
|
||||
<!-- @filter-change="filter"-->
|
||||
<!-- :data="tableData" row-key="id" class="test-content adjust-table ms-select-all-fixed"-->
|
||||
<!-- @select-all="handleSelectAll"-->
|
||||
<!-- @header-dragend="headerDragend"-->
|
||||
<!-- @select="handleSelect" :height="screenHeight">-->
|
||||
<!-- <el-table-column width="50" type="selection"/>-->
|
||||
|
||||
<!-- <ms-table-header-select-popover v-show="total>0"-->
|
||||
<!-- :page-size="pageSize>total?total:pageSize"-->
|
||||
<!-- :total="total"-->
|
||||
<!-- :select-data-counts="selectDataCounts"-->
|
||||
<!-- @selectPageAll="isSelectDataAll(false)"-->
|
||||
<!-- @selectAll="isSelectDataAll(true)"/>-->
|
||||
|
||||
<!-- <el-table-column width="30" :resizable="false" align="center">-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <!– 选中记录后浮现的按钮,提供对记录的批量操作 –>-->
|
||||
<!-- <show-more-btn :is-show="scope.row.showMore" :buttons="trashEnable ? trashButtons : buttons" :size="selectDataCounts" v-tester/>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <template v-for="(item, index) in tableLabel">-->
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'num'"-->
|
||||
<!-- prop="num"-->
|
||||
<!-- label="ID"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- min-width="80px"-->
|
||||
<!-- sortable="custom"-->
|
||||
<!-- :key="index">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <!– 判断为只读用户的话不可点击ID进行编辑操作 –>-->
|
||||
<!-- <span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>-->
|
||||
<!-- <el-tooltip v-else content="编辑">-->
|
||||
<!-- <a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>-->
|
||||
<!-- </el-tooltip>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'name'"-->
|
||||
<!-- prop="name"-->
|
||||
<!-- :label="$t('api_test.definition.api_name')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- sortable="custom"-->
|
||||
<!-- min-width="120px"-->
|
||||
<!-- :key="index"/>-->
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'status'"-->
|
||||
<!-- prop="status"-->
|
||||
<!-- column-key="status"-->
|
||||
<!-- sortable="custom"-->
|
||||
<!-- :filters="statusFilters"-->
|
||||
<!-- :label="$t('api_test.definition.api_status')"-->
|
||||
<!-- min-width="120px"-->
|
||||
<!-- :key="index">-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <span class="el-dropdown-link">-->
|
||||
<!-- <api-status :value="scope.row.status"/>-->
|
||||
<!-- </span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'method'"-->
|
||||
<!-- prop="method"-->
|
||||
<!-- sortable="custom"-->
|
||||
<!-- column-key="method"-->
|
||||
<!-- :filters="methodFilters"-->
|
||||
<!-- :label="$t('api_test.definition.api_type')"-->
|
||||
<!-- show-overflow-tooltip min-width="120px"-->
|
||||
<!-- :key="index">-->
|
||||
<!-- <template v-slot:default="scope" class="request-method">-->
|
||||
<!-- <el-tag size="mini"-->
|
||||
<!-- :style="{'background-color': getColor(true, scope.row.method), border: getColor(true, scope.row.method)}"-->
|
||||
<!-- class="api-el-tag">-->
|
||||
<!-- {{ scope.row.method }}-->
|
||||
<!-- </el-tag>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'userName'"-->
|
||||
<!-- prop="userName"-->
|
||||
<!-- sortable="custom"-->
|
||||
<!-- :filters="userFilters"-->
|
||||
<!-- column-key="user_id"-->
|
||||
<!-- :label="$t('api_test.definition.api_principal')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- min-width="100px"-->
|
||||
<!-- :key="index"/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'path'"-->
|
||||
<!-- prop="path"-->
|
||||
<!-- min-width="120px"-->
|
||||
<!-- :label="$t('api_test.definition.api_path')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- :key="index"/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'tags'"-->
|
||||
<!-- prop="tags"-->
|
||||
<!-- :label="$t('commons.tag')"-->
|
||||
<!-- min-width="120px"-->
|
||||
<!-- :key="index">-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :show-tooltip="true" :content="itemName"-->
|
||||
<!-- style="margin-left: 0px; margin-right: 2px"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'updateTime'"-->
|
||||
<!-- width="160"-->
|
||||
<!-- :label="$t('api_test.definition.api_last_time')"-->
|
||||
<!-- sortable="custom"-->
|
||||
<!-- min-width="160px"-->
|
||||
<!-- prop="updateTime"-->
|
||||
<!-- :key="index">-->
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <span>{{ scope.row.updateTime | timestampFormatDate }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'caseTotal'"-->
|
||||
<!-- prop="caseTotal"-->
|
||||
<!-- min-width="80px"-->
|
||||
<!-- :label="$t('api_test.definition.api_case_number')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- :key="index"/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'caseStatus'"-->
|
||||
<!-- prop="caseStatus"-->
|
||||
<!-- min-width="80px"-->
|
||||
<!-- :label="$t('api_test.definition.api_case_status')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- :key="index"/>-->
|
||||
|
||||
<!-- <el-table-column-->
|
||||
<!-- v-if="item.id == 'casePassingRate'"-->
|
||||
<!-- prop="casePassingRate"-->
|
||||
<!-- :width="100"-->
|
||||
<!-- min-width="100px"-->
|
||||
<!-- :label="$t('api_test.definition.api_case_passing_rate')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- :key="index"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- <!– 操作 –>-->
|
||||
<!-- <el-table-column fixed="right" v-if="!isReadOnly" min-width="180"-->
|
||||
<!-- align="center">-->
|
||||
|
||||
<!-- <template slot="header">-->
|
||||
<!-- <header-label-operate @exec="customHeader"/>-->
|
||||
<!-- </template>-->
|
||||
|
||||
<!-- <template v-slot:default="scope">-->
|
||||
<!-- <ms-table-operator-button class="run-button" :is-tester-permission="true"-->
|
||||
<!-- :tip="$t('api_test.automation.execute')"-->
|
||||
<!-- icon="el-icon-video-play"-->
|
||||
<!-- @exec="runApi(scope.row)"/>-->
|
||||
<!-- <!– 回收站的恢复按钮 –>-->
|
||||
<!-- <ms-table-operator-button :tip="$t('commons.reduction')" icon="el-icon-refresh-left"-->
|
||||
<!-- @exec="reductionApi(scope.row)" v-if="trashEnable" v-tester/>-->
|
||||
<!-- <ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="editApi(scope.row)" v-else-->
|
||||
<!-- v-tester/>-->
|
||||
<!-- <el-tooltip :content="$t('test_track.case.case_list')"-->
|
||||
<!-- placement="bottom"-->
|
||||
<!-- :enterable="false"-->
|
||||
<!-- effect="dark">-->
|
||||
<!-- <el-button @click="handleTestCase(scope.row)"-->
|
||||
<!-- @keydown.enter.native.prevent-->
|
||||
<!-- type="primary"-->
|
||||
<!-- :disabled="isReadOnly"-->
|
||||
<!-- circle-->
|
||||
<!-- style="color:white;padding: 0px 0.1px;font-size: 11px;width: 28px;height: 28px;"-->
|
||||
<!-- size="mini">case-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </el-tooltip>-->
|
||||
<!-- <ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" @exec="handleDelete(scope.row)"-->
|
||||
<!-- type="danger" v-tester/>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <header-custom ref="headerCustom" :initTableData="initTable" :optionalFields=headerItems-->
|
||||
<!-- :type=type></header-custom>-->
|
||||
<!-- </el-table>-->
|
||||
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
</div>
|
||||
|
@ -429,7 +239,6 @@ export default {
|
|||
moduleId: "",
|
||||
selectDataRange: "all",
|
||||
deletePath: "/test/case/delete",
|
||||
selectRows: new Set(),
|
||||
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},
|
||||
|
@ -453,6 +262,8 @@ export default {
|
|||
tableTrashOperatorButtons: [
|
||||
{tip: this.$t('api_test.automation.execute'), icon: "el-icon-video-play", exec: this.runApi},
|
||||
{tip: this.$t('commons.reduction'), icon: "el-icon-refresh-left", exec: this.reductionApi},
|
||||
{tip: "CASE", exec: this.handleTestCase, isDivButton: true, type: "primary"},
|
||||
{tip: this.$t('commons.delete'), exec: this.handleDelete, icon: "el-icon-delete", type: "danger"},
|
||||
],
|
||||
typeArr: [
|
||||
{id: 'status', name: this.$t('api_test.definition.api_status')},
|
||||
|
@ -531,8 +342,11 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
projectId() {
|
||||
return this.$store.state.projectId
|
||||
return this.$store.state.projectId;
|
||||
},
|
||||
selectRows() {
|
||||
return this.$refs.apiDefinitionTable.getSelectRows();
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
if (this.trashEnable) {
|
||||
|
@ -577,7 +391,9 @@ export default {
|
|||
this.$refs.testCaseBatchMove.open(this.moduleTree, [], this.moduleOptions);
|
||||
},
|
||||
initTable() {
|
||||
this.selectRows = new Set();
|
||||
if (this.$refs.apiDefinitionTable) {
|
||||
this.$refs.apiDefinitionTable.clearSelectRows();
|
||||
}
|
||||
initCondition(this.condition, this.condition.selectAll);
|
||||
this.selectDataCounts = 0;
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
|
@ -683,22 +499,6 @@ export default {
|
|||
});
|
||||
});
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
_handleSelectAll(this, selection, this.tableData, this.selectRows, this.condition);
|
||||
setUnSelectIds(this.tableData, this.condition, this.selectRows);
|
||||
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows);
|
||||
},
|
||||
handleSelect(selection, row) {
|
||||
_handleSelect(this, selection, row, this.selectRows);
|
||||
setUnSelectIds(this.tableData, this.condition, this.selectRows);
|
||||
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows);
|
||||
},
|
||||
isSelectDataAll(data) {
|
||||
this.condition.selectAll = data;
|
||||
setUnSelectIds(this.tableData, this.condition, this.selectRows);
|
||||
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows);
|
||||
toggleAllSelection(this.$refs.apiDefinitionTable, this.tableData, this.selectRows);
|
||||
},
|
||||
search() {
|
||||
this.changeSelectDataRangeAll();
|
||||
this.initTable();
|
||||
|
@ -765,7 +565,7 @@ export default {
|
|||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.$post('/api/definition/deleteBatchByParams/', buildBatchParam(this), () => {
|
||||
this.selectRows.clear();
|
||||
this.$refs.apiDefinitionTable.clearSelectRows();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
});
|
||||
|
@ -778,7 +578,7 @@ export default {
|
|||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.$post('/api/definition/removeToGcByParams/', buildBatchParam(this), () => {
|
||||
this.selectRows.clear();
|
||||
this.$refs.apiDefinitionTable.clearSelectRows();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.$refs.caseList.apiCaseClose();
|
||||
|
|
|
@ -240,7 +240,19 @@ export default {
|
|||
},
|
||||
checkTableRowIsSelect() {
|
||||
checkTableRowIsSelect(this, this.condition, this.data, this.$refs.table, this.selectRows);
|
||||
}
|
||||
},
|
||||
clearSelection() {
|
||||
this.selectRows = new Set();
|
||||
if (this.$refs.table) {
|
||||
this.$refs.table.clearSelection();
|
||||
}
|
||||
},
|
||||
getSelectRows() {
|
||||
return this.selectRows;
|
||||
},
|
||||
clearSelectRows() {
|
||||
this.selectRows = new Set();
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue