refactor(缺陷管理): 优化第三方平台默认模板的展示
This commit is contained in:
parent
bd2076b718
commit
658e78a098
|
@ -981,8 +981,10 @@ public class BugService {
|
|||
// 平台状态为空
|
||||
bug.setStatus(StringUtils.EMPTY);
|
||||
}
|
||||
// 第三方平台内置的处理人字段需要从自定义字段中移除
|
||||
request.getCustomFields().removeIf(field -> StringUtils.startsWith(field.getName(), BugTemplateCustomField.HANDLE_USER.getName()));
|
||||
// 第三方平台内置的处理人字段需要从自定义字段中移除 (当使用MS系统模板时)
|
||||
if (!isPluginDefaultTemplate(request.getTemplateId(), request.getProjectId())) {
|
||||
request.getCustomFields().removeIf(field -> StringUtils.startsWith(field.getName(), BugTemplateCustomField.HANDLE_USER.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
//保存基础信息
|
||||
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) => {
|
||||
customFields.push({
|
||||
id: item.fieldId,
|
||||
name: item.fieldName,
|
||||
type: item.type,
|
||||
value: item.defaultValue,
|
||||
});
|
||||
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 = {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
:preview-url="EditorPreviewFileUrl"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- 平台默认模板展示字段, 暂时支持输入框, 富文本类型 -->
|
||||
<!-- 平台默认模板展示字段, 暂时支持输入框, 富文本类型 -->
|
||||
<div v-if="isPlatformDefaultTemplate">
|
||||
<a-form-item
|
||||
v-for="(value, key) in form.platformSystemFields"
|
||||
|
@ -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') {
|
||||
const arr = JSON.parse(item.value);
|
||||
if (arr && arr instanceof Array && arr.length > 0) {
|
||||
tmpObj[item.id] = arr[arr.length - 1];
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue