| | |
| | | import { convertApi2FormUrlOnlyOne } from '@/utils'; |
| | | import { convertApi2FormUrl, convertApi2FormUrlOnlyOne } from '@/utils'; |
| | | import { |
| | | ApplyTransferMaterialFileTableItem, |
| | | FourStreamsMaterialFileTableItem, |
| | | TransferFileEnumInRewardGrandTableItem, |
| | | } from '../types'; |
| | | import { UploadUserFile } from '@bole-core/components'; |
| | | import _ from 'lodash'; |
| | | import { |
| | | ApplyTransferFileBusinessTypeEnum, |
| | | ApplyTransferFileBusinessTypeEnumKey, |
| | | FourStreamsMaterialFileBusinessTypeEnum, |
| | | FourStreamsMaterialFileBusinessTypeEnumKey, |
| | | FourStreamsMaterialFileTableItem, |
| | | } from '../types'; |
| | | TransferFileEnumInRewardGrand, |
| | | TransferFileEnumInRewardGrandKey, |
| | | } from '@/constants'; |
| | | |
| | | export class FourStreamsMaterialUtils { |
| | | /**实体产业园材料 */ |
| | |
| | | /**数字经济园材料 */ |
| | | static DigitIndustrialParkMaterialFile = [ |
| | | FourStreamsMaterialFileBusinessTypeEnum.ParkEnterPactUrl, |
| | | FourStreamsMaterialFileBusinessTypeEnum.EnterRelateUrl, |
| | | // FourStreamsMaterialFileBusinessTypeEnum.EnterRelateUrl, |
| | | FourStreamsMaterialFileBusinessTypeEnum.RatePaymentFileUrl, |
| | | FourStreamsMaterialFileBusinessTypeEnum.TaxSubFileUrl, |
| | | FourStreamsMaterialFileBusinessTypeEnum.OperateProfitesUrl, |
| | | FourStreamsMaterialFileBusinessTypeEnum.PersonTaxRatePayUrl, |
| | | FourStreamsMaterialFileBusinessTypeEnum.PersonTaxInstructUrl, |
| | | ]; |
| | | |
| | | /**财政拨付和平台充值凭证 */ |
| | | static ApplyTransferMaterialFile = [ |
| | | ApplyTransferFileBusinessTypeEnum.FinanceToFileUrl, |
| | | ApplyTransferFileBusinessTypeEnum.TransferToFileUrl, |
| | | ]; |
| | | |
| | | /**财政拨付和平台充值凭证 奖励金发放*/ |
| | | static TransferFileEnumInRewardGrandFile = [ |
| | | TransferFileEnumInRewardGrand.FinanceFileUrl, |
| | | TransferFileEnumInRewardGrand.SettleFileUrl, |
| | | ]; |
| | | |
| | | static isFourStreamsParkType(parkTypeName) { |
| | |
| | | ]) |
| | | ); |
| | | } |
| | | |
| | | static initApplyTransferMaterialFileList< |
| | | T extends { financeToFileUrl?: string; transferToFileUrl?: string } |
| | | >(data: T) { |
| | | return this.ApplyTransferMaterialFile.map((item) => { |
| | | const filePathList = data[ApplyTransferFileBusinessTypeEnumKey[item]] |
| | | ? data[ApplyTransferFileBusinessTypeEnumKey[item]].split('|') |
| | | : []; |
| | | return { |
| | | fileBusinessType: item, |
| | | fileList: filePathList.map(convertApi2FormUrl), |
| | | } as ApplyTransferMaterialFileTableItem; |
| | | }); |
| | | } |
| | | |
| | | static initApplyRewardGrandFileList< |
| | | T extends { financeFileUrl?: string; settleFileUrl?: string } |
| | | >(data: T) { |
| | | return this.TransferFileEnumInRewardGrandFile.map((item) => { |
| | | const filePathList = data[TransferFileEnumInRewardGrandKey[item]] |
| | | ? data[TransferFileEnumInRewardGrandKey[item]].split('|') |
| | | : []; |
| | | return { |
| | | fileBusinessType: item, |
| | | fileList: filePathList.map(convertApi2FormUrl), |
| | | } as TransferFileEnumInRewardGrandTableItem; |
| | | }); |
| | | } |
| | | } |
| | | |
| | | export class ParkTypeUtils { |
| | |
| | | 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'; |
| | | }); |
| | | }); |
| | | } |
| | | } |