fix(测试跟踪): 用例列表导入多选输入字段时, 解析值有误

[BUG]v1.20.18, 用例模板添加了多个多种类型字段后,导入的用例在web 列表页不可见,但是在脑图模式可见github#21366, https://github.com/metersphere/metersphere/issues/21366
This commit is contained in:
song-cc-rock 2023-01-16 16:52:22 +08:00 committed by fit2-zhao
parent 47be0a89c0
commit cb2807c840
1 changed files with 29 additions and 4 deletions

View File

@ -544,11 +544,13 @@ export function getCustomFieldValue(row, field, members) {
return val; return val;
} else if (field.type === 'multipleInput') { } else if (field.type === 'multipleInput') {
let val = ''; let val = '';
if (item.value instanceof Array) { if (!item.value || item.value === '') {
item.value.forEach(i => { return val;
val += i + ' ';
});
} }
let mulArr = parseMultipleInputToArray(item.value)
mulArr.forEach(i => {
val += i + ' ';
});
return val; return val;
} else if (field.type === 'datetime' || field.type === 'date') { } else if (field.type === 'datetime' || field.type === 'date') {
return datetimeFormat(item.value); return datetimeFormat(item.value);
@ -561,6 +563,29 @@ export function getCustomFieldValue(row, field, members) {
} }
} }
/**
* 多值输入值解析, 按照导入规则括号中字符可解析[, ; |]
* @param mulInputStr
* @returns {*[]|*}
*/
export function parseMultipleInputToArray(mulInputStr) {
if (mulInputStr.indexOf(",")) {
return mulInputStr.split(",")
} else if (mulInputStr.indexOf(";")) {
return mulInputStr.split(";")
} else if (mulInputStr.indexOf("")) {
return mulInputStr.split("")
} else if (mulInputStr.indexOf("")) {
return mulInputStr.split("")
} else if (mulInputStr.indexOf("|")) {
return mulInputStr.split("|")
} else {
let mulArr = [];
mulArr.push(mulInputStr)
return mulArr;
}
}
/** /**
* 获取批量编辑的自定义字段选项 * 获取批量编辑的自定义字段选项
* @param customFields * @param customFields