refactor(权限管理): 接口测试权限 处理冲突
This commit is contained in:
parent
60e8036c2a
commit
0e1ffbf873
|
@ -21,7 +21,7 @@ import io.metersphere.log.annotation.MsAuditLog;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -33,14 +33,13 @@ import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/api/automation")
|
@RequestMapping(value = "/api/automation")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
|
||||||
public class ApiAutomationController {
|
public class ApiAutomationController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ApiAutomationService apiAutomationService;
|
ApiAutomationService apiAutomationService;
|
||||||
|
|
||||||
@PostMapping("/list/{goPage}/{pageSize}")
|
@PostMapping("/list/{goPage}/{pageSize}")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
|
||||||
public Pager<List<ApiScenarioDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
|
public Pager<List<ApiScenarioDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
@ -48,26 +47,26 @@ public class ApiAutomationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list/all")
|
@PostMapping("/list/all")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
|
||||||
public List<ApiScenarioWithBLOBs> listAll(@RequestBody ApiScenarioBatchRequest request) {
|
public List<ApiScenarioWithBLOBs> listAll(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
return apiAutomationService.listAll(request);
|
return apiAutomationService.listAll(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/listWithIds/all")
|
@PostMapping("/listWithIds/all")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
|
||||||
public List<ApiScenarioWithBLOBs> listWithIds(@RequestBody ApiScenarioBatchRequest request) {
|
public List<ApiScenarioWithBLOBs> listWithIds(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
return apiAutomationService.listWithIds(request);
|
return apiAutomationService.listWithIds(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/id/all")
|
@PostMapping("/id/all")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
|
||||||
public List<String> idAll(@RequestBody ApiScenarioBatchRequest request) {
|
public List<String> idAll(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
return apiAutomationService.idAll(request);
|
return apiAutomationService.idAll(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list/{projectId}")
|
@GetMapping("/list/{projectId}")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
|
||||||
public List<ApiScenarioDTO> list(@PathVariable String projectId) {
|
public List<ApiScenarioDTO> list(@PathVariable String projectId) {
|
||||||
ApiScenarioRequest request = new ApiScenarioRequest();
|
ApiScenarioRequest request = new ApiScenarioRequest();
|
||||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
@ -77,6 +76,7 @@ public class ApiAutomationController {
|
||||||
|
|
||||||
@PostMapping(value = "/create")
|
@PostMapping(value = "/create")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
|
||||||
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+CREATE")
|
||||||
public ApiScenario create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles,
|
public ApiScenario create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles,
|
||||||
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) {
|
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) {
|
||||||
return apiAutomationService.create(request, bodyFiles, scenarioFiles);
|
return apiAutomationService.create(request, bodyFiles, scenarioFiles);
|
||||||
|
@ -84,6 +84,7 @@ public class ApiAutomationController {
|
||||||
|
|
||||||
@PostMapping(value = "/update")
|
@PostMapping(value = "/update")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
|
||||||
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EDIT")
|
||||||
public void update(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles,
|
public void update(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles,
|
||||||
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) {
|
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) {
|
||||||
apiAutomationService.update(request, bodyFiles, scenarioFiles);
|
apiAutomationService.update(request, bodyFiles, scenarioFiles);
|
||||||
|
@ -91,6 +92,7 @@ public class ApiAutomationController {
|
||||||
|
|
||||||
@GetMapping("/delete/{id}")
|
@GetMapping("/delete/{id}")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiAutomationService.class)
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiAutomationService.class)
|
||||||
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+delete")
|
||||||
public void delete(@PathVariable String id) {
|
public void delete(@PathVariable String id) {
|
||||||
apiAutomationService.delete(id);
|
apiAutomationService.delete(id);
|
||||||
}
|
}
|
||||||
|
@ -186,14 +188,14 @@ public class ApiAutomationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch/edit")
|
@PostMapping("/batch/edit")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EDIT")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
|
||||||
public void bathEdit(@RequestBody ApiScenarioBatchRequest request) {
|
public void bathEdit(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
apiAutomationService.bathEdit(request);
|
apiAutomationService.bathEdit(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch/update/env")
|
@PostMapping("/batch/update/env")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EDIT")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
|
||||||
public void batchUpdateEnv(@RequestBody ApiScenarioBatchRequest request) {
|
public void batchUpdateEnv(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
apiAutomationService.batchUpdateEnv(request);
|
apiAutomationService.batchUpdateEnv(request);
|
||||||
|
@ -246,21 +248,21 @@ public class ApiAutomationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
||||||
public ScenarioImport scenarioImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
|
public ScenarioImport scenarioImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
|
||||||
return apiAutomationService.scenarioImport(file, request);
|
return apiAutomationService.scenarioImport(file, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/export")
|
@PostMapping(value = "/export")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
||||||
public ApiScenrioExportResult export(@RequestBody ApiScenarioBatchRequest request) {
|
public ApiScenrioExportResult export(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
return apiAutomationService.export(request);
|
return apiAutomationService.export(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/export/jmx")
|
@PostMapping(value = "/export/jmx")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
||||||
public List<ApiScenrioExportJmx> exportJmx(@RequestBody ApiScenarioBatchRequest request) {
|
public List<ApiScenrioExportJmx> exportJmx(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
return apiAutomationService.exportJmx(request);
|
return apiAutomationService.exportJmx(request);
|
||||||
|
|
|
@ -20,7 +20,6 @@ import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||||
import io.metersphere.base.domain.Schedule;
|
import io.metersphere.base.domain.Schedule;
|
||||||
import io.metersphere.commons.constants.OperLogConstants;
|
import io.metersphere.commons.constants.OperLogConstants;
|
||||||
import io.metersphere.commons.constants.RoleConstants;
|
|
||||||
import io.metersphere.commons.json.JSONSchemaGenerator;
|
import io.metersphere.commons.json.JSONSchemaGenerator;
|
||||||
import io.metersphere.commons.utils.CronUtils;
|
import io.metersphere.commons.utils.CronUtils;
|
||||||
import io.metersphere.commons.utils.PageUtils;
|
import io.metersphere.commons.utils.PageUtils;
|
||||||
|
@ -32,9 +31,7 @@ import io.metersphere.service.CheckPermissionService;
|
||||||
import io.metersphere.service.ScheduleService;
|
import io.metersphere.service.ScheduleService;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@ -97,7 +94,7 @@ public class ApiDefinitionController {
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+CREATE_API")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
|
||||||
public void create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
public void create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||||
checkPermissionService.checkProjectOwner(request.getProjectId());
|
checkPermissionService.checkProjectOwner(request.getProjectId());
|
||||||
|
@ -105,7 +102,7 @@ public class ApiDefinitionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
|
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EDIT_API")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
|
||||||
public ApiDefinitionWithBLOBs update(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
public ApiDefinitionWithBLOBs update(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||||
checkPermissionService.checkProjectOwner(request.getProjectId());
|
checkPermissionService.checkProjectOwner(request.getProjectId());
|
||||||
|
@ -113,14 +110,14 @@ public class ApiDefinitionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/delete/{id}")
|
@GetMapping("/delete/{id}")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiDefinitionService.class)
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiDefinitionService.class)
|
||||||
public void delete(@PathVariable String id) {
|
public void delete(@PathVariable String id) {
|
||||||
apiDefinitionService.delete(id);
|
apiDefinitionService.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/deleteBatch")
|
@PostMapping("/deleteBatch")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class)
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class)
|
||||||
public void deleteBatch(@RequestBody List<String> ids) {
|
public void deleteBatch(@RequestBody List<String> ids) {
|
||||||
apiDefinitionService.deleteBatch(ids);
|
apiDefinitionService.deleteBatch(ids);
|
||||||
|
@ -142,14 +139,14 @@ public class ApiDefinitionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/removeToGc")
|
@PostMapping("/removeToGc")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.GC, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiDefinitionService.class)
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.GC, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiDefinitionService.class)
|
||||||
public void removeToGc(@RequestBody List<String> ids) {
|
public void removeToGc(@RequestBody List<String> ids) {
|
||||||
apiDefinitionService.removeToGc(ids);
|
apiDefinitionService.removeToGc(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/removeToGcByParams")
|
@PostMapping("/removeToGcByParams")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_GC, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class)
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_GC, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class)
|
||||||
public void removeToGcByParams(@RequestBody ApiBatchRequest request) {
|
public void removeToGcByParams(@RequestBody ApiBatchRequest request) {
|
||||||
apiDefinitionService.removeToGcByParams(request);
|
apiDefinitionService.removeToGcByParams(request);
|
||||||
|
@ -195,14 +192,14 @@ public class ApiDefinitionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+IMPORT_API")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
||||||
public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
|
public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
|
||||||
return apiDefinitionService.apiTestImport(file, request);
|
return apiDefinitionService.apiTestImport(file, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/export/{type}")
|
@PostMapping(value = "/export/{type}")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EXPORT_API")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
|
||||||
public ApiExportResult export(@RequestBody ApiBatchRequest request, @PathVariable String type) {
|
public ApiExportResult export(@RequestBody ApiBatchRequest request, @PathVariable String type) {
|
||||||
return apiDefinitionService.export(request, type);
|
return apiDefinitionService.export(request, type);
|
||||||
|
@ -262,13 +259,13 @@ public class ApiDefinitionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch/edit")
|
@PostMapping("/batch/edit")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EDIT_API")
|
||||||
public void editApiBath(@RequestBody ApiBatchRequest request) {
|
public void editApiBath(@RequestBody ApiBatchRequest request) {
|
||||||
apiDefinitionService.editApiBath(request);
|
apiDefinitionService.editApiBath(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch/editByParams")
|
@PostMapping("/batch/editByParams")
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EDIT_API")
|
||||||
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request)", content = "#msClass.getLogDetails(#request)", msClass = ApiDefinitionService.class)
|
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request)", content = "#msClass.getLogDetails(#request)", msClass = ApiDefinitionService.class)
|
||||||
public void editByParams(@RequestBody ApiBatchRequest request) {
|
public void editByParams(@RequestBody ApiBatchRequest request) {
|
||||||
apiDefinitionService.editApiByParam(request);
|
apiDefinitionService.editApiByParam(request);
|
||||||
|
@ -291,7 +288,7 @@ public class ApiDefinitionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export/esbExcelTemplate")
|
@GetMapping("/export/esbExcelTemplate")
|
||||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EXPORT_API")
|
||||||
public void testCaseTemplateExport(HttpServletResponse response) {
|
public void testCaseTemplateExport(HttpServletResponse response) {
|
||||||
esbImportService.templateExport(response);
|
esbImportService.templateExport(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
:name="item.name"
|
:name="item.name"
|
||||||
closable>
|
closable>
|
||||||
<div class="ms-api-scenario-div">
|
<div class="ms-api-scenario-div">
|
||||||
<ms-edit-api-scenario @refresh="refresh" @openScenario="editScenario" @closePage="closePage" :currentScenario="item.currentScenario"
|
<ms-edit-api-scenario @refresh="refresh" @openScenario="editScenario" @closePage="closePage"
|
||||||
|
:currentScenario="item.currentScenario"
|
||||||
:custom-num="customNum" :moduleOptions="moduleOptions" ref="autoScenarioConfig"/>
|
:custom-num="customNum" :moduleOptions="moduleOptions" ref="autoScenarioConfig"/>
|
||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
@ -51,7 +52,10 @@
|
||||||
<el-dropdown @command="handleCommand" v-tester>
|
<el-dropdown @command="handleCommand" v-tester>
|
||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="ADD">{{ $t('api_test.automation.add_scenario') }}</el-dropdown-item>
|
<el-dropdown-item command="ADD"
|
||||||
|
v-permission="['PROJECT_API_SCENARIO:READ+CREATE']">
|
||||||
|
{{ $t('api_test.automation.add_scenario') }}
|
||||||
|
</el-dropdown-item>
|
||||||
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
|
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
|
@ -65,13 +69,13 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import MsContainer from "@/business/components/common/components/MsContainer";
|
import MsContainer from "@/business/components/common/components/MsContainer";
|
||||||
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
|
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
|
||||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||||
import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList";
|
import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList";
|
||||||
import {getUUID, downloadFile, checkoutTestManagerOrTestUser, getCurrentUser} from "@/common/js/utils";
|
import {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils";
|
||||||
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
|
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
|
||||||
import MsEditApiScenario from "./scenario/EditApiScenario";
|
import MsEditApiScenario from "./scenario/EditApiScenario";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiAutomation",
|
name: "ApiAutomation",
|
||||||
|
@ -228,137 +232,137 @@
|
||||||
currentScenario.modulePath = this.currentModulePath;
|
currentScenario.modulePath = this.currentModulePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||||
currentScenario.apiScenarioModuleId = this.selectNodeIds[0];
|
currentScenario.apiScenarioModuleId = this.selectNodeIds[0];
|
||||||
this.getPath(this.selectNodeIds[0], this.moduleOptions);
|
this.getPath(this.selectNodeIds[0], this.moduleOptions);
|
||||||
currentScenario.modulePath = this.currentModulePath;
|
currentScenario.modulePath = this.currentModulePath;
|
||||||
}
|
|
||||||
this.tabs.push({label: label, name: name, currentScenario: currentScenario});
|
|
||||||
}
|
}
|
||||||
if (tab.name === 'edit') {
|
this.tabs.push({label: label, name: name, currentScenario: currentScenario});
|
||||||
let label = this.$t('api_test.automation.add_scenario');
|
|
||||||
let name = getUUID().substring(0, 8);
|
|
||||||
this.activeName = name;
|
|
||||||
label = tab.currentScenario.name;
|
|
||||||
this.tabs.push({label: label, name: name, currentScenario: tab.currentScenario});
|
|
||||||
}
|
|
||||||
if (this.$refs && this.$refs.autoScenarioConfig) {
|
|
||||||
this.$refs.autoScenarioConfig.forEach(item => {
|
|
||||||
item.removeListener();
|
|
||||||
}); // 删除所有tab的 ctrl + s 监听
|
|
||||||
this.addListener();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addListener() {
|
|
||||||
let index = this.tabs.findIndex(item => item.name === this.activeName); // 找到当前选中tab的index
|
|
||||||
if (index != -1) { // 为当前选中的tab添加监听
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.autoScenarioConfig[index].addListener();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleTabClose() {
|
|
||||||
this.tabs = [];
|
|
||||||
this.activeName = "default";
|
|
||||||
this.refresh();
|
|
||||||
},
|
|
||||||
handleCommand(e) {
|
|
||||||
switch (e) {
|
|
||||||
case "ADD":
|
|
||||||
this.addTab({name: 'add'});
|
|
||||||
break;
|
|
||||||
case "CLOSE_ALL":
|
|
||||||
this.handleTabClose();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.addTab({name: 'add'});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closePage(targetName) {
|
|
||||||
this.tabs = this.tabs.filter(tab => tab.label !== targetName);
|
|
||||||
if (this.tabs.length > 0) {
|
|
||||||
this.activeName = this.tabs[this.tabs.length - 1].name;
|
|
||||||
this.addListener(); // 自动切换当前标签时,也添加监听
|
|
||||||
} else {
|
|
||||||
this.activeName = "default"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeTab(targetName) {
|
|
||||||
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
|
|
||||||
if (this.tabs.length > 0) {
|
|
||||||
this.activeName = this.tabs[this.tabs.length - 1].name;
|
|
||||||
this.addListener(); // 自动切换当前标签时,也添加监听
|
|
||||||
} else {
|
|
||||||
this.activeName = "default"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setTabLabel(data) {
|
|
||||||
for (const tab of this.tabs) {
|
|
||||||
if (tab.name === this.activeName) {
|
|
||||||
tab.label = data.name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectModule(data) {
|
|
||||||
this.currentModule = data;
|
|
||||||
},
|
|
||||||
saveScenario(data) {
|
|
||||||
this.setTabLabel(data);
|
|
||||||
this.$refs.apiScenarioList.search(data);
|
|
||||||
},
|
|
||||||
refresh(data) {
|
|
||||||
this.setTabTitle(data);
|
|
||||||
this.$refs.apiScenarioList.search(data);
|
|
||||||
},
|
|
||||||
refreshAll() {
|
|
||||||
this.$refs.nodeTree.list();
|
|
||||||
this.$refs.apiScenarioList.search();
|
|
||||||
},
|
|
||||||
setTabTitle(data) {
|
|
||||||
for (let index in this.tabs) {
|
|
||||||
let tab = this.tabs[index];
|
|
||||||
if (tab.name === this.activeName) {
|
|
||||||
tab.label = data.name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
editScenario(row) {
|
|
||||||
this.addTab({name: 'edit', currentScenario: row});
|
|
||||||
},
|
|
||||||
|
|
||||||
nodeChange(node, nodeIds, pNodes) {
|
|
||||||
this.selectNodeIds = nodeIds;
|
|
||||||
},
|
|
||||||
setModuleOptions(data) {
|
|
||||||
this.moduleOptions = data;
|
|
||||||
},
|
|
||||||
setNodeTree(data) {
|
|
||||||
this.nodeTree = data;
|
|
||||||
},
|
|
||||||
changeSelectDataRangeAll(tableType) {
|
|
||||||
this.$route.params.dataSelectRange = 'all';
|
|
||||||
},
|
|
||||||
enableTrash(data) {
|
|
||||||
this.activeName = "default";
|
|
||||||
this.trashEnable = data;
|
|
||||||
},
|
|
||||||
getProject() {
|
|
||||||
this.$get("/project/get/" + this.projectId, result => {
|
|
||||||
let data = result.data;
|
|
||||||
if (data) {
|
|
||||||
this.customNum = data.scenarioCustomNum;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
if (tab.name === 'edit') {
|
||||||
|
let label = this.$t('api_test.automation.add_scenario');
|
||||||
|
let name = getUUID().substring(0, 8);
|
||||||
|
this.activeName = name;
|
||||||
|
label = tab.currentScenario.name;
|
||||||
|
this.tabs.push({label: label, name: name, currentScenario: tab.currentScenario});
|
||||||
|
}
|
||||||
|
if (this.$refs && this.$refs.autoScenarioConfig) {
|
||||||
|
this.$refs.autoScenarioConfig.forEach(item => {
|
||||||
|
item.removeListener();
|
||||||
|
}); // 删除所有tab的 ctrl + s 监听
|
||||||
|
this.addListener();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addListener() {
|
||||||
|
let index = this.tabs.findIndex(item => item.name === this.activeName); // 找到当前选中tab的index
|
||||||
|
if (index != -1) { // 为当前选中的tab添加监听
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.autoScenarioConfig[index].addListener();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleTabClose() {
|
||||||
|
this.tabs = [];
|
||||||
|
this.activeName = "default";
|
||||||
|
this.refresh();
|
||||||
|
},
|
||||||
|
handleCommand(e) {
|
||||||
|
switch (e) {
|
||||||
|
case "ADD":
|
||||||
|
this.addTab({name: 'add'});
|
||||||
|
break;
|
||||||
|
case "CLOSE_ALL":
|
||||||
|
this.handleTabClose();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.addTab({name: 'add'});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closePage(targetName) {
|
||||||
|
this.tabs = this.tabs.filter(tab => tab.label !== targetName);
|
||||||
|
if (this.tabs.length > 0) {
|
||||||
|
this.activeName = this.tabs[this.tabs.length - 1].name;
|
||||||
|
this.addListener(); // 自动切换当前标签时,也添加监听
|
||||||
|
} else {
|
||||||
|
this.activeName = "default";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeTab(targetName) {
|
||||||
|
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
|
||||||
|
if (this.tabs.length > 0) {
|
||||||
|
this.activeName = this.tabs[this.tabs.length - 1].name;
|
||||||
|
this.addListener(); // 自动切换当前标签时,也添加监听
|
||||||
|
} else {
|
||||||
|
this.activeName = "default";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setTabLabel(data) {
|
||||||
|
for (const tab of this.tabs) {
|
||||||
|
if (tab.name === this.activeName) {
|
||||||
|
tab.label = data.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectModule(data) {
|
||||||
|
this.currentModule = data;
|
||||||
|
},
|
||||||
|
saveScenario(data) {
|
||||||
|
this.setTabLabel(data);
|
||||||
|
this.$refs.apiScenarioList.search(data);
|
||||||
|
},
|
||||||
|
refresh(data) {
|
||||||
|
this.setTabTitle(data);
|
||||||
|
this.$refs.apiScenarioList.search(data);
|
||||||
|
},
|
||||||
|
refreshAll() {
|
||||||
|
this.$refs.nodeTree.list();
|
||||||
|
this.$refs.apiScenarioList.search();
|
||||||
|
},
|
||||||
|
setTabTitle(data) {
|
||||||
|
for (let index in this.tabs) {
|
||||||
|
let tab = this.tabs[index];
|
||||||
|
if (tab.name === this.activeName) {
|
||||||
|
tab.label = data.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
editScenario(row) {
|
||||||
|
this.addTab({name: 'edit', currentScenario: row});
|
||||||
|
},
|
||||||
|
|
||||||
|
nodeChange(node, nodeIds, pNodes) {
|
||||||
|
this.selectNodeIds = nodeIds;
|
||||||
|
},
|
||||||
|
setModuleOptions(data) {
|
||||||
|
this.moduleOptions = data;
|
||||||
|
},
|
||||||
|
setNodeTree(data) {
|
||||||
|
this.nodeTree = data;
|
||||||
|
},
|
||||||
|
changeSelectDataRangeAll(tableType) {
|
||||||
|
this.$route.params.dataSelectRange = 'all';
|
||||||
|
},
|
||||||
|
enableTrash(data) {
|
||||||
|
this.activeName = "default";
|
||||||
|
this.trashEnable = data;
|
||||||
|
},
|
||||||
|
getProject() {
|
||||||
|
this.$get("/project/get/" + this.projectId, result => {
|
||||||
|
let data = result.data;
|
||||||
|
if (data) {
|
||||||
|
this.customNum = data.scenarioCustomNum;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/deep/ .el-tabs__header {
|
/deep/ .el-tabs__header {
|
||||||
margin: 0 0 0px;
|
margin: 0 0 0px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
<ms-table-operator-button :tip="$t('api_report.detail')" icon="el-icon-s-data"
|
<ms-table-operator-button :tip="$t('api_report.detail')" icon="el-icon-s-data"
|
||||||
@exec="handleView(scope.row)" type="primary"/>
|
@exec="handleView(scope.row)" type="primary"/>
|
||||||
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_report.delete')"
|
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_report.delete')"
|
||||||
|
v-permission="['PROJECT_API_REPORT:READ+DELETE']"
|
||||||
icon="el-icon-delete" @exec="handleDelete(scope.row)" type="danger"/>
|
icon="el-icon-delete" @exec="handleDelete(scope.row)" type="danger"/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -89,14 +89,17 @@
|
||||||
operators: [
|
operators: [
|
||||||
{
|
{
|
||||||
label: this.$t('api_test.automation.add_scenario'),
|
label: this.$t('api_test.automation.add_scenario'),
|
||||||
callback: this.addScenario
|
callback: this.addScenario,
|
||||||
|
permissions: ['PROJECT_API_SCENARIO:READ+CREATE']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: this.$t('api_test.api_import.label'),
|
label: this.$t('api_test.api_import.label'),
|
||||||
callback: this.handleImport
|
callback: this.handleImport,
|
||||||
|
permissions: ['PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: this.$t('report.export'),
|
label: this.$t('report.export'),
|
||||||
|
permissions: ['PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO'],
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
label: this.$t('report.export_to_ms_format'),
|
label: this.$t('report.export_to_ms_format'),
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
</el-link>
|
</el-link>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="ref">{{ $t('api_test.automation.view_ref') }}</el-dropdown-item>
|
<el-dropdown-item command="ref">{{ $t('api_test.automation.view_ref') }}</el-dropdown-item>
|
||||||
<el-dropdown-item command="schedule" v-tester>{{ $t('api_test.automation.schedule') }}</el-dropdown-item>
|
<el-dropdown-item command="schedule" v-permission="['PROJECT_API_SCENARIO:READ+SCHEDULE']">
|
||||||
<el-dropdown-item command="create_performance" v-tester v-modules="['performance']">
|
{{ $t('api_test.automation.schedule') }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="create_performance" v-permission="['PROJECT_API_SCENARIO:READ+CREATE_PERFORMANCE']"
|
||||||
|
v-modules="['performance']">
|
||||||
{{ $t('api_test.create_performance_test') }}
|
{{ $t('api_test.create_performance_test') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
|
@ -19,68 +22,68 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsReferenceView from "@/business/components/api/automation/scenario/ReferenceView";
|
import MsReferenceView from "@/business/components/api/automation/scenario/ReferenceView";
|
||||||
import MsScheduleMaintain from "@/business/components/api/automation/schedule/ScheduleMaintain"
|
import MsScheduleMaintain from "@/business/components/api/automation/schedule/ScheduleMaintain";
|
||||||
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
|
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "MsScenarioExtendButtons",
|
|
||||||
components: {MsReferenceView, MsScheduleMaintain},
|
|
||||||
props: {
|
|
||||||
row: Object
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleCommand(cmd) {
|
|
||||||
switch (cmd) {
|
|
||||||
case "ref":
|
|
||||||
this.$refs.viewRef.open(this.row);
|
|
||||||
break;
|
|
||||||
case "schedule":
|
|
||||||
this.$refs.scheduleMaintain.open(this.row);
|
|
||||||
break;
|
|
||||||
case "create_performance":
|
|
||||||
this.createPerformance(this.row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
createPerformance(row) {
|
|
||||||
this.infoDb = false;
|
|
||||||
let url = "/api/automation/genPerformanceTestJmx";
|
|
||||||
let run = {};
|
|
||||||
let scenarioIds = [];
|
|
||||||
scenarioIds.push(row.id);
|
|
||||||
run.projectId = getCurrentProjectID();
|
|
||||||
run.ids = scenarioIds;
|
|
||||||
run.id = getUUID();
|
|
||||||
run.name = row.name;
|
|
||||||
this.$post(url, run, response => {
|
|
||||||
let jmxObj = {};
|
|
||||||
jmxObj.name = response.data.name;
|
|
||||||
jmxObj.xml = response.data.xml;
|
|
||||||
jmxObj.attachFiles = response.data.attachFiles;
|
|
||||||
jmxObj.attachByteFiles = response.data.attachByteFiles;
|
|
||||||
jmxObj.scenarioId = row.id;
|
|
||||||
this.$store.commit('setTest', {
|
|
||||||
name: row.name,
|
|
||||||
jmx: jmxObj
|
|
||||||
})
|
|
||||||
this.$router.push({
|
|
||||||
path: "/performance/test/create"
|
|
||||||
})
|
|
||||||
});
|
|
||||||
},
|
|
||||||
openScenario (item) {
|
|
||||||
this.$emit('openScenario', item)
|
|
||||||
},
|
|
||||||
refreshTable() {
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "MsScenarioExtendButtons",
|
||||||
|
components: {MsReferenceView, MsScheduleMaintain},
|
||||||
|
props: {
|
||||||
|
row: Object
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleCommand(cmd) {
|
||||||
|
switch (cmd) {
|
||||||
|
case "ref":
|
||||||
|
this.$refs.viewRef.open(this.row);
|
||||||
|
break;
|
||||||
|
case "schedule":
|
||||||
|
this.$refs.scheduleMaintain.open(this.row);
|
||||||
|
break;
|
||||||
|
case "create_performance":
|
||||||
|
this.createPerformance(this.row);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
createPerformance(row) {
|
||||||
|
this.infoDb = false;
|
||||||
|
let url = "/api/automation/genPerformanceTestJmx";
|
||||||
|
let run = {};
|
||||||
|
let scenarioIds = [];
|
||||||
|
scenarioIds.push(row.id);
|
||||||
|
run.projectId = getCurrentProjectID();
|
||||||
|
run.ids = scenarioIds;
|
||||||
|
run.id = getUUID();
|
||||||
|
run.name = row.name;
|
||||||
|
this.$post(url, run, response => {
|
||||||
|
let jmxObj = {};
|
||||||
|
jmxObj.name = response.data.name;
|
||||||
|
jmxObj.xml = response.data.xml;
|
||||||
|
jmxObj.attachFiles = response.data.attachFiles;
|
||||||
|
jmxObj.attachByteFiles = response.data.attachByteFiles;
|
||||||
|
jmxObj.scenarioId = row.id;
|
||||||
|
this.$store.commit('setTest', {
|
||||||
|
name: row.name,
|
||||||
|
jmx: jmxObj
|
||||||
|
});
|
||||||
|
this.$router.push({
|
||||||
|
path: "/performance/test/create"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
openScenario(item) {
|
||||||
|
this.$emit('openScenario', item);
|
||||||
|
},
|
||||||
|
refreshTable() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.scenario-ext-btn {
|
.scenario-ext-btn {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -84,13 +84,17 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- 快捷调试 -->
|
<!-- 快捷调试 -->
|
||||||
<div v-else-if="item.type=== 'debug'" class="ms-api-div">
|
<div v-else-if="item.type=== 'debug'" class="ms-api-div">
|
||||||
<ms-debug-http-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
|
<ms-debug-http-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
|
||||||
|
@refreshModule="refreshModule"
|
||||||
v-if="currentProtocol==='HTTP'"/>
|
v-if="currentProtocol==='HTTP'"/>
|
||||||
<ms-debug-jdbc-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
|
<ms-debug-jdbc-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
|
||||||
|
@refreshModule="refreshModule"
|
||||||
v-if="currentProtocol==='SQL'"/>
|
v-if="currentProtocol==='SQL'"/>
|
||||||
<ms-debug-tcp-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
|
<ms-debug-tcp-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
|
||||||
|
@refreshModule="refreshModule"
|
||||||
v-if="currentProtocol==='TCP'"/>
|
v-if="currentProtocol==='TCP'"/>
|
||||||
<ms-debug-dubbo-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
|
<ms-debug-dubbo-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
|
||||||
|
@refreshModule="refreshModule"
|
||||||
v-if="currentProtocol==='DUBBO'"/>
|
v-if="currentProtocol==='DUBBO'"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -119,8 +123,12 @@
|
||||||
<el-dropdown @command="handleCommand" v-tester>
|
<el-dropdown @command="handleCommand" v-tester>
|
||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="debug">{{ $t('api_test.definition.request.fast_debug') }}</el-dropdown-item>
|
<el-dropdown-item command="debug" v-permission="['PROJECT_API_DEFINITION:READ+DEBUG']">
|
||||||
<el-dropdown-item command="ADD">{{ $t('api_test.definition.request.title') }}</el-dropdown-item>
|
{{ $t('api_test.definition.request.fast_debug') }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="ADD" v-permission="['PROJECT_API_DEFINITION:READ+CREATE_API']">
|
||||||
|
{{ $t('api_test.definition.request.title') }}
|
||||||
|
</el-dropdown-item>
|
||||||
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
|
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
|
@ -136,382 +144,388 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import MsApiList from './components/list/ApiList';
|
import MsApiList from './components/list/ApiList';
|
||||||
import MsContainer from "../../common/components/MsContainer";
|
import MsContainer from "../../common/components/MsContainer";
|
||||||
import MsMainContainer from "../../common/components/MsMainContainer";
|
import MsMainContainer from "../../common/components/MsMainContainer";
|
||||||
import MsAsideContainer from "../../common/components/MsAsideContainer";
|
import MsAsideContainer from "../../common/components/MsAsideContainer";
|
||||||
import MsApiConfig from "./components/ApiConfig";
|
import MsApiConfig from "./components/ApiConfig";
|
||||||
import MsDebugHttpPage from "./components/debug/DebugHttpPage";
|
import MsDebugHttpPage from "./components/debug/DebugHttpPage";
|
||||||
import MsDebugJdbcPage from "./components/debug/DebugJdbcPage";
|
import MsDebugJdbcPage from "./components/debug/DebugJdbcPage";
|
||||||
import MsDebugTcpPage from "./components/debug/DebugTcpPage";
|
import MsDebugTcpPage from "./components/debug/DebugTcpPage";
|
||||||
import MsDebugDubboPage from "./components/debug/DebugDubboPage";
|
import MsDebugDubboPage from "./components/debug/DebugDubboPage";
|
||||||
|
|
||||||
import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
|
import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
|
||||||
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
|
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
|
||||||
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
|
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
|
||||||
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
|
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
|
||||||
import {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils";
|
import {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils";
|
||||||
import MsApiModule from "./components/module/ApiModule";
|
import MsApiModule from "./components/module/ApiModule";
|
||||||
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
|
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
|
||||||
|
|
||||||
import ApiDocumentsPage from "@/business/components/api/definition/components/list/ApiDocumentsPage";
|
import ApiDocumentsPage from "@/business/components/api/definition/components/list/ApiDocumentsPage";
|
||||||
import MsTableButton from "@/business/components/common/components/MsTableButton";
|
import MsTableButton from "@/business/components/common/components/MsTableButton";
|
||||||
import MsTabButton from "@/business/components/common/components/MsTabButton";
|
import MsTabButton from "@/business/components/common/components/MsTabButton";
|
||||||
import {getLabel} from "@/common/js/tableUtils";
|
import {getLabel} from "@/common/js/tableUtils";
|
||||||
import {API_CASE_LIST, API_LIST} from "@/common/js/constants";
|
import {API_CASE_LIST, API_LIST} from "@/common/js/constants";
|
||||||
|
|
||||||
import MockConfig from "@/business/components/api/definition/components/mock/MockConfig";
|
import MockConfig from "@/business/components/api/definition/components/mock/MockConfig";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiDefinition",
|
name: "ApiDefinition",
|
||||||
computed: {
|
computed: {
|
||||||
queryDataType: function () {
|
queryDataType: function () {
|
||||||
let routeParam = this.$route.params.dataType;
|
let routeParam = this.$route.params.dataType;
|
||||||
let redirectIDParam = this.$route.params.redirectID;
|
let redirectIDParam = this.$route.params.redirectID;
|
||||||
this.changeRedirectParam(redirectIDParam);
|
this.changeRedirectParam(redirectIDParam);
|
||||||
return routeParam;
|
return routeParam;
|
||||||
},
|
|
||||||
isReadOnly() {
|
|
||||||
return !checkoutTestManagerOrTestUser();
|
|
||||||
},
|
|
||||||
projectId() {
|
|
||||||
return this.$store.state.projectId
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
components: {
|
isReadOnly() {
|
||||||
MsTabButton,
|
return !checkoutTestManagerOrTestUser();
|
||||||
MsTableButton,
|
|
||||||
ApiCaseSimpleList,
|
|
||||||
MsApiModule,
|
|
||||||
MsApiList,
|
|
||||||
MsMainContainer,
|
|
||||||
MsContainer,
|
|
||||||
MsAsideContainer,
|
|
||||||
MsApiConfig,
|
|
||||||
MsDebugHttpPage,
|
|
||||||
MsRunTestHttpPage,
|
|
||||||
MsDebugJdbcPage,
|
|
||||||
MsDebugTcpPage,
|
|
||||||
MsDebugDubboPage,
|
|
||||||
MsRunTestTcpPage,
|
|
||||||
MsRunTestSqlPage,
|
|
||||||
MsRunTestDubboPage,
|
|
||||||
ApiDocumentsPage,
|
|
||||||
MockConfig
|
|
||||||
},
|
},
|
||||||
props: {
|
projectId() {
|
||||||
visible: {
|
return this.$store.state.projectId;
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
currentRow: {
|
|
||||||
type: Object,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
data() {
|
},
|
||||||
return {
|
components: {
|
||||||
redirectID: '',
|
MsTabButton,
|
||||||
renderComponent: true,
|
MsTableButton,
|
||||||
selectDataRange: 'all',
|
ApiCaseSimpleList,
|
||||||
showCasePage: true,
|
MsApiModule,
|
||||||
apiDefaultTab: 'default',
|
MsApiList,
|
||||||
currentProtocol: 'HTTP',
|
MsMainContainer,
|
||||||
currentModule: null,
|
MsContainer,
|
||||||
selectNodeIds: [],
|
MsAsideContainer,
|
||||||
currentApi: {},
|
MsApiConfig,
|
||||||
moduleOptions: [],
|
MsDebugHttpPage,
|
||||||
trashEnable: false,
|
MsRunTestHttpPage,
|
||||||
apiTabs: [{
|
MsDebugJdbcPage,
|
||||||
title: this.$t('api_test.definition.api_title'),
|
MsDebugTcpPage,
|
||||||
name: 'default',
|
MsDebugDubboPage,
|
||||||
type: "list",
|
MsRunTestTcpPage,
|
||||||
closable: false
|
MsRunTestSqlPage,
|
||||||
}],
|
MsRunTestDubboPage,
|
||||||
activeDom: "left",
|
ApiDocumentsPage,
|
||||||
syncTabs: [],
|
MockConfig
|
||||||
nodeTree: [],
|
},
|
||||||
currentModulePath: "",
|
props: {
|
||||||
}
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
created() {
|
currentRow: {
|
||||||
let dataRange = this.$route.params.dataSelectRange;
|
type: Object,
|
||||||
if (dataRange && dataRange.length > 0) {
|
}
|
||||||
this.activeDom = 'middle';
|
},
|
||||||
}
|
data() {
|
||||||
if (this.activeDom === 'left') {
|
return {
|
||||||
getLabel(this, API_LIST);
|
redirectID: '',
|
||||||
} else if (this.activeDom === 'right') {
|
renderComponent: true,
|
||||||
getLabel(this, API_CASE_LIST);
|
selectDataRange: 'all',
|
||||||
|
showCasePage: true,
|
||||||
|
apiDefaultTab: 'default',
|
||||||
|
currentProtocol: 'HTTP',
|
||||||
|
currentModule: null,
|
||||||
|
selectNodeIds: [],
|
||||||
|
currentApi: {},
|
||||||
|
moduleOptions: [],
|
||||||
|
trashEnable: false,
|
||||||
|
apiTabs: [{
|
||||||
|
title: this.$t('api_test.definition.api_title'),
|
||||||
|
name: 'default',
|
||||||
|
type: "list",
|
||||||
|
closable: false
|
||||||
|
}],
|
||||||
|
activeDom: "left",
|
||||||
|
syncTabs: [],
|
||||||
|
nodeTree: [],
|
||||||
|
currentModulePath: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
let dataRange = this.$route.params.dataSelectRange;
|
||||||
|
if (dataRange && dataRange.length > 0) {
|
||||||
|
this.activeDom = 'middle';
|
||||||
|
}
|
||||||
|
if (this.activeDom === 'left') {
|
||||||
|
getLabel(this, API_LIST);
|
||||||
|
} else if (this.activeDom === 'right') {
|
||||||
|
getLabel(this, API_CASE_LIST);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
currentProtocol() {
|
||||||
|
this.handleCommand("CLOSE_ALL");
|
||||||
},
|
},
|
||||||
watch: {
|
selectNodeIds() {
|
||||||
currentProtocol() {
|
this.apiDefaultTab = "default";
|
||||||
this.handleCommand("CLOSE_ALL");
|
|
||||||
},
|
|
||||||
selectNodeIds() {
|
|
||||||
this.apiDefaultTab = "default";
|
|
||||||
},
|
|
||||||
redirectID() {
|
|
||||||
this.renderComponent = false;
|
|
||||||
this.$nextTick(() => {
|
|
||||||
// 在 DOM 中添加 my-component 组件
|
|
||||||
this.renderComponent = true;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'$route'(to, from) { // 路由改变时,把接口定义界面中的 ctrl s 保存快捷键监听移除
|
|
||||||
if (to.path.indexOf('/api/definition') === -1) {
|
|
||||||
if (this.$refs && this.$refs.apiConfig) {
|
|
||||||
this.$refs.apiConfig.forEach(item => {
|
|
||||||
item.removeListener();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
redirectID() {
|
||||||
methods: {
|
this.renderComponent = false;
|
||||||
getPath(id, arr) {
|
this.$nextTick(() => {
|
||||||
if (id === null) {
|
// 在 DOM 中添加 my-component 组件
|
||||||
return null;
|
this.renderComponent = true;
|
||||||
}
|
});
|
||||||
if(arr) {
|
},
|
||||||
arr.forEach(item => {
|
'$route'(to, from) { // 路由改变时,把接口定义界面中的 ctrl s 保存快捷键监听移除
|
||||||
if (item.id === id) {
|
if (to.path.indexOf('/api/definition') === -1) {
|
||||||
this.currentModulePath = item.path;
|
if (this.$refs && this.$refs.apiConfig) {
|
||||||
}
|
|
||||||
if (item.children && item.children.length > 0) {
|
|
||||||
this.getPath(id, item.children);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
changeRedirectParam(redirectIDParam) {
|
|
||||||
this.redirectID = redirectIDParam;
|
|
||||||
},
|
|
||||||
addTab(tab) {
|
|
||||||
if (tab.name === 'add') {
|
|
||||||
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
|
|
||||||
}
|
|
||||||
if (this.$refs.apiConfig) {
|
|
||||||
this.$refs.apiConfig.forEach(item => {
|
this.$refs.apiConfig.forEach(item => {
|
||||||
item.removeListener();
|
item.removeListener();
|
||||||
}); // 删除所有tab的 ctrl + s 监听
|
|
||||||
let tabs = this.apiTabs;
|
|
||||||
let index = tabs.findIndex(item => item.name === tab.name); // 找到当前选中tab的index
|
|
||||||
if (index !== -1 && this.$refs.apiConfig[index - 1]) {
|
|
||||||
this.$refs.apiConfig[index - 1].addListener(); // 为选中tab添加 ctrl + s 监听(index-1的原因是要除去第一个固有tab)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleCommand(e) {
|
|
||||||
switch (e) {
|
|
||||||
case "ADD":
|
|
||||||
this.handleTabAdd(e);
|
|
||||||
break;
|
|
||||||
case "TEST":
|
|
||||||
this.handleTabsEdit(this.$t("commons.api"), e);
|
|
||||||
break;
|
|
||||||
case "CLOSE_ALL":
|
|
||||||
this.handleTabClose();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleTabAdd(e) {
|
|
||||||
if (!this.projectId) {
|
|
||||||
this.$warning(this.$t('commons.check_project_tip'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let api = {
|
|
||||||
status: "Underway", method: "GET", userId: getCurrentUser().id,
|
|
||||||
url: "", protocol: this.currentProtocol, environmentId: "", moduleId: 'default-module', modulePath: "/" + this.$t("commons.module_title")
|
|
||||||
};
|
|
||||||
this.currentModulePath = "";
|
|
||||||
if (this.nodeTree && this.nodeTree.length > 0) {
|
|
||||||
api.moduleId = this.nodeTree[0].id;
|
|
||||||
this.getPath(this.nodeTree[0].id, this.moduleOptions);
|
|
||||||
api.modulePath = this.currentModulePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
|
||||||
api.moduleId = this.selectNodeIds[0];
|
|
||||||
this.getPath(this.selectNodeIds[0], this.moduleOptions);
|
|
||||||
api.modulePath = this.currentModulePath;
|
|
||||||
}
|
|
||||||
this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api);
|
|
||||||
},
|
|
||||||
handleTabClose() {
|
|
||||||
let tabs = this.apiTabs[0];
|
|
||||||
this.apiTabs = [];
|
|
||||||
this.apiDefaultTab = tabs.name;
|
|
||||||
this.apiTabs.push(tabs);
|
|
||||||
},
|
|
||||||
handleTabRemove(targetName) {
|
|
||||||
let tabs = this.apiTabs;
|
|
||||||
let activeName = this.apiDefaultTab;
|
|
||||||
if (activeName === targetName) {
|
|
||||||
tabs.forEach((tab, index) => {
|
|
||||||
if (tab.name === targetName) {
|
|
||||||
let nextTab = tabs[index + 1] || tabs[index - 1];
|
|
||||||
if (nextTab) {
|
|
||||||
activeName = nextTab.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.apiDefaultTab = activeName;
|
|
||||||
this.apiTabs = tabs.filter(tab => tab.name !== targetName);
|
|
||||||
this.refresh();
|
|
||||||
},
|
|
||||||
//创建左侧树的根目录模块
|
|
||||||
createRootModel() {
|
|
||||||
this.$refs.nodeTree.createRootModel();
|
|
||||||
},
|
|
||||||
handleMockTabsConfig(targetName, action, param) {
|
|
||||||
if (!this.projectId) {
|
|
||||||
this.$warning(this.$t('commons.check_project_tip'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (targetName === undefined || targetName === null) {
|
|
||||||
targetName = this.$t('api_test.definition.request.title');
|
|
||||||
}
|
|
||||||
let newTabName = getUUID();
|
|
||||||
this.apiTabs.push({
|
|
||||||
title: targetName,
|
|
||||||
name: newTabName,
|
|
||||||
closable: true,
|
|
||||||
type: action,
|
|
||||||
mock: param,
|
|
||||||
});
|
|
||||||
this.apiDefaultTab = newTabName;
|
|
||||||
},
|
|
||||||
handleTabsEdit(targetName, action, api) {
|
|
||||||
if (!this.projectId) {
|
|
||||||
this.$warning(this.$t('commons.check_project_tip'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (targetName === undefined || targetName === null) {
|
|
||||||
targetName = this.$t('api_test.definition.request.title');
|
|
||||||
}
|
|
||||||
let newTabName = getUUID();
|
|
||||||
this.apiTabs.push({
|
|
||||||
title: targetName,
|
|
||||||
name: newTabName,
|
|
||||||
closable: true,
|
|
||||||
type: action,
|
|
||||||
api: api,
|
|
||||||
});
|
|
||||||
this.apiDefaultTab = newTabName;
|
|
||||||
},
|
|
||||||
debug(id) {
|
|
||||||
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id);
|
|
||||||
},
|
|
||||||
editApi(row) {
|
|
||||||
let name = "";
|
|
||||||
|
|
||||||
if (row.isCopy) {
|
|
||||||
name = "copy" + "-" + row.name;
|
|
||||||
row.name = "copy" + "-" + row.name;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name;
|
|
||||||
}
|
|
||||||
this.handleTabsEdit(name, "ADD", row);
|
|
||||||
},
|
|
||||||
handleCase(api) {
|
|
||||||
this.currentApi = api;
|
|
||||||
this.showCasePage = false;
|
|
||||||
},
|
|
||||||
apiCaseClose() {
|
|
||||||
this.showCasePage = true;
|
|
||||||
},
|
|
||||||
exportAPI(type) {
|
|
||||||
if (this.activeDom !== 'left') {
|
|
||||||
this.$warning('用例列表暂不支持导出,请切换成接口列表');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.apiList[0].exportApi(type);
|
|
||||||
},
|
|
||||||
refreshModule() {
|
|
||||||
this.$refs.nodeTree.list();
|
|
||||||
},
|
|
||||||
refresh(data) {
|
|
||||||
this.$refs.apiList[0].initTable(data);
|
|
||||||
},
|
|
||||||
setTabTitle(data) {
|
|
||||||
for (let index in this.apiTabs) {
|
|
||||||
let tab = this.apiTabs[index];
|
|
||||||
if (tab.name === this.apiDefaultTab) {
|
|
||||||
tab.title = this.$t('api_test.definition.request.edit_api') + "-" + data.name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
runTest(data) {
|
|
||||||
this.handleTabsEdit(this.$t("commons.api"), "TEST", data);
|
|
||||||
this.setTabTitle(data);
|
|
||||||
},
|
|
||||||
mockConfig(data) {
|
|
||||||
let targetName = this.$t("commons.mock") + "-" + data.apiName;
|
|
||||||
this.handleMockTabsConfig(targetName, "MOCK", data);
|
|
||||||
},
|
|
||||||
saveApi(data) {
|
|
||||||
this.setTabTitle(data);
|
|
||||||
this.refresh(data);
|
|
||||||
},
|
|
||||||
|
|
||||||
showExecResult(row) {
|
|
||||||
this.debug(row);
|
|
||||||
},
|
|
||||||
nodeChange(node, nodeIds, pNodes) {
|
|
||||||
this.selectNodeIds = nodeIds;
|
|
||||||
},
|
|
||||||
handleProtocolChange(protocol) {
|
|
||||||
this.currentProtocol = protocol;
|
|
||||||
},
|
|
||||||
setModuleOptions(data) {
|
|
||||||
this.moduleOptions = data;
|
|
||||||
},
|
|
||||||
setNodeTree(data) {
|
|
||||||
this.nodeTree = data;
|
|
||||||
},
|
|
||||||
changeSelectDataRangeAll(tableType) {
|
|
||||||
this.$route.params.dataSelectRange = 'all';
|
|
||||||
},
|
|
||||||
enableTrash(data) {
|
|
||||||
this.trashEnable = data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
getPath(id, arr) {
|
||||||
|
if (id === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (arr) {
|
||||||
|
arr.forEach(item => {
|
||||||
|
if (item.id === id) {
|
||||||
|
this.currentModulePath = item.path;
|
||||||
|
}
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
this.getPath(id, item.children);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
changeRedirectParam(redirectIDParam) {
|
||||||
|
this.redirectID = redirectIDParam;
|
||||||
|
},
|
||||||
|
addTab(tab) {
|
||||||
|
if (tab.name === 'add') {
|
||||||
|
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
|
||||||
|
}
|
||||||
|
if (this.$refs.apiConfig) {
|
||||||
|
this.$refs.apiConfig.forEach(item => {
|
||||||
|
item.removeListener();
|
||||||
|
}); // 删除所有tab的 ctrl + s 监听
|
||||||
|
let tabs = this.apiTabs;
|
||||||
|
let index = tabs.findIndex(item => item.name === tab.name); // 找到当前选中tab的index
|
||||||
|
if (index !== -1 && this.$refs.apiConfig[index - 1]) {
|
||||||
|
this.$refs.apiConfig[index - 1].addListener(); // 为选中tab添加 ctrl + s 监听(index-1的原因是要除去第一个固有tab)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleCommand(e) {
|
||||||
|
switch (e) {
|
||||||
|
case "ADD":
|
||||||
|
this.handleTabAdd(e);
|
||||||
|
break;
|
||||||
|
case "TEST":
|
||||||
|
this.handleTabsEdit(this.$t("commons.api"), e);
|
||||||
|
break;
|
||||||
|
case "CLOSE_ALL":
|
||||||
|
this.handleTabClose();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleTabAdd(e) {
|
||||||
|
if (!this.projectId) {
|
||||||
|
this.$warning(this.$t('commons.check_project_tip'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let api = {
|
||||||
|
status: "Underway",
|
||||||
|
method: "GET",
|
||||||
|
userId: getCurrentUser().id,
|
||||||
|
url: "",
|
||||||
|
protocol: this.currentProtocol,
|
||||||
|
environmentId: "",
|
||||||
|
moduleId: 'default-module',
|
||||||
|
modulePath: "/" + this.$t("commons.module_title")
|
||||||
|
};
|
||||||
|
this.currentModulePath = "";
|
||||||
|
if (this.nodeTree && this.nodeTree.length > 0) {
|
||||||
|
api.moduleId = this.nodeTree[0].id;
|
||||||
|
this.getPath(this.nodeTree[0].id, this.moduleOptions);
|
||||||
|
api.modulePath = this.currentModulePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||||
|
api.moduleId = this.selectNodeIds[0];
|
||||||
|
this.getPath(this.selectNodeIds[0], this.moduleOptions);
|
||||||
|
api.modulePath = this.currentModulePath;
|
||||||
|
}
|
||||||
|
this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api);
|
||||||
|
},
|
||||||
|
handleTabClose() {
|
||||||
|
let tabs = this.apiTabs[0];
|
||||||
|
this.apiTabs = [];
|
||||||
|
this.apiDefaultTab = tabs.name;
|
||||||
|
this.apiTabs.push(tabs);
|
||||||
|
},
|
||||||
|
handleTabRemove(targetName) {
|
||||||
|
let tabs = this.apiTabs;
|
||||||
|
let activeName = this.apiDefaultTab;
|
||||||
|
if (activeName === targetName) {
|
||||||
|
tabs.forEach((tab, index) => {
|
||||||
|
if (tab.name === targetName) {
|
||||||
|
let nextTab = tabs[index + 1] || tabs[index - 1];
|
||||||
|
if (nextTab) {
|
||||||
|
activeName = nextTab.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.apiDefaultTab = activeName;
|
||||||
|
this.apiTabs = tabs.filter(tab => tab.name !== targetName);
|
||||||
|
this.refresh();
|
||||||
|
},
|
||||||
|
//创建左侧树的根目录模块
|
||||||
|
createRootModel() {
|
||||||
|
this.$refs.nodeTree.createRootModel();
|
||||||
|
},
|
||||||
|
handleMockTabsConfig(targetName, action, param) {
|
||||||
|
if (!this.projectId) {
|
||||||
|
this.$warning(this.$t('commons.check_project_tip'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (targetName === undefined || targetName === null) {
|
||||||
|
targetName = this.$t('api_test.definition.request.title');
|
||||||
|
}
|
||||||
|
let newTabName = getUUID();
|
||||||
|
this.apiTabs.push({
|
||||||
|
title: targetName,
|
||||||
|
name: newTabName,
|
||||||
|
closable: true,
|
||||||
|
type: action,
|
||||||
|
mock: param,
|
||||||
|
});
|
||||||
|
this.apiDefaultTab = newTabName;
|
||||||
|
},
|
||||||
|
handleTabsEdit(targetName, action, api) {
|
||||||
|
if (!this.projectId) {
|
||||||
|
this.$warning(this.$t('commons.check_project_tip'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (targetName === undefined || targetName === null) {
|
||||||
|
targetName = this.$t('api_test.definition.request.title');
|
||||||
|
}
|
||||||
|
let newTabName = getUUID();
|
||||||
|
this.apiTabs.push({
|
||||||
|
title: targetName,
|
||||||
|
name: newTabName,
|
||||||
|
closable: true,
|
||||||
|
type: action,
|
||||||
|
api: api,
|
||||||
|
});
|
||||||
|
this.apiDefaultTab = newTabName;
|
||||||
|
},
|
||||||
|
debug(id) {
|
||||||
|
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id);
|
||||||
|
},
|
||||||
|
editApi(row) {
|
||||||
|
let name = "";
|
||||||
|
|
||||||
|
if (row.isCopy) {
|
||||||
|
name = "copy" + "-" + row.name;
|
||||||
|
row.name = "copy" + "-" + row.name;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name;
|
||||||
|
}
|
||||||
|
this.handleTabsEdit(name, "ADD", row);
|
||||||
|
},
|
||||||
|
handleCase(api) {
|
||||||
|
this.currentApi = api;
|
||||||
|
this.showCasePage = false;
|
||||||
|
},
|
||||||
|
apiCaseClose() {
|
||||||
|
this.showCasePage = true;
|
||||||
|
},
|
||||||
|
exportAPI(type) {
|
||||||
|
if (this.activeDom !== 'left') {
|
||||||
|
this.$warning('用例列表暂不支持导出,请切换成接口列表');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$refs.apiList[0].exportApi(type);
|
||||||
|
},
|
||||||
|
refreshModule() {
|
||||||
|
this.$refs.nodeTree.list();
|
||||||
|
},
|
||||||
|
refresh(data) {
|
||||||
|
this.$refs.apiList[0].initTable(data);
|
||||||
|
},
|
||||||
|
setTabTitle(data) {
|
||||||
|
for (let index in this.apiTabs) {
|
||||||
|
let tab = this.apiTabs[index];
|
||||||
|
if (tab.name === this.apiDefaultTab) {
|
||||||
|
tab.title = this.$t('api_test.definition.request.edit_api') + "-" + data.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
runTest(data) {
|
||||||
|
this.handleTabsEdit(this.$t("commons.api"), "TEST", data);
|
||||||
|
this.setTabTitle(data);
|
||||||
|
},
|
||||||
|
mockConfig(data) {
|
||||||
|
let targetName = this.$t("commons.mock") + "-" + data.apiName;
|
||||||
|
this.handleMockTabsConfig(targetName, "MOCK", data);
|
||||||
|
},
|
||||||
|
saveApi(data) {
|
||||||
|
this.setTabTitle(data);
|
||||||
|
this.refresh(data);
|
||||||
|
},
|
||||||
|
|
||||||
|
showExecResult(row) {
|
||||||
|
this.debug(row);
|
||||||
|
},
|
||||||
|
nodeChange(node, nodeIds, pNodes) {
|
||||||
|
this.selectNodeIds = nodeIds;
|
||||||
|
},
|
||||||
|
handleProtocolChange(protocol) {
|
||||||
|
this.currentProtocol = protocol;
|
||||||
|
},
|
||||||
|
setModuleOptions(data) {
|
||||||
|
this.moduleOptions = data;
|
||||||
|
},
|
||||||
|
setNodeTree(data) {
|
||||||
|
this.nodeTree = data;
|
||||||
|
},
|
||||||
|
changeSelectDataRangeAll(tableType) {
|
||||||
|
this.$route.params.dataSelectRange = 'all';
|
||||||
|
},
|
||||||
|
enableTrash(data) {
|
||||||
|
this.trashEnable = data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.ms-api-div {
|
.ms-api-div {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
height: calc(100vh - 155px)
|
height: calc(100vh - 155px)
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-main {
|
/deep/ .el-main {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-tabs__header {
|
/deep/ .el-tabs__header {
|
||||||
margin: 0 0 0px;
|
margin: 0 0 0px;
|
||||||
/*width: calc(100% - 90px);*/
|
/*width: calc(100% - 90px);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-card {
|
/deep/ .el-card {
|
||||||
/*border: 1px solid #EBEEF5;*/
|
/*border: 1px solid #EBEEF5;*/
|
||||||
/*border-style: none;*/
|
/*border-style: none;*/
|
||||||
border-top: none;
|
border-top: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .api-component {
|
/deep/ .api-component {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -194,18 +194,7 @@ import MsTableAdvSearchBar from "@/business/components/common/components/search/
|
||||||
import {API_DEFINITION_CONFIGS} from "@/business/components/common/components/search/search-components";
|
import {API_DEFINITION_CONFIGS} from "@/business/components/common/components/search/search-components";
|
||||||
import MsTipButton from "@/business/components/common/components/MsTipButton";
|
import MsTipButton from "@/business/components/common/components/MsTipButton";
|
||||||
import CaseBatchMove from "@/business/components/api/definition/components/basis/BatchMove";
|
import CaseBatchMove from "@/business/components/api/definition/components/basis/BatchMove";
|
||||||
import {
|
import {_filter, _sort, buildBatchParam, getLabel, initCondition} from "@/common/js/tableUtils";
|
||||||
_filter,
|
|
||||||
_handleSelect,
|
|
||||||
_handleSelectAll,
|
|
||||||
_sort,
|
|
||||||
buildBatchParam, deepClone,
|
|
||||||
getLabel,
|
|
||||||
getSelectDataCounts,
|
|
||||||
initCondition,
|
|
||||||
setUnSelectIds,
|
|
||||||
toggleAllSelection
|
|
||||||
} from "@/common/js/tableUtils";
|
|
||||||
import {Api_List} from "@/business/components/common/model/JsonData";
|
import {Api_List} from "@/business/components/common/model/JsonData";
|
||||||
import HeaderCustom from "@/business/components/common/head/HeaderCustom";
|
import HeaderCustom from "@/business/components/common/head/HeaderCustom";
|
||||||
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
|
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
|
||||||
|
@ -251,31 +240,90 @@ export default {
|
||||||
selectDataRange: "all",
|
selectDataRange: "all",
|
||||||
deletePath: "/test/case/delete",
|
deletePath: "/test/case/delete",
|
||||||
buttons: [
|
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},
|
|
||||||
{
|
{
|
||||||
name: this.$t('api_test.definition.request.batch_move'), handleClick: this.handleBatchMove
|
name: this.$t('api_test.definition.request.batch_delete'),
|
||||||
|
handleClick: this.handleDeleteBatch,
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+DELETE_API']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: this.$t('api_test.definition.request.batch_edit'),
|
||||||
|
handleClick: this.handleEditBatch,
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+EDIT_API']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: this.$t('api_test.definition.request.batch_move'),
|
||||||
|
handleClick: this.handleBatchMove,
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+BATCH_MOVE']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
trashButtons: [
|
trashButtons: [
|
||||||
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
|
{
|
||||||
|
name: this.$t('api_test.definition.request.batch_delete'),
|
||||||
|
handleClick: this.handleDeleteBatch,
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+DELETE_API']
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "批量恢复", handleClick: this.handleBatchRestore
|
name: "批量恢复", handleClick: this.handleBatchRestore
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
tableOperatorButtons: [],
|
tableOperatorButtons: [],
|
||||||
tableUsualOperatorButtons: [
|
tableUsualOperatorButtons: [
|
||||||
{tip: this.$t('api_test.automation.execute'), icon: "el-icon-video-play", exec: this.runApi},
|
{
|
||||||
{tip: this.$t('commons.edit'), icon: "el-icon-edit", exec: this.editApi},
|
tip: this.$t('api_test.automation.execute'),
|
||||||
{tip: "CASE", exec: this.handleTestCase, isDivButton: true, type: "primary"},
|
icon: "el-icon-video-play",
|
||||||
{tip: this.$t('commons.delete'), exec: this.handleDelete, icon: "el-icon-delete", type: "danger"},
|
exec: this.runApi,
|
||||||
{tip: this.$t('commons.copy'), exec: this.handleCopy, icon: "el-icon-document-copy", type: "primary"},
|
permissions: ['PROJECT_API_DEFINITION:READ+RUN']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tip: this.$t('commons.edit'),
|
||||||
|
icon: "el-icon-edit",
|
||||||
|
exec: this.editApi,
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+EDIT_API']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tip: "CASE",
|
||||||
|
exec: this.handleTestCase,
|
||||||
|
isDivButton: true,
|
||||||
|
type: "primary",
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+CREATE_CASE']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tip: this.$t('commons.delete'),
|
||||||
|
exec: this.handleDelete,
|
||||||
|
icon: "el-icon-delete",
|
||||||
|
type: "danger",
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+DELETE_API']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tip: this.$t('commons.copy'),
|
||||||
|
exec: this.handleCopy,
|
||||||
|
icon: "el-icon-document-copy",
|
||||||
|
type: "primary",
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+COPY']
|
||||||
|
},
|
||||||
],
|
],
|
||||||
tableTrashOperatorButtons: [
|
tableTrashOperatorButtons: [
|
||||||
{tip: this.$t('api_test.automation.execute'), icon: "el-icon-video-play", exec: this.runApi},
|
{
|
||||||
|
tip: this.$t('api_test.automation.execute'),
|
||||||
|
icon: "el-icon-video-play",
|
||||||
|
exec: this.runApi,
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+RUN']
|
||||||
|
},
|
||||||
{tip: this.$t('commons.reduction'), icon: "el-icon-refresh-left", exec: this.reductionApi},
|
{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"},
|
tip: "CASE",
|
||||||
|
exec: this.handleTestCase,
|
||||||
|
isDivButton: true,
|
||||||
|
type: "primary",
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+CREATE_CASE']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tip: this.$t('commons.delete'),
|
||||||
|
exec: this.handleDelete,
|
||||||
|
icon: "el-icon-delete",
|
||||||
|
type: "danger",
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+DELETE_API']
|
||||||
|
},
|
||||||
],
|
],
|
||||||
typeArr: [
|
typeArr: [
|
||||||
{id: 'status', name: this.$t('api_test.definition.api_status')},
|
{id: 'status', name: this.$t('api_test.definition.api_status')},
|
||||||
|
@ -321,7 +369,7 @@ export default {
|
||||||
screenHeight: document.documentElement.clientHeight - 310,//屏幕高度,
|
screenHeight: document.documentElement.clientHeight - 310,//屏幕高度,
|
||||||
environmentId: undefined,
|
environmentId: undefined,
|
||||||
selectDataCounts: 0,
|
selectDataCounts: 0,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
currentProtocol: String,
|
currentProtocol: String,
|
||||||
|
@ -347,13 +395,13 @@ export default {
|
||||||
moduleTree: {
|
moduleTree: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default() {
|
default() {
|
||||||
return []
|
return [];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
moduleOptions: {
|
moduleOptions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default() {
|
default() {
|
||||||
return []
|
return [];
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -453,7 +501,7 @@ export default {
|
||||||
if (item.tags && item.tags.length > 0) {
|
if (item.tags && item.tags.length > 0) {
|
||||||
item.tags = JSON.parse(item.tags);
|
item.tags = JSON.parse(item.tags);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// nexttick:表格加载完成之后触发。判断是否需要勾选行
|
// nexttick:表格加载完成之后触发。判断是否需要勾选行
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
|
@ -461,7 +509,7 @@ export default {
|
||||||
this.$refs.apiDefinitionTable.checkTableRowIsSelect();
|
this.$refs.apiDefinitionTable.checkTableRowIsSelect();
|
||||||
this.$refs.apiDefinitionTable.doLayout();
|
this.$refs.apiDefinitionTable.doLayout();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getLabel(this, API_LIST);
|
getLabel(this, API_LIST);
|
||||||
|
@ -513,7 +561,7 @@ export default {
|
||||||
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||||
this.valueArr.userId = response.data;
|
this.valueArr.userId = response.data;
|
||||||
this.userFilters = response.data.map(u => {
|
this.userFilters = response.data.map(u => {
|
||||||
return {text: u.name, value: u.id}
|
return {text: u.name, value: u.id};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -562,8 +610,8 @@ export default {
|
||||||
}
|
}
|
||||||
response.body = body;
|
response.body = body;
|
||||||
}
|
}
|
||||||
row.request = request
|
row.request = request;
|
||||||
row.response = response
|
row.response = response;
|
||||||
this.$emit('runTest', row);
|
this.$emit('runTest', row);
|
||||||
},
|
},
|
||||||
reductionApi(row) {
|
reductionApi(row) {
|
||||||
|
@ -706,7 +754,7 @@ export default {
|
||||||
this.$emit("changeSelectDataRangeAll", "api");
|
this.$emit("changeSelectDataRangeAll", "api");
|
||||||
},
|
},
|
||||||
getIds(rowSets) {
|
getIds(rowSets) {
|
||||||
let rowArray = Array.from(rowSets)
|
let rowArray = Array.from(rowSets);
|
||||||
let ids = rowArray.map(s => s.id);
|
let ids = rowArray.map(s => s.id);
|
||||||
return ids;
|
return ids;
|
||||||
},
|
},
|
||||||
|
@ -739,7 +787,7 @@ export default {
|
||||||
if (api.moduleId === item.id) {
|
if (api.moduleId === item.id) {
|
||||||
api.modulePath = item.path;
|
api.modulePath = item.path;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -773,7 +821,7 @@ export default {
|
||||||
return row[property] === value;
|
return row[property] === value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
@ -27,134 +27,144 @@
|
||||||
@saveAsEdit="saveAsEdit"
|
@saveAsEdit="saveAsEdit"
|
||||||
@refresh="refresh"
|
@refresh="refresh"
|
||||||
ref="basisApi"/>
|
ref="basisApi"/>
|
||||||
<api-import :propotal="condition.protocol" ref="apiImport" :moduleOptions="moduleOptions" @refresh="$emit('refresh')"/>
|
<api-import :propotal="condition.protocol" ref="apiImport" :moduleOptions="moduleOptions"
|
||||||
|
@refresh="$emit('refresh')"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {OPTIONS} from "../../model/JsonData";
|
import {OPTIONS} from "../../model/JsonData";
|
||||||
import MsAddBasisApi from "../basis/AddBasisApi";
|
import MsAddBasisApi from "../basis/AddBasisApi";
|
||||||
import ApiImport from "../import/ApiImport";
|
import ApiImport from "../import/ApiImport";
|
||||||
import ModuleTrashButton from "./ModuleTrashButton";
|
import ModuleTrashButton from "./ModuleTrashButton";
|
||||||
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
|
import TemplateComponent from "../../../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
|
||||||
import TemplateComponent from "../../../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
|
import MsSearchBar from "@/business/components/common/components/search/MsSearchBar";
|
||||||
import MsSearchBar from "@/business/components/common/components/search/MsSearchBar";
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiModuleHeader",
|
name: "ApiModuleHeader",
|
||||||
components: {MsSearchBar, TemplateComponent, ModuleTrashButton, ApiImport, MsAddBasisApi},
|
components: {MsSearchBar, TemplateComponent, ModuleTrashButton, ApiImport, MsAddBasisApi},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
options: OPTIONS,
|
options: OPTIONS,
|
||||||
operators: [
|
operators: [
|
||||||
{
|
{
|
||||||
label: this.$t('api_test.definition.request.title'),
|
label: this.$t('api_test.definition.request.title'),
|
||||||
callback: this.addApi
|
callback: this.addApi,
|
||||||
|
permissions: ['PROJECT_API_DEFINITION:READ+CREATE_API']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('api_test.definition.request.fast_debug'),
|
||||||
|
callback: () => {
|
||||||
|
this.$emit('debug');
|
||||||
},
|
},
|
||||||
{
|
permissions: ['PROJECT_API_DEFINITION:READ+DEBUG']
|
||||||
label: this.$t('api_test.definition.request.fast_debug'),
|
},
|
||||||
callback: () => {this.$emit('debug')}
|
{
|
||||||
},
|
label: this.$t('api_test.api_import.label'),
|
||||||
{
|
callback: this.handleImport,
|
||||||
label: this.$t('api_test.api_import.label'),
|
permissions: ['PROJECT_API_DEFINITION:READ+IMPORT_API']
|
||||||
callback: this.handleImport
|
},
|
||||||
},
|
{
|
||||||
{
|
label: this.$t('report.export'),
|
||||||
label: this.$t('report.export'),
|
permissions: ['PROJECT_API_DEFINITION:READ+EXPORT_API'],
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
label: this.$t('report.export_to_ms_format') ,
|
label: this.$t('report.export_to_ms_format'),
|
||||||
callback: () => {
|
callback: () => {
|
||||||
if (!this.projectId) {
|
if (!this.projectId) {
|
||||||
this.$warning(this.$t('commons.check_project_tip'));
|
this.$warning(this.$t('commons.check_project_tip'));
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
this.$emit('exportAPI', 'MS');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: this.$t('report.export_to_swagger3_format'),
|
|
||||||
callback: () => {
|
|
||||||
if (!this.projectId) {
|
|
||||||
this.$warning(this.$t('commons.check_project_tip'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$emit('exportAPI', 'Swagger');
|
|
||||||
}
|
}
|
||||||
|
this.$emit('exportAPI', 'MS');
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
}
|
{
|
||||||
]
|
label: this.$t('report.export_to_swagger3_format'),
|
||||||
|
callback: () => {
|
||||||
|
if (!this.projectId) {
|
||||||
|
this.$warning(this.$t('commons.check_project_tip'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$emit('exportAPI', 'Swagger');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
condition: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
showOperator: Boolean,
|
||||||
condition: {
|
moduleOptions: Array,
|
||||||
type: Object,
|
currentModule: {
|
||||||
default() {
|
type: Object,
|
||||||
return {}
|
default() {
|
||||||
}
|
return {};
|
||||||
},
|
|
||||||
showOperator: Boolean,
|
|
||||||
moduleOptions: Array,
|
|
||||||
currentModule: {
|
|
||||||
type: Object,
|
|
||||||
default() {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
isReadOnly: {
|
|
||||||
type: Boolean,
|
|
||||||
default() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
projectId() {
|
|
||||||
return this.$store.state.projectId
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleImport() {
|
|
||||||
if (!this.projectId) {
|
|
||||||
this.$warning(this.$t('commons.check_project_tip'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.protocol = "HTTP";
|
|
||||||
this.$refs.apiImport.open(this.moduleOptions);
|
|
||||||
},
|
|
||||||
addApi() {
|
|
||||||
if (!this.projectId) {
|
|
||||||
this.$warning(this.$t('commons.check_project_tip'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.basisApi.open(this.currentModule);
|
|
||||||
},
|
|
||||||
saveAsEdit(data) {
|
|
||||||
this.$emit('saveAsEdit', data);
|
|
||||||
},
|
|
||||||
refresh() {
|
|
||||||
this.$emit('refresh');
|
|
||||||
},
|
|
||||||
enableTrash() {
|
|
||||||
this.condition.trashEnable = true;
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isReadOnly: {
|
||||||
|
type: Boolean,
|
||||||
|
default() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
projectId() {
|
||||||
|
return this.$store.state.projectId;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleImport() {
|
||||||
|
if (!this.projectId) {
|
||||||
|
this.$warning(this.$t('commons.check_project_tip'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.protocol = "HTTP";
|
||||||
|
this.$refs.apiImport.open(this.moduleOptions);
|
||||||
|
},
|
||||||
|
addApi() {
|
||||||
|
if (!this.projectId) {
|
||||||
|
this.$warning(this.$t('commons.check_project_tip'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$refs.basisApi.open(this.currentModule);
|
||||||
|
},
|
||||||
|
saveAsEdit(data) {
|
||||||
|
this.$emit('saveAsEdit', data);
|
||||||
|
},
|
||||||
|
refresh() {
|
||||||
|
this.$emit('refresh');
|
||||||
|
},
|
||||||
|
enableTrash() {
|
||||||
|
this.condition.trashEnable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.protocol-select {
|
.protocol-select {
|
||||||
width: 92px;
|
width: 92px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
}
|
}
|
||||||
.protocol-col {
|
|
||||||
min-width: 93px;
|
.protocol-col {
|
||||||
}
|
min-width: 93px;
|
||||||
.read-only {
|
}
|
||||||
width: 150px !important;
|
|
||||||
}
|
.read-only {
|
||||||
.filter-input {
|
width: 150px !important;
|
||||||
width: 174px;
|
}
|
||||||
padding-left: 3px;
|
|
||||||
}
|
.filter-input {
|
||||||
|
width: 174px;
|
||||||
|
padding-left: 3px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
<i class="el-icon-arrow-down el-icon--right"/>
|
<i class="el-icon-arrow-down el-icon--right"/>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item v-for="(item, index) in commands" :key="index" @click.native.stop="click(item)">
|
<el-dropdown-item v-for="(item, index) in commands" :key="index" @click.native.stop="click(item)"
|
||||||
|
v-permission="item.permissions"
|
||||||
|
>
|
||||||
<span class="tip-font" v-if="!item.children">
|
<span class="tip-font" v-if="!item.children">
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -96,7 +96,7 @@ export function hasPermission(permission) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let systemPermissions = user.userGroups.filter(gp => gp.group.type === 'SYSTEM')
|
let systemPermissions = user.userGroups.filter(gp => gp.group.type === 'SYSTEM')
|
||||||
.filter(ug => ug.sourceId === 'system')[0]?.userGroupPermissions
|
.filter(ug => ug.sourceId === 'system' || ug.sourceId === 'adminSourceId')[0]?.userGroupPermissions
|
||||||
.map(g => g.permissionId) || [];
|
.map(g => g.permissionId) || [];
|
||||||
|
|
||||||
for (const p of systemPermissions) {
|
for (const p of systemPermissions) {
|
||||||
|
|
Loading…
Reference in New Issue