feat: migrate cross checking ui to v3 flow
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
type CrossCheckingUploadedFile,
|
||||
generateFileId,
|
||||
formatFileSize,
|
||||
batchUploadAndAssignCrossCheckingFiles,
|
||||
uploadCrossCheckingDocument,
|
||||
createCrossReviewTask
|
||||
} from "~/api/cross-checking/cross-files-upload";
|
||||
import {
|
||||
@@ -302,8 +302,7 @@ export default function CrossCheckingUpload() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 第一步:上传文件并自动分配任务(新接口)
|
||||
// console.log("开始批量上传文件并分配任务:", filesToUpload.length, "个,案卷类型:", selectedDocType.name);
|
||||
// 第一步:先上传文档到平台,再用 v3 接口创建交叉评查任务
|
||||
|
||||
// 提取用户ID(从选中的组织架构中获取用户)
|
||||
const userIds = groupChecked.filter(id => {
|
||||
@@ -316,23 +315,6 @@ export default function CrossCheckingUpload() {
|
||||
return;
|
||||
}
|
||||
|
||||
// const requireParam = {
|
||||
// filesToUpload: filesToUpload,
|
||||
// selectedDocTypeId: selectedDocTypeId,
|
||||
// priority: priority,
|
||||
// documentNumber: documentNumber,
|
||||
// remark: remark,
|
||||
// isTestDocument: isTestDocument,
|
||||
// userIds: userIds,
|
||||
// taskInfo_name: taskInfo.name,
|
||||
// selectedDocType_name: selectedDocType.code,
|
||||
// taskInfo_type: taskInfo.type,
|
||||
// frontendJWT
|
||||
// }
|
||||
|
||||
// // console.log("requireParam", requireParam)
|
||||
// return;
|
||||
|
||||
// 构建负责人ID数组:当前用户(主要负责人)+ 额外负责人
|
||||
const principalUserIds: number[] = [];
|
||||
// 添加当前用户作为主要负责人
|
||||
@@ -347,37 +329,63 @@ export default function CrossCheckingUpload() {
|
||||
}
|
||||
});
|
||||
|
||||
// 使用文档类型名称作为 doc_type
|
||||
const uploadResult = await batchUploadAndAssignCrossCheckingFiles(
|
||||
filesToUpload,
|
||||
selectedDocTypeId, // 使用选中的文档类型ID
|
||||
priority,
|
||||
documentNumber,
|
||||
remark,
|
||||
isTestDocument,
|
||||
const uploadSuccesses: Array<{ file: CrossCheckingUploadedFile; documentId: number }> = [];
|
||||
const uploadFailures: Array<{ file: CrossCheckingUploadedFile; error: string }> = [];
|
||||
|
||||
for (const fileInfo of filesToUpload) {
|
||||
const binaryData = await fileInfo.file.arrayBuffer();
|
||||
const uploadResponse = await uploadCrossCheckingDocument(
|
||||
binaryData,
|
||||
fileInfo.name,
|
||||
fileInfo.type,
|
||||
selectedDocTypeId,
|
||||
priority,
|
||||
documentNumber,
|
||||
remark,
|
||||
isTestDocument,
|
||||
null,
|
||||
false,
|
||||
frontendJWT
|
||||
);
|
||||
|
||||
if (uploadResponse.error || !uploadResponse.data?.result?.id) {
|
||||
uploadFailures.push({
|
||||
file: fileInfo,
|
||||
error: uploadResponse.error || '上传后未返回文档ID'
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
uploadSuccesses.push({
|
||||
file: fileInfo,
|
||||
documentId: uploadResponse.data.result.id
|
||||
});
|
||||
}
|
||||
|
||||
if (uploadFailures.length > 0) {
|
||||
toastService.error(`文件上传失败:${uploadFailures[0].error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const createTaskResult = await createCrossReviewTask({
|
||||
documentIds: uploadSuccesses.map(item => item.documentId),
|
||||
userIds,
|
||||
taskInfo.name,
|
||||
selectedDocType.code, // 使用文档类型code
|
||||
taskInfo.type, // 使用任务类型(市局间交叉评查 或 区局间交叉评查)
|
||||
frontendJWT,
|
||||
principalUserIds, // 负责人ID数组
|
||||
attributeType // 合同类型
|
||||
);
|
||||
principalUserIds,
|
||||
taskName: taskInfo.name,
|
||||
docTypeId: selectedDocTypeId,
|
||||
docType: selectedDocType.code,
|
||||
taskType: taskInfo.type
|
||||
}, frontendJWT);
|
||||
|
||||
|
||||
// return;
|
||||
|
||||
const { successes, failures } = uploadResult;
|
||||
|
||||
if (failures.length > 0) {
|
||||
toastService.error(`文件上传或任务分配失败:${failures[0].error}`);
|
||||
if (!createTaskResult.success) {
|
||||
toastService.error(createTaskResult.error || '创建交叉评查任务失败');
|
||||
return;
|
||||
}
|
||||
|
||||
// 任务创建成功
|
||||
toastService.success("交叉评查任务创建成功!");
|
||||
messageService.success(
|
||||
`任务创建完成!\n任务名称:${taskInfo.name}\n上传文件:${successes.length} 个\n评查人员:${userIds.length} 人`,
|
||||
`任务创建完成!\n任务名称:${taskInfo.name}\n上传文件:${uploadSuccesses.length} 个\n评查人员:${userIds.length} 人`,
|
||||
{
|
||||
title: '任务创建成功',
|
||||
confirmText: '确定',
|
||||
@@ -1183,4 +1191,4 @@ export default function CrossCheckingUpload() {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user