From e9dda9e6c52cb737267185f5118ded73c0053115 Mon Sep 17 00:00:00 2001 From: wupengfei <834520024@qq.com> Date: 星期二, 06 五月 2025 17:13:41 +0800 Subject: [PATCH] feat: 接口 --- src/components/commonView/utils/index.ts | 131 +++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 125 insertions(+), 6 deletions(-) diff --git a/src/components/commonView/utils/index.ts b/src/components/commonView/utils/index.ts index 8918223..9550a10 100644 --- a/src/components/commonView/utils/index.ts +++ b/src/components/commonView/utils/index.ts @@ -1,15 +1,19 @@ import { convertApi2FormUrl, convertApi2FormUrlOnlyOne } from '@/utils'; import { - ApplyTransferFileBusinessTypeEnum, - ApplyTransferFileBusinessTypeEnumKey, ApplyTransferMaterialFileTableItem, - FourStreamsMaterialFileBusinessTypeEnum, - FourStreamsMaterialFileBusinessTypeEnumKey, FourStreamsMaterialFileTableItem, - TransferFileEnumInRewardGrand, - TransferFileEnumInRewardGrandKey, TransferFileEnumInRewardGrandTableItem, } from '../types'; +import { UploadUserFile } from '@bole-core/components'; +import _ from 'lodash'; +import { + ApplyTransferFileBusinessTypeEnum, + ApplyTransferFileBusinessTypeEnumKey, + FourStreamsMaterialFileBusinessTypeEnum, + FourStreamsMaterialFileBusinessTypeEnumKey, + TransferFileEnumInRewardGrand, + TransferFileEnumInRewardGrandKey, +} from '@/constants'; export class FourStreamsMaterialUtils { /**瀹炰綋浜т笟鍥潗鏂� */ @@ -112,3 +116,118 @@ return parkTypeName === '鏁板瓧缁忔祹鍥�'; } } + +export type CustomerApplyFileTypeListItem = { + id?: string; + fileSearchTypeId?: string; + fileTypeName?: string; + lastUpdateTime?: string; + listFiles?: (API.CustomerUploadMonthApplyFileTypeDto & UploadUserFile)[]; +}; + +export class EnterpriseApplyFileUtils { + static convertApiFileToParkCollectFileList(listFiles: API.CustomerUploadMonthApplyFileTypeDto[]) { + const group = _.groupBy(listFiles, 'fileSearchTypeId'); + return Object.keys(group).map( + (x) => + ({ + fileSearchTypeId: x, + fileTypeName: group[x][0].fileSearchTypeName, + listFiles: group[x] + .filter((x) => !!x.fileUrl) + .map((a) => ({ + ...a, + ...convertApi2FormUrl(a.fileUrl), + })), + } as CustomerApplyFileTypeListItem) + ); + } + + static initParkCollectFileList(parkCollectFileTypeList: API.GetCustomerUploadApplyFilesOutput[]) { + return parkCollectFileTypeList.map( + (x) => + ({ + fileSearchTypeId: x.fileSearchTypeId, + fileTypeName: x.fileTypeName, + listFiles: [], + } as CustomerApplyFileTypeListItem) + ); + } + + static initParkCollectFileListApplyFiles( + applyUploadFiles: API.GetEnterpriseParkApplyUploadFileOutput[], + applyFiles: API.GetCustomerUploadApplyFilesOutput[], + lastUploadEnterPactFile: API.CustomerUploadMonthApplyFileTypeDto[] + ) { + return applyUploadFiles.map((x) => { + const applyFile = applyFiles.find((a) => a.fileSearchTypeId === x.fileSearchTypeId); + let listFiles: API.CustomerUploadMonthApplyFileTypeDto[]; + if (x.fileSearchTypeName === '鍥尯鍏ラ┗鍗忚') { + listFiles = !x.listFiles.length ? lastUploadEnterPactFile : x.listFiles; + } else { + listFiles = + !x.listFiles.length && applyFile?.listFiles?.length > 0 + ? applyFile.listFiles + : x.listFiles; + } + + return { + fileSearchTypeId: x.fileSearchTypeId, + fileTypeName: x.fileSearchTypeName, + listFiles: listFiles.map((a) => ({ ...a, ...convertApi2FormUrl(a.fileUrl) })), + } as CustomerApplyFileTypeListItem; + }); + } + + static convertFileTableListToApi(fileTableList: CustomerApplyFileTypeListItem[]) { + return fileTableList.map( + (x) => + ({ + fileSearchTypeId: x.fileSearchTypeId, + listFiles: x.listFiles.map((a) => ({ + fileSearchTypeId: x.fileSearchTypeId, + fileSearchTypeName: x.fileTypeName, + fileSize: a.fileSize || a.size, + fileUrl: a.path, + })), + } as API.CustomerUploadMonthApplyFileType) + ); + } + + static convertFileTableListToApplyCompanyFile(fileTableList: CustomerApplyFileTypeListItem[]) { + return fileTableList.map( + (x) => + ({ + fileSearchTypeId: x.fileSearchTypeId, + fileSearchTypeName: x.fileTypeName, + listFiles: x.listFiles.map((a) => ({ + fileSearchTypeId: x.fileSearchTypeId, + fileSearchTypeName: x.fileTypeName, + fileSize: a.fileSize || a.size, + fileUrl: a.path, + })), + } as API.UploadParkApplyCustomerFileTypes) + ); + } + + static convertFileTableListToApiBatch(fileTableList: CustomerApplyFileTypeListItem[]) { + const applyFileTypeList = this.convertFileTableListToApi(fileTableList); + return _.flatMap(applyFileTypeList, (x) => x.listFiles); + } + + static isFileTableListAllUploaded(fileTableList: CustomerApplyFileTypeListItem[]) { + return fileTableList.every((fileTableListItem) => { + return fileTableListItem.listFiles.every((fileItem) => { + return fileItem.status === 'success'; + }); + }); + } + + static isFileTableListExist(fileTableList: CustomerApplyFileTypeListItem[]) { + return fileTableList.some((fileTableListItem) => { + return fileTableListItem.listFiles.some((fileItem) => { + return fileItem.status === 'success'; + }); + }); + } +} -- Gitblit v1.9.1