mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 05:29:29 +08:00
fix(测试跟踪): 修改执行测试计划时报告里运行环境的查询方式
--bug=1021786 --user=宋天阳 【测试跟踪】历史数据运行环境显示不对 https://www.tapd.cn/55049933/s/1339992
This commit is contained in:
parent
66e2b7843c
commit
5606626ce4
@ -41,6 +41,7 @@ import io.metersphere.service.plan.remote.TestPlanService;
|
||||
import io.metersphere.service.scenario.ApiScenarioModuleService;
|
||||
import io.metersphere.service.scenario.ApiScenarioReportService;
|
||||
import io.metersphere.service.scenario.ApiScenarioService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -52,7 +53,6 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -351,12 +351,11 @@ public class TestPlanScenarioCaseService {
|
||||
map.put(s, envMap.get(s));
|
||||
}
|
||||
}
|
||||
String envJsonStr = JSON.toJSONString(map);
|
||||
if (!StringUtils.equals(envJsonStr, testPlanApiScenario.getEnvironment())) {
|
||||
testPlanApiScenario.setEnvironmentType(EnvironmentType.JSON.toString());
|
||||
testPlanApiScenario.setEnvironment(JSON.toJSONString(map));
|
||||
mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario);
|
||||
}
|
||||
|
||||
testPlanApiScenario.setEnvironmentType(runModeConfig.getEnvironmentType());
|
||||
testPlanApiScenario.setEnvironmentGroupId(runModeConfig.getEnvironmentGroupId());
|
||||
testPlanApiScenario.setEnvironment(JSON.toJSONString(map));
|
||||
mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario);
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
if (sqlSession != null && sqlSessionFactory != null) {
|
||||
|
@ -40,7 +40,7 @@
|
||||
AND t.user_id = #{request.executor}
|
||||
</if>
|
||||
AND (t.integrated_report_id IS NULL OR t.integrated_report_id = 'null')
|
||||
ORDER BY t.create_time DESC
|
||||
ORDER BY t.create_time,t.end_time DESC
|
||||
</select>
|
||||
|
||||
<select id="getScenarioTasks" resultType="io.metersphere.task.dto.TaskCenterDTO" parameterType="java.lang.String">
|
||||
@ -70,7 +70,7 @@
|
||||
<if test="request.executor != null and request.executor != ''">
|
||||
AND t.user_id = #{request.executor}
|
||||
</if>
|
||||
ORDER BY t.create_time DESC
|
||||
ORDER BY t.create_time,t.end_time DESC
|
||||
</select>
|
||||
|
||||
<select id="getPerfTasks" resultType="io.metersphere.task.dto.TaskCenterDTO" parameterType="java.lang.String">
|
||||
|
@ -5,11 +5,13 @@ import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.commons.constants.*;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.dto.ScheduleDTO;
|
||||
import io.metersphere.dto.TestPlanDTOWithMetric;
|
||||
import io.metersphere.dto.TestPlanRerunParametersDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.log.annotation.MsAuditLog;
|
||||
import io.metersphere.notice.annotation.SendNotice;
|
||||
import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
|
||||
@ -26,15 +28,15 @@ import io.metersphere.plan.request.function.TestCaseRelevanceRequest;
|
||||
import io.metersphere.plan.service.TestPlanProjectService;
|
||||
import io.metersphere.plan.service.TestPlanRerunService;
|
||||
import io.metersphere.plan.service.TestPlanService;
|
||||
import io.metersphere.plan.service.remote.api.PlanApiAutomationService;
|
||||
import io.metersphere.request.ScheduleRequest;
|
||||
import io.metersphere.service.BaseScheduleService;
|
||||
import io.metersphere.service.BaseUserService;
|
||||
import io.metersphere.service.wapper.CheckPermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -53,7 +55,7 @@ public class TestPlanController {
|
||||
@Resource
|
||||
private BaseScheduleService baseScheduleService;
|
||||
@Resource
|
||||
private PlanApiAutomationService planApiAutomationService;
|
||||
private BaseUserService baseUserService;
|
||||
@Resource
|
||||
private TestPlanRerunService testPlanRerunService;
|
||||
|
||||
@ -240,6 +242,9 @@ public class TestPlanController {
|
||||
|
||||
@PostMapping("/run")
|
||||
public String run(@RequestBody TestPlanRunRequest testplanRunRequest) {
|
||||
if (baseUserService.getUserDTO(testplanRunRequest.getUserId()) == null) {
|
||||
MSException.throwException(Translator.get("user_not_exist"));
|
||||
}
|
||||
return testPlanService.runPlan(testplanRunRequest);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ public class TestPlanReportRunInfoDTO {
|
||||
private String envGroupId;
|
||||
|
||||
private String runMode;
|
||||
private Map<String, String> requestEnvMap;
|
||||
|
||||
// <测试计划场景关联表ID, <项目ID,环境ID>>
|
||||
private Map<String, Map<String, List<String>>> scenarioRunInfo;
|
||||
// <测试计划场景关联表ID, <项目ID,环境ID>>
|
||||
@ -47,7 +49,7 @@ public class TestPlanReportRunInfoDTO {
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void putUiScenarioRunInfo(String scenarioResourceId, String projectId, String environmentId) {
|
||||
if (uiScenarioRunInfo.containsKey(scenarioResourceId)) {
|
||||
if (uiScenarioRunInfo.get(scenarioResourceId).containsKey(projectId)) {
|
||||
|
@ -10,7 +10,9 @@ import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.environment.service.BaseEnvGroupProjectService;
|
||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||
import io.metersphere.excel.constants.TestPlanTestCaseStatus;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.log.vo.OperatingLogDetails;
|
||||
import io.metersphere.plan.constant.ApiReportStatus;
|
||||
import io.metersphere.plan.dto.*;
|
||||
@ -24,6 +26,7 @@ import io.metersphere.plan.service.remote.ui.PlanTestPlanUiScenarioCaseService;
|
||||
import io.metersphere.plan.utils.TestPlanRequestUtil;
|
||||
import io.metersphere.plan.utils.TestPlanStatusCalculator;
|
||||
import io.metersphere.request.report.QueryTestPlanReportRequest;
|
||||
import io.metersphere.service.BaseProjectService;
|
||||
import io.metersphere.service.BaseUserService;
|
||||
import io.metersphere.service.ServiceUtils;
|
||||
import io.metersphere.utils.DiscoveryUtil;
|
||||
@ -105,6 +108,10 @@ public class TestPlanReportService {
|
||||
private PlanTestPlanScenarioCaseService planTestPlanScenarioCaseService;
|
||||
@Resource
|
||||
private BaseUserService baseUserService;
|
||||
@Resource
|
||||
private BaseEnvironmentService apiTestEnvironmentService;
|
||||
@Resource
|
||||
private BaseProjectService baseProjectService;
|
||||
|
||||
private final String GROUP = "GROUP";
|
||||
|
||||
@ -264,6 +271,8 @@ public class TestPlanReportService {
|
||||
List<TestPlanApiScenarioInfoDTO> scenarios) {
|
||||
|
||||
TestPlanReportRunInfoDTO runInfoDTO = new TestPlanReportRunInfoDTO();
|
||||
runInfoDTO.setRequestEnvMap(config.getEnvMap());
|
||||
|
||||
final Map<String, String> runEnvMap = MapUtils.isNotEmpty(config.getEnvMap()) ? config.getEnvMap() : new HashMap<>();
|
||||
runInfoDTO.setRunMode(config.getMode());
|
||||
|
||||
@ -1129,7 +1138,8 @@ public class TestPlanReportService {
|
||||
}
|
||||
TestPlanSimpleReportDTO testPlanReportDTO = new TestPlanSimpleReportDTO();
|
||||
BeanUtils.copyBean(testPlanReportDTO, testPlanReportContent);
|
||||
this.generateEnvironmentInfo(testPlanReportDTO, reportId);
|
||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId);
|
||||
this.initTestPlanReportEnv(testPlanReportDTO, testPlanReport);
|
||||
|
||||
testPlanReportDTO.setFunctionResult(
|
||||
getReportContentResultObject(testPlanReportContent.getFunctionResult(), TestPlanFunctionResultReportDTO.class)
|
||||
@ -1204,7 +1214,6 @@ public class TestPlanReportService {
|
||||
);
|
||||
|
||||
testPlanReportDTO.setId(reportId);
|
||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId());
|
||||
testPlanReportDTO.setName(testPlanReport.getName());
|
||||
TestPlanService testPlanService = CommonBeanFactory.getBean(TestPlanService.class);
|
||||
TestPlanExtReportDTO extReport = null;
|
||||
@ -1253,6 +1262,46 @@ public class TestPlanReportService {
|
||||
}
|
||||
}
|
||||
|
||||
public void initTestPlanReportEnv(TestPlanSimpleReportDTO testPlanReportDTO, TestPlanReport testPlanReport) {
|
||||
TestPlanReportRunInfoDTO runInfoDTO = null;
|
||||
if (StringUtils.isNotEmpty(testPlanReport.getRunInfo())) {
|
||||
try {
|
||||
runInfoDTO = JSON.parseObject(testPlanReport.getRunInfo(), TestPlanReportRunInfoDTO.class);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("解析测试计划报告记录的运行环境信息[" + testPlanReport.getRunInfo() + "]时出错!", e);
|
||||
}
|
||||
|
||||
}
|
||||
if (runInfoDTO != null) {
|
||||
if (StringUtils.isNotEmpty(runInfoDTO.getEnvGroupId())) {
|
||||
EnvironmentGroup environmentGroup = apiTestEnvironmentService.selectById(runInfoDTO.getEnvGroupId());
|
||||
if (StringUtils.isNotEmpty(environmentGroup.getName())) {
|
||||
testPlanReportDTO.setEnvGroupName(environmentGroup.getName());
|
||||
}
|
||||
} else {
|
||||
if (MapUtils.isNotEmpty(runInfoDTO.getRequestEnvMap())) {
|
||||
Map<String, List<String>> projectEnvMap = new HashMap<>();
|
||||
for (Map.Entry<String, String> entry : runInfoDTO.getRequestEnvMap().entrySet()) {
|
||||
String projectId = entry.getKey();
|
||||
String envId = entry.getValue();
|
||||
Project project = baseProjectService.getProjectById(projectId);
|
||||
String projectName = project == null ? null : project.getName();
|
||||
String envNames = apiTestEnvironmentService.selectNameById(envId);
|
||||
if (StringUtils.isNotEmpty(projectName) && StringUtils.isNotEmpty(envNames)) {
|
||||
projectEnvMap.put(projectName, new ArrayList<>() {{
|
||||
this.add(envNames);
|
||||
}});
|
||||
}
|
||||
}
|
||||
if (MapUtils.isNotEmpty(projectEnvMap)) {
|
||||
testPlanReportDTO.setProjectEnvMap(projectEnvMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
testPlanReportDTO.setRunMode(StringUtils.equalsIgnoreCase(runInfoDTO.getRunMode(), "serial") ? Translator.get("serial") : Translator.get("parallel"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDynamicallyGenerateReports(TestPlanReportContentWithBLOBs testPlanReportContent) {
|
||||
return testPlanReportContent != null &&
|
||||
(StringUtils.isNotEmpty(testPlanReportContent.getPlanApiCaseReportStruct()) || StringUtils.isNotEmpty(testPlanReportContent.getPlanScenarioReportStruct()) || StringUtils.isNotEmpty(testPlanReportContent.getPlanLoadCaseReportStruct()) || StringUtils.isNotEmpty(testPlanReportContent.getPlanUiScenarioReportStruct()));
|
||||
|
@ -1332,6 +1332,7 @@ public class TestPlanService {
|
||||
config = JSON.parseMap(reportConfig);
|
||||
}
|
||||
TestPlanExecuteReportDTO testPlanExecuteReportDTO = testPlanReportService.genTestPlanExecuteReportDTOByTestPlanReportContent(testPlanReportContentWithBLOBs);
|
||||
|
||||
TestPlanSimpleReportDTO report = null;
|
||||
boolean apiBaseInfoChanged = false;
|
||||
if (StringUtils.isEmpty(testPlanReportContentWithBLOBs.getApiBaseCount())) {
|
||||
|
@ -1,66 +1,138 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-radio-group v-model="radio" style="width: 100%" @change="radioChange" class="radio-change">
|
||||
<el-radio :label="ENV_TYPE.JSON">{{ $t('workspace.env_group.env_list') }}</el-radio>
|
||||
<el-radio :label="ENV_TYPE.GROUP" v-if="showEnvGroup">{{ $t('workspace.env_group.name') }}<i class="el-icon-tickets mode-span" @click="viewGroup"></i></el-radio>
|
||||
<el-radio-group
|
||||
v-model="radio"
|
||||
style="width: 100%"
|
||||
@change="radioChange"
|
||||
class="radio-change"
|
||||
>
|
||||
<el-radio :label="ENV_TYPE.JSON">{{
|
||||
$t("workspace.env_group.env_list")
|
||||
}}</el-radio>
|
||||
<el-radio :label="ENV_TYPE.GROUP" v-if="showEnvGroup"
|
||||
>{{ $t("workspace.env_group.name")
|
||||
}}<i class="el-icon-tickets mode-span" @click="viewGroup"></i
|
||||
></el-radio>
|
||||
</el-radio-group>
|
||||
<div v-for="(pe, pIndex) in eventData" :key="pe.id" v-show="radio === ENV_TYPE.JSON">
|
||||
<el-card shadow="never" style="margin-top: 8px;background: #F5F6F7;border-radius: 4px;">
|
||||
<i @click="expandCard(pIndex)" v-if="pe.expendStatus==='close'" class="el-icon-caret-right" style="color: var(--primary_color)"/>
|
||||
<i @click="expandCard(pIndex)" v-else class="el-icon-caret-bottom" style="color: var(--primary_color)"/>
|
||||
<div
|
||||
v-for="(pe, pIndex) in eventData"
|
||||
:key="pe.id"
|
||||
v-show="radio === ENV_TYPE.JSON"
|
||||
>
|
||||
<el-card
|
||||
shadow="never"
|
||||
style="margin-top: 8px; background: #f5f6f7; border-radius: 4px"
|
||||
>
|
||||
<i
|
||||
@click="expandCard(pIndex)"
|
||||
v-if="pe.expendStatus === 'close'"
|
||||
class="el-icon-caret-right"
|
||||
style="color: var(--primary_color)"
|
||||
/>
|
||||
<i
|
||||
@click="expandCard(pIndex)"
|
||||
v-else
|
||||
class="el-icon-caret-bottom"
|
||||
style="color: var(--primary_color)"
|
||||
/>
|
||||
<span class="project-name" :title="getProjectName(pe.id)">
|
||||
{{ getProjectName(pe.id) }}
|
||||
</span><br/>
|
||||
<div v-if="pe.expendStatus==='open'">
|
||||
<el-radio-group v-model="pe.envRadio" style="width: 100%;" @change="envRadioChange(pe.envRadio,pIndex)" class="radio-change">
|
||||
<el-radio label="DEFAULT_ENV" style="margin-top: 7px">{{$t('api_test.environment.default_environment') }}</el-radio>
|
||||
<el-radio label="CUSTOMIZE_ENV" style="margin-top: 7px">{{$t('api_test.environment.choose_new_environment')}}</el-radio>
|
||||
{{ getProjectName(pe.id) }} </span
|
||||
><br />
|
||||
<div v-if="pe.expendStatus === 'open'">
|
||||
<el-radio-group
|
||||
v-model="pe.envRadio"
|
||||
style="width: 100%"
|
||||
@change="envRadioChange(pe.envRadio, pIndex)"
|
||||
class="radio-change"
|
||||
>
|
||||
<el-radio label="DEFAULT_ENV" style="margin-top: 7px">{{
|
||||
$t("api_test.environment.default_environment")
|
||||
}}</el-radio>
|
||||
<el-radio label="CUSTOMIZE_ENV" style="margin-top: 7px">{{
|
||||
$t("api_test.environment.choose_new_environment")
|
||||
}}</el-radio>
|
||||
</el-radio-group>
|
||||
<el-tag v-show="!pe.showEnvSelect" v-for="(itemName,index) in selectedEnvName.get(pe.id)" :key="index" size="mini"
|
||||
style="margin-left: 0; margin-right: 2px;margin-top: 8px">{{ itemName }}</el-tag>
|
||||
<el-select v-show="pe.showEnvSelect" v-model="pe['selectEnv']" filterable
|
||||
:placeholder="$t('api_test.environment.select_environment')"
|
||||
style="margin-top: 8px;width: 100%;" size="small" @change="chooseEnv">
|
||||
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||
:label="environment.name"
|
||||
:value="environment.id"/>
|
||||
<el-tag
|
||||
v-show="!pe.showEnvSelect"
|
||||
v-for="(itemName, index) in selectedEnvName.get(pe.id)"
|
||||
:key="index"
|
||||
size="mini"
|
||||
style="margin-left: 0; margin-right: 2px; margin-top: 8px"
|
||||
>{{ itemName }}</el-tag
|
||||
>
|
||||
<el-select
|
||||
v-show="pe.showEnvSelect"
|
||||
v-model="pe['selectEnv']"
|
||||
filterable
|
||||
:placeholder="$t('api_test.environment.select_environment')"
|
||||
style="margin-top: 8px; width: 100%"
|
||||
size="small"
|
||||
@change="chooseEnv"
|
||||
>
|
||||
<el-option
|
||||
v-for="(environment, index) in pe.envs"
|
||||
:key="index"
|
||||
:label="environment.name"
|
||||
:value="environment.id"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
<div v-show="radio === ENV_TYPE.GROUP">
|
||||
<div>
|
||||
<el-select v-show="!hasOptionGroup" v-model="envGroupId" :placeholder="$t('workspace.env_group.select')" @change="chooseEnvGroup"
|
||||
style="margin-top: 8px;width: 100%;" size="small">
|
||||
<el-option v-for="(group, index) in groups" :key="index"
|
||||
:label="group.name"
|
||||
:value="group.id"/>
|
||||
<el-select
|
||||
v-show="!hasOptionGroup"
|
||||
v-model="envGroupId"
|
||||
:placeholder="$t('workspace.env_group.select')"
|
||||
@change="chooseEnvGroup"
|
||||
style="margin-top: 8px; width: 100%"
|
||||
size="small"
|
||||
>
|
||||
<el-option
|
||||
v-for="(group, index) in groups"
|
||||
:key="index"
|
||||
:label="group.name"
|
||||
:value="group.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select v-show="hasOptionGroup" v-model="envGroupId" :placeholder="$t('workspace.env_group.select')"
|
||||
style="margin-top: 8px;width: 100%;" @change="chooseEnvGroup" size="small" clearable>
|
||||
<el-select
|
||||
v-show="hasOptionGroup"
|
||||
v-model="envGroupId"
|
||||
:placeholder="$t('workspace.env_group.select')"
|
||||
style="margin-top: 8px; width: 100%"
|
||||
@change="chooseEnvGroup"
|
||||
size="small"
|
||||
clearable
|
||||
>
|
||||
<el-option-group
|
||||
v-for="group in groups"
|
||||
:key="group.label"
|
||||
:label="group.label">
|
||||
:label="group.label"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in group.options"
|
||||
:key="item.name"
|
||||
:label="item.name"
|
||||
:disabled="item.disabled"
|
||||
:value="item.id">
|
||||
:value="item.id"
|
||||
>
|
||||
</el-option>
|
||||
</el-option-group>
|
||||
</el-select>
|
||||
|
||||
</div>
|
||||
<el-dialog :visible="visible" append-to-body :title="$t('workspace.env_group.name')" @close="visible = false"
|
||||
style="height: 800px;">
|
||||
<el-dialog
|
||||
:visible="visible"
|
||||
append-to-body
|
||||
:title="$t('workspace.env_group.name')"
|
||||
@close="visible = false"
|
||||
style="height: 800px"
|
||||
>
|
||||
<template>
|
||||
<environment-group style="overflow-y: auto;"
|
||||
:screen-height="'350px'"
|
||||
:read-only="true"
|
||||
<environment-group
|
||||
style="overflow-y: auto"
|
||||
:screen-height="'350px'"
|
||||
:read-only="true"
|
||||
></environment-group>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@ -68,33 +140,34 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
import {ENV_TYPE} from "metersphere-frontend/src/utils/constants";
|
||||
import {environmentGetALL,getEnvironmentOptions} from "metersphere-frontend/src/api/environment";
|
||||
import { ENV_TYPE } from "metersphere-frontend/src/utils/constants";
|
||||
import {
|
||||
environmentGetALL,
|
||||
getEnvironmentOptions,
|
||||
} from "metersphere-frontend/src/api/environment";
|
||||
import MsTag from "metersphere-frontend/src/components/MsTag";
|
||||
import EnvironmentGroup from "@/business/plan/env/EnvironmentGroupList";
|
||||
import {getEnvironmentByProjectId} from "@/api/remote/api/api-environment";
|
||||
import {parseEnvironment} from "metersphere-frontend/src/model/EnvironmentModel";
|
||||
import { getEnvironmentByProjectId } from "@/api/remote/api/api-environment";
|
||||
import { parseEnvironment } from "metersphere-frontend/src/model/EnvironmentModel";
|
||||
|
||||
export default {
|
||||
name: "EnvSelectPopover",
|
||||
components: {MsTag,EnvironmentGroup},
|
||||
data(){
|
||||
components: { MsTag, EnvironmentGroup },
|
||||
data() {
|
||||
return {
|
||||
radio: this.environmentType,
|
||||
visible: false,
|
||||
groups:[],
|
||||
groups: [],
|
||||
disabledGroups: [],
|
||||
notDisabledGroups: [],
|
||||
selectedEnvName:new Map(),
|
||||
showEnvName:false,
|
||||
eventData:[],
|
||||
evnList:[],
|
||||
selectEnvMap:new Map(),
|
||||
selectedEnvName: new Map(),
|
||||
showEnvName: false,
|
||||
eventData: [],
|
||||
evnList: [],
|
||||
selectEnvMap: new Map(),
|
||||
envGroupId: this.groupId,
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
groupId(val) {
|
||||
@ -102,150 +175,163 @@ export default {
|
||||
},
|
||||
environmentType(val) {
|
||||
this.radio = val;
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
ENV_TYPE() {
|
||||
return ENV_TYPE;
|
||||
}
|
||||
},
|
||||
},
|
||||
props:{
|
||||
props: {
|
||||
showEnvGroup: {
|
||||
type : Boolean,
|
||||
default: true
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
projectIds: Set,
|
||||
projectList:Array,
|
||||
projectEnvMap:Object,
|
||||
projectList: Array,
|
||||
projectEnvMap: Object,
|
||||
envMap: Map,
|
||||
environmentType: String,
|
||||
groupId: {
|
||||
type: String,
|
||||
default() {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
},
|
||||
hasOptionGroup: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
open(){
|
||||
open() {
|
||||
this.envGroupId = this.groupId;
|
||||
this.initDefaultEnv();
|
||||
this.getgroups();
|
||||
},
|
||||
radioChange(val){
|
||||
radioChange(val) {
|
||||
this.$emit("update:environmentType", val);
|
||||
},
|
||||
getProjectName(id) {
|
||||
const project = this.projectList.find(p => p.id === id);
|
||||
const project = this.projectList.find((p) => p.id === id);
|
||||
return project ? project.name : "";
|
||||
},
|
||||
envRadioChange(val,index){
|
||||
this.eventData[index].envRadio = val
|
||||
this.eventData[index].showEnvSelect = this.eventData[index].envRadio === "CUSTOMIZE_ENV";
|
||||
envRadioChange(val, index) {
|
||||
this.eventData[index].envRadio = val;
|
||||
this.eventData[index].showEnvSelect =
|
||||
this.eventData[index].envRadio === "CUSTOMIZE_ENV";
|
||||
},
|
||||
viewGroup() {
|
||||
this.visible = true;
|
||||
},
|
||||
getgroups(){
|
||||
if (!this.hasOptionGroup){
|
||||
environmentGetALL().then(res => {
|
||||
getgroups() {
|
||||
if (!this.hasOptionGroup) {
|
||||
environmentGetALL().then((res) => {
|
||||
let data = res.data;
|
||||
this.groups = data ? data : [];
|
||||
})
|
||||
});
|
||||
} else {
|
||||
getEnvironmentOptions({projectIds: [...this.projectIds]}).then(res => {
|
||||
let groups = res.data;
|
||||
this.disabledGroups = groups.filter(group => group.disabled === true);
|
||||
this.notDisabledGroups = groups.filter(group => group.disabled === false);
|
||||
this.$set(this.groups, 0, {
|
||||
label: this.$t('workspace.env_group.available_group'),
|
||||
options: this.notDisabledGroups
|
||||
});
|
||||
this.$set(this.groups, 1, {
|
||||
label: this.$t('workspace.env_group.not_available_group'),
|
||||
options: this.disabledGroups
|
||||
});
|
||||
})
|
||||
getEnvironmentOptions({ projectIds: [...this.projectIds] }).then(
|
||||
(res) => {
|
||||
let groups = res.data;
|
||||
this.disabledGroups = groups.filter(
|
||||
(group) => group.disabled === true
|
||||
);
|
||||
this.notDisabledGroups = groups.filter(
|
||||
(group) => group.disabled === false
|
||||
);
|
||||
this.$set(this.groups, 0, {
|
||||
label: this.$t("workspace.env_group.available_group"),
|
||||
options: this.notDisabledGroups,
|
||||
});
|
||||
this.$set(this.groups, 1, {
|
||||
label: this.$t("workspace.env_group.not_available_group"),
|
||||
options: this.disabledGroups,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
},
|
||||
chooseEnv(val){
|
||||
let filter = this.evnList.filter(e => e.id === val);
|
||||
this.selectEnvMap.set(filter[0].projectId,val);
|
||||
this.$emit('setProjectEnvMap', this.selectEnvMap);
|
||||
chooseEnv(val) {
|
||||
let filter = this.evnList.filter((e) => e.id === val);
|
||||
this.selectEnvMap.set(filter[0].projectId, val);
|
||||
this.$emit("setProjectEnvMap", this.selectEnvMap);
|
||||
},
|
||||
chooseEnvGroup(envGroupId){
|
||||
chooseEnvGroup(envGroupId) {
|
||||
this.$emit("setEnvGroup", envGroupId);
|
||||
},
|
||||
initDefaultEnv(){
|
||||
initDefaultEnv() {
|
||||
this.selectedEnvName = new Map();
|
||||
this.evnList = [];
|
||||
this.projectIds.forEach(d => {
|
||||
let item = {id: d, envs: [], selectEnv: "",envRadio:"DEFAULT_ENV",showEnvSelect:false,expendStatus:"open"};
|
||||
this.projectIds.forEach((d) => {
|
||||
let item = {
|
||||
id: d,
|
||||
envs: [],
|
||||
selectEnv: "",
|
||||
envRadio: "DEFAULT_ENV",
|
||||
showEnvSelect: false,
|
||||
expendStatus: "open",
|
||||
};
|
||||
this.eventData.push(item);
|
||||
getEnvironmentByProjectId(d)
|
||||
.then(res => {
|
||||
let envs = res.data;
|
||||
envs.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
// 固定环境列表渲染顺序
|
||||
let temp = this.eventData.find(dt => dt.id === d);
|
||||
temp.envs = envs;
|
||||
envs.forEach(t=>{
|
||||
this.evnList.push(t);
|
||||
})
|
||||
if (this.envMap && this.envMap.size > 0) {
|
||||
let envId = this.envMap.get(id);
|
||||
// 选中环境是否存在
|
||||
temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId;
|
||||
}
|
||||
if (this.projectEnvMap && Object.keys(this.projectEnvMap).length > 0) {
|
||||
let projectEnvMapElement = this.projectEnvMap[d];
|
||||
if (projectEnvMapElement.length>0) {
|
||||
projectEnvMapElement.forEach(envId => {
|
||||
let filter = envs.filter(e => e.id === envId);
|
||||
if (!this.selectedEnvName.has(d)) {
|
||||
let name = [];
|
||||
name.push(filter[0].name)
|
||||
this.selectedEnvName.set(d,name);
|
||||
} else {
|
||||
this.selectedEnvName.get(d).push(filter[0].name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
getEnvironmentByProjectId(d).then((res) => {
|
||||
let envs = res.data;
|
||||
envs.forEach((environment) => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
})
|
||||
// 固定环境列表渲染顺序
|
||||
let temp = this.eventData.find((dt) => dt.id === d);
|
||||
temp.envs = envs;
|
||||
envs.forEach((t) => {
|
||||
this.evnList.push(t);
|
||||
});
|
||||
if (this.envMap && this.envMap.size > 0) {
|
||||
let envId = this.envMap.get(id);
|
||||
// 选中环境是否存在
|
||||
temp.selectEnv =
|
||||
envs.filter((e) => e.id === envId).length === 0 ? null : envId;
|
||||
}
|
||||
if (
|
||||
this.projectEnvMap &&
|
||||
Object.keys(this.projectEnvMap).length > 0
|
||||
) {
|
||||
let projectEnvMapElement = this.projectEnvMap[d];
|
||||
if (projectEnvMapElement.length > 0) {
|
||||
projectEnvMapElement.forEach((envId) => {
|
||||
let filter = envs.filter((e) => e.id === envId);
|
||||
if (!this.selectedEnvName.has(d)) {
|
||||
let name = [];
|
||||
name.push(filter[0].name);
|
||||
this.selectedEnvName.set(d, name);
|
||||
} else {
|
||||
this.selectedEnvName.get(d).push(filter[0].name);
|
||||
}
|
||||
this.chooseEnv(filter[0].id);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
expandCard(index){
|
||||
expandCard(index) {
|
||||
if (this.eventData[index].expendStatus === "open") {
|
||||
this.eventData[index].expendStatus = "close"
|
||||
}else {
|
||||
this.eventData[index].expendStatus = "open"
|
||||
this.eventData[index].expendStatus = "close";
|
||||
} else {
|
||||
this.eventData[index].expendStatus = "open";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mode-span{
|
||||
.mode-span {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
<style lang="scss" scoped>
|
||||
.radio-change:deep(.el-radio__input.is-checked + .el-radio__label) {
|
||||
color: #606266 !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user