fix(用例管理): 导入问题&用例模板用例等级字段不允许删除
This commit is contained in:
parent
7ae3ea52fb
commit
92be886eb1
|
@ -1095,23 +1095,27 @@ public class FunctionalCaseService {
|
|||
private void handleImportCustomField(FunctionalCaseExcelData functionalCaseExcelData, String caseId, FunctionalCaseCustomFieldMapper customFieldMapper, Map<String, TemplateCustomFieldDTO> customFieldsMap) {
|
||||
//需要保存的自定义字段
|
||||
Map<String, Object> customData = functionalCaseExcelData.getCustomData();
|
||||
customData.forEach((k, v) -> {
|
||||
if (customFieldsMap.containsKey(k)) {
|
||||
TemplateCustomFieldDTO templateCustomFieldDTO = customFieldsMap.get(k);
|
||||
customFieldsMap.forEach((k, v) -> {
|
||||
Object value = customData.get(k);
|
||||
FunctionalCaseCustomField caseCustomField = new FunctionalCaseCustomField();
|
||||
caseCustomField.setCaseId(caseId);
|
||||
caseCustomField.setFieldId(templateCustomFieldDTO.getFieldId());
|
||||
if (StringUtils.equalsIgnoreCase(v.toString(), "[]")) {
|
||||
//数组类型
|
||||
caseCustomField.setValue(JSON.toJSONString(templateCustomFieldDTO.getDefaultValue()));
|
||||
} else {
|
||||
caseCustomField.setValue(StringUtils.defaultIfBlank(v.toString(),
|
||||
Optional.ofNullable(templateCustomFieldDTO.getDefaultValue()).map(Object::toString).orElse(StringUtils.EMPTY)
|
||||
));
|
||||
}
|
||||
customFieldMapper.insertSelective(caseCustomField);
|
||||
}
|
||||
caseCustomField.setFieldId(v.getFieldId());
|
||||
Optional.ofNullable(value).ifPresentOrElse(v1 -> {
|
||||
setCustomFieldValue(v1.toString(), caseCustomField);
|
||||
}, () -> {
|
||||
setCustomFieldValue(v.getDefaultValue(), caseCustomField);
|
||||
});
|
||||
customFieldMapper.insertSelective(caseCustomField);
|
||||
});
|
||||
}
|
||||
|
||||
private void setCustomFieldValue(Object value, FunctionalCaseCustomField caseCustomField) {
|
||||
if (StringUtils.equalsIgnoreCase(value.toString(), "[]") || value instanceof List) {
|
||||
//数组类型
|
||||
caseCustomField.setValue(JSON.toJSONString(value));
|
||||
} else {
|
||||
caseCustomField.setValue(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -103,10 +103,14 @@
|
|||
@click="editField(formItem as DefinedFieldItem)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-divider v-if="!formItem.templateRequired" direction="vertical" class="!m-0 !mx-2" />
|
||||
<a-divider
|
||||
v-if="!formItem.required && formItem.name != t('case.caseLevel')"
|
||||
direction="vertical"
|
||||
class="!m-0 !mx-2"
|
||||
/>
|
||||
<a-tooltip :content="t('common.delete')">
|
||||
<MsIcon
|
||||
v-if="!formItem.templateRequired"
|
||||
v-if="!formItem.required && formItem.name != t('case.caseLevel')"
|
||||
type="icon-icon_delete-trash_outlined"
|
||||
size="16"
|
||||
@click="deleteSelectedField(formItem as DefinedFieldItem)"
|
||||
|
|
Loading…
Reference in New Issue