style(系统设置): 模板字段删除文案修改,excel导入文案修改

--bug=1036740 --user=宋天阳 【系统设置】组织-模板-字段设置-该字段未被使用-删除提示信息错误 https://www.tapd.cn/55049933/s/1472141;--bug=1035875 --user=宋天阳 【用例管理】功能用例-导入excel文件用例,校验成功后的页面提示信息优化 https://www.tapd.cn/55049933/s/1472137
This commit is contained in:
song-tianyang 2024-03-08 19:53:42 +08:00 committed by 刘瑞斌
parent db88c8d6fd
commit 8824e88d92
10 changed files with 48 additions and 2 deletions

View File

@ -9,4 +9,5 @@ import java.util.List;
@Data @Data
public class CustomFieldDTO extends CustomField { public class CustomFieldDTO extends CustomField {
private List<CustomFieldOption> options; private List<CustomFieldOption> options;
private boolean used;
} }

View File

@ -0,0 +1,9 @@
package io.metersphere.system.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtTemplateCustomFieldMapper {
List<String> selectUsedFieldIds(@Param("fieldIds") List<String> list);
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.system.mapper.ExtTemplateCustomFieldMapper">
<select id="selectUsedFieldIds" resultType="java.lang.String">
SELECT distinct field_id
FROM template_custom_field
WHERE field_id in
<foreach collection="fieldIds" item="fieldId" open="(" close=")" separator=",">
#{fieldId}
</foreach>
</select>
</mapper>

View File

@ -15,6 +15,7 @@ import io.metersphere.system.dto.request.DefaultFunctionalCustomField;
import io.metersphere.system.dto.sdk.CustomFieldDTO; import io.metersphere.system.dto.sdk.CustomFieldDTO;
import io.metersphere.system.dto.sdk.request.CustomFieldOptionRequest; import io.metersphere.system.dto.sdk.request.CustomFieldOptionRequest;
import io.metersphere.system.mapper.CustomFieldMapper; import io.metersphere.system.mapper.CustomFieldMapper;
import io.metersphere.system.mapper.ExtTemplateCustomFieldMapper;
import io.metersphere.system.mapper.TemplateCustomFieldMapper; import io.metersphere.system.mapper.TemplateCustomFieldMapper;
import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.ServiceUtils; import io.metersphere.system.utils.ServiceUtils;
@ -50,6 +51,8 @@ public class BaseCustomFieldService {
protected BaseOrganizationParameterService baseOrganizationParameterService; protected BaseOrganizationParameterService baseOrganizationParameterService;
@Resource @Resource
protected TemplateCustomFieldMapper templateCustomFieldMapper; protected TemplateCustomFieldMapper templateCustomFieldMapper;
@Resource
private ExtTemplateCustomFieldMapper extTemplateCustomFieldMapper;
private static final String CREATE_USER = "CREATE_USER"; private static final String CREATE_USER = "CREATE_USER";
@ -57,6 +60,11 @@ public class BaseCustomFieldService {
checkScene(scene); checkScene(scene);
List<CustomField> customFields = getByScopeIdAndScene(scopeId, scene); List<CustomField> customFields = getByScopeIdAndScene(scopeId, scene);
List<String> userIds = customFields.stream().map(CustomField::getCreateUser).toList(); List<String> userIds = customFields.stream().map(CustomField::getCreateUser).toList();
List<String> usedFieldIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(customFields)) {
usedFieldIds.addAll(extTemplateCustomFieldMapper.selectUsedFieldIds(customFields.stream().map(CustomField::getId).toList()));
}
Map<String, String> userNameMap = userLoginService.getUserNameMap(userIds); Map<String, String> userNameMap = userLoginService.getUserNameMap(userIds);
List<CustomFieldOption> customFieldOptions = baseCustomFieldOptionService.getByFieldIds(customFields.stream().map(CustomField::getId).toList()); List<CustomFieldOption> customFieldOptions = baseCustomFieldOptionService.getByFieldIds(customFields.stream().map(CustomField::getId).toList());
Map<String, List<CustomFieldOption>> optionMap = customFieldOptions.stream().collect(Collectors.groupingBy(CustomFieldOption::getFieldId)); Map<String, List<CustomFieldOption>> optionMap = customFieldOptions.stream().collect(Collectors.groupingBy(CustomFieldOption::getFieldId));
@ -67,6 +75,10 @@ public class BaseCustomFieldService {
} }
CustomFieldDTO customFieldDTO = new CustomFieldDTO(); CustomFieldDTO customFieldDTO = new CustomFieldDTO();
BeanUtils.copyBean(customFieldDTO, item); BeanUtils.copyBean(customFieldDTO, item);
//判断有没有用到
if (usedFieldIds.contains(item.getId())) {
customFieldDTO.setUsed(true);
}
customFieldDTO.setOptions(optionMap.get(item.getId())); customFieldDTO.setOptions(optionMap.get(item.getId()));
if (CustomFieldType.getHasOptionValueSet().contains(customFieldDTO.getType()) && customFieldDTO.getOptions() == null) { if (CustomFieldType.getHasOptionValueSet().contains(customFieldDTO.getType()) && customFieldDTO.getOptions() == null) {
customFieldDTO.setOptions(List.of()); customFieldDTO.setOptions(List.of());

View File

@ -63,6 +63,7 @@ export interface FieldOption {
export interface AddOrUpdateField { export interface AddOrUpdateField {
id?: string; id?: string;
name: string; name: string;
used: boolean;
scene: SeneType; // 使用场景 scene: SeneType; // 使用场景
type: FormItemType; type: FormItemType;
remark: string; // 备注 remark: string; // 备注

View File

@ -57,7 +57,9 @@
</template> </template>
</a-popover> </a-popover>
</div> </div>
<div> {{ t('caseManagement.featureCase.afterFailingToModify', { type: props.validateType }) }}</div> <div v-if="validateResultInfo.failCount > 0">
{{ t('caseManagement.featureCase.afterFailingToModify', { type: props.validateType }) }}</div
>
</div> </div>
<template #footer> <template #footer>
<div class="flex justify-end"> <div class="flex justify-end">

View File

@ -163,6 +163,7 @@
}); });
const initFieldForm: AddOrUpdateField = { const initFieldForm: AddOrUpdateField = {
name: '', name: '',
used: false,
type: undefined, type: undefined,
remark: '', remark: '',
scopeId: scopeId.value, scopeId: scopeId.value,
@ -278,6 +279,7 @@
const params: AddOrUpdateField = { const params: AddOrUpdateField = {
name, name,
used: false,
options, options,
scopeId: scopeId.value, scopeId: scopeId.value,
scene, scene,

View File

@ -325,10 +325,14 @@
const deleteApi = getFieldRequestApi(props.mode).delete; const deleteApi = getFieldRequestApi(props.mode).delete;
// //
const handlerDelete = (record: AddOrUpdateField) => { const handlerDelete = (record: AddOrUpdateField) => {
let contentStr = t('system.orgTemplate.deleteFiledContentNotUsed');
if (record.used) {
contentStr = t('system.orgTemplate.deleteFiledContent');
}
openModal({ openModal({
type: 'error', type: 'error',
title: t('system.orgTemplate.deleteTitle', { name: characterLimit(record.name) }), title: t('system.orgTemplate.deleteTitle', { name: characterLimit(record.name) }),
content: t('system.orgTemplate.deleteFiledContent'), content: contentStr,
okText: t('common.confirmDelete'), okText: t('common.confirmDelete'),
cancelText: t('common.cancel'), cancelText: t('common.cancel'),
okButtonProps: { okButtonProps: {

View File

@ -129,6 +129,7 @@ export default {
'After delete, will be effective in the project and delete irrevocable, please careful operation.', 'After delete, will be effective in the project and delete irrevocable, please careful operation.',
'system.orgTemplate.deleteFiledContent': 'system.orgTemplate.deleteFiledContent':
'This field has been used in the template, data will be lost after deletion, please be careful!', 'This field has been used in the template, data will be lost after deletion, please be careful!',
'system.orgTemplate.deleteFiledContentNotUsed': 'This field will be lost, please be careful!',
'system.orgTemplate.deleteSuccess': 'Delete Successfully', 'system.orgTemplate.deleteSuccess': 'Delete Successfully',
'system.orgTemplate.setInitStateSuccess': 'Set the initial state successfully', 'system.orgTemplate.setInitStateSuccess': 'Set the initial state successfully',
'system.orgTemplate.setEndStateSuccess': 'Setting the end status succeeded', 'system.orgTemplate.setEndStateSuccess': 'Setting the end status succeeded',

View File

@ -123,6 +123,7 @@ export default {
'system.orgTemplate.deleteStateTitle': '确定删除 {name} 状态吗?', 'system.orgTemplate.deleteStateTitle': '确定删除 {name} 状态吗?',
'system.orgTemplate.deleteStateContent': '删除后,会在项目中立即生效且删除不可撤回,请谨慎操作!', 'system.orgTemplate.deleteStateContent': '删除后,会在项目中立即生效且删除不可撤回,请谨慎操作!',
'system.orgTemplate.deleteFiledContent': '该字段在模板中已使用,删除后数据将会丢失,请谨慎操作!', 'system.orgTemplate.deleteFiledContent': '该字段在模板中已使用,删除后数据将会丢失,请谨慎操作!',
'system.orgTemplate.deleteFiledContentNotUsed': '删除后,字段将从字段列表移除,请谨慎操作!',
'system.orgTemplate.deleteSuccess': '删除成功', 'system.orgTemplate.deleteSuccess': '删除成功',
'system.orgTemplate.setInitStateSuccess': '设置初始态成功', 'system.orgTemplate.setInitStateSuccess': '设置初始态成功',
'system.orgTemplate.setEndStateSuccess': '设置结束状态成功', 'system.orgTemplate.setEndStateSuccess': '设置结束状态成功',