From 2b5483dc23b2d7d275fc2ac6363bbeffe36045a4 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 19 Mar 2021 18:04:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E4=BE=8B=E5=AF=BC=E5=85=A5tag?= =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E4=B8=BA=E7=A9=BA=E5=AF=BC=E5=85=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/excel/annotation/NotRequired.java | 9 +++++++++ .../metersphere/excel/domain/TestCaseExcelDataCn.java | 2 ++ .../metersphere/excel/domain/TestCaseExcelDataTw.java | 7 +++++++ .../metersphere/excel/domain/TestCaseExcelDataUs.java | 7 +++++++ .../metersphere/excel/listener/EasyExcelListener.java | 11 ++++++----- .../src/business/components/track/case/TestCase.vue | 1 + .../components/track/common/TestCaseNodeTree.vue | 1 - 7 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/excel/annotation/NotRequired.java diff --git a/backend/src/main/java/io/metersphere/excel/annotation/NotRequired.java b/backend/src/main/java/io/metersphere/excel/annotation/NotRequired.java new file mode 100644 index 0000000000..ba07866442 --- /dev/null +++ b/backend/src/main/java/io/metersphere/excel/annotation/NotRequired.java @@ -0,0 +1,9 @@ +package io.metersphere.excel.annotation; + +import java.lang.annotation.*; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Inherited +public @interface NotRequired { +} diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java index 5bca529228..847dcd845e 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java @@ -2,6 +2,7 @@ package io.metersphere.excel.domain; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; +import io.metersphere.excel.annotation.NotRequired; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -40,6 +41,7 @@ public class TestCaseExcelDataCn extends TestCaseExcelData { @ColumnWidth(50) @ExcelProperty("标签") + @NotRequired @Length(min = 0, max = 1000) private String tags; diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java index 3c9560a051..4137f4e76c 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java @@ -2,6 +2,7 @@ package io.metersphere.excel.domain; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; +import io.metersphere.excel.annotation.NotRequired; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -38,6 +39,12 @@ public class TestCaseExcelDataTw extends TestCaseExcelData { @Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}") private String priority; + @ColumnWidth(50) + @ExcelProperty("標簽") + @NotRequired + @Length(min = 0, max = 1000) + private String tags; + @NotBlank(message = "{cannot_be_null}") @ExcelProperty("測試方式") @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}") diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java index 9dcce7ad83..1795d0545a 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java @@ -2,6 +2,7 @@ package io.metersphere.excel.domain; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; +import io.metersphere.excel.annotation.NotRequired; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -39,6 +40,12 @@ public class TestCaseExcelDataUs extends TestCaseExcelData { @Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}") private String priority; + @ColumnWidth(50) + @ExcelProperty("Tag") + @NotRequired + @Length(min = 0, max = 1000) + private String tags; + @NotBlank(message = "{cannot_be_null}") @ExcelProperty("Method") @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}") diff --git a/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java b/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java index 3f2dbf0326..e96023d90a 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/EasyExcelListener.java @@ -6,15 +6,13 @@ import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.exception.ExcelAnalysisException; import com.alibaba.excel.util.StringUtils; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.excel.annotation.NotRequired; import io.metersphere.excel.domain.ExcelErrData; import io.metersphere.excel.domain.TestCaseExcelData; -import io.metersphere.excel.domain.UserExcelData; import io.metersphere.excel.utils.ExcelValidateHelper; import io.metersphere.i18n.Translator; import java.lang.reflect.Field; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; import java.util.*; public abstract class EasyExcelListener extends AnalysisEventListener { @@ -131,7 +129,10 @@ public abstract class EasyExcelListener extends AnalysisEventListener { for (String v : excelProperty.value()) { value.append(v); } - result.add(value.toString()); + // 检查是否必有的头部信息 + if (field.getAnnotation(NotRequired.class) == null) { + result.add(value.toString()); + } } } return result; @@ -140,4 +141,4 @@ public abstract class EasyExcelListener extends AnalysisEventListener { public List> getErrList() { return errList; } -} \ No newline at end of file +} diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index f3bae0ef40..5dd3b0690f 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -8,6 +8,7 @@ @setTreeNodes="setTreeNodes" @exportTestCase="exportTestCase" @saveAsEdit="editTestCase" + @refreshAll="refreshAll" :type="'edit'" ref="nodeTree" /> diff --git a/frontend/src/business/components/track/common/TestCaseNodeTree.vue b/frontend/src/business/components/track/common/TestCaseNodeTree.vue index ed31d2c7df..37dfbfb333 100644 --- a/frontend/src/business/components/track/common/TestCaseNodeTree.vue +++ b/frontend/src/business/components/track/common/TestCaseNodeTree.vue @@ -101,7 +101,6 @@ export default { this.$emit("refreshTable"); }, refreshAll() { - this.selectRows.clear(); this.$emit('refreshAll'); }, handleCommand(e) {