fix(缺陷管理): 缺陷编辑附件更新失败
--bug=1036395 --user=宋昌昌 【缺陷管理】编辑ms平台缺陷,关联附件,更新失败 https://www.tapd.cn/55049933/s/1469807
This commit is contained in:
parent
5e17fe21cb
commit
ebf7d5ca5f
|
@ -576,7 +576,7 @@ public class BugAttachmentService {
|
|||
private String getLocalFileType(String fileName) {
|
||||
int i = fileName.lastIndexOf(".");
|
||||
if (i > 0) {
|
||||
return fileName.substring(i);
|
||||
return fileName.substring(i + 1);
|
||||
} else {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ import { CommentParams } from '@/components/business/ms-comment/types';
|
|||
import MSR from '@/api/http/index';
|
||||
import * as bugURL from '@/api/requrls/bug-management';
|
||||
|
||||
import { BugEditFormObject, BugExportParams, BugListItem } from '@/models/bug-management';
|
||||
import { AssociatedList, CreateOrUpdateDemand, DemandItem, OperationFile } from '@/models/caseManagement/featureCase';
|
||||
import {BugEditFormObject, BugListItem} from '@/models/bug-management';
|
||||
import {AssociatedList, DemandItem, OperationFile} from '@/models/caseManagement/featureCase';
|
||||
import {CommonList, TableQueryParams, TemplateOption} from '@/models/common';
|
||||
|
||||
/**
|
||||
|
@ -154,8 +154,8 @@ export function checkFileIsUpdateRequest(data: string[]) {
|
|||
}
|
||||
|
||||
// 更新文件
|
||||
export function updateFile(projectId: string, id: string) {
|
||||
return MSR.get({ url: `${bugURL.getFileIsUpdateUrl}/${projectId}/${id}` });
|
||||
export function updateFile(data: OperationFile) {
|
||||
return MSR.post({ url: bugURL.getFileIsUpdateUrl, data });
|
||||
}
|
||||
|
||||
// 删除文件或取消关联用例文件
|
||||
|
|
|
@ -288,7 +288,8 @@
|
|||
innerFileList.value = [fileItem];
|
||||
inputFileName.value = fileItem.name || '';
|
||||
}
|
||||
emit('change', innerFileList.value, { ...fileItem, local: true });
|
||||
fileItem.local = true;
|
||||
emit('change', _fileList);
|
||||
nextTick(() => {
|
||||
// 在 emit 文件上去之后再关闭菜单
|
||||
buttonDropDownVisible.value = false;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<!-- 本地文件 -->
|
||||
<div v-if="item.local || item.status === 'init'" class="flex flex-nowrap">
|
||||
<MsButton
|
||||
v-if="item.status !== 'init'"
|
||||
v-if="item.status !== 'init' && item.file.type.includes('image')"
|
||||
type="button"
|
||||
status="primary"
|
||||
class="!mr-[4px]"
|
||||
|
@ -80,7 +80,7 @@
|
|||
<!-- 关联文件 -->
|
||||
<div v-else class="flex flex-nowrap">
|
||||
<MsButton
|
||||
v-if="item.status !== 'init'"
|
||||
v-if="item.status !== 'init' && item.file.type.includes('image')"
|
||||
type="button"
|
||||
status="primary"
|
||||
class="!mr-[4px]"
|
||||
|
@ -136,7 +136,7 @@
|
|||
import MsRichText from '@/components/pure/ms-rich-text/MsRichText.vue';
|
||||
import MsFileList from '@/components/pure/ms-upload/fileList.vue';
|
||||
import { MsFileItem } from '@/components/pure/ms-upload/types';
|
||||
import AddAttachment from "@/components/business/ms-add-attachment/index.vue";
|
||||
import AddAttachment from '@/components/business/ms-add-attachment/index.vue';
|
||||
import RelateFileDrawer from '@/components/business/ms-link-file/associatedFileDrawer.vue';
|
||||
import TransferModal from '@/views/case-management/caseManagementFeature/components/tabContent/transferModal.vue';
|
||||
|
||||
|
@ -151,7 +151,7 @@
|
|||
previewFile,
|
||||
transferFileRequest,
|
||||
updateFile,
|
||||
uploadOrAssociationFile
|
||||
uploadOrAssociationFile,
|
||||
} from '@/api/modules/bug-management';
|
||||
import { getModules, getModulesCount } from '@/api/modules/project-management/fileManagement';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
|
@ -223,7 +223,7 @@
|
|||
return {
|
||||
...fileInfo,
|
||||
name: fileInfo.fileName,
|
||||
isUpdateFlag: checkUpdateFileIds.includes(fileInfo.id),
|
||||
isUpdateFlag: checkUpdateFileIds.includes(fileInfo.fileId),
|
||||
};
|
||||
})
|
||||
.map((fileInfo: any) => {
|
||||
|
@ -241,7 +241,7 @@
|
|||
form.value.title = title;
|
||||
form.value.description = description;
|
||||
defaultContentValue.value = description;
|
||||
handleFileFunc(attachments);
|
||||
await handleFileFunc(attachments);
|
||||
};
|
||||
|
||||
// 取消富文本框编辑时,要将数据复位
|
||||
|
@ -264,7 +264,7 @@
|
|||
item.local ? t('caseManagement.featureCase.deleteSuccess') : t('caseManagement.featureCase.cancelLinkSuccess')
|
||||
);
|
||||
const attachments = await getAttachmentList(bugId.value);
|
||||
handleFileFunc(attachments);
|
||||
await handleFileFunc(attachments);
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
|
@ -357,7 +357,7 @@
|
|||
async (val) => {
|
||||
const isNewFiles = val.filter((item) => item.status === 'init').length;
|
||||
if (val && isNewFiles) {
|
||||
startUpload();
|
||||
await startUpload();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -365,8 +365,16 @@
|
|||
// 更新文件
|
||||
async function handleUpdateFile(item: MsFileItem) {
|
||||
try {
|
||||
await updateFile(currentProjectId.value, item.associationId);
|
||||
const params = {
|
||||
refId: item.associateId,
|
||||
associated: !item.local,
|
||||
bugId: bugId.value,
|
||||
projectId: currentProjectId.value,
|
||||
};
|
||||
await updateFile(params);
|
||||
Message.success(t('common.updateSuccess'));
|
||||
const attachments = await getAttachmentList(bugId.value);
|
||||
await handleFileFunc(attachments);
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
|
@ -438,12 +446,12 @@
|
|||
request: {
|
||||
bugId: bugId.value as string,
|
||||
projectId: currentProjectId.value,
|
||||
selectIds: fileResultList.map((item: any) => item.uid)
|
||||
}
|
||||
selectIds: fileResultList.map((item: any) => item.uid),
|
||||
},
|
||||
};
|
||||
await uploadOrAssociationFile(params);
|
||||
const attachments = await getAttachmentList(bugId.value);
|
||||
handleFileFunc(attachments);
|
||||
await handleFileFunc(attachments);
|
||||
Message.success(t('common.linkSuccess'));
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<!-- 本地文件 -->
|
||||
<div v-if="item.local || item.status === 'init'" class="flex flex-nowrap">
|
||||
<MsButton
|
||||
v-if="item.status !== 'init'"
|
||||
v-if="item.status !== 'init' && item.file.type.includes('image')"
|
||||
type="button"
|
||||
status="primary"
|
||||
class="!mr-[4px]"
|
||||
|
@ -92,7 +92,7 @@
|
|||
<!-- 关联文件 -->
|
||||
<div v-else class="flex flex-nowrap">
|
||||
<MsButton
|
||||
v-if="item.status !== 'init'"
|
||||
v-if="item.status !== 'init' && item.file.type.includes('image')"
|
||||
type="button"
|
||||
status="primary"
|
||||
class="!mr-[4px]"
|
||||
|
@ -270,22 +270,23 @@
|
|||
|
||||
// 处理文件参数
|
||||
function getFilesParams() {
|
||||
const associateFileIds = attachmentsList.value.filter((item) => !item.local).map((item) => item.id);
|
||||
const newAssociateFileListIds = fileList.value
|
||||
// link file
|
||||
const associateFileIds = attachmentsList.value.filter((item) => !item.local).map((item) => item.fileId);
|
||||
form.value.linkFileIds = fileList.value
|
||||
.filter((item) => !item.local && !associateFileIds.includes(item.uid))
|
||||
.map((item) => item.uid);
|
||||
|
||||
const currentOldLocalFileList = fileList.value
|
||||
// unlink file
|
||||
const remainLinkFileIds = fileList.value.filter((item) => !item.local).map((item) => item.uid);
|
||||
form.value.unLinkRefIds = attachmentsList.value
|
||||
.filter((item) => !item.local && !remainLinkFileIds.includes(item.fileId))
|
||||
.map((item) => item.refId);
|
||||
// delete local file
|
||||
const remainLocalFileIds = fileList.value
|
||||
.filter((item) => item.local && item.status !== 'init')
|
||||
.map((item) => item.uid);
|
||||
|
||||
// 更新form的值
|
||||
form.value.deleteLocalFileIds = attachmentsList.value
|
||||
.filter((item) => item.local && !currentOldLocalFileList.includes(item.uid))
|
||||
.map((item) => item.uid);
|
||||
|
||||
form.value.unLinkRefIds = associateFileIds.filter((id) => !newAssociateFileListIds.includes(id));
|
||||
form.value.linkFileIds = newAssociateFileListIds;
|
||||
.filter((item) => item.local && !remainLocalFileIds.includes(item.fileId))
|
||||
.map((item) => item.fileId);
|
||||
}
|
||||
|
||||
// 监视文件列表处理关联和本地文件
|
||||
|
@ -404,7 +405,13 @@
|
|||
// 更新文件
|
||||
async function handleUpdateFile(item: MsFileItem) {
|
||||
try {
|
||||
await updateFile(currentProjectId.value, item.associationId);
|
||||
const params = {
|
||||
refId: item.associateId,
|
||||
associated: !item.local,
|
||||
bugId: bugId.value,
|
||||
projectId: currentProjectId.value,
|
||||
};
|
||||
await updateFile(params);
|
||||
Message.success(t('common.updateSuccess'));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
@ -429,7 +436,6 @@
|
|||
return {
|
||||
...e,
|
||||
enable: true, // 是否启用
|
||||
local: true, // 是否本地文件
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -466,8 +472,10 @@
|
|||
if (isCopy.value) {
|
||||
delete tmpObj.id;
|
||||
}
|
||||
// 过滤出本地保存的文件
|
||||
const localFiles = fileList.value.filter((item) => item.local && item.status === 'init');
|
||||
// 执行保存操作
|
||||
const res = await createOrUpdateBug({ request: tmpObj, fileList: fileList.value as unknown as File[] });
|
||||
const res = await createOrUpdateBug({ request: tmpObj, fileList: localFiles as unknown as File[] });
|
||||
if (isEdit.value) {
|
||||
Message.success(t('common.updateSuccess'));
|
||||
router.push({
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* @param {stafileInfotus} 文件file
|
||||
*/
|
||||
|
||||
import { getFileEnum } from '@/components/pure/ms-upload/iconMap';
|
||||
import { MsFileItem } from '@/components/pure/ms-upload/types';
|
||||
|
||||
import { AssociatedList } from '@/models/caseManagement/featureCase';
|
||||
|
@ -11,11 +12,14 @@ import { AssociatedList } from '@/models/caseManagement/featureCase';
|
|||
export function convertToFileByBug(fileInfo: AssociatedList): MsFileItem {
|
||||
const gatewayAddress = `${window.location.protocol}//${window.location.hostname}:${window.location.port}`;
|
||||
const fileName = `${fileInfo.name}`;
|
||||
const type = `${fileInfo.fileType}`;
|
||||
const fileFormatMatch = fileName.match(/\.([a-zA-Z0-9]+)$/);
|
||||
const fileFormatType = fileFormatMatch ? fileFormatMatch[1] : 'none';
|
||||
const type = getFileEnum(fileFormatType);
|
||||
const file = new File([new Blob()], `${fileName}`, {
|
||||
type: `application/${type}`,
|
||||
});
|
||||
Object.defineProperty(file, 'size', { value: fileInfo.fileSize });
|
||||
Object.defineProperty(file, 'type', { value: type });
|
||||
const { fileId, local, isUpdateFlag, refId, createUserName, createTime } = fileInfo;
|
||||
return {
|
||||
enable: fileInfo.enable || false,
|
||||
|
@ -30,7 +34,7 @@ export function convertToFileByBug(fileInfo: AssociatedList): MsFileItem {
|
|||
isUpdateFlag,
|
||||
associateId: refId,
|
||||
createUserName,
|
||||
uploadedTime: createTime
|
||||
uploadedTime: createTime,
|
||||
};
|
||||
}
|
||||
/** *
|
||||
|
|
|
@ -654,7 +654,6 @@
|
|||
return {
|
||||
...e,
|
||||
enable: true, // 是否启用
|
||||
local: true, // 是否本地文件
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue