fix(测试用例,接口定义,接口自动化): 增加默认模块,默认创建用例都放到默认模块下
This commit is contained in:
parent
c84d1e8535
commit
cff32b828c
|
@ -21,10 +21,7 @@ import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.api.jmeter.JMeterService;
|
import io.metersphere.api.jmeter.JMeterService;
|
||||||
import io.metersphere.api.parse.ApiImportParser;
|
import io.metersphere.api.parse.ApiImportParser;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
|
||||||
import io.metersphere.base.mapper.TestCaseReviewScenarioMapper;
|
|
||||||
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
|
|
||||||
import io.metersphere.base.mapper.ext.*;
|
import io.metersphere.base.mapper.ext.*;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
@ -61,6 +58,8 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class ApiAutomationService {
|
public class ApiAutomationService {
|
||||||
|
@Resource
|
||||||
|
ApiScenarioModuleMapper apiScenarioModuleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtScheduleMapper extScheduleMapper;
|
private ExtScheduleMapper extScheduleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -242,9 +241,14 @@ public class ApiAutomationService {
|
||||||
} else {
|
} else {
|
||||||
scenario.setUserId(request.getUserId());
|
scenario.setUserId(request.getUserId());
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(request.getApiScenarioModuleId()) || StringUtils.isEmpty(request.getModulePath())) {
|
if (StringUtils.isEmpty(request.getApiScenarioModuleId()) || StringUtils.isEmpty(request.getModulePath()) || "default-module".equals(request.getApiScenarioModuleId())) {
|
||||||
scenario.setApiScenarioModuleId("default-module");
|
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||||
scenario.setModulePath("/默认模块");
|
example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andNameEqualTo("默认模块");
|
||||||
|
List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(example);
|
||||||
|
if (CollectionUtils.isNotEmpty(modules)) {
|
||||||
|
scenario.setApiScenarioModuleId(modules.get(0).getId());
|
||||||
|
scenario.setModulePath(modules.get(0).getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return scenario;
|
return scenario;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,8 @@ public class ApiDefinitionService {
|
||||||
private ApiTestEnvironmentService environmentService;
|
private ApiTestEnvironmentService environmentService;
|
||||||
@Resource
|
@Resource
|
||||||
private EsbApiParamService esbApiParamService;
|
private EsbApiParamService esbApiParamService;
|
||||||
|
@Resource
|
||||||
|
ApiModuleMapper apiModuleMapper;
|
||||||
|
|
||||||
private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24);
|
private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24);
|
||||||
|
|
||||||
|
@ -262,9 +264,14 @@ public class ApiDefinitionService {
|
||||||
test.setEnvironmentId(request.getEnvironmentId());
|
test.setEnvironmentId(request.getEnvironmentId());
|
||||||
test.setUserId(request.getUserId());
|
test.setUserId(request.getUserId());
|
||||||
test.setTags(request.getTags());
|
test.setTags(request.getTags());
|
||||||
if (StringUtils.isEmpty(request.getModulePath()) || StringUtils.isEmpty(request.getModuleId())) {
|
if (StringUtils.isEmpty(request.getModulePath()) || StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) {
|
||||||
test.setModulePath("/默认模块");
|
ApiModuleExample example = new ApiModuleExample();
|
||||||
test.setModuleId("default-module");
|
example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("默认模块");
|
||||||
|
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
|
||||||
|
if (CollectionUtils.isNotEmpty(modules)) {
|
||||||
|
test.setModuleId(modules.get(0).getId());
|
||||||
|
test.setModulePath(modules.get(0).getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
apiDefinitionMapper.updateByPrimaryKeySelective(test);
|
apiDefinitionMapper.updateByPrimaryKeySelective(test);
|
||||||
return test;
|
return test;
|
||||||
|
@ -290,9 +297,14 @@ public class ApiDefinitionService {
|
||||||
test.setStatus(APITestStatus.Underway.name());
|
test.setStatus(APITestStatus.Underway.name());
|
||||||
test.setModulePath(request.getModulePath());
|
test.setModulePath(request.getModulePath());
|
||||||
test.setModuleId(request.getModuleId());
|
test.setModuleId(request.getModuleId());
|
||||||
if (StringUtils.isEmpty(request.getModulePath()) || StringUtils.isEmpty(request.getModuleId())) {
|
if (StringUtils.isEmpty(request.getModulePath()) || StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) {
|
||||||
|
ApiModuleExample example = new ApiModuleExample();
|
||||||
|
example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("默认模块");
|
||||||
|
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
|
||||||
|
if (CollectionUtils.isNotEmpty(modules)) {
|
||||||
|
test.setModuleId(modules.get(0).getId());
|
||||||
test.setModulePath("/默认模块");
|
test.setModulePath("/默认模块");
|
||||||
test.setModuleId("default-module");
|
}
|
||||||
}
|
}
|
||||||
test.setResponse(JSONObject.toJSONString(request.getResponse()));
|
test.setResponse(JSONObject.toJSONString(request.getResponse()));
|
||||||
test.setEnvironmentId(request.getEnvironmentId());
|
test.setEnvironmentId(request.getEnvironmentId());
|
||||||
|
@ -604,9 +616,14 @@ public class ApiDefinitionService {
|
||||||
}
|
}
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
ApiDefinitionWithBLOBs item = data.get(i);
|
ApiDefinitionWithBLOBs item = data.get(i);
|
||||||
if (StringUtils.isEmpty(item.getModuleId()) || StringUtils.isEmpty(item.getModulePath())) {
|
if (StringUtils.isEmpty(item.getModuleId()) || StringUtils.isEmpty(item.getModulePath()) || "default-module".equals(item.getModuleId())) {
|
||||||
item.setModuleId("default-module");
|
ApiModuleExample example = new ApiModuleExample();
|
||||||
item.setModulePath("/默认模块");
|
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("默认模块");
|
||||||
|
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
|
||||||
|
if (CollectionUtils.isNotEmpty(modules)) {
|
||||||
|
item.setModuleId(modules.get(0).getId());
|
||||||
|
item.setModulePath(modules.get(0).getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (item.getName().length() > 255) {
|
if (item.getName().length() > 255) {
|
||||||
item.setName(item.getName().substring(0, 255));
|
item.setName(item.getName().substring(0, 255));
|
||||||
|
|
|
@ -39,8 +39,6 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
@Resource
|
@Resource
|
||||||
ExtApiModuleMapper extApiModuleMapper;
|
ExtApiModuleMapper extApiModuleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionMapper apiDefinitionMapper;
|
|
||||||
@Resource
|
|
||||||
private ExtApiDefinitionMapper extApiDefinitionMapper;
|
private ExtApiDefinitionMapper extApiDefinitionMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanProjectService testPlanProjectService;
|
private TestPlanProjectService testPlanProjectService;
|
||||||
|
@ -61,6 +59,22 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiModuleDTO> getNodeTreeByProjectId(String projectId, String protocol) {
|
public List<ApiModuleDTO> getNodeTreeByProjectId(String projectId, String protocol) {
|
||||||
|
// 判断当前项目下是否有默认模块,没有添加默认模块
|
||||||
|
ApiModuleExample example = new ApiModuleExample();
|
||||||
|
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("默认模块");
|
||||||
|
long count = apiModuleMapper.countByExample(example);
|
||||||
|
if (count <= 0) {
|
||||||
|
ApiModule record = new ApiModule();
|
||||||
|
record.setId(UUID.randomUUID().toString());
|
||||||
|
record.setName("默认模块");
|
||||||
|
record.setProtocol(protocol);
|
||||||
|
record.setPos(1.0);
|
||||||
|
record.setLevel(1);
|
||||||
|
record.setCreateTime(System.currentTimeMillis());
|
||||||
|
record.setUpdateTime(System.currentTimeMillis());
|
||||||
|
record.setProjectId(projectId);
|
||||||
|
apiModuleMapper.insert(record);
|
||||||
|
}
|
||||||
List<ApiModuleDTO> apiModules = extApiModuleMapper.getNodeTreeByProjectId(projectId, protocol);
|
List<ApiModuleDTO> apiModules = extApiModuleMapper.getNodeTreeByProjectId(projectId, protocol);
|
||||||
return getNodeTrees(apiModules);
|
return getNodeTrees(apiModules);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,22 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiScenarioModuleDTO> getNodeTreeByProjectId(String projectId) {
|
public List<ApiScenarioModuleDTO> getNodeTreeByProjectId(String projectId) {
|
||||||
|
// 判断当前项目下是否有默认模块,没有添加默认模块
|
||||||
|
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||||
|
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("默认模块");
|
||||||
|
long count = apiScenarioModuleMapper.countByExample(example);
|
||||||
|
if (count <= 0) {
|
||||||
|
ApiScenarioModule record = new ApiScenarioModule();
|
||||||
|
record.setId(UUID.randomUUID().toString());
|
||||||
|
record.setName("默认模块");
|
||||||
|
record.setPos(1.0);
|
||||||
|
record.setLevel(1);
|
||||||
|
record.setCreateTime(System.currentTimeMillis());
|
||||||
|
record.setUpdateTime(System.currentTimeMillis());
|
||||||
|
record.setProjectId(projectId);
|
||||||
|
apiScenarioModuleMapper.insert(record);
|
||||||
|
}
|
||||||
|
|
||||||
List<ApiScenarioModuleDTO> nodes = extApiScenarioModuleMapper.getNodeTreeByProjectId(projectId);
|
List<ApiScenarioModuleDTO> nodes = extApiScenarioModuleMapper.getNodeTreeByProjectId(projectId);
|
||||||
return getNodeTrees(nodes);
|
return getNodeTrees(nodes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,21 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId) {
|
public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId) {
|
||||||
|
// 判断当前项目下是否有默认模块,没有添加默认模块
|
||||||
|
TestCaseNodeExample example = new TestCaseNodeExample();
|
||||||
|
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("默认模块");
|
||||||
|
long count = testCaseNodeMapper.countByExample(example);
|
||||||
|
if (count <= 0) {
|
||||||
|
TestCaseNode record = new TestCaseNode();
|
||||||
|
record.setId(UUID.randomUUID().toString());
|
||||||
|
record.setName("默认模块");
|
||||||
|
record.setPos(1.0);
|
||||||
|
record.setLevel(1);
|
||||||
|
record.setCreateTime(System.currentTimeMillis());
|
||||||
|
record.setUpdateTime(System.currentTimeMillis());
|
||||||
|
record.setProjectId(projectId);
|
||||||
|
testCaseNodeMapper.insert(record);
|
||||||
|
}
|
||||||
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
|
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
|
||||||
return getNodeTrees(testCaseNodes);
|
return getNodeTrees(testCaseNodes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class TestCaseService {
|
public class TestCaseService {
|
||||||
|
@Resource
|
||||||
|
TestCaseNodeMapper testCaseNodeMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
TestCaseMapper testCaseMapper;
|
TestCaseMapper testCaseMapper;
|
||||||
|
@ -90,6 +92,18 @@ public class TestCaseService {
|
||||||
@Resource
|
@Resource
|
||||||
TestCaseTestMapper testCaseTestMapper;
|
TestCaseTestMapper testCaseTestMapper;
|
||||||
|
|
||||||
|
private void setNode(TestCaseWithBLOBs testCase){
|
||||||
|
if (StringUtils.isEmpty(testCase.getNodeId()) || StringUtils.isEmpty(testCase.getNodePath()) || "default-module".equals(testCase.getNodeId())) {
|
||||||
|
TestCaseNodeExample example = new TestCaseNodeExample();
|
||||||
|
example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("默认模块");
|
||||||
|
List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(example);
|
||||||
|
if (CollectionUtils.isNotEmpty(nodes)) {
|
||||||
|
testCase.setNodeId(nodes.get(0).getId());
|
||||||
|
testCase.setNodePath("/" + nodes.get(0).getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public TestCaseWithBLOBs addTestCase(TestCaseWithBLOBs testCase) {
|
public TestCaseWithBLOBs addTestCase(TestCaseWithBLOBs testCase) {
|
||||||
testCase.setName(testCase.getName());
|
testCase.setName(testCase.getName());
|
||||||
checkTestCaseExist(testCase);
|
checkTestCaseExist(testCase);
|
||||||
|
@ -100,7 +114,7 @@ public class TestCaseService {
|
||||||
testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
|
testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
|
||||||
testCase.setDemandId(testCase.getDemandId());
|
testCase.setDemandId(testCase.getDemandId());
|
||||||
testCase.setDemandName(testCase.getDemandName());
|
testCase.setDemandName(testCase.getDemandName());
|
||||||
|
this.setNode(testCase);
|
||||||
testCaseMapper.insert(testCase);
|
testCaseMapper.insert(testCase);
|
||||||
return testCase;
|
return testCase;
|
||||||
}
|
}
|
||||||
|
@ -195,16 +209,16 @@ public class TestCaseService {
|
||||||
* 根据id和pojectId查询id是否在数据库中存在。
|
* 根据id和pojectId查询id是否在数据库中存在。
|
||||||
* 在数据库中单id的话是可重复的,id与projectId的组合是唯一的
|
* 在数据库中单id的话是可重复的,id与projectId的组合是唯一的
|
||||||
*/
|
*/
|
||||||
public Integer checkIdExist(Integer id, String projectId){
|
public Integer checkIdExist(Integer id, String projectId) {
|
||||||
TestCaseExample example = new TestCaseExample();
|
TestCaseExample example = new TestCaseExample();
|
||||||
TestCaseExample.Criteria criteria = example.createCriteria();
|
TestCaseExample.Criteria criteria = example.createCriteria();
|
||||||
if (null != id) {
|
if (null != id) {
|
||||||
criteria.andNumEqualTo(id);
|
criteria.andNumEqualTo(id);
|
||||||
criteria.andProjectIdEqualTo(projectId);
|
criteria.andProjectIdEqualTo(projectId);
|
||||||
long count = testCaseMapper.countByExample(example); //查询是否有包含此ID的数据
|
long count = testCaseMapper.countByExample(example); //查询是否有包含此ID的数据
|
||||||
if(count == 0){ //如果ID不存在
|
if (count == 0) { //如果ID不存在
|
||||||
return null;
|
return null;
|
||||||
}else { //有对应ID的数据
|
} else { //有对应ID的数据
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,6 +457,7 @@ public class TestCaseService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 把Excel中带ID的数据更新到数据库
|
* 把Excel中带ID的数据更新到数据库
|
||||||
|
*
|
||||||
* @param testCases
|
* @param testCases
|
||||||
* @param projectId
|
* @param projectId
|
||||||
*/
|
*/
|
||||||
|
@ -820,14 +835,14 @@ public class TestCaseService {
|
||||||
|
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
files.forEach(file -> {
|
files.forEach(file -> {
|
||||||
final FileMetadata fileMetadata = fileService.saveFile(file,testCaseWithBLOBs.getProjectId());
|
final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId());
|
||||||
TestCaseFile testCaseFile = new TestCaseFile();
|
TestCaseFile testCaseFile = new TestCaseFile();
|
||||||
testCaseFile.setFileId(fileMetadata.getId());
|
testCaseFile.setFileId(fileMetadata.getId());
|
||||||
testCaseFile.setCaseId(request.getId());
|
testCaseFile.setCaseId(request.getId());
|
||||||
testCaseFileMapper.insert(testCaseFile);
|
testCaseFileMapper.insert(testCaseFile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.setNode(request);
|
||||||
editTestCase(request);
|
editTestCase(request);
|
||||||
return request.getId();
|
return request.getId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,13 +139,6 @@
|
||||||
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
|
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
|
||||||
if (response.data != undefined && response.data != null) {
|
if (response.data != undefined && response.data != null) {
|
||||||
this.data = response.data;
|
this.data = response.data;
|
||||||
this.data.unshift({
|
|
||||||
"id": "default-module",
|
|
||||||
"name": this.$t('commons.module_title'),
|
|
||||||
"level": 0,
|
|
||||||
"path": "/" + this.$t('commons.module_title'),
|
|
||||||
"children": [],
|
|
||||||
});
|
|
||||||
this.data.forEach(node => {
|
this.data.forEach(node => {
|
||||||
buildTree(node, {path: ''});
|
buildTree(node, {path: ''});
|
||||||
});
|
});
|
||||||
|
@ -166,13 +159,6 @@
|
||||||
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
|
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
|
||||||
if (response.data != undefined && response.data != null) {
|
if (response.data != undefined && response.data != null) {
|
||||||
this.data = response.data;
|
this.data = response.data;
|
||||||
this.data.unshift({
|
|
||||||
"id": "default-module",
|
|
||||||
"name": this.$t('commons.module_title'),
|
|
||||||
"level": 0,
|
|
||||||
"path": "/" + this.$t('commons.module_title'),
|
|
||||||
"children": [],
|
|
||||||
});
|
|
||||||
this.data.forEach(node => {
|
this.data.forEach(node => {
|
||||||
buildTree(node, {path: ''});
|
buildTree(node, {path: ''});
|
||||||
});
|
});
|
||||||
|
@ -196,13 +182,6 @@
|
||||||
this.result = this.$get(url, response => {
|
this.result = this.$get(url, response => {
|
||||||
if (response.data != undefined && response.data != null) {
|
if (response.data != undefined && response.data != null) {
|
||||||
this.data = response.data;
|
this.data = response.data;
|
||||||
this.data.unshift({
|
|
||||||
"id": "default-module",
|
|
||||||
"name": this.$t('commons.module_title'),
|
|
||||||
"level": 0,
|
|
||||||
"path": "/" + this.$t('commons.module_title'),
|
|
||||||
"children": [],
|
|
||||||
});
|
|
||||||
this.data.forEach(node => {
|
this.data.forEach(node => {
|
||||||
buildTree(node, {path: ''});
|
buildTree(node, {path: ''});
|
||||||
});
|
});
|
||||||
|
|
|
@ -252,13 +252,6 @@
|
||||||
this.result = this.$get(url, response => {
|
this.result = this.$get(url, response => {
|
||||||
if (response.data != undefined && response.data != null) {
|
if (response.data != undefined && response.data != null) {
|
||||||
this.moduleOptions = response.data;
|
this.moduleOptions = response.data;
|
||||||
this.moduleOptions.unshift({
|
|
||||||
"id": "default-module",
|
|
||||||
"name": this.$t('commons.module_title'),
|
|
||||||
"level": 0,
|
|
||||||
"path": "/" + this.$t('commons.module_title'),
|
|
||||||
"children": [],
|
|
||||||
});
|
|
||||||
this.moduleOptions.forEach(node => {
|
this.moduleOptions.forEach(node => {
|
||||||
buildTree(node, {path: ''});
|
buildTree(node, {path: ''});
|
||||||
});
|
});
|
||||||
|
|
|
@ -130,13 +130,6 @@
|
||||||
this.result = this.$get(url, response => {
|
this.result = this.$get(url, response => {
|
||||||
if (response.data != undefined && response.data != null) {
|
if (response.data != undefined && response.data != null) {
|
||||||
this.data = response.data;
|
this.data = response.data;
|
||||||
this.data.unshift({
|
|
||||||
"id": "default-module",
|
|
||||||
"name": this.$t('commons.module_title'),
|
|
||||||
"level": 0,
|
|
||||||
"path": "/" + this.$t('commons.module_title'),
|
|
||||||
"children": [],
|
|
||||||
});
|
|
||||||
this.data.forEach(node => {
|
this.data.forEach(node => {
|
||||||
buildTree(node, {path: ''});
|
buildTree(node, {path: ''});
|
||||||
});
|
});
|
||||||
|
|
|
@ -315,7 +315,7 @@ export default {
|
||||||
form: {
|
form: {
|
||||||
name: '',
|
name: '',
|
||||||
module: 'default-module',
|
module: 'default-module',
|
||||||
nodePath:'',
|
nodePath:'/默认模块',
|
||||||
maintainer: getCurrentUser().id,
|
maintainer: getCurrentUser().id,
|
||||||
priority: 'P0',
|
priority: 'P0',
|
||||||
type: '',
|
type: '',
|
||||||
|
@ -416,6 +416,10 @@ export default {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
if(this.selectNode && this.selectNode.data && !this.form.id){
|
||||||
|
this.form.module = this.selectNode.data.id;
|
||||||
|
this.form.nodePath = this.selectNode.data.path;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
treeNodes() {
|
treeNodes() {
|
||||||
|
@ -428,9 +432,11 @@ export default {
|
||||||
created() {
|
created() {
|
||||||
this.loadOptions();
|
this.loadOptions();
|
||||||
this.addListener(); // 添加 ctrl s 监听
|
this.addListener(); // 添加 ctrl s 监听
|
||||||
if(this.selectNode && this.selectNode.data && this.form.id){
|
if(this.selectNode && this.selectNode.data && !this.form.id){
|
||||||
this.form.module = this.selectNode.data.id;
|
this.form.module = this.selectNode.data.id;
|
||||||
this.form.nodePath = this.selectNode.data.path;
|
this.form.nodePath = this.selectNode.data.path;
|
||||||
|
}else{
|
||||||
|
this.form.module =this.treeNodes && this.length>0? this.treeNodes[0].id:"";
|
||||||
}
|
}
|
||||||
if (this.type === 'edit' || this.type === 'copy') {
|
if (this.type === 'edit' || this.type === 'copy') {
|
||||||
this.form.module = this.currentTestCaseInfo.nodeId;
|
this.form.module = this.currentTestCaseInfo.nodeId;
|
||||||
|
|
|
@ -116,13 +116,6 @@ export default {
|
||||||
if (this.projectId) {
|
if (this.projectId) {
|
||||||
this.result = this.$get("/case/node/list/" + this.projectId, response => {
|
this.result = this.$get("/case/node/list/" + this.projectId, response => {
|
||||||
this.treeNodes = response.data;
|
this.treeNodes = response.data;
|
||||||
this.treeNodes.unshift({
|
|
||||||
"id": "default-module",
|
|
||||||
"name": this.$t('commons.module_title'),
|
|
||||||
"level": 0,
|
|
||||||
"path": "/" + this.$t('commons.module_title'),
|
|
||||||
"children": [],
|
|
||||||
});
|
|
||||||
this.treeNodes.forEach(node => {
|
this.treeNodes.forEach(node => {
|
||||||
buildTree(node, {path: ''});
|
buildTree(node, {path: ''});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2115bd28a90854d2b6276a90878934715498c584
|
Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd
|
Loading…
Reference in New Issue