mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 03:58:33 +08:00
fix(测试跟踪): 功能用例导入多选输入自定义字段后,数据无法显示
--bug=1020905 --user=陈建星 【测试跟踪】导入带自定义字段的用例后列表中不显示,但是左侧模块树中有统计 https://www.tapd.cn/55049933/s/1316327
This commit is contained in:
parent
809d16beb7
commit
585f5bd26e
@ -541,9 +541,11 @@ export function getCustomFieldValue(row, field, members) {
|
||||
return val;
|
||||
} else if (field.type === 'multipleInput') {
|
||||
let val = '';
|
||||
item.value.forEach(i => {
|
||||
val += i + ' ';
|
||||
});
|
||||
if (item.value instanceof Array) {
|
||||
item.value.forEach(i => {
|
||||
val += i + ' ';
|
||||
});
|
||||
}
|
||||
return val;
|
||||
} else if (field.type === 'datetime' || field.type === 'date') {
|
||||
return datetimeFormat(item.value);
|
||||
|
@ -52,11 +52,21 @@ public abstract class AbstractCustomFieldValidator {
|
||||
try {
|
||||
// [a, b] => ["a","b"]
|
||||
if (!StringUtils.equals(value, "[]")) {
|
||||
value = value.replace("[", "[\"")
|
||||
.replace("]", "\"]")
|
||||
.replace(",", "\",\"")
|
||||
.replace(",", "\",\"")
|
||||
.replace(StringUtils.SPACE, StringUtils.EMPTY);
|
||||
if (!value.contains("[\"")) {
|
||||
value = value.replace("[", "[\"");
|
||||
}
|
||||
if (!value.contains("\"]")) {
|
||||
value = value.replace("]", "\"]");
|
||||
|
||||
}
|
||||
if (!value.contains("\",\"")) {
|
||||
value = value.replace(",", "\",\"");
|
||||
|
||||
}
|
||||
if (!value.contains("\",\"")) {
|
||||
value = value.replace(",", "\",\"");
|
||||
}
|
||||
value = value.replace(StringUtils.SPACE, StringUtils.EMPTY);
|
||||
}
|
||||
return JSON.parseArray(value, String.class);
|
||||
} catch (Exception e) {
|
||||
|
@ -1,21 +1,33 @@
|
||||
package io.metersphere.validate;
|
||||
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.exception.CustomFieldValidateException;
|
||||
import io.metersphere.dto.CustomFieldDao;
|
||||
import io.metersphere.exception.CustomFieldValidateException;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class CustomFieldMultipleTextValidator extends AbstractCustomFieldValidator {
|
||||
|
||||
public CustomFieldMultipleTextValidator() {
|
||||
this.isKVOption = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, String value) throws CustomFieldValidateException {
|
||||
validateRequired(customField, value);
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
try {
|
||||
JSON.parseArray(value);
|
||||
parse2Array(customField.getName(), value);
|
||||
} catch (Exception e) {
|
||||
CustomFieldValidateException.throwException(String.format(Translator.get("custom_field_array_tip"), customField.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parse2Key(String keyOrValuesStr, CustomFieldDao customField) {
|
||||
if (StringUtils.isBlank(keyOrValuesStr)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return parse2Array(keyOrValuesStr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user