diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanPrincipal.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanPrincipal.java new file mode 100644 index 0000000000..57d14eff1f --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanPrincipal.java @@ -0,0 +1,13 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class TestPlanPrincipal implements Serializable { + private String testPlanId; + + private String principalId; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanPrincipalExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanPrincipalExample.java new file mode 100644 index 0000000000..82dccf2e9e --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanPrincipalExample.java @@ -0,0 +1,340 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class TestPlanPrincipalExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public TestPlanPrincipalExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andTestPlanIdIsNull() { + addCriterion("test_plan_id is null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIsNotNull() { + addCriterion("test_plan_id is not null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdEqualTo(String value) { + addCriterion("test_plan_id =", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotEqualTo(String value) { + addCriterion("test_plan_id <>", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThan(String value) { + addCriterion("test_plan_id >", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) { + addCriterion("test_plan_id >=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThan(String value) { + addCriterion("test_plan_id <", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThanOrEqualTo(String value) { + addCriterion("test_plan_id <=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLike(String value) { + addCriterion("test_plan_id like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotLike(String value) { + addCriterion("test_plan_id not like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIn(List values) { + addCriterion("test_plan_id in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotIn(List values) { + addCriterion("test_plan_id not in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdBetween(String value1, String value2) { + addCriterion("test_plan_id between", value1, value2, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotBetween(String value1, String value2) { + addCriterion("test_plan_id not between", value1, value2, "testPlanId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdIsNull() { + addCriterion("principal_id is null"); + return (Criteria) this; + } + + public Criteria andPrincipalIdIsNotNull() { + addCriterion("principal_id is not null"); + return (Criteria) this; + } + + public Criteria andPrincipalIdEqualTo(String value) { + addCriterion("principal_id =", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdNotEqualTo(String value) { + addCriterion("principal_id <>", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdGreaterThan(String value) { + addCriterion("principal_id >", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdGreaterThanOrEqualTo(String value) { + addCriterion("principal_id >=", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdLessThan(String value) { + addCriterion("principal_id <", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdLessThanOrEqualTo(String value) { + addCriterion("principal_id <=", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdLike(String value) { + addCriterion("principal_id like", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdNotLike(String value) { + addCriterion("principal_id not like", value, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdIn(List values) { + addCriterion("principal_id in", values, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdNotIn(List values) { + addCriterion("principal_id not in", values, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdBetween(String value1, String value2) { + addCriterion("principal_id between", value1, value2, "principalId"); + return (Criteria) this; + } + + public Criteria andPrincipalIdNotBetween(String value1, String value2) { + addCriterion("principal_id not between", value1, value2, "principalId"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanPrincipalMapper.java b/backend/src/main/java/io/metersphere/base/mapper/TestPlanPrincipalMapper.java new file mode 100644 index 0000000000..09a94a42d9 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanPrincipalMapper.java @@ -0,0 +1,22 @@ +package io.metersphere.base.mapper; + +import io.metersphere.base.domain.TestPlanPrincipal; +import io.metersphere.base.domain.TestPlanPrincipalExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface TestPlanPrincipalMapper { + long countByExample(TestPlanPrincipalExample example); + + int deleteByExample(TestPlanPrincipalExample example); + + int insert(TestPlanPrincipal record); + + int insertSelective(TestPlanPrincipal record); + + List selectByExample(TestPlanPrincipalExample example); + + int updateByExampleSelective(@Param("record") TestPlanPrincipal record, @Param("example") TestPlanPrincipalExample example); + + int updateByExample(@Param("record") TestPlanPrincipal record, @Param("example") TestPlanPrincipalExample example); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanPrincipalMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanPrincipalMapper.xml new file mode 100644 index 0000000000..d6dfbffb90 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanPrincipalMapper.xml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + test_plan_id, principal_id + + + + delete from test_plan_principal + + + + + + insert into test_plan_principal (test_plan_id, principal_id) + values (#{testPlanId,jdbcType=VARCHAR}, #{principalId,jdbcType=VARCHAR}) + + + insert into test_plan_principal + + + test_plan_id, + + + principal_id, + + + + + #{testPlanId,jdbcType=VARCHAR}, + + + #{principalId,jdbcType=VARCHAR}, + + + + + + update test_plan_principal + + + test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + + + principal_id = #{record.principalId,jdbcType=VARCHAR}, + + + + + + + + update test_plan_principal + set test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + principal_id = #{record.principalId,jdbcType=VARCHAR} + + + + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/service/TestPlanPrincipalService.java b/backend/src/main/java/io/metersphere/service/TestPlanPrincipalService.java new file mode 100644 index 0000000000..e6dce1499b --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/TestPlanPrincipalService.java @@ -0,0 +1,33 @@ +package io.metersphere.service; + +import io.metersphere.base.domain.TestPlanPrincipal; +import io.metersphere.base.domain.TestPlanPrincipalExample; +import io.metersphere.base.mapper.TestPlanPrincipalMapper; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; + +@Service +@Transactional(rollbackFor = Exception.class) +public class TestPlanPrincipalService { + + @Resource + private TestPlanPrincipalMapper testPlanPrincipalMapper; + + + public void deleteTestPlanPrincipalByPlanId(String planId) { + if (StringUtils.isBlank(planId)) { + return; + } + TestPlanPrincipalExample example = new TestPlanPrincipalExample(); + example.createCriteria().andTestPlanIdEqualTo(planId); + testPlanPrincipalMapper.deleteByExample(example); + } + + public TestPlanPrincipal insert(TestPlanPrincipal testPlanPrincipal) { + testPlanPrincipalMapper.insert(testPlanPrincipal); + return testPlanPrincipal; + } +} diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 5e1f54af8e..4a072663a1 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -5,10 +5,7 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest; import io.metersphere.api.service.ApiAutomationService; -import io.metersphere.base.domain.Project; -import io.metersphere.base.domain.Schedule; -import io.metersphere.base.domain.TestPlan; -import io.metersphere.base.domain.TestPlanWithBLOBs; +import io.metersphere.base.domain.*; import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.PermissionConstants; @@ -107,8 +104,8 @@ public class TestPlanController { @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT) @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanDTO.id)", content = "#msClass.getLogDetails(#testPlanDTO.id)", msClass = TestPlanService.class) @SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.UPDATE, mailTemplate = "track/TestPlanEnd", subject = "测试计划通知") - public TestPlan editTestPlan(@RequestBody TestPlanDTO testPlanDTO) { - return testPlanService.editTestPlan(testPlanDTO); + public TestPlan editTestPlan(@RequestBody AddTestPlanRequest testPlanDTO) { + return testPlanService.editTestPlanWithRequest(testPlanDTO); } @PostMapping("/edit/status/{planId}") @@ -259,4 +256,9 @@ public class TestPlanController { public boolean haveExecCase(@PathVariable String id) { return testPlanService.haveExecCase(id); } + + @GetMapping("/principal/{planId}") + public List getPlanPrincipal(@PathVariable String planId) { + return testPlanService.getPlanPrincipal(planId); + } } diff --git a/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java index b16f00970e..1394765eeb 100644 --- a/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java @@ -12,7 +12,7 @@ public class TestPlanDTO extends TestPlanWithBLOBs { private String projectName; private String userName; private List projectIds; - + private List principals; /** * 定时任务ID */ diff --git a/backend/src/main/java/io/metersphere/track/request/testplan/AddTestPlanRequest.java b/backend/src/main/java/io/metersphere/track/request/testplan/AddTestPlanRequest.java index 76ce3b8f3d..d538e4c957 100644 --- a/backend/src/main/java/io/metersphere/track/request/testplan/AddTestPlanRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testplan/AddTestPlanRequest.java @@ -10,4 +10,5 @@ import java.util.List; @Setter public class AddTestPlanRequest extends TestPlanWithBLOBs { private List projectIds; + private List principals; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index b91ec9fed5..d63005b1de 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -50,6 +50,7 @@ import io.metersphere.plugin.core.MsTestElement; import io.metersphere.service.IssueTemplateService; import io.metersphere.service.ScheduleService; import io.metersphere.service.SystemParameterService; +import io.metersphere.service.TestPlanPrincipalService; import io.metersphere.track.Factory.ReportComponentFactory; import io.metersphere.track.domain.ReportComponent; import io.metersphere.track.dto.*; @@ -183,6 +184,10 @@ public class TestPlanService { private PerformanceReportService performanceReportService; @Resource private MetricQueryService metricQueryService; + @Resource + private TestPlanPrincipalService testPlanPrincipalService; + @Resource + private TestPlanPrincipalMapper testPlanPrincipalMapper; private final ExecutorService executorService = Executors.newFixedThreadPool(20); @@ -194,6 +199,16 @@ public class TestPlanService { testPlan.setCreateTime(System.currentTimeMillis()); testPlan.setUpdateTime(System.currentTimeMillis()); testPlan.setCreator(SessionUtils.getUser().getId()); + + String planId = testPlan.getId(); + List principals = testPlan.getPrincipals(); + for (String principal : principals) { + TestPlanPrincipal testPlanPrincipal = new TestPlanPrincipal(); + testPlanPrincipal.setTestPlanId(planId); + testPlanPrincipal.setPrincipalId(principal); + testPlanPrincipalService.insert(testPlanPrincipal); + } + if (StringUtils.isBlank(testPlan.getProjectId())) { testPlan.setProjectId(SessionUtils.getCurrentProjectId()); } @@ -214,6 +229,22 @@ public class TestPlanService { return Optional.ofNullable(testPlanMapper.selectByPrimaryKey(testPlanId)).orElse(new TestPlanWithBLOBs()); } + public TestPlan editTestPlanWithRequest(AddTestPlanRequest request) { + List principals = request.getPrincipals(); + if (!CollectionUtils.isEmpty(principals)) { + if (StringUtils.isNotBlank(request.getId())) { + testPlanPrincipalService.deleteTestPlanPrincipalByPlanId(request.getId()); + for (String principal : principals) { + TestPlanPrincipal testPlanPrincipal = new TestPlanPrincipal(); + testPlanPrincipal.setTestPlanId(request.getId()); + testPlanPrincipal.setPrincipalId(principal); + testPlanPrincipalService.insert(testPlanPrincipal); + } + } + } + return this.editTestPlan(request); + } + public TestPlan editTestPlan(TestPlanWithBLOBs testPlan) { checkTestPlanExist(testPlan); TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库 @@ -326,6 +357,7 @@ public class TestPlanService { } public int deleteTestPlan(String planId) { + testPlanPrincipalService.deleteTestPlanPrincipalByPlanId(planId); deleteTestCaseByPlanId(planId); testPlanApiCaseService.deleteByPlanId(planId); testPlanScenarioCaseService.deleteByPlanId(planId); @@ -1243,7 +1275,6 @@ public class TestPlanService { targetPlan.setWorkspaceId(testPlan.getWorkspaceId()); targetPlan.setDescription(testPlan.getDescription()); targetPlan.setStage(testPlan.getStage()); - targetPlan.setPrincipal(testPlan.getPrincipal()); targetPlan.setTags(testPlan.getTags()); targetPlan.setProjectId(testPlan.getProjectId()); testPlan.setAutomaticStatusUpdate(testPlan.getAutomaticStatusUpdate()); @@ -1253,11 +1284,26 @@ public class TestPlanService { targetPlan.setUpdateTime(System.currentTimeMillis()); testPlanMapper.insert(targetPlan); + copyPlanPrincipal(targetPlanId, planId); copyPlanCase(sourcePlanId, targetPlanId); return targetPlan; } + private void copyPlanPrincipal(String targetPlanId, String sourcePlanId) { + TestPlanPrincipalExample example = new TestPlanPrincipalExample(); + example.createCriteria().andTestPlanIdEqualTo(sourcePlanId); + List testPlanPrincipals = testPlanPrincipalMapper.selectByExample(example); + if (!CollectionUtils.isEmpty(testPlanPrincipals)) { + for (TestPlanPrincipal tpp : testPlanPrincipals) { + TestPlanPrincipal testPlanPrincipal = new TestPlanPrincipal(); + testPlanPrincipal.setPrincipalId(tpp.getPrincipalId()); + testPlanPrincipal.setTestPlanId(targetPlanId); + testPlanPrincipalMapper.insert(testPlanPrincipal); + } + } + } + @Transactional(rollbackFor = Exception.class) public void copyPlanCase(String sourcePlanId, String targetPlanId) { TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample(); @@ -1992,4 +2038,21 @@ public class TestPlanService { List testPlanLoadCases = testPlanLoadCaseMapper.selectByExample(loadCaseExample); return !CollectionUtils.isEmpty(testPlanLoadCases); } + + public List getPlanPrincipal(String planId) { + List result = new ArrayList<>(); + if (StringUtils.isBlank(planId)) { + return result; + } + TestPlanPrincipalExample example = new TestPlanPrincipalExample(); + example.createCriteria().andTestPlanIdEqualTo(planId); + List testPlanPrincipals = testPlanPrincipalMapper.selectByExample(example); + List userIds = testPlanPrincipals.stream().map(TestPlanPrincipal::getPrincipalId).distinct().collect(Collectors.toList()); + if (CollectionUtils.isEmpty(userIds)) { + return result; + } + UserExample userExample = new UserExample(); + userExample.createCriteria().andIdIn(userIds); + return userMapper.selectByExample(userExample); + } } diff --git a/backend/src/main/resources/db/migration/V96__v1.13.1__release.sql b/backend/src/main/resources/db/migration/V96__v1.13.1__release.sql index c22ced36b7..9937736e26 100644 --- a/backend/src/main/resources/db/migration/V96__v1.13.1__release.sql +++ b/backend/src/main/resources/db/migration/V96__v1.13.1__release.sql @@ -1,4 +1,18 @@ CREATE INDEX load_test_report_test_resource_pool_id_index ON load_test_report (test_resource_pool_id); + + +create table if not exists test_plan_principal +( + test_plan_id varchar(50) null, + principal_id varchar(50) null, + constraint test_plan_principal_pk + unique (test_plan_id, principal_id) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci; + +insert into test_plan_principal(test_plan_id, principal_id) select id test_plan_id, principal principal_id from test_plan; +alter table test_plan modify principal varchar(50) null comment 'Plan principal'; + + ALTER TABLE test_case_review_test_case ADD `order` bigint(20) NOT NULL COMMENT '自定义排序,间隔5000'; diff --git a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue index 74a0388a3e..19bff06c69 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue @@ -3,33 +3,36 @@
+ top="8vh" + width="60%"> - - - + + - + - + - + - - - - + + + + - + @@ -52,31 +55,31 @@ - - + + + type="datetime" value-format="timestamp" style="width: 100%;"> - + + type="datetime" value-format="timestamp" style="width: 100%;"> - - + + - - + + - - + + @@ -147,10 +150,11 @@ export default { return { isStepTableAlive: true, dialogFormVisible: false, + itemSize: "medium", form: { name: '', projectIds: [], - principal: '', + principals: [], stage: '', description: '', plannedStartTime: '', @@ -162,7 +166,7 @@ export default { {required: true, message: this.$t('test_track.plan.input_plan_name'), trigger: 'blur'}, {max: 30, message: this.$t('test_track.length_less_than') + '30', trigger: 'blur'} ], - principal: [{required: true, message: this.$t('test_track.plan.input_plan_principal'), trigger: 'change'}], + principals: [{required: true, message: this.$t('test_track.plan.input_plan_principal'), trigger: 'change'}], stage: [{required: true, message: this.$t('test_track.plan.input_plan_stage'), trigger: 'change'}], description: [{max: 200, message: this.$t('test_track.length_less_than') + '200', trigger: 'blur'}] }, @@ -174,8 +178,6 @@ export default { created() { //设置“测试阶段”和“负责人”的默认值 this.form.stage = 'smoke'; - const adminToken = JSON.parse(localStorage.getItem("Admin-Token")); - this.form.principal = adminToken.id; }, methods: { reload() { @@ -280,8 +282,8 @@ export default { this.$refs['planFrom'].resetFields(); this.form.name = ''; this.form.projectIds = []; - const adminToken = JSON.parse(localStorage.getItem("Admin-Token")); - this.form.principal = adminToken.id; + this.form.principals = []; + this.form.automaticStatusUpdate = false; this.form.stage = 'smoke'; this.form.description = ''; this.form.status = null; diff --git a/frontend/src/business/components/track/plan/components/TestPlanList.vue b/frontend/src/business/components/track/plan/components/TestPlanList.vue index a2a1f41d64..d3263cab3a 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanList.vue @@ -26,7 +26,7 @@ @@ -216,7 +216,7 @@ - @@ -331,7 +331,7 @@ export default { this.initTableData(); }, methods: { - inite() { + init() { this.initTableData(); }, customHeader() { @@ -358,12 +358,23 @@ export default { item.tags = JSON.parse(item.tags); } item.passRate = item.passRate + '%'; - // if (item.creator) { - // this.$get("user/info/" + item.creator, response => { - // let name = response.data.name; - // item.createUser = name; - // }); - // } + this.$get("/test/plan/principal/" + item.id, res => { + let data = res.data; + let principal = ""; + let principalIds = data.map(d => d.id); + if (data) { + data.forEach(d => { + if (principal !== "") { + principal = principal + "、" + d.name; + } else { + principal = principal + d.name; + } + }) + } + this.$set(item, "principalName", principal); + // 编辑时初始化id + this.$set(item, "principals", principalIds); + }) }); }); getLabel(this, TEST_PLAN_LIST);