feat(测试计划): 负责人支持多个#1002991

--story=1002991 --user=lyh 19.测试计划的负责人允许输入多个人名
https://www.tapd.cn/55049933/s/1051258
This commit is contained in:
shiziyuan9527 2021-09-24 15:20:56 +08:00 committed by shiziyuan9527
parent 8df24cd6b5
commit 2faae8df24
12 changed files with 687 additions and 46 deletions

View File

@ -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;
}

View File

@ -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<Criteria> oredCriteria;
public TestPlanPrincipalExample() {
oredCriteria = new ArrayList<Criteria>();
}
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<Criteria> 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<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> 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<String> values) {
addCriterion("test_plan_id in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotIn(List<String> 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<String> values) {
addCriterion("principal_id in", values, "principalId");
return (Criteria) this;
}
public Criteria andPrincipalIdNotIn(List<String> 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);
}
}
}

View File

@ -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<TestPlanPrincipal> selectByExample(TestPlanPrincipalExample example);
int updateByExampleSelective(@Param("record") TestPlanPrincipal record, @Param("example") TestPlanPrincipalExample example);
int updateByExample(@Param("record") TestPlanPrincipal record, @Param("example") TestPlanPrincipalExample example);
}

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.TestPlanPrincipalMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestPlanPrincipal">
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
<result column="principal_id" jdbcType="VARCHAR" property="principalId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
test_plan_id, principal_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanPrincipalExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from test_plan_principal
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestPlanPrincipalExample">
delete from test_plan_principal
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanPrincipal">
insert into test_plan_principal (test_plan_id, principal_id)
values (#{testPlanId,jdbcType=VARCHAR}, #{principalId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanPrincipal">
insert into test_plan_principal
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="testPlanId != null">
test_plan_id,
</if>
<if test="principalId != null">
principal_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="testPlanId != null">
#{testPlanId,jdbcType=VARCHAR},
</if>
<if test="principalId != null">
#{principalId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanPrincipalExample" resultType="java.lang.Long">
select count(*) from test_plan_principal
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_principal
<set>
<if test="record.testPlanId != null">
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
</if>
<if test="record.principalId != null">
principal_id = #{record.principalId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_plan_principal
set test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
principal_id = #{record.principalId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
</mapper>

View File

@ -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;
}
}

View File

@ -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<User> getPlanPrincipal(@PathVariable String planId) {
return testPlanService.getPlanPrincipal(planId);
}
}

View File

@ -12,7 +12,7 @@ public class TestPlanDTO extends TestPlanWithBLOBs {
private String projectName;
private String userName;
private List<String> projectIds;
private List<String> principals;
/**
* 定时任务ID
*/

View File

@ -10,4 +10,5 @@ import java.util.List;
@Setter
public class AddTestPlanRequest extends TestPlanWithBLOBs {
private List<String> projectIds;
private List<String> principals;
}

View File

@ -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<String> 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<String> 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<TestPlanPrincipal> 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<TestPlanLoadCase> testPlanLoadCases = testPlanLoadCaseMapper.selectByExample(loadCaseExample);
return !CollectionUtils.isEmpty(testPlanLoadCases);
}
public List<User> getPlanPrincipal(String planId) {
List<User> result = new ArrayList<>();
if (StringUtils.isBlank(planId)) {
return result;
}
TestPlanPrincipalExample example = new TestPlanPrincipalExample();
example.createCriteria().andTestPlanIdEqualTo(planId);
List<TestPlanPrincipal> testPlanPrincipals = testPlanPrincipalMapper.selectByExample(example);
List<String> 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);
}
}

View File

@ -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';

View File

