From cab0a1f73425ca385e5fd96dc21c25e16493764b Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 26 Oct 2021 11:37:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E6=A8=A1=E6=9D=BF=E4=B8=AD=E5=B8=A6=E6=9C=89?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E4=B8=8B=E6=8B=89=E6=A1=86=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=AD=97=E6=AE=B5=E6=97=B6=E5=AF=BC=E5=85=A5=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1007126 --user=lyh 【github#6699】用例模板中带有多选下拉框自定义字段时导入报错 https://www.tapd.cn/55049933/s/1059014 --- frontend/src/common/js/custom_field.js | 5 +++++ frontend/src/common/js/tableUtils.js | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/common/js/custom_field.js b/frontend/src/common/js/custom_field.js index 8f262f71eb..abe03a4d19 100644 --- a/frontend/src/common/js/custom_field.js +++ b/frontend/src/common/js/custom_field.js @@ -58,6 +58,11 @@ export function parseCustomField(data, template, customFieldForm, rules, oldFiel for (let i = 0; i < data.customFields.length; i++) { let customField = data.customFields[i]; 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); break; } diff --git a/frontend/src/common/js/tableUtils.js b/frontend/src/common/js/tableUtils.js index dcfff9b76c..38a1603dbc 100644 --- a/frontend/src/common/js/tableUtils.js +++ b/frontend/src/common/js/tableUtils.js @@ -469,7 +469,12 @@ export function getCustomFieldValue(row, field, members) { else if (['multipleSelect', 'checkbox'].indexOf(field.type) > -1) { if (item.value) { 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 => { for (let j = 0; j < field.options.length; j++) { let option = field.options[j]; @@ -480,6 +485,8 @@ export function getCustomFieldValue(row, field, members) { } } }); + } catch (e) { + values = ''; } return values; }