refactor(缺陷管理): 优化第三方平台默认模板的展示
This commit is contained in:
parent
bd2076b718
commit
658e78a098
|
@ -981,9 +981,11 @@ public class BugService {
|
||||||
// 平台状态为空
|
// 平台状态为空
|
||||||
bug.setStatus(StringUtils.EMPTY);
|
bug.setStatus(StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
// 第三方平台内置的处理人字段需要从自定义字段中移除
|
// 第三方平台内置的处理人字段需要从自定义字段中移除 (当使用MS系统模板时)
|
||||||
|
if (!isPluginDefaultTemplate(request.getTemplateId(), request.getProjectId())) {
|
||||||
request.getCustomFields().removeIf(field -> StringUtils.startsWith(field.getName(), BugTemplateCustomField.HANDLE_USER.getName()));
|
request.getCustomFields().removeIf(field -> StringUtils.startsWith(field.getName(), BugTemplateCustomField.HANDLE_USER.getName()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//保存基础信息
|
//保存基础信息
|
||||||
if (StringUtils.isEmpty(bug.getId())) {
|
if (StringUtils.isEmpty(bug.getId())) {
|
||||||
|
@ -1520,7 +1522,7 @@ public class BugService {
|
||||||
// 移除除状态, 处理人以外的所有非API映射的字段
|
// 移除除状态, 处理人以外的所有非API映射的字段
|
||||||
platformCustomFields.removeIf(field -> systemCustomFieldApiMap.containsKey(field.getId()) && StringUtil.isBlank(systemCustomFieldApiMap.get(field.getId())));
|
platformCustomFields.removeIf(field -> systemCustomFieldApiMap.containsKey(field.getId()) && StringUtil.isBlank(systemCustomFieldApiMap.get(field.getId())));
|
||||||
} else {
|
} else {
|
||||||
systemCustomFieldApiMap = new HashMap<>();
|
systemCustomFieldApiMap = new HashMap<>(16);
|
||||||
}
|
}
|
||||||
return platformCustomFields.stream().map(field -> {
|
return platformCustomFields.stream().map(field -> {
|
||||||
PlatformCustomFieldItemDTO platformCustomFieldItem = new PlatformCustomFieldItemDTO();
|
PlatformCustomFieldItemDTO platformCustomFieldItem = new PlatformCustomFieldItemDTO();
|
||||||
|
|
|
@ -134,6 +134,7 @@
|
||||||
ref="bugDetailTabRef"
|
ref="bugDetailTabRef"
|
||||||
:allow-edit="hasAnyPermission(['PROJECT_BUG:READ+UPDATE'])"
|
:allow-edit="hasAnyPermission(['PROJECT_BUG:READ+UPDATE'])"
|
||||||
:detail-info="detailInfo"
|
:detail-info="detailInfo"
|
||||||
|
:current-custom-fields="currentCustomFields"
|
||||||
:is-platform-default-template="isPlatformDefaultTemplate"
|
:is-platform-default-template="isPlatformDefaultTemplate"
|
||||||
:platform-system-fields="platformSystemFields"
|
:platform-system-fields="platformSystemFields"
|
||||||
:current-platform="props.currentPlatform"
|
:current-platform="props.currentPlatform"
|
||||||
|
@ -374,6 +375,7 @@
|
||||||
platformSystemFields.value.forEach((item) => {
|
platformSystemFields.value.forEach((item) => {
|
||||||
item.defaultValue = tmpObj[item.fieldId];
|
item.defaultValue = tmpObj[item.fieldId];
|
||||||
});
|
});
|
||||||
|
|
||||||
getFormRules(
|
getFormRules(
|
||||||
customFieldsRes.customFields.filter((field: Record<string, any>) => !field.platformSystemField),
|
customFieldsRes.customFields.filter((field: Record<string, any>) => !field.platformSystemField),
|
||||||
tmpObj
|
tmpObj
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
<!-- 特殊布局内容(平台默认模板时展示) -->
|
<!-- 特殊布局内容(平台默认模板时展示) -->
|
||||||
<div v-if="isPlatformDefaultTemplate" class="special-content">
|
<div v-if="isPlatformDefaultTemplate" class="special-content">
|
||||||
<div v-for="(item, index) in platformSystemFields" :key="index">
|
<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">
|
<h1 class="header-title">
|
||||||
<strong>{{ item.fieldName }}</strong>
|
<strong>{{ item.fieldName }}</strong>
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -233,11 +233,16 @@
|
||||||
import { downloadByteFile, sleep } from '@/utils';
|
import { downloadByteFile, sleep } from '@/utils';
|
||||||
import { hasAnyPermission } from '@/utils/permission';
|
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 { AssociatedList, AttachFileInfo } from '@/models/caseManagement/featureCase';
|
||||||
import { TableQueryParams } from '@/models/common';
|
import { TableQueryParams } from '@/models/common';
|
||||||
|
|
||||||
import { convertToFileByBug, convertToFileByDetail } from '@/views/bug-management/utils';
|
import { convertToFileByBug } from '@/views/bug-management/utils';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'BugDetailTab',
|
name: 'BugDetailTab',
|
||||||
|
@ -252,6 +257,7 @@
|
||||||
isPlatformDefaultTemplate: boolean; // 是否是平台默认模板
|
isPlatformDefaultTemplate: boolean; // 是否是平台默认模板
|
||||||
platformSystemFields: BugEditCustomField[]; // 平台系统字段
|
platformSystemFields: BugEditCustomField[]; // 平台系统字段
|
||||||
currentPlatform: string; // 当前平台
|
currentPlatform: string; // 当前平台
|
||||||
|
currentCustomFields: CustomFieldItem[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
@ -453,12 +459,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDetailCustomFields() {
|
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 {
|
return {
|
||||||
id: item.id,
|
id: field.fieldId,
|
||||||
name: item.name,
|
name: field.fieldName,
|
||||||
type: item.type,
|
type: field.type,
|
||||||
value: item.value,
|
value: field.fieldId === 'status' ? props.detailInfo.status : filterField.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -468,15 +475,21 @@
|
||||||
try {
|
try {
|
||||||
confirmLoading.value = true;
|
confirmLoading.value = true;
|
||||||
const customFields: BugEditCustomFieldItem[] = getDetailCustomFields();
|
const customFields: BugEditCustomFieldItem[] = getDetailCustomFields();
|
||||||
|
console.log(customFields);
|
||||||
if (props.isPlatformDefaultTemplate) {
|
if (props.isPlatformDefaultTemplate) {
|
||||||
// 平台系统默认字段插入自定义集合
|
// 平台系统默认字段插入自定义集合
|
||||||
props.platformSystemFields.forEach((item) => {
|
props.platformSystemFields.forEach((item) => {
|
||||||
|
const systemField = customFields.filter((field) => field.id === item.fieldId)[0];
|
||||||
|
if (systemField) {
|
||||||
|
systemField.value = item.defaultValue;
|
||||||
|
} else {
|
||||||
customFields.push({
|
customFields.push({
|
||||||
id: item.fieldId,
|
id: item.fieldId,
|
||||||
name: item.fieldName,
|
name: item.fieldName,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
value: item.defaultValue,
|
value: item.defaultValue,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const tmpObj: BugEditFormObject = {
|
const tmpObj: BugEditFormObject = {
|
||||||
|
|
|
@ -383,6 +383,8 @@
|
||||||
const getFormRules = (arr: BugEditCustomField[]) => {
|
const getFormRules = (arr: BugEditCustomField[]) => {
|
||||||
formRules.value = [];
|
formRules.value = [];
|
||||||
const memberType = ['MEMBER', 'MULTIPLE_MEMBER'];
|
const memberType = ['MEMBER', 'MULTIPLE_MEMBER'];
|
||||||
|
const multipleType = ['MULTIPLE_SELECT', 'CHECKBOX'];
|
||||||
|
const numberType = ['INT', 'FLOAT'];
|
||||||
|
|
||||||
if (Array.isArray(arr) && arr.length) {
|
if (Array.isArray(arr) && arr.length) {
|
||||||
formRules.value = arr.map((item: any) => {
|
formRules.value = arr.map((item: any) => {
|
||||||
|
@ -391,7 +393,13 @@
|
||||||
if (memberType.includes(item.type)) {
|
if (memberType.includes(item.type)) {
|
||||||
if (item.defaultValue === 'CREATE_USER' || item.defaultValue.includes('CREATE_USER')) {
|
if (item.defaultValue === 'CREATE_USER' || item.defaultValue.includes('CREATE_USER')) {
|
||||||
initValue = item.type === 'MEMBER' ? userStore.id : [userStore.id];
|
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 {
|
return {
|
||||||
type: item.type,
|
type: item.type,
|
||||||
|
@ -746,11 +754,12 @@
|
||||||
} else if (item.type === 'INT' || item.type === 'FLOAT') {
|
} else if (item.type === 'INT' || item.type === 'FLOAT') {
|
||||||
tmpObj[item.id] = Number(item.value);
|
tmpObj[item.id] = Number(item.value);
|
||||||
} else if (item.type === 'CASCADER') {
|
} else if (item.type === 'CASCADER') {
|
||||||
|
if (item.value) {
|
||||||
const arr = JSON.parse(item.value);
|
const arr = JSON.parse(item.value);
|
||||||
if (arr && arr instanceof Array && arr.length > 0) {
|
if (arr && arr instanceof Array && arr.length > 0) {
|
||||||
tmpObj[item.id] = arr[arr.length - 1];
|
tmpObj[item.id] = arr[arr.length - 1];
|
||||||
}
|
}
|
||||||
// 单选多选项
|
}
|
||||||
} else if (SINGRADIO_TYPE.includes(item.type)) {
|
} else if (SINGRADIO_TYPE.includes(item.type)) {
|
||||||
const multipleOptions = getOptionFromTemplate(
|
const multipleOptions = getOptionFromTemplate(
|
||||||
currentCustomFields.value.find((filed: any) => item.id === filed.fieldId)
|
currentCustomFields.value.find((filed: any) => item.id === filed.fieldId)
|
||||||
|
|
Loading…
Reference in New Issue