fix(测试跟踪): 功能用例导入下拉框值不显示
--bug=1021996 --user=陈建星 【测试跟踪】github#21366,v1.20.18, 用例模板添加了多个多种类型字段后,导入的用例在web 列表页不可见,但是在脑图模式可见 https://www.tapd.cn/55049933/s/1329992
This commit is contained in:
parent
90e9149e79
commit
3290d22594
|
@ -681,21 +681,27 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||
String customName = customEntry.getKey();
|
||||
CustomFieldDao field = customEntry.getValue();
|
||||
|
||||
String value = null;
|
||||
Object value;
|
||||
String inputValue;
|
||||
if (StringUtils.equals(customName, "status")) {
|
||||
value = data.getStatus();
|
||||
inputValue = data.getStatus();
|
||||
} else if (StringUtils.equals(customName, "priority")) {
|
||||
value = data.getPriority();
|
||||
inputValue = data.getPriority();
|
||||
} else if (StringUtils.equals(customName, "maintainer")) {
|
||||
value = data.getMaintainer();
|
||||
inputValue = data.getMaintainer();
|
||||
} else {
|
||||
value = data.getCustomDatas().get(customName);
|
||||
inputValue = data.getCustomDatas().get(customName);
|
||||
}
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
value = "";
|
||||
if (StringUtils.isEmpty(inputValue)) {
|
||||
inputValue = StringUtils.EMPTY;
|
||||
}
|
||||
if (field.getType().equalsIgnoreCase("multipleSelect")) {
|
||||
value = modifyMultipleSelectPattern(value);
|
||||
value = inputValue;
|
||||
|
||||
if (StringUtils.equalsAnyIgnoreCase(field.getType(), "multipleSelect", "multipleInput")) {
|
||||
value = modifyMultipleSelectPattern(field, inputValue);
|
||||
}
|
||||
if (StringUtils.equalsAnyIgnoreCase(field.getType(), "select")) {
|
||||
value = parseText2Value(field, inputValue);
|
||||
}
|
||||
JSONObject statusObj = new JSONObject();
|
||||
statusObj.put("id", UUID.randomUUID().toString());
|
||||
|
@ -708,29 +714,44 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||
return customArr.toJSONString();
|
||||
}
|
||||
|
||||
private String parseText2Value(CustomFieldDao field, String inputValue) {
|
||||
String optionsStr = field.getOptions();
|
||||
if (StringUtils.isNotBlank(optionsStr)) {
|
||||
List<JSONObject> options = JSONArray.parseArray(optionsStr, JSONObject.class);
|
||||
for (JSONObject option : options) {
|
||||
if (StringUtils.equals(option.getString("text"), inputValue)) {
|
||||
return option.getString("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
return inputValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整自定义多选下拉框格式,便于前端进行解析。
|
||||
* 例如对于:下拉值1,下拉值2。将调整为:["下拉值1","下拉值2"]。
|
||||
*/
|
||||
public String modifyMultipleSelectPattern(String values) {
|
||||
public List modifyMultipleSelectPattern(CustomFieldDao field, String values) {
|
||||
List<String> result = new ArrayList<>();
|
||||
try {
|
||||
if (StringUtils.isNotBlank(values)) {
|
||||
JSONArray array = JSONArray.parseArray(values);
|
||||
return array.toJSONString();
|
||||
result = JSONArray.parseArray(values, String.class);
|
||||
}
|
||||
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 "[]";
|
||||
if (values.startsWith("[")) {
|
||||
values = values.substring(1);
|
||||
}
|
||||
if (values.endsWith("]")) {
|
||||
values = values.substring(0, values.length() - 1);
|
||||
}
|
||||
result = Arrays.asList(values.split("[,;,;]")); //当标签值以中英文的逗号和分号分隔时才能正确解析
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
result.set(i, parseText2Value(field, result.get(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<el-form-item
|
||||
:placeholder="$t('test_track.case.input_name')"
|
||||
:label="$t('test_track.case.name')"
|
||||
:label-width="formLabelWidth"
|
||||
prop="name">
|
||||
<el-input
|
||||
v-model="form.name"
|
||||
|
@ -22,6 +23,7 @@
|
|||
|
||||
<el-row>
|
||||
<el-form-item :label="$t('test_track.case.module')" prop="module"
|
||||
:label-width="formLabelWidth"
|
||||
v-if="!publicEnable">
|
||||
<ms-select-tree :disabled="readOnly" :data="treeNodes" :defaultKey="form.module" :obj="moduleObj"
|
||||
@getValue="setModule" clearable checkStrictly size="small"/>
|
||||
|
@ -30,6 +32,7 @@
|
|||
|
||||
<el-row>
|
||||
<el-form-item :label="$t('test_track.case.project')" prop="projectId"
|
||||
:label-width="formLabelWidth"
|
||||
v-if="publicEnable">
|
||||
<el-select v-model="form.projectId" filterable clearable>
|
||||
<el-option v-for="item in projectList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
|
@ -38,7 +41,8 @@
|
|||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-form-item :label="$t('commons.tag')" prop="tags">
|
||||
<el-form-item :label="$t('commons.tag')" prop="tags"
|
||||
:label-width="formLabelWidth">
|
||||
<ms-input-tag :read-only="readOnly" :currentScenario="form" v-if="showInputTag" ref="tag"
|
||||
class="ms-case-input"></ms-input-tag>
|
||||
</el-form-item>
|
||||
|
@ -51,11 +55,13 @@
|
|||
<custom-filed-form-row :form="customFieldForm"
|
||||
:disabled="readOnly"
|
||||
:default-open="defaultOpen"
|
||||
:form-label-width="formLabelWidth"
|
||||
:issue-template="testCaseTemplate"/>
|
||||
</el-form>
|
||||
|
||||
<el-row v-if="isCustomNum">
|
||||
<el-form-item label="ID" prop="customNum">
|
||||
<el-form-item label="ID" prop="customNum"
|
||||
:label-width="formLabelWidth">
|
||||
<el-input :disabled="readOnly" v-model.trim="form.customNum" size="small"
|
||||
class="ms-case-input"></el-input>
|
||||
</el-form-item>
|
||||
|
@ -80,6 +86,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
formLabelWidth: '120px',
|
||||
rules: {
|
||||
name: [
|
||||
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
|
||||
|
|
|
@ -548,7 +548,9 @@ export function getCustomFieldValue(row, field, members) {
|
|||
* @returns {*[]|*}
|
||||
*/
|
||||
export function parseMultipleInputToArray(mulInputStr) {
|
||||
if (mulInputStr.indexOf(",")) {
|
||||
if (mulInputStr instanceof Array) {
|
||||
return mulInputStr;
|
||||
} else if (mulInputStr.indexOf(",")) {
|
||||
return mulInputStr.split(",")
|
||||
} else if (mulInputStr.indexOf(";")) {
|
||||
return mulInputStr.split(";")
|
||||
|
|
Loading…
Reference in New Issue