fix(缺陷管理): 缺陷创建编辑复制状态流转问题

--bug=1036120 --user=宋昌昌 【缺陷管理】缺陷状态只有新建 https://www.tapd.cn/55049933/s/1464084
This commit is contained in:
song-cc-rock 2024-02-22 18:34:13 +08:00 committed by 刘瑞斌
parent f2e4816c64
commit eed6f82bcc
7 changed files with 156 additions and 118 deletions

View File

@ -47,5 +47,12 @@ public class BugDetailDTO {
private Boolean followFlag;
@Schema(description = "附件集合")
List<BugFileDTO> attachments;
private List<BugFileDTO> attachments;
@Schema(description = "第三方平台缺陷ID")
private String platformBugId;
@Schema(description = "缺陷状态")
private String status;
}

View File

@ -254,6 +254,8 @@ public class BugService {
detail.setProjectId(bug.getProjectId());
detail.setTemplateId(template.getId());
detail.setPlatformDefault(template.getPlatformDefault());
detail.setStatus(bug.getStatus());
detail.setPlatformBugId(bug.getPlatformBugId());
if (!detail.getPlatformDefault()) {
// 非平台默认模板 {标题, 内容, 标签, 自定义字段: 处理人, 状态}
detail.setTitle(bug.getTitle());

View File

@ -20,6 +20,7 @@ import io.metersphere.system.mapper.StatusDefinitionMapper;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -296,11 +297,13 @@ public class BaseStatusFlowSettingService {
} else {
//修改时, 获取当前状态的流转选项值即可
List<StatusFlow> nextStatusFlows = baseStatusFlowService.getNextStatusFlows(targetStatusId);
List<String> toIds = new ArrayList<>();
if (CollectionUtils.isEmpty(nextStatusFlows)) {
// 当前状态选项值没有下一步流转选项值, 返回空集合
return List.of();
// 当前状态选项值没有下一步流转选项值, 返回当前状态即可
toIds = List.of(targetStatusId);
} else {
toIds = ListUtils.union(nextStatusFlows.stream().map(StatusFlow::getToId).collect(Collectors.toList()), List.of(targetStatusId));
}
List<String> toIds = nextStatusFlows.stream().map(StatusFlow::getToId).toList();
List<StatusItem> statusItems = baseStatusItemService.getToStatusItemByScopeIdAndScene(scopeId, scene, toIds);
statusItems = baseStatusItemService.translateInternalStatusItem(statusItems);
return statusItems.stream().map(item -> new SelectOption(item.getName(), item.getId())).toList();

View File

@ -86,3 +86,8 @@ export interface OperationFile {
associated: boolean; // 是否是本地 还是关联
moduleId?: string; // 文件转存模块id
}
export interface BugTemplateRequest {
fromStatusId: string; // 缺陷当前状态
platformBugKey: string; // 缺陷第三方平台Key
}

View File

@ -187,7 +187,7 @@
import {useAppStore} from '@/store';
import {characterLimit} from '@/utils';
import { BugEditCustomField, BugEditFormObject } from '@/models/bug-management';
import {BugEditCustomField, BugEditFormObject, BugTemplateRequest} from '@/models/bug-management';
import {SelectValue} from '@/models/projectManagement/menuManagement';
import {RouteEnum} from '@/enums/routeEnum';
@ -245,10 +245,10 @@
}
};
const templateChange = async (v: SelectValue, valueObj: BugEditFormObject) => {
const templateChange = async (v: SelectValue, valueObj: BugEditFormObject, request: BugTemplateRequest) => {
if (v) {
try {
const res = await getTemplateById({ projectId: appStore.currentProjectId, id: v });
const res = await getTemplateById({ projectId: appStore.currentProjectId, id: v, fromStatusId: request.fromStatusId, platformBugKey: request.platformBugKey});
getFormRules(res.customFields, valueObj);
} catch (error) {
// eslint-disable-next-line no-console
@ -268,7 +268,7 @@
});
}
//
await templateChange(templateId, tmpObj);
await templateChange(templateId, tmpObj, {platformBugKey: detail.platformBugId, fromStatusId: detail.status});
}
const editLoading = ref<boolean>(false);

View File

@ -231,6 +231,7 @@
},
});
const form = ref({
title: '',
description: '',
deleteLocalFileIds: [] as string[],
unLinkRefIds: [] as string[],
@ -261,7 +262,8 @@
const confirmLoading = ref<boolean>(false);
const initCurrentDetail = async (detail: BugEditFormObject) => {
const { attachments, description } = detail;
const { attachments, title, description } = detail;
form.value.title = title;
form.value.description = description;
handleFileFunc(attachments);
};
@ -430,6 +432,7 @@
templateId: props.detailInfo.templateId,
customFields,
};
console.log(tmpObj)
//
const res = await createOrUpdateBug({ request: tmpObj, fileList: fileList.value as unknown as File[] });
if (res) {

View File

@ -197,7 +197,6 @@
import {FormItem, FormRuleItem} from '@/components/pure/ms-form-create/types';
import MsRichText from '@/components/pure/ms-rich-text/MsRichText.vue';
import MsTagsInput from '@/components/pure/ms-tags-input/index.vue';
import FileList from '@/components/pure/ms-upload/fileList.vue';
import MsUpload from '@/components/pure/ms-upload/index.vue';
import {MsFileItem} from '@/components/pure/ms-upload/types';
import RelateFileDrawer from '@/components/business/ms-link-file/associatedFileDrawer.vue';
@ -224,7 +223,12 @@
import {downloadByteFile} from '@/utils';
import {scrollIntoView} from '@/utils/dom';
import { BugEditCustomField, BugEditCustomFieldItem, BugEditFormObject } from '@/models/bug-management';
import {
BugEditCustomField,
BugEditCustomFieldItem,
BugEditFormObject,
BugTemplateRequest
} from '@/models/bug-management';
import {AssociatedList, AttachFileInfo} from '@/models/caseManagement/featureCase';
import {TableQueryParams} from '@/models/common';
import {SelectValue} from '@/models/projectManagement/menuManagement';
@ -348,10 +352,14 @@
}
};
const templateChange = async (v: SelectValue) => {
const templateChange = async (v: SelectValue, request?: BugTemplateRequest) => {
if (v) {
try {
const res = await getTemplateById({ projectId: appStore.currentProjectId, id: v });
let param = {projectId: appStore.currentProjectId, id: v}
if (request) {
param = {...param, ...request}
}
const res = await getTemplateById(param);
getFormRules(res.customFields);
} catch (error) {
// eslint-disable-next-line no-console
@ -542,7 +550,12 @@
const res = await getBugDetail(id);
const { customFields, templateId, attachments } = res;
// ID
if (isCopy.value) {
// ,
await templateChange(templateId);
} else {
await templateChange(templateId, {fromStatusId: res.status, platformBugKey: res.platformBugId})
}
if (attachments && attachments.length) {
attachmentsList.value = attachments;
//
@ -564,7 +577,12 @@
const tmpObj = {};
if (customFields && Array.isArray(customFields)) {
customFields.forEach((item) => {
if (item.id === 'status' && isCopy.value) {
// ,
tmpObj[item.id] = '';
} else {
tmpObj[item.id] = item.value;
}
});
}
//