refactor(缺陷管理): 优化第三方平台默认模板的展示

This commit is contained in:
song-cc-rock 2024-07-31 10:18:32 +08:00 committed by 刘瑞斌
parent bd2076b718
commit 658e78a098
4 changed files with 48 additions and 22 deletions

View File

@ -981,9 +981,11 @@ public class BugService {
// 平台状态为空
bug.setStatus(StringUtils.EMPTY);
}
// 第三方平台内置的处理人字段需要从自定义字段中移除
// 第三方平台内置的处理人字段需要从自定义字段中移除 (当使用MS系统模板时)
if (!isPluginDefaultTemplate(request.getTemplateId(), request.getProjectId())) {
request.getCustomFields().removeIf(field -> StringUtils.startsWith(field.getName(), BugTemplateCustomField.HANDLE_USER.getName()));
}
}
//保存基础信息
if (StringUtils.isEmpty(bug.getId())) {
@ -1520,7 +1522,7 @@ public class BugService {
// 移除除状态, 处理人以外的所有非API映射的字段
platformCustomFields.removeIf(field -> systemCustomFieldApiMap.containsKey(field.getId()) && StringUtil.isBlank(systemCustomFieldApiMap.get(field.getId())));
} else {
systemCustomFieldApiMap = new HashMap<>();
systemCustomFieldApiMap = new HashMap<>(16);
}
return platformCustomFields.stream().map(field -> {
PlatformCustomFieldItemDTO platformCustomFieldItem = new PlatformCustomFieldItemDTO();

View File

@ -134,6 +134,7 @@
ref="bugDetailTabRef"
:allow-edit="hasAnyPermission(['PROJECT_BUG:READ+UPDATE'])"
:detail-info="detailInfo"
:current-custom-fields="currentCustomFields"
:is-platform-default-template="isPlatformDefaultTemplate"
:platform-system-fields="platformSystemFields"
:current-platform="props.currentPlatform"
@ -374,6 +375,7 @@
platformSystemFields.value.forEach((item) => {
item.defaultValue = tmpObj[item.fieldId];
});
getFormRules(
customFieldsRes.customFields.filter((field: Record<string, any>) => !field.platformSystemField),
tmpObj

View File

@ -39,7 +39,7 @@
<!-- 特殊布局内容(平台默认模板时展示) -->
<div v-if="isPlatformDefaultTemplate" class="special-content">
<div v-for="(item, index) in platformSystemFields" :key="index">
<div v-if="item.fieldId !== 'summary'">
<div v-if="item.fieldId !== 'summary' && item.fieldId !== 'title'">
<h1 class="header-title">
<strong>{{ item.fieldName }}</strong>
</h1>
@ -233,11 +233,16 @@
import { downloadByteFile, sleep } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
import { BugEditCustomField, BugEditCustomFieldItem, BugEditFormObject } from '@/models/bug-management';
import {
BugEditCustomField,
BugEditCustomFieldItem,
BugEditFormObject,
type CustomFieldItem,
} from '@/models/bug-management';
import { AssociatedList, AttachFileInfo } from '@/models/caseManagement/featureCase';
import { TableQueryParams } from '@/models/common';
import { convertToFileByBug, convertToFileByDetail } from '@/views/bug-management/utils';
import { convertToFileByBug } from '@/views/bug-management/utils';
defineOptions({
name: 'BugDetailTab',
@ -252,6 +257,7 @@
isPlatformDefaultTemplate: boolean; //
platformSystemFields: BugEditCustomField[]; //
currentPlatform: string; //
currentCustomFields: CustomFieldItem[];
}>();
const emit = defineEmits<{
@ -453,12 +459,13 @@
}
function getDetailCustomFields() {
return props.detailInfo.customFields.map((item: any) => {
return props.currentCustomFields.map((field) => {
const filterField = props.detailInfo.customFields.filter((item: any) => item.id === field.fieldId)[0];
return {
id: item.id,
name: item.name,
type: item.type,
value: item.value,
id: field.fieldId,
name: field.fieldName,
type: field.type,
value: field.fieldId === 'status' ? props.detailInfo.status : filterField.value,
};
});
}
@ -468,15 +475,21 @@
try {
confirmLoading.value = true;
const customFields: BugEditCustomFieldItem[] = getDetailCustomFields();
console.log(customFields);
if (props.isPlatformDefaultTemplate) {
//
props.platformSystemFields.forEach((item) => {
const systemField = customFields.filter((field) => field.id === item.fieldId)[0];
if (systemField) {
systemField.value = item.defaultValue;
} else {
customFields.push({
id: item.fieldId,
name: item.fieldName,
type: item.type,
value: item.defaultValue,
});
}
});
}
const tmpObj: BugEditFormObject = {

View File

@ -383,6 +383,8 @@
const getFormRules = (arr: BugEditCustomField[]) => {
formRules.value = [];
const memberType = ['MEMBER', 'MULTIPLE_MEMBER'];
const multipleType = ['MULTIPLE_SELECT', 'CHECKBOX'];
const numberType = ['INT', 'FLOAT'];
if (Array.isArray(arr) && arr.length) {
formRules.value = arr.map((item: any) => {
@ -391,7 +393,13 @@
if (memberType.includes(item.type)) {
if (item.defaultValue === 'CREATE_USER' || item.defaultValue.includes('CREATE_USER')) {
initValue = item.type === 'MEMBER' ? userStore.id : [userStore.id];
} else if (item.type === 'MULTIPLE_MEMBER' && item.defaultValue) {
initValue = JSON.parse(item.defaultValue);
}
} else if (multipleType.includes(item.type)) {
initValue = item.defaultValue ? JSON.parse(item.defaultValue) : [];
} else if (numberType.includes(item.type)) {
initValue = Number(initValue);
}
return {
type: item.type,
@ -746,11 +754,12 @@
} else if (item.type === 'INT' || item.type === 'FLOAT') {
tmpObj[item.id] = Number(item.value);
} else if (item.type === 'CASCADER') {
if (item.value) {
const arr = JSON.parse(item.value);
if (arr && arr instanceof Array && arr.length > 0) {
tmpObj[item.id] = arr[arr.length - 1];
}
//
}
} else if (SINGRADIO_TYPE.includes(item.type)) {
const multipleOptions = getOptionFromTemplate(
currentCustomFields.value.find((filed: any) => item.id === filed.fieldId)