From 8824e88d92a885cc5309128f4d5eaa642c9a51c7 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 8 Mar 2024 19:53:42 +0800 Subject: [PATCH] =?UTF-8?q?style(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=AD=97=E6=AE=B5=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E6=A1=88=E4=BF=AE=E6=94=B9=EF=BC=8Cexcel=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=96=87=E6=A1=88=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1036740 --user=宋天阳 【系统设置】组织-模板-字段设置-该字段未被使用-删除提示信息错误 https://www.tapd.cn/55049933/s/1472141;--bug=1035875 --user=宋天阳 【用例管理】功能用例-导入excel文件用例,校验成功后的页面提示信息优化 https://www.tapd.cn/55049933/s/1472137 --- .../metersphere/system/dto/sdk/CustomFieldDTO.java | 1 + .../system/mapper/ExtTemplateCustomFieldMapper.java | 9 +++++++++ .../system/mapper/ExtTemplateCustomFieldMapper.xml | 13 +++++++++++++ .../system/service/BaseCustomFieldService.java | 12 ++++++++++++ frontend/src/models/setting/template.ts | 1 + .../components/export/validateResult.vue | 4 +++- .../template/components/editFieldDrawer.vue | 2 ++ .../template/components/fieldSetting.vue | 6 +++++- .../setting/organization/template/locale/en-US.ts | 1 + .../setting/organization/template/locale/zh-CN.ts | 1 + 10 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtTemplateCustomFieldMapper.xml 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 }) }}