fix(功能用例):测试用例导入多选下拉框解析问题
--bug=1008163 --user=李敏 【测试跟踪】测试用例导入有console报错,多选下拉框没有值 https://www.tapd.cn/55049933/s/1108286
This commit is contained in:
parent
02098a2f65
commit
89a596c437
|
@ -511,7 +511,6 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public String getSteps(TestCaseExcelData data) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
||||
|
@ -696,7 +695,9 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||
if (StringUtils.isEmpty(value)) {
|
||||
value = "";
|
||||
}
|
||||
|
||||
if (field.getType().equalsIgnoreCase("multipleSelect")) {
|
||||
value = modifyMultipleSelectPattern(value);
|
||||
}
|
||||
JSONObject statusObj = new JSONObject();
|
||||
statusObj.put("id", UUID.randomUUID().toString());
|
||||
statusObj.put("name", field.getName());
|
||||
|
@ -708,6 +709,31 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||
return customArr.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整自定义多选下拉框格式,便于前端进行解析。
|
||||
* 例如对于:下拉值1,下拉值2。将调整为:["下拉值1","下拉值2"]。
|
||||
*/
|
||||
public String modifyMultipleSelectPattern(String values) {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(values)) {
|
||||
JSONArray array = JSONArray.parseArray(values);
|
||||
return array.toJSONString();
|
||||
}
|
||||
return "[]";
|
||||
} catch (Exception e) {
|
||||
if (values != null) {
|
||||
Stream<String> stringStream = Arrays.stream(values.split("[,;,;]")); //当标签值以中英文的逗号和分号分隔时才能正确解析
|
||||
List<String> valueList = stringStream.map(multip -> multip = "\"" + multip + "\"")
|
||||
.collect(Collectors.toList());
|
||||
String modifiedValues = StringUtils.join(valueList, ",");
|
||||
modifiedValues = "[" + modifiedValues + "]";
|
||||
return modifiedValues;
|
||||
} else {
|
||||
return "[]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取注解里ExcelProperty的value
|
||||
*/
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7e6272ea7fe3f835c3698ba06efa0168f6403f26
|
||||
Subproject commit d890a8cffc940ba39512f97ec33f66ac1ccd4fc5
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<ms-table
|
||||
v-loading="cardResult.loading"
|
||||
operator-width="170px"
|
||||
operator-width="220px"
|
||||
row-key="id"
|
||||
:data="tableData"
|
||||
:condition="condition"
|
||||
|
|
Loading…
Reference in New Issue