diff --git a/framework/sdk-parent/frontend/src/utils/custom_field.js b/framework/sdk-parent/frontend/src/utils/custom_field.js index 807efca394..cb2460c22b 100644 --- a/framework/sdk-parent/frontend/src/utils/custom_field.js +++ b/framework/sdk-parent/frontend/src/utils/custom_field.js @@ -105,6 +105,10 @@ export function parseCustomField(data, template, rules, oldFields) { } } + if (item.type === 'int' && item.defaultValue === null) { + // el-input-number 需要设置成 undefined,默认值才能设置为空 + item.defaultValue = undefined; + } customFieldForm[item.name] = item.defaultValue; }); @@ -210,6 +214,10 @@ export function parseCustomFieldForId(data, template, rules, oldFields) { } } + if (item.type === 'int' && item.defaultValue === null) { + // el-input-number 需要设置成 undefined,默认值才能设置为空 + item.defaultValue = undefined; + } customFieldForm[item.id] = item.defaultValue; }); diff --git a/framework/sdk-parent/frontend/src/utils/tableUtils.js b/framework/sdk-parent/frontend/src/utils/tableUtils.js index 452ef7145a..f0bb4e070a 100644 --- a/framework/sdk-parent/frontend/src/utils/tableUtils.js +++ b/framework/sdk-parent/frontend/src/utils/tableUtils.js @@ -535,7 +535,12 @@ export function getCustomFieldValue(row, field, members) { for (let i = 0; i < row.fields.length; i++) { let item = row.fields[i]; if (item.id === field.id) { - if (!item.value) return ''; + if (item.value === 0) { + return '0'; + } + if (!item.value) { + return ''; + } if (item.textValue && item.textValue.startsWith(OPTION_LABEL_PREFIX) && field.options) { // 处理 jira 远程搜索字段 diff --git a/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue b/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue index 68aebdadf7..eb7086d2da 100644 --- a/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue +++ b/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue @@ -208,6 +208,10 @@ export default { } else if (item.type === 'checkbox') { item.defaultValue = []; } + if (item.type === 'int' && item.defaultValue === null) { + // el-input-number 需要设置成 undefined,默认值才能设置为空 + item.defaultValue = undefined; + } this.templateContainIds.add(item.fieldId); }); this.$refs.customFieldFormList.refreshTable(); diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index f839aea39a..ad897f9806 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -175,6 +175,9 @@ public class IssuesService { JSON.parseObject(JSON.toJSONString(issuesRequest), PlatformIssuesUpdateRequest.class); List customFieldItemDTOS = JSON.parseArray(JSON.toJSONString(issuesRequest.getRequestFields()), PlatformCustomFieldItemDTO.class); + customFieldItemDTOS = customFieldItemDTOS.stream() + .filter(item -> item != null && item.getValue() != null) + .toList(); platformIssuesUpdateRequest.setCustomFieldList(customFieldItemDTOS); // todo 全部插件化后去掉 platformIssuesUpdateRequest.setUserPlatformUserConfig(userService.getCurrentPlatformInfoStr(SessionUtils.getCurrentWorkspaceId())); platformIssuesUpdateRequest.setProjectConfig(PlatformPluginService.getCompatibleProjectConfig(project)); @@ -381,6 +384,9 @@ public class IssuesService { } List customFieldItemDTOS = JSON.parseArray(JSON.toJSONString(issuesRequest.getRequestFields()), PlatformCustomFieldItemDTO.class); + customFieldItemDTOS = customFieldItemDTOS.stream() + .filter(item -> item != null && item.getValue() != null) + .toList(); platformIssuesUpdateRequest.setCustomFieldList(customFieldItemDTOS); // todo 全部插件化后去掉 platformIssuesUpdateRequest.setUserPlatformUserConfig(userService.getCurrentPlatformInfoStr(SessionUtils.getCurrentWorkspaceId())); platformIssuesUpdateRequest.setProjectConfig(PlatformPluginService.getCompatibleProjectConfig(project));