@ -3,33 +3,36 @@
<div>
<el-dialog :close-on-click-modal="false"
:destroy-on-close="true"
:title="operationType === 'edit' ? $t('test_track.plan.edit_plan') : $t('test_track.plan.create_plan')"
:visible.sync="dialogFormVisible"
@close="close"
width="65%">
top="8vh"
width="60%">
<el-form :model="form" :rules="rules" ref="planFrom" v-if="isStepTableAlive">
<el-row>
<el-col :span="8" :offset="1">
<el-row type="flex" :gutter="20">
<el-col :span="12">
<el-form-item
:label="$t('test_track.plan.plan_name')"
:label-width="formLabelWidth"
prop="name">
<el-input v-model="form.name" :placeholder="$t('test_track.plan.input_plan_name')"></el-input>
<el-input v-model="form.name" :placeholder="$t('test_track.plan.input_plan_name')" :size="itemSize"></el-input>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-col :span="12">
<el-form-item :label="$t('commons.tag')" :label-width="formLabelWidth" prop="tag">
<ms-input-tag :currentScenario="form" ref="tag"/>
<ms-input-tag :currentScenario="form" ref="tag" :size="itemSize"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="1">
<el-form-item :label="$t('test_track.plan.plan_principal')" :label-width="formLabelWidth" prop="principal">
<el-select v-model="form.principal" :placeholder="$t('test_track.plan.input_plan_principal')" filterable>
<el-row type="flex" :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('test_track.plan.plan_principal')" :label-width="formLabelWidth" prop="principals">
<el-select v-model="form.principals" :placeholder="$t('test_track.plan.input_plan_principal')"
style="width: 100%;"
filterable multiple :size="itemSize">
<el-option
v-for="(item) in principalOptions"
:key="item.id"
@ -42,7 +45,7 @@
<el-col :span="12">
<el-form-item :label="$t('test_track.plan.plan_stage')" :label-width="formLabelWidth" prop="stage">
<el-select v-model="form.stage" clearable :placeholder="$t('test_track.plan.input_plan_stage')">
<el-select v-model="form.stage" clearable :placeholder="$t('test_track.plan.input_plan_stage')" style="width: 100%;" :size="itemSize">
<el-option :label="$t('test_track.plan.smoke_test')" value="smoke"></el-option>
<el-option :label="$t('test_track.plan.system_test')" value="system"></el-option>
<el-option :label="$t('test_track.plan.regression_test')" value="regression"></el-option>
@ -52,31 +55,31 @@
</el-row>
<!--start:xuxm增加自定义计划开始计划结束时间字段-->
<el-row>
<el-col :span="8" :offset="1">
<el-row type="flex" :gutter="20">
<el-col :span="12">
<el-form-item
:label="$t('test_track.plan.planned_start_time')"
:label-width="formLabelWidth"
prop="plannedStartTime">
<el-date-picker :placeholder="$t('test_track.plan.planned_start_time')" v-model="form.plannedStartTime"
type="datetime" value-format="timestamp"></el-date-picker>
type="datetime" value-format="timestamp" style="width: 100%;"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="11" :offset="2">
<el-col :span="12">
<el-form-item
:label="$t('test_track.plan.planned_end_time')"
:label-width="formLabelWidth"
prop="plannedEndTime">
<el-date-picker :placeholder="$t('test_track.plan.planned_end_time')" v-model="form.plannedEndTime"
type="datetime" value-format="timestamp"></el-date-picker>
type="datetime" value-format="timestamp" style="width: 100%;"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<!--end:xuxm增加自定义计划开始计划结束时间字段-->
<el-row>
<el-col :span="8" :offset="1">
<el-row type="flex" :gutter="20">
<el-col :span="12">
<el-form-item
:label="$t('自动更新状态')"
:label-width="formLabelWidth"
@ -87,8 +90,8 @@
</el-col>
</el-row>
<el-row type="flex" justify="left" style="margin-top: 10px;">
<el-col :span="23" :offset="1">
<el-row type="flex" justify="left" :gutter="20">
<el-col :span="24">
<el-form-item :label="$t('commons.description')" :label-width="formLabelWidth" prop="description">
<el-input v-model="form.description"
type="textarea"
@ -99,8 +102,8 @@
</el-col>
</el-row>
<el-row v-if="operationType === 'edit'" type="flex" justify="left" style="margin-top: 10px;">
<el-col :span="19" :offset="1">
<el-row v-if="operationType === 'edit'" type="flex" justify="left" :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('test_track.plan.plan_status')" :label-width="formLabelWidth" prop="status">
<test-plan-status-button :status="form.status" @statusChange="statusChange"/>
</el-form-item>
@ -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;

View File

@ -26,7 +26,7 @@
</el-table-column>
<el-table-column
v-if="item.id == 'userName'"
prop="userName"
prop="principalName"
:label="$t('test_track.plan.plan_principal')"
show-overflow-tooltip
:key="index">
@ -216,7 +216,7 @@
</template>
</el-table-column>
</el-table>
<header-custom ref="headerCustom" :initTableData="inite" :optionalFields=headerItems
<header-custom ref="headerCustom" :initTableData="init" :optionalFields=headerItems
:type=type></header-custom>
@ -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);