fix(功能用例):测试用例导入多选下拉框解析问题
--bug=1008163 --user=李敏 【测试跟踪】测试用例导入有console报错,多选下拉框没有值 https://www.tapd.cn/55049933/s/1108286
This commit is contained in:
parent
f0c87dc5f2
commit
67c35411df
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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