diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 72b9faa7f2..a4cde4d18a 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -218,7 +218,9 @@ public class TestCaseService { testCaseMapper.insert(request); saveFollows(request.getId(), request.getFollows()); - customFieldTestCaseService.addFields(request.getId(), request.getAddFields()); + List addFields = request.getAddFields(); + addFields.addAll(request.getEditFields()); + customFieldTestCaseService.addFields(request.getId(), addFields); return request; } diff --git a/frontend/src/business/components/common/components/form/CustomFiledFormRow.vue b/frontend/src/business/components/common/components/form/CustomFiledFormRow.vue index 257549fcb9..c94828c3b1 100644 --- a/frontend/src/business/components/common/components/form/CustomFiledFormRow.vue +++ b/frontend/src/business/components/common/components/form/CustomFiledFormRow.vue @@ -57,7 +57,7 @@ export default { let total = 0;//定义total用于控制循环结束 let customFields = this.issueTemplate.customFields; for (let i = 0; total < customFields.length; total++) { - if (customFields[i].type === 'input' && typeof (customFields[i].defaultValue) === 'string' || customFields[i].defaultValue instanceof String) { + if (typeof (customFields[i].defaultValue) === 'string' || customFields[i].defaultValue instanceof String) { try { customFields[i].defaultValue = JSON.parse(customFields[i].defaultValue); } catch (e) { diff --git a/frontend/src/common/js/custom_field.js b/frontend/src/common/js/custom_field.js index 91332d31ad..b74c3ca585 100644 --- a/frontend/src/common/js/custom_field.js +++ b/frontend/src/common/js/custom_field.js @@ -28,7 +28,13 @@ export function parseCustomField(data, template, rules, oldFields) { template.customFields.forEach(item => { if (item.defaultValue && !item.hasParse) { - setDefaultValue(item, JSON.parse(item.defaultValue)); + let val = item.defaultValue; + try { + val = JSON.parse(item.defaultValue); + } catch (e) { + // + } + setDefaultValue(item, val); } // 添加自定义字段必填校验