feat(缺陷管理): 导出接口对接

This commit is contained in:
RubyLiu 2024-02-07 17:52:59 +08:00 committed by Craftsman
parent ac9a0e5c78
commit a739d09cf9
4 changed files with 52 additions and 23 deletions

View File

@ -76,8 +76,11 @@ export function syncBugOpenSource(params: { projectId: string }) {
}
// 导出缺陷
export function exportBug(data: BugExportParams) {
return MSR.post({ url: bugURL.postExportBugUrl, data });
export function exportBug(data: TableQueryParams) {
return MSR.post<BlobPart>(
{ url: bugURL.postExportBugUrl, data, responseType: 'blob' },
{ isTransformResponse: false }
);
}
// 获取关联文件列表
export function getAssociatedFileList(data: TableQueryParams) {

View File

@ -72,7 +72,7 @@
:show-delete="props.allowEdit"
>
<template #actions="{ item }">
<div v-if="props.allowEdit">
<div>
<!-- 本地文件 -->
<div v-if="item.local || item.status === 'init'" class="flex flex-nowrap">
<MsButton
@ -191,8 +191,7 @@
import { AssociatedList, AttachFileInfo } from '@/models/caseManagement/featureCase';
import { TableQueryParams } from '@/models/common';
import { convertToFileByBug } from '@/views/bug-management/utils';
import { convertToFile } from '@/views/case-management/caseManagementFeature/components/utils';
import { convertToFileByBug, convertToFileByDetail } from '@/views/bug-management/utils';
defineOptions({
name: 'BugDetailTab',
@ -340,12 +339,6 @@
associatedDrawer.value = true;
}
//
function saveSelectAssociatedFile(fileData: AssociatedList[]) {
const fileResultList = fileData.map((fileInfo) => convertToFile(fileInfo));
fileList.value.push(...fileResultList);
}
// localitem
const oldLocalFileList = computed(() => {
return attachmentsList.value.filter((item) => item.local).map((item: any) => item.uid);
@ -412,7 +405,7 @@
watch(
() => fileList.value,
async (val) => {
const isNewFiles = val.filter((item) => item.status === 'init' || (!item.local && !item.associateId)).length;
const isNewFiles = val.filter((item) => item.status === 'init').length;
if (val && isNewFiles) {
startUpload();
}
@ -486,6 +479,13 @@
}
}
//
function saveSelectAssociatedFile(fileData: AssociatedList[]) {
const fileResultList = fileData.map(convertToFileByDetail);
fileList.value.push(...fileResultList);
handleSave();
}
watchEffect(() => {
initCurrentDetail(props.detailInfo);
});

View File

@ -157,7 +157,7 @@
import router from '@/router';
import { useAppStore, useTableStore } from '@/store';
import useLicenseStore from '@/store/modules/setting/license';
import { customFieldToColumns, tableParamsToRequestParams } from '@/utils';
import { customFieldToColumns, downloadByteFile, tableParamsToRequestParams } from '@/utils';
import { BugEditCustomField, BugListItem } from '@/models/bug-management';
import { RouteEnum } from '@/enums/routeEnum';
@ -379,19 +379,18 @@
const exportConfirm = async (option: MsExportDrawerOption[]) => {
try {
const { selectedIds, selectAll, excludeIds } = currentSelectParams.value;
await exportBug({
selectIds: selectedIds || [],
selectAll,
excludeIds,
condition: { keyword: keyword.value },
bugExportColumns: option.map((item) => item),
const params = tableParamsToRequestParams(currentSelectParams.value);
const blob = await exportBug({
...params,
exportColumns: option.map((item) => item),
projectId: appStore.currentProjectId,
});
Message.success(t('common.exportSuccess'));
downloadByteFile(blob, `${t('bugManagement.exportBug')}.zip`);
exportVisible.value = false;
resetSelector();
} catch (error) {
Message.error(t('common.exportFail'));
// eslint-disable-next-line no-console
console.log(error);
}
};

View File

@ -31,5 +31,32 @@ export function convertToFileByBug(fileInfo: AssociatedList): MsFileItem {
associateId: refId,
};
}
/** *
*
* @description
* @param {stafileInfotus} file
*/
export default {};
export function convertToFileByDetail(fileInfo: AssociatedList): MsFileItem {
const gatewayAddress = `${window.location.protocol}//${window.location.hostname}:${window.location.port}`;
const fileName = fileInfo.fileType ? `${fileInfo.name}.${fileInfo.fileType || ''}` : `${fileInfo.name}`;
const type = fileName.split('.')[1];
const file = new File([new Blob()], `${fileName}`, {
type: `application/${type}`,
});
Object.defineProperty(file, 'size', { value: fileInfo.size });
const { id, local, isUpdateFlag, associateId } = fileInfo;
return {
enable: fileInfo.enable || false,
file,
name: fileName,
percent: 0,
status: 'done',
uid: id,
url: `${gatewayAddress}/${fileInfo.filePath || ''}`,
local,
deleteContent: local ? '' : 'caseManagement.featureCase.cancelLink',
isUpdateFlag,
associateId,
};
}