fix(测试用例): 用例模板中带有多选下拉框自定义字段时导入报错

--bug=1007126 --user=lyh 【github#6699】用例模板中带有多选下拉框自定义字段时导入报错
https://www.tapd.cn/55049933/s/1059014
This commit is contained in:
shiziyuan9527 2021-10-26 11:37:14 +08:00 committed by shiziyuan9527
parent 74f89d8597
commit 53c41126da
2 changed files with 13 additions and 1 deletions

View File

@ -58,6 +58,11 @@ export function parseCustomField(data, template, customFieldForm, rules, oldFiel
for (let i = 0; i < data.customFields.length; i++) { for (let i = 0; i < data.customFields.length; i++) {
let customField = data.customFields[i]; let customField = data.customFields[i];
if (customField.name === item.name) { if (customField.name === item.name) {
if (customField.type === 'multipleSelect') {
if (typeof (customField.value) === 'string' || customField.value instanceof String) {
customField.value = JSON.parse(customField.value);
}
}
setDefaultValue(item, customField.value); setDefaultValue(item, customField.value);
break; break;
} }

View File

@ -469,7 +469,12 @@ export function getCustomFieldValue(row, field, members) {
else if (['multipleSelect', 'checkbox'].indexOf(field.type) > -1) { else if (['multipleSelect', 'checkbox'].indexOf(field.type) > -1) {
if (item.value) { if (item.value) {
let values = ''; let values = '';
if (item.value instanceof Array) { try {
if (field.type === 'multipleSelect') {
if (typeof (item.value) === 'string' || item.value instanceof String) {
item.value = JSON.parse(item.value);
}
}
item.value.forEach(v => { item.value.forEach(v => {
for (let j = 0; j < field.options.length; j++) { for (let j = 0; j < field.options.length; j++) {
let option = field.options[j]; let option = field.options[j];
@ -480,6 +485,8 @@ export function getCustomFieldValue(row, field, members) {
} }
} }
}); });
} catch (e) {
values = '';
} }
return values; return values;
} }