wupengfei
2025-03-28 acaec313ab0e3c9381060e36bf3ce4abc606dc9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import dayjs from 'dayjs';
import { UploadUserFile } from '@bole-core/components';
import { InsuranceClaimAttachmentBusinessTypeEnum } from '@/constants';
import { convertApi2FormUrl } from '@/utils';
 
export function convertFormToattAchments(
  files: UploadUserFile[],
  businessType: InsuranceClaimAttachmentBusinessTypeEnum
) {
  return files.map((x) => ({
    fileName: x.name,
    url: x.path,
    businessType: businessType,
  }));
}
 
export function convertAttAchmentsToForm(
  attachments: API.InsuranceClaimAttachmentOutput[],
  businessType: InsuranceClaimAttachmentBusinessTypeEnum
) {
  const filterAttachments = attachments.filter((x) => x.businessType === businessType);
  return filterAttachments.length > 0
    ? filterAttachments.map((x) => convertApi2FormUrl(x.url))
    : [];
}