feat(缺陷管理): 缺陷管理详情编辑报错优化
This commit is contained in:
parent
db0c14f723
commit
97741d4b33
|
@ -575,13 +575,6 @@
|
||||||
} else {
|
} else {
|
||||||
activeTab.value = 'detail';
|
activeTab.value = 'detail';
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!props.pagination && !props.tableData) return;
|
|
||||||
const query = { ...route.query };
|
|
||||||
delete query.id;
|
|
||||||
router.replace({
|
|
||||||
query,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,7 +17,13 @@
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<div class="h-[calc(100vh-168px)] w-full">
|
<div class="h-[calc(100vh-168px)] w-full">
|
||||||
<BugDetail ref="bugDetailRef" v-model:template-id="bugTemplateId" :bug-id="bugId" @save-params="saveParams" />
|
<BugDetail
|
||||||
|
ref="bugDetailRef"
|
||||||
|
v-model:template-id="bugTemplateId"
|
||||||
|
:bug-id="bugId"
|
||||||
|
:is-copy-bug="isCopy"
|
||||||
|
@save-params="saveParams"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</MsCard>
|
</MsCard>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -215,7 +215,6 @@
|
||||||
import { EditorPreviewFileUrl } from '@/api/requrls/bug-management';
|
import { EditorPreviewFileUrl } from '@/api/requrls/bug-management';
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
import { useI18n } from '@/hooks/useI18n';
|
||||||
import { useAppStore } from '@/store';
|
import { useAppStore } from '@/store';
|
||||||
import useUserStore from '@/store/modules/user';
|
|
||||||
import { downloadByteFile } from '@/utils';
|
import { downloadByteFile } from '@/utils';
|
||||||
import { scrollIntoView } from '@/utils/dom';
|
import { scrollIntoView } from '@/utils/dom';
|
||||||
import { findParents, Option } from '@/utils/recursion';
|
import { findParents, Option } from '@/utils/recursion';
|
||||||
|
@ -239,6 +238,7 @@
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
templateId: string; // 缺陷模板id
|
templateId: string; // 缺陷模板id
|
||||||
|
isCopyBug?: boolean; // 是否复制
|
||||||
bugId?: string; // 缺陷id,不传递为创建
|
bugId?: string; // 缺陷id,不传递为创建
|
||||||
isDrawer?: boolean; // 是否是弹窗模式
|
isDrawer?: boolean; // 是否是弹窗模式
|
||||||
caseType?: CaseLinkEnum; // 用例类型
|
caseType?: CaseLinkEnum; // 用例类型
|
||||||
|
@ -262,7 +262,6 @@
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const route = useRoute();
|
|
||||||
const form = ref<BugEditFormObject>({
|
const form = ref<BugEditFormObject>({
|
||||||
projectId: appStore.currentProjectId,
|
projectId: appStore.currentProjectId,
|
||||||
title: '',
|
title: '',
|
||||||
|
@ -297,11 +296,9 @@
|
||||||
const associatedDrawer = ref(false);
|
const associatedDrawer = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const acceptType = ref('none'); // 模块-上传文件类型
|
const acceptType = ref('none'); // 模块-上传文件类型
|
||||||
const userStore = useUserStore();
|
const isEdit = computed(() => props.bugId && !props.isCopyBug);
|
||||||
const isEdit = computed(() => !!route.query.id && route.params.mode === 'edit');
|
|
||||||
const bugId = ref<string | undefined>(props.bugId);
|
const bugId = ref<string | undefined>(props.bugId);
|
||||||
const isEditOrCopy = computed(() => !!bugId.value);
|
const isEditOrCopy = computed(() => !!bugId.value);
|
||||||
const isCopy = computed(() => route.params.mode === 'copy');
|
|
||||||
const isPlatformDefaultTemplate = ref(false);
|
const isPlatformDefaultTemplate = ref(false);
|
||||||
const imageUrl = ref('');
|
const imageUrl = ref('');
|
||||||
const previewVisible = ref<boolean>(false);
|
const previewVisible = ref<boolean>(false);
|
||||||
|
@ -310,7 +307,7 @@
|
||||||
// 描述-环境/富文本临时附件ID
|
// 描述-环境/富文本临时附件ID
|
||||||
const descriptionFileIdMap = ref<Record<string, string[]>>({});
|
const descriptionFileIdMap = ref<Record<string, string[]>>({});
|
||||||
|
|
||||||
const isLoading = ref<boolean>(true);
|
const isLoading = ref<boolean>(false);
|
||||||
const rowLength = ref<number>(0);
|
const rowLength = ref<number>(0);
|
||||||
|
|
||||||
// 处理文件参数
|
// 处理文件参数
|
||||||
|
@ -593,7 +590,7 @@
|
||||||
copyFiles,
|
copyFiles,
|
||||||
richTextTmpFileIds: isPlatformDefaultTemplate.value ? getDescriptionFileId() : descriptionFileIds.value,
|
richTextTmpFileIds: isPlatformDefaultTemplate.value ? getDescriptionFileId() : descriptionFileIds.value,
|
||||||
};
|
};
|
||||||
if (isCopy.value) {
|
if (props.isCopyBug) {
|
||||||
delete tmpObj.id;
|
delete tmpObj.id;
|
||||||
delete tmpObj.richTextTmpFileIds;
|
delete tmpObj.richTextTmpFileIds;
|
||||||
}
|
}
|
||||||
|
@ -644,51 +641,61 @@
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取详情
|
// 设置模板值
|
||||||
const getDetailInfo = async () => {
|
async function setTemplateValue(bugDetail: BugEditFormObject) {
|
||||||
loading.value = true;
|
const { status, templateId, platformBugId } = bugDetail;
|
||||||
const id = route.query.id as string;
|
try {
|
||||||
if (!id) return;
|
if (props.isCopyBug) {
|
||||||
const res = await getBugDetail(id);
|
// 复制, 只需返回初始状态
|
||||||
const { customFields, templateId, attachments } = res;
|
await templateChange(templateId);
|
||||||
// 根据模板ID 初始化自定义字段
|
} else {
|
||||||
if (isCopy.value) {
|
await templateChange(templateId, { fromStatusId: status, platformBugKey: platformBugId });
|
||||||
// 复制, 只需返回初始状态
|
|
||||||
await templateChange(templateId);
|
|
||||||
} else {
|
|
||||||
await templateChange(templateId, { fromStatusId: res.status, platformBugKey: res.platformBugId });
|
|
||||||
}
|
|
||||||
if (attachments && attachments.length) {
|
|
||||||
if (!isCopy.value) {
|
|
||||||
// 非Copy时, 附件列表赋值
|
|
||||||
attachmentsList.value = attachments;
|
|
||||||
}
|
}
|
||||||
// 检查文件是否有更新
|
} catch (error) {
|
||||||
const checkUpdateFileIds = await checkFileIsUpdateRequest(attachments.map((item: any) => item.fileId));
|
// eslint-disable-next-line no-console
|
||||||
// 处理文件列表
|
console.log(error);
|
||||||
fileList.value = attachments
|
}
|
||||||
.map((fileInfo: any) => {
|
}
|
||||||
return {
|
|
||||||
...fileInfo,
|
// 处理文件
|
||||||
name: fileInfo.fileName,
|
async function handleFile(attachments: AttachFileInfo[]) {
|
||||||
isUpdateFlag: checkUpdateFileIds.includes(fileInfo.fileId),
|
if (!attachments.length) {
|
||||||
isCopyFlag: isCopy.value,
|
return;
|
||||||
};
|
}
|
||||||
})
|
// 非Copy时, 附件列表赋值
|
||||||
.map((fileInfo: any) => {
|
if (!props.isCopyBug) {
|
||||||
return convertToFileByBug(fileInfo);
|
attachmentsList.value = attachments;
|
||||||
});
|
}
|
||||||
|
// 检查文件是否有更新
|
||||||
|
const checkUpdateFileIds = await checkFileIsUpdateRequest(attachments.map((item: any) => item.fileId));
|
||||||
|
// 处理文件列表
|
||||||
|
fileList.value = attachments
|
||||||
|
.map((fileInfo: any) => {
|
||||||
|
return {
|
||||||
|
...fileInfo,
|
||||||
|
name: fileInfo.fileName,
|
||||||
|
isUpdateFlag: checkUpdateFileIds.includes(fileInfo.fileId),
|
||||||
|
isCopyFlag: props.isCopyBug,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.map((fileInfo: any) => {
|
||||||
|
return convertToFileByBug(fileInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeCustomValue(bugDetail: BugEditFormObject) {
|
||||||
|
const { customFields, status } = bugDetail;
|
||||||
|
let tmpObj: Record<string, any> = {};
|
||||||
|
|
||||||
|
if (isEdit.value) {
|
||||||
|
tmpObj = { status };
|
||||||
}
|
}
|
||||||
|
|
||||||
let tmpObj: Record<string, any> = {};
|
|
||||||
if (isEdit.value) {
|
|
||||||
tmpObj = { status: res.status };
|
|
||||||
}
|
|
||||||
if (customFields && Array.isArray(customFields)) {
|
if (customFields && Array.isArray(customFields)) {
|
||||||
const MULTIPLE_TYPE = ['MULTIPLE_SELECT', 'MULTIPLE_INPUT', 'CHECKBOX', 'MULTIPLE_MEMBER'];
|
const MULTIPLE_TYPE = ['MULTIPLE_SELECT', 'MULTIPLE_INPUT', 'CHECKBOX', 'MULTIPLE_MEMBER'];
|
||||||
const SINGRADIO_TYPE = ['RADIO', 'SELECT', 'MEMBER'];
|
const SINGRADIO_TYPE = ['RADIO', 'SELECT', 'MEMBER'];
|
||||||
customFields.forEach((item) => {
|
customFields.forEach((item) => {
|
||||||
if (item.id === 'status' && isCopy.value) {
|
if (item.id === 'status' && props.isCopyBug) {
|
||||||
// 复制时, 状态赋值为空
|
// 复制时, 状态赋值为空
|
||||||
tmpObj[item.id] = '';
|
tmpObj[item.id] = '';
|
||||||
// 多选类型需要过滤选项
|
// 多选类型需要过滤选项
|
||||||
|
@ -730,34 +737,57 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 自定义字段赋值
|
return tmpObj;
|
||||||
fApi.value.setValue(tmpObj);
|
}
|
||||||
// 平台默认模板系统字段单独处理
|
|
||||||
if (isPlatformDefaultTemplate.value && form.value.platformSystemFields) {
|
|
||||||
Object.keys(form.value.platformSystemFields).forEach((key) => {
|
|
||||||
form.value.platformSystemFields[key] = tmpObj[key];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const { platformSystemFields } = form.value;
|
|
||||||
|
|
||||||
let copyName = '';
|
// 获取详情
|
||||||
if (isCopy.value) {
|
const getDetailInfo = async () => {
|
||||||
copyName = `copy_${res.title}`;
|
try {
|
||||||
if (copyName.length > 255) {
|
loading.value = true;
|
||||||
form.value.title = copyName.slice(0, 255);
|
const res = await getBugDetail(bugId.value as string);
|
||||||
|
const { templateId, attachments } = res;
|
||||||
|
if (templateId) {
|
||||||
|
await setTemplateValue(res);
|
||||||
}
|
}
|
||||||
|
// 处理附件
|
||||||
|
handleFile(attachments);
|
||||||
|
|
||||||
|
// 处理自定义字段以及三方字段
|
||||||
|
const tmpObj = await makeCustomValue(res);
|
||||||
|
fApi.value.setValue(tmpObj);
|
||||||
|
|
||||||
|
// 平台默认模板系统字段单独处理
|
||||||
|
if (isPlatformDefaultTemplate.value && form.value.platformSystemFields) {
|
||||||
|
Object.keys(form.value.platformSystemFields).forEach((key) => {
|
||||||
|
form.value.platformSystemFields[key] = tmpObj[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const { platformSystemFields } = form.value;
|
||||||
|
|
||||||
|
let copyName = '';
|
||||||
|
if (props.isCopyBug) {
|
||||||
|
copyName = `copy_${res.title}`;
|
||||||
|
if (copyName.length > 255) {
|
||||||
|
form.value.title = copyName.slice(0, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单赋值
|
||||||
|
form.value = {
|
||||||
|
id: res.id,
|
||||||
|
title: props.isCopyBug ? copyName : res.title,
|
||||||
|
description: res.description,
|
||||||
|
templateId: res.templateId,
|
||||||
|
tags: res.tags || [],
|
||||||
|
projectId: res.projectId,
|
||||||
|
platformSystemFields,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
}
|
}
|
||||||
// 表单赋值
|
|
||||||
form.value = {
|
|
||||||
id: res.id,
|
|
||||||
title: isCopy.value ? copyName : res.title,
|
|
||||||
description: res.description,
|
|
||||||
templateId: res.templateId,
|
|
||||||
tags: res.tags || [],
|
|
||||||
projectId: res.projectId,
|
|
||||||
platformSystemFields,
|
|
||||||
};
|
|
||||||
loading.value = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 监视自定义字段改变处理formCreate
|
// 监视自定义字段改变处理formCreate
|
||||||
|
|
Loading…
Reference in New Issue