zhengyiming
3 天以前 89f387786da0e4383cf06ee162526db54971f9cf
src/components/commonView/utils/index.ts
@@ -13,6 +13,8 @@
  FourStreamsMaterialFileBusinessTypeEnumKey,
  TransferFileEnumInRewardGrand,
  TransferFileEnumInRewardGrandKey,
  FourStreamsExtraMaterialFileSearchType,
  SearchType,
} from '@/constants';
export class FourStreamsMaterialUtils {
@@ -120,6 +122,7 @@
export type CustomerApplyFileTypeListItem = {
  id?: string;
  fileSearchTypeId?: string;
  searchType?: number;
  fileTypeName?: string;
  lastUpdateTime?: string;
  listFiles?: (API.CustomerUploadMonthApplyFileTypeDto & UploadUserFile)[];
@@ -154,29 +157,71 @@
    );
  }
  static convertApiFileToExtraListFiles(listFiles: API.CustomerUploadMonthApplyFileTypeDto[]) {
    if (listFiles.length > 0) {
      return this.convertApiFileToParkCollectFileList(listFiles);
    } else {
      return [
        {
          fileSearchTypeId: FourStreamsExtraMaterialFileSearchType[SearchType.BountyExtraFileType],
          fileTypeName: '补充材料',
          listFiles: [],
        } as CustomerApplyFileTypeListItem,
      ];
    }
  }
  static initParkCollectFileListApplyFiles(
    applyUploadFiles: API.GetEnterpriseParkApplyUploadFileOutput[],
    applyFiles: API.GetCustomerUploadApplyFilesOutput[],
    lastUploadEnterPactFile: API.CustomerUploadMonthApplyFileTypeDto[]
    lastUploadEnterPactFile: API.CustomerUploadMonthApplyFileTypeDto[],
    applyUploadExtraFiles: API.GetEnterpriseParkApplyUploadFileOutput[]
  ) {
    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;
      }
    const extraFiles =
      applyUploadExtraFiles.length > 0
        ? applyUploadExtraFiles.map((x) => {
            return {
              fileSearchTypeId: x.fileSearchTypeId,
              fileTypeName: x.fileSearchTypeName,
              listFiles: x.listFiles.map((a) => ({ ...a, ...convertApi2FormUrl(a.fileUrl) })),
            } as CustomerApplyFileTypeListItem;
          })
        : [
            {
              fileSearchTypeId:
                FourStreamsExtraMaterialFileSearchType[SearchType.BountyApplyExtraFileType],
              fileTypeName: '补充材料',
              listFiles: [],
            } as CustomerApplyFileTypeListItem,
          ];
      return {
        fileSearchTypeId: x.fileSearchTypeId,
        fileTypeName: x.fileSearchTypeName,
        listFiles: listFiles.map((a) => ({ ...a, ...convertApi2FormUrl(a.fileUrl) })),
      } as CustomerApplyFileTypeListItem;
    });
    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;
      })
      .concat(extraFiles);
  }
  static isApplyUploadExtraFileSearchTypeId(fileSearchTypeId: string) {
    return (
      (fileSearchTypeId ?? '').toLowerCase() ===
      FourStreamsExtraMaterialFileSearchType[SearchType.BountyApplyExtraFileType].toLowerCase()
    );
  }
  static convertFileTableListToApi(fileTableList: CustomerApplyFileTypeListItem[]) {