feat: 测试计划关联用例支持跨项目
This commit is contained in:
parent
c1dfe05e87
commit
dad8ad2be9
|
@ -97,9 +97,7 @@
|
|||
|
||||
<select id="list" resultMap="BaseResultMap"
|
||||
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
|
||||
select test_plan.*, project.name as project_name
|
||||
from test_plan
|
||||
left join project on test_plan.project_id = project.id
|
||||
select test_plan.* from test_plan
|
||||
<where>
|
||||
<if test="request.combine != null">
|
||||
<include refid="combine">
|
||||
|
@ -111,10 +109,7 @@
|
|||
and test_plan.name like CONCAT('%', #{request.name},'%')
|
||||
</if>
|
||||
<if test="request.workspaceId != null">
|
||||
AND project.workspace_id = #{request.workspaceId}
|
||||
</if>
|
||||
<if test="request.projectId != null">
|
||||
AND project.id = #{request.projectId}
|
||||
AND test_plan.workspace_id = #{request.workspaceId}
|
||||
</if>
|
||||
<if test="request.id != null">
|
||||
AND test_plan.id = #{request.id}
|
||||
|
@ -150,9 +145,7 @@
|
|||
</select>
|
||||
|
||||
<select id="listRelate" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric">
|
||||
select test_plan.*, project.name as project_name
|
||||
from test_plan
|
||||
left join project on test_plan.project_id = project.id
|
||||
select test_plan.* from test_plan
|
||||
where test_plan.workspace_id = #{request.workspaceId}
|
||||
and (test_plan.principal = #{request.principal}
|
||||
<if test="request.planIds != null and request.planIds.size() > 0">
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.base.domain.TestCaseNode;
|
|||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.track.dto.TestCaseNodeDTO;
|
||||
import io.metersphere.track.request.testcase.DragNodeRequest;
|
||||
import io.metersphere.track.request.testcase.QueryNodeRequest;
|
||||
import io.metersphere.track.service.TestCaseNodeService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
|
@ -26,9 +27,9 @@ public class TestCaseNodeController {
|
|||
}
|
||||
|
||||
/*模块列表列表*/
|
||||
@GetMapping("/list/all/plan/{planId}")
|
||||
public List<TestCaseNodeDTO> getAllNodeByPlanId(@PathVariable String planId) {
|
||||
return testCaseNodeService.getAllNodeByPlanId(planId);
|
||||
@PostMapping("/list/all/plan")
|
||||
public List<TestCaseNodeDTO> getAllNodeByPlanId(@RequestBody QueryNodeRequest request) {
|
||||
return testCaseNodeService.getAllNodeByPlanId(request);
|
||||
}
|
||||
|
||||
@GetMapping("/list/plan/{planId}")
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.track.controller;
|
|||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.domain.TestPlan;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
|
@ -12,6 +13,8 @@ import io.metersphere.track.dto.TestPlanDTO;
|
|||
import io.metersphere.track.dto.TestPlanDTOWithMetric;
|
||||
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
||||
import io.metersphere.track.service.TestPlanProjectService;
|
||||
import io.metersphere.track.service.TestPlanService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
|
@ -26,6 +29,8 @@ public class TestPlanController {
|
|||
|
||||
@Resource
|
||||
TestPlanService testPlanService;
|
||||
@Resource
|
||||
TestPlanProjectService testPlanProjectService;
|
||||
|
||||
@PostMapping("/list/{goPage}/{pageSize}")
|
||||
public Pager<List<TestPlanDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
|
||||
|
@ -37,7 +42,7 @@ public class TestPlanController {
|
|||
|
||||
/*jenkins测试计划*/
|
||||
@GetMapping("/list/all/{projectId}/{workspaceId}")
|
||||
public List<TestPlanDTO> listByprojectId(@PathVariable String projectId, @PathVariable String workspaceId) {
|
||||
public List<TestPlanDTO> listByProjectId(@PathVariable String projectId, @PathVariable String workspaceId) {
|
||||
QueryTestPlanRequest request = new QueryTestPlanRequest();
|
||||
request.setWorkspaceId(workspaceId);
|
||||
request.setProjectId(projectId);
|
||||
|
@ -69,7 +74,7 @@ public class TestPlanController {
|
|||
|
||||
@PostMapping("/add")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public void addTestPlan(@RequestBody TestPlan testPlan) {
|
||||
public void addTestPlan(@RequestBody AddTestPlanRequest testPlan) {
|
||||
testPlanService.addTestPlan(testPlan);
|
||||
}
|
||||
|
||||
|
@ -100,4 +105,14 @@ public class TestPlanController {
|
|||
public TestCaseReportMetricDTO getMetric(@PathVariable String planId) {
|
||||
return testPlanService.getMetric(planId);
|
||||
}
|
||||
|
||||
@GetMapping("/project/name/{planId}")
|
||||
public String getProjectNameByPlanId(@PathVariable String planId) {
|
||||
return testPlanService.getProjectNameByPlanId(planId);
|
||||
}
|
||||
|
||||
@GetMapping("/project/{planId}")
|
||||
public List<Project> getProjectByPlanId(@PathVariable String planId) {
|
||||
return testPlanProjectService.getProjectByPlanId(planId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package io.metersphere.track.domain;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.base.domain.Issues;
|
||||
import io.metersphere.base.domain.TestCaseNode;
|
||||
import io.metersphere.base.domain.TestCaseNodeExample;
|
||||
import io.metersphere.base.mapper.TestCaseNodeMapper;
|
||||
|
@ -11,6 +9,7 @@ import io.metersphere.commons.utils.MathUtils;
|
|||
import io.metersphere.track.dto.*;
|
||||
import io.metersphere.track.service.IssuesService;
|
||||
import io.metersphere.track.service.TestCaseNodeService;
|
||||
import io.metersphere.track.service.TestPlanProjectService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -30,8 +29,9 @@ public class ReportResultComponent extends ReportComponent {
|
|||
public void init() {
|
||||
TestCaseNodeService testCaseNodeService = (TestCaseNodeService) CommonBeanFactory.getBean("testCaseNodeService");
|
||||
TestCaseNodeMapper testCaseNodeMapper = (TestCaseNodeMapper) CommonBeanFactory.getBean("testCaseNodeMapper");
|
||||
TestPlanProjectService testPlanProjectService = (TestPlanProjectService) CommonBeanFactory.getBean("testPlanProjectService");
|
||||
TestCaseNodeExample testCaseNodeExample = new TestCaseNodeExample();
|
||||
testCaseNodeExample.createCriteria().andProjectIdEqualTo(testPlan.getProjectId());
|
||||
testCaseNodeExample.createCriteria().andProjectIdIn(testPlanProjectService.getProjectIdsByPlanId(testPlan.getId()));
|
||||
List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(testCaseNodeExample);
|
||||
nodeTrees = testCaseNodeService.getNodeTrees(nodes);
|
||||
nodeTrees.forEach(item -> {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.track.request.testcase;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class QueryNodeRequest {
|
||||
|
||||
private String testPlanId;
|
||||
private String projectId;
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.track.request.testplan;
|
||||
|
||||
import io.metersphere.base.domain.TestPlan;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AddTestPlanRequest extends TestPlan {
|
||||
private List<String> projectIds;
|
||||
}
|
|
@ -2,10 +2,7 @@ package io.metersphere.track.service;
|
|||
|
||||
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.TestCaseMapper;
|
||||
import io.metersphere.base.mapper.TestCaseNodeMapper;
|
||||
import io.metersphere.base.mapper.TestPlanMapper;
|
||||
import io.metersphere.base.mapper.TestPlanTestCaseMapper;
|
||||
import io.metersphere.base.mapper.*;
|
||||
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
||||
import io.metersphere.commons.constants.TestCaseConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
|
@ -15,6 +12,7 @@ import io.metersphere.i18n.Translator;
|
|||
import io.metersphere.track.dto.TestCaseDTO;
|
||||
import io.metersphere.track.dto.TestCaseNodeDTO;
|
||||
import io.metersphere.track.request.testcase.DragNodeRequest;
|
||||
import io.metersphere.track.request.testcase.QueryNodeRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestCaseRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
|
@ -43,6 +41,10 @@ public class TestCaseNodeService {
|
|||
ExtTestCaseMapper extTestCaseMapper;
|
||||
@Resource
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
@Resource
|
||||
TestPlanProjectService testPlanProjectService;
|
||||
@Resource
|
||||
ProjectMapper projectMapper;
|
||||
|
||||
public String addNode(TestCaseNode node) {
|
||||
validateNode(node);
|
||||
|
@ -182,8 +184,22 @@ public class TestCaseNodeService {
|
|||
*/
|
||||
public List<TestCaseNodeDTO> getNodeByPlanId(String planId) {
|
||||
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
|
||||
List<TestCaseNodeDTO> list = new ArrayList<>();
|
||||
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(planId);
|
||||
projectIds.forEach(id -> {
|
||||
String name = projectMapper.selectByPrimaryKey(id).getName();
|
||||
List<TestCaseNodeDTO> nodeList = getNodeDTO(id, planId);
|
||||
TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO();
|
||||
testCaseNodeDTO.setName(name);
|
||||
testCaseNodeDTO.setLabel(name);
|
||||
testCaseNodeDTO.setChildren(nodeList);
|
||||
list.add(testCaseNodeDTO);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<TestCaseNodeDTO> getNodeDTO(String projectId, String planId) {
|
||||
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
|
||||
testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(planId);
|
||||
List<TestPlanTestCase> testPlanTestCases = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample);
|
||||
|
@ -193,7 +209,7 @@ public class TestCaseNodeService {
|
|||
}
|
||||
|
||||
TestCaseNodeExample testCaseNodeExample = new TestCaseNodeExample();
|
||||
testCaseNodeExample.createCriteria().andProjectIdEqualTo(testPlan.getProjectId());
|
||||
testCaseNodeExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(testCaseNodeExample);
|
||||
|
||||
List<String> caseIds = testPlanTestCases.stream()
|
||||
|
@ -254,12 +270,16 @@ public class TestCaseNodeService {
|
|||
return false;
|
||||
}
|
||||
|
||||
public List<TestCaseNodeDTO> getAllNodeByPlanId(String planId) {
|
||||
public List<TestCaseNodeDTO> getAllNodeByPlanId(QueryNodeRequest request) {
|
||||
// todo jenkins 获取模块
|
||||
String planId = request.getTestPlanId();
|
||||
String projectId = request.getProjectId();
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
|
||||
if (testPlan == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getNodeTreeByProjectId(testPlan.getProjectId());
|
||||
|
||||
return getNodeTreeByProjectId(projectId);
|
||||
}
|
||||
|
||||
public Map<String, String> createNodeByTestCases(List<TestCaseWithBLOBs> testCases, String projectId) {
|
||||
|
|
|
@ -182,9 +182,7 @@ public class TestCaseService {
|
|||
public List<TestCase> getTestCaseNames(QueryTestCaseRequest request) {
|
||||
if (StringUtils.isNotBlank(request.getPlanId())) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
|
||||
if (testPlan != null) {
|
||||
request.setProjectId(testPlan.getProjectId());
|
||||
}
|
||||
// request 传入要查询的 projectId 切换的项目ID
|
||||
}
|
||||
|
||||
List<TestCase> testCaseNames = extTestCaseMapper.getTestCaseNames(request);
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package io.metersphere.track.service;
|
||||
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.domain.ProjectExample;
|
||||
import io.metersphere.base.domain.TestPlanProject;
|
||||
import io.metersphere.base.domain.TestPlanProjectExample;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.TestPlanProjectMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TestPlanProjectService {
|
||||
|
||||
@Resource
|
||||
TestPlanProjectMapper testPlanProjectMapper;
|
||||
@Resource
|
||||
ProjectMapper projectMapper;
|
||||
|
||||
public List<String> getProjectIdsByPlanId(String planId) {
|
||||
TestPlanProjectExample example = new TestPlanProjectExample();
|
||||
example.createCriteria().andTestPlanIdEqualTo(planId);
|
||||
List<String> projectIds = testPlanProjectMapper.selectByExample(example)
|
||||
.stream()
|
||||
.map(TestPlanProject::getProjectId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (projectIds.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return projectIds;
|
||||
}
|
||||
|
||||
public List<Project> getProjectByPlanId(String planId) {
|
||||
List<String> projectIds = getProjectIdsByPlanId(planId);
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andIdIn(projectIds);
|
||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||
return Optional.ofNullable(projects).orElse(new ArrayList<>());
|
||||
}
|
||||
}
|
|
@ -4,10 +4,7 @@ package io.metersphere.track.service;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.TestCaseMapper;
|
||||
import io.metersphere.base.mapper.TestCaseReportMapper;
|
||||
import io.metersphere.base.mapper.TestPlanMapper;
|
||||
import io.metersphere.base.mapper.TestPlanTestCaseMapper;
|
||||
import io.metersphere.base.mapper.*;
|
||||
import io.metersphere.base.mapper.ext.ExtProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
||||
|
@ -28,6 +25,7 @@ import io.metersphere.track.dto.TestPlanDTO;
|
|||
import io.metersphere.track.dto.TestPlanDTOWithMetric;
|
||||
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
||||
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
|
@ -72,12 +70,29 @@ public class TestPlanService {
|
|||
@Resource
|
||||
TestCaseReportMapper testCaseReportMapper;
|
||||
|
||||
public void addTestPlan(TestPlan testPlan) {
|
||||
@Resource
|
||||
TestPlanProjectMapper testPlanProjectMapper;
|
||||
@Resource
|
||||
TestPlanProjectService testPlanProjectService;
|
||||
@Resource
|
||||
ProjectMapper projectMapper;
|
||||
|
||||
public void addTestPlan(AddTestPlanRequest testPlan) {
|
||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||
MSException.throwException(Translator.get("plan_name_already_exists"));
|
||||
}
|
||||
;
|
||||
testPlan.setId(UUID.randomUUID().toString());
|
||||
|
||||
String testPlanId = UUID.randomUUID().toString();
|
||||
|
||||
List<String> projectIds = testPlan.getProjectIds();
|
||||
projectIds.forEach(id -> {
|
||||
TestPlanProject testPlanProject = new TestPlanProject();
|
||||
testPlanProject.setProjectId(id);
|
||||
testPlanProject.setTestPlanId(testPlanId);
|
||||
testPlanProjectMapper.insertSelective(testPlanProject);
|
||||
});
|
||||
|
||||
testPlan.setId(testPlanId);
|
||||
testPlan.setStatus(TestPlanStatus.Prepare.name());
|
||||
testPlan.setCreateTime(System.currentTimeMillis());
|
||||
testPlan.setUpdateTime(System.currentTimeMillis());
|
||||
|
@ -316,4 +331,23 @@ public class TestPlanService {
|
|||
testPlan.setStatus(TestPlanStatus.Completed.name());
|
||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||
}
|
||||
|
||||
public String getProjectNameByPlanId(String testPlanId) {
|
||||
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(testPlanId);
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andIdIn(projectIds);
|
||||
|
||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String projectName = "";
|
||||
|
||||
if (projects.size() > 0) {
|
||||
for (Project project : projects) {
|
||||
stringBuilder.append(project.getName()).append("、");
|
||||
}
|
||||
projectName = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
|
||||
}
|
||||
|
||||
return projectName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<template>
|
||||
<el-dialog v-loading="result.loading"
|
||||
:visible.sync="dialogVisible"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
highlight-current-row
|
||||
@current-change="handleCurrentChange"
|
||||
style="width: 100%">
|
||||
<el-table-column prop="name" :label="$t('commons.name')" show-overflow-tooltip/>
|
||||
<el-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
{{ scope.row.description }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
sortable
|
||||
prop="createTime"
|
||||
:label="$t('commons.create_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
sortable
|
||||
prop="updateTime"
|
||||
:label="$t('commons.update_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template v-slot:footer>
|
||||
<div class="dialog-footer">
|
||||
<ms-dialog-footer
|
||||
@cancel="dialogVisible = false"
|
||||
@confirm="submit()"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsDialogFooter from "../../../common/components/MsDialogFooter";
|
||||
|
||||
export default {
|
||||
name: "SwitchProject",
|
||||
components: {MsDialogFooter},
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
result: {},
|
||||
dialogVisible: false,
|
||||
projectId: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open(planId) {
|
||||
this.dialogVisible = true;
|
||||
this.initData(planId);
|
||||
},
|
||||
initData(planId) {
|
||||
this.result = this.$get("/test/plan/project/" + planId,res => {
|
||||
this.tableData = res.data;
|
||||
})
|
||||
},
|
||||
handleCurrentChange(currentRow) {
|
||||
// initData 改变表格数据会触发此方法
|
||||
if (currentRow) {
|
||||
this.projectId = currentRow.id;
|
||||
}
|
||||
},
|
||||
submit() {
|
||||
this.$emit('getProjectNode', this.projectId);
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -230,12 +230,16 @@ export default {
|
|||
this.$emit("refresh");
|
||||
},
|
||||
nodeExpand(data) {
|
||||
if (data.id) {
|
||||
this.expandedNode.push(data.id);
|
||||
}
|
||||
},
|
||||
nodeCollapse(data) {
|
||||
if (data.id) {
|
||||
this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -90,6 +90,12 @@
|
|||
initTableData() {
|
||||
this.result = this.$post('/test/plan/list/all/relate', this.condition, response => {
|
||||
this.tableData = response.data;
|
||||
for (let i = 0; i < this.tableData.length; i++) {
|
||||
let path = "/test/plan/project/name/" + this.tableData[i].id;
|
||||
this.$get(path, res => {
|
||||
this.$set(this.tableData[i], "projectName", res.data);
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
intoPlan(row, event, column) {
|
||||
|
|
|
@ -22,11 +22,14 @@
|
|||
</el-col>
|
||||
|
||||
<el-col :span="11" :offset="2">
|
||||
<el-form-item :label="$t('test_track.plan.plan_project')" :label-width="formLabelWidth" prop="projectId">
|
||||
<el-form-item :label="$t('test_track.plan.plan_project')" :label-width="formLabelWidth" prop="projectIds">
|
||||
<el-select
|
||||
:disabled="(form.status == null) ? false : true"
|
||||
v-model="form.projectId"
|
||||
v-model="form.projectIds"
|
||||
:placeholder="$t('test_track.plan.input_plan_project')"
|
||||
multiple
|
||||
style="width: 100%"
|
||||
collapse-tags
|
||||
filterable>
|
||||
<el-option
|
||||
v-for="item in projects"
|
||||
|
@ -68,7 +71,7 @@
|
|||
</el-row>
|
||||
|
||||
<el-row type="flex" justify="left" style="margin-top: 10px;">
|
||||
<el-col :span="19" :offset="1">
|
||||
<el-col :span="23" :offset="1">
|
||||
<el-form-item :label="$t('commons.description')" :label-width="formLabelWidth" prop="description">
|
||||
<el-input v-model="form.description"
|
||||
type="textarea"
|
||||
|
@ -124,7 +127,7 @@ export default {
|
|||
dialogFormVisible: false,
|
||||
form: {
|
||||
name: '',
|
||||
projectId: '',
|
||||
projectIds: [],
|
||||
principal: '',
|
||||
stage: '',
|
||||
description: ''
|
||||
|
@ -134,7 +137,7 @@ export default {
|
|||
{required: true, message: this.$t('test_track.plan.input_plan_name'), trigger: 'blur'},
|
||||
{max: 30, message: this.$t('test_track.length_less_than') + '30', trigger: 'blur'}
|
||||
],
|
||||
projectId: [{required: true, message: this.$t('test_track.plan.input_plan_project'), trigger: 'change'}],
|
||||
projectIds: [{required: true, message: this.$t('test_track.plan.input_plan_project'), trigger: 'change'}],
|
||||
principal: [{required: true, message: this.$t('test_track.plan.input_plan_principal'), trigger: 'change'}],
|
||||
stage: [{required: true, message: this.$t('test_track.plan.input_plan_stage'), trigger: 'change'}],
|
||||
description: [{max: 200, message: this.$t('test_track.length_less_than') + '200', trigger: 'blur'}]
|
||||
|
@ -213,7 +216,7 @@ export default {
|
|||
this.$refs['planFrom'].validate((valid) => {
|
||||
this.$refs['planFrom'].resetFields();
|
||||
this.form.name = '';
|
||||
this.form.projectId = '';
|
||||
this.form.projectIds = [];
|
||||
this.form.principal = '';
|
||||
this.form.stage = '';
|
||||
this.form.description = '';
|
||||
|
|
|
@ -191,6 +191,12 @@ export default {
|
|||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
for (let i = 0; i < this.tableData.length; i++) {
|
||||
let path = "/test/plan/project/name/" + this.tableData[i].id;
|
||||
this.$get(path, res => {
|
||||
this.$set(this.tableData[i], "projectName", res.data);
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
buildPagePath(path) {
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
:visible.sync="dialogFormVisible"
|
||||
@close="close"
|
||||
width="60%" v-loading="result.loading"
|
||||
:close-on-click-modal="false"
|
||||
top="50px">
|
||||
|
||||
<el-container class="main-content">
|
||||
<el-aside class="tree-aside" width="250px">
|
||||
<el-link type="primary" class="project-link" @click="switchProject">{{projectName ? projectName : '切换项目' }}</el-link>
|
||||
<node-tree class="node-tree"
|
||||
@nodeSelectEvent="nodeChange"
|
||||
@refresh="refresh"
|
||||
|
@ -71,6 +73,8 @@
|
|||
</template>
|
||||
|
||||
</el-dialog>
|
||||
|
||||
<switch-project ref="switchProject" @getProjectNode="getProjectNode"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
@ -86,6 +90,7 @@
|
|||
import MsTableAdvSearchBar from "../../../../common/components/search/MsTableAdvSearchBar";
|
||||
import MsTableHeader from "../../../../common/components/MsTableHeader";
|
||||
import {TEST_CASE_CONFIGS} from "../../../../common/components/search/search-components";
|
||||
import SwitchProject from "../../../case/components/SwitchProject";
|
||||
|
||||
export default {
|
||||
name: "TestCaseRelevance",
|
||||
|
@ -96,7 +101,8 @@
|
|||
TypeTableItem,
|
||||
MsTableSearchBar,
|
||||
MsTableAdvSearchBar,
|
||||
MsTableHeader
|
||||
MsTableHeader,
|
||||
SwitchProject
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -108,6 +114,9 @@
|
|||
treeNodes: [],
|
||||
selectNodeIds: [],
|
||||
selectNodeNames: [],
|
||||
projectId: '',
|
||||
projectName: '',
|
||||
projects: [],
|
||||
condition: {
|
||||
components: TEST_CASE_CONFIGS
|
||||
},
|
||||
|
@ -135,6 +144,9 @@
|
|||
},
|
||||
selectNodeIds() {
|
||||
this.getCaseNames();
|
||||
},
|
||||
projectId() {
|
||||
this.getProjectNode();
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
|
@ -157,7 +169,6 @@
|
|||
});
|
||||
},
|
||||
getCaseNames() {
|
||||
let param = {};
|
||||
if (this.planId) {
|
||||
// param.planId = this.planId;
|
||||
this.condition.planId = this.planId;
|
||||
|
@ -168,12 +179,17 @@
|
|||
} else {
|
||||
this.condition.nodeIds = [];
|
||||
}
|
||||
|
||||
if (this.projectId) {
|
||||
this.condition.projectId = this.projectId;
|
||||
this.result = this.$post('/test/case/name', this.condition, response => {
|
||||
this.testCases = response.data;
|
||||
this.testCases.forEach(item => {
|
||||
item.checked = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
if (selection.length > 0) {
|
||||
|
@ -203,13 +219,18 @@
|
|||
initData() {
|
||||
this.getCaseNames();
|
||||
this.getAllNodeTreeByPlanId();
|
||||
this.getProject();
|
||||
},
|
||||
refresh() {
|
||||
this.close();
|
||||
},
|
||||
getAllNodeTreeByPlanId() {
|
||||
if (this.planId) {
|
||||
this.result = this.$get("/case/node/list/all/plan/" + this.planId, response => {
|
||||
let param = {
|
||||
testPlanId: this.planId,
|
||||
projectId: this.projectId
|
||||
};
|
||||
this.result = this.$post("/case/node/list/all/plan", param , response => {
|
||||
this.treeNodes = response.data;
|
||||
});
|
||||
}
|
||||
|
@ -233,6 +254,36 @@
|
|||
})
|
||||
})
|
||||
},
|
||||
getProject() {
|
||||
if (this.planId) {
|
||||
this.$get("/test/plan/project/" + this.planId,res => {
|
||||
let data = res.data;
|
||||
if (data) {
|
||||
this.projects = data;
|
||||
this.projectId = data[0].id;
|
||||
this.projectName = data[0].name;
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
switchProject() {
|
||||
this.$refs.switchProject.open(this.planId);
|
||||
},
|
||||
getProjectNode(projectId) {
|
||||
const index = this.projects.findIndex(project => project.id === projectId);
|
||||
if (index !== -1) {
|
||||
this.projectName = this.projects[index].name;
|
||||
}
|
||||
if (projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
this.result = this.$post("/case/node/list/all/plan",
|
||||
{testPlanId: this.planId, projectId: this.projectId} , response => {
|
||||
this.treeNodes = response.data;
|
||||
});
|
||||
|
||||
this.selectNodeIds = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -281,4 +332,10 @@
|
|||
/*border: 1px solid #EBEEF5;*/
|
||||
}
|
||||
|
||||
.project-link {
|
||||
float: right;
|
||||
margin-right: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue