diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java index 4a7a0690db..c62271269d 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java @@ -9,4 +9,5 @@ import java.util.List; @Data public class CustomFieldDTO extends CustomField { private List options; + private boolean used; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.java new file mode 100644 index 0000000000..aec4d92574 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.java @@ -0,0 +1,9 @@ +package io.metersphere.system.mapper; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtTemplateCustomFieldMapper { + List selectUsedFieldIds(@Param("fieldIds") List list); +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.xml new file mode 100644 index 0000000000..d4e01e49da --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java index 5a95169956..8a00e2bab1 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java @@ -15,6 +15,7 @@ import io.metersphere.system.dto.request.DefaultFunctionalCustomField; import io.metersphere.system.dto.sdk.CustomFieldDTO; import io.metersphere.system.dto.sdk.request.CustomFieldOptionRequest; import io.metersphere.system.mapper.CustomFieldMapper; +import io.metersphere.system.mapper.ExtTemplateCustomFieldMapper; import io.metersphere.system.mapper.TemplateCustomFieldMapper; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.utils.ServiceUtils; @@ -50,6 +51,8 @@ public class BaseCustomFieldService { protected BaseOrganizationParameterService baseOrganizationParameterService; @Resource protected TemplateCustomFieldMapper templateCustomFieldMapper; + @Resource + private ExtTemplateCustomFieldMapper extTemplateCustomFieldMapper; private static final String CREATE_USER = "CREATE_USER"; @@ -57,6 +60,11 @@ public class BaseCustomFieldService { checkScene(scene); List customFields = getByScopeIdAndScene(scopeId, scene); List userIds = customFields.stream().map(CustomField::getCreateUser).toList(); + List usedFieldIds = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(customFields)) { + usedFieldIds.addAll(extTemplateCustomFieldMapper.selectUsedFieldIds(customFields.stream().map(CustomField::getId).toList())); + } + Map userNameMap = userLoginService.getUserNameMap(userIds); List customFieldOptions = baseCustomFieldOptionService.getByFieldIds(customFields.stream().map(CustomField::getId).toList()); Map> optionMap = customFieldOptions.stream().collect(Collectors.groupingBy(CustomFieldOption::getFieldId)); @@ -67,6 +75,10 @@ public class BaseCustomFieldService { } CustomFieldDTO customFieldDTO = new CustomFieldDTO(); BeanUtils.copyBean(customFieldDTO, item); + //判断有没有用到 + if (usedFieldIds.contains(item.getId())) { + customFieldDTO.setUsed(true); + } customFieldDTO.setOptions(optionMap.get(item.getId())); if (CustomFieldType.getHasOptionValueSet().contains(customFieldDTO.getType()) && customFieldDTO.getOptions() == null) { customFieldDTO.setOptions(List.of()); diff --git a/frontend/src/models/setting/template.ts b/frontend/src/models/setting/template.ts index 42765237dc..5b7ad59bca 100644 --- a/frontend/src/models/setting/template.ts +++ b/frontend/src/models/setting/template.ts @@ -63,6 +63,7 @@ export interface FieldOption { export interface AddOrUpdateField { id?: string; name: string; + used: boolean; scene: SeneType; // 使用场景 type: FormItemType; remark: string; // 备注 diff --git a/frontend/src/views/case-management/caseManagementFeature/components/export/validateResult.vue b/frontend/src/views/case-management/caseManagementFeature/components/export/validateResult.vue index 031a766477..a7b59a60d9 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/export/validateResult.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/export/validateResult.vue @@ -57,7 +57,9 @@ -
{{ t('caseManagement.featureCase.afterFailingToModify', { type: props.validateType }) }}
+
+ {{ t('caseManagement.featureCase.afterFailingToModify', { type: props.validateType }) }}