|  |  |  | 
|---|
|  |  |  | import { convertAttAchmentsToForm } from '../utils'; | 
|---|
|  |  |  | import { UploadUserFile } from '@bole-core/components'; | 
|---|
|  |  |  | import dayjs from 'dayjs'; | 
|---|
|  |  |  | import { omit } from 'lodash'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | type UseInsuranceClaimDetailOptions = { | 
|---|
|  |  |  | insuranceOrderId?: MaybeRef<string>; | 
|---|
|  |  |  | fromRoute?: MaybeRef<string>; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export function useInsuranceClaimDetail({ insuranceOrderId }: UseInsuranceClaimDetailOptions) { | 
|---|
|  |  |  | export function useInsuranceClaimDetail({ | 
|---|
|  |  |  | insuranceOrderId, | 
|---|
|  |  |  | fromRoute, | 
|---|
|  |  |  | }: UseInsuranceClaimDetailOptions) { | 
|---|
|  |  |  | const DefaultAccidentProcess = `事故经过: | 
|---|
|  |  |  | 治疗医院:二级及以上公立医院 | 
|---|
|  |  |  | 诊断结果(与诊断证明一致) | 
|---|
|  |  |  | 
|---|
|  |  |  | name: '', | 
|---|
|  |  |  | idNumber: '', | 
|---|
|  |  |  | workType: '', | 
|---|
|  |  |  | orderNo: '', | 
|---|
|  |  |  | laborContractEnterprise: '', | 
|---|
|  |  |  | workEnterprise: '', | 
|---|
|  |  |  | enterpriseName: '', | 
|---|
|  |  |  | insuranceBeginTime: '', | 
|---|
|  |  |  | insuranceEndTime: '', | 
|---|
|  |  |  | insuredInstitution: '', | 
|---|
|  |  |  | insuranceOrg: '', | 
|---|
|  |  |  | insuranceScheme: '', | 
|---|
|  |  |  | contactNumber: '', | 
|---|
|  |  |  | bakContactNumber: '', | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const form = reactive({ | 
|---|
|  |  |  | insuranceOrderId: unref(insuranceOrderId), | 
|---|
|  |  |  | fromRoute: unref(fromRoute), | 
|---|
|  |  |  | reportedTime: '', | 
|---|
|  |  |  | accidentTime: '', | 
|---|
|  |  |  | ...DefaultForm, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function resetForm() { | 
|---|
|  |  |  | Object.assign(form, { ...DefaultForm }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function resetFormWithNotOrder() { | 
|---|
|  |  |  | Object.assign(form, { ...omit(DefaultForm, 'idNumber'), accidentTime: '' }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const queryClient = useQueryClient(); | 
|---|
|  |  |  | 
|---|
|  |  |  | queryFn: async () => { | 
|---|
|  |  |  | return await insuranceClaimServices.getInsuranceClaimDetailByOrderId( | 
|---|
|  |  |  | { | 
|---|
|  |  |  | orderId: form.insuranceOrderId, | 
|---|
|  |  |  | orderId: _insuranceOrderId.value, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | showLoading: false, | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { isLoading: isClaimDetailLoading } = useQuery({ | 
|---|
|  |  |  | queryKey: ['insuranceClaimServices/getInsuranceClaimDetail', _insuranceOrderId], | 
|---|
|  |  |  | queryFn: async () => { | 
|---|
|  |  |  | return await insuranceClaimServices.getInsuranceClaimDetail( | 
|---|
|  |  |  | { id: form.insuranceOrderId }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | showLoading: false, | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | placeholderData: () => ({} as API.InsuranceClaimDetailOutput), | 
|---|
|  |  |  | onSuccess(data) { | 
|---|
|  |  |  | if (data) { | 
|---|
|  |  |  | form.name = data.name; | 
|---|
|  |  |  | form.idNumber = data.idNumber; | 
|---|
|  |  |  | // form.insuredInstitution = data.insuredInstitution; | 
|---|
|  |  |  | form.insuranceScheme = data.insuranceScheme; | 
|---|
|  |  |  | form.insuranceOrg = data.insuranceOrg; | 
|---|
|  |  |  | form.orderNo = data.orderNo; | 
|---|
|  |  |  | form.enterpriseName = data.enterpriseName; | 
|---|
|  |  |  | form.reportedTime = data.reportedTime; | 
|---|
|  |  |  | form.contactNumber = data.contactNumber; | 
|---|
|  |  |  | form.bakContactNumber = data.bakContactNumber; | 
|---|
|  |  |  | form.accidentType = data.accidentType; | 
|---|
|  |  |  | form.accidentTime = data.accidentTime; | 
|---|
|  |  |  | form.disabilityRatio = data.disabilityRatio ?? 0; | 
|---|
|  |  |  | form.accidentAddress = data.accidentAddress; | 
|---|
|  |  |  | form.accidentProcess = data.accidentProcess ?? DefaultAccidentProcess; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | form.insuranceBeginTime = data.insuranceBeginTime; | 
|---|
|  |  |  | form.insuranceEndTime = data.insuranceEndTime; | 
|---|
|  |  |  | form.laborContractEnterprise = data.laborContractEnterprise; | 
|---|
|  |  |  | form.workEnterprise = data.workEnterprise; | 
|---|
|  |  |  | form.workType = data.workType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | form.channel = data.channel; | 
|---|
|  |  |  | form.onJobFlag = data.onJobFlag; | 
|---|
|  |  |  | form.gender = data.gender; | 
|---|
|  |  |  | form.age = data.age; | 
|---|
|  |  |  | form.premiumAmount = data.premiumAmount; | 
|---|
|  |  |  | form.incDecAmount = data.incDecAmount; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | form.claimResult = data.claimResult ?? ('' as any as InsuranceClaimResultEnum); | 
|---|
|  |  |  | form.claimResultTime = data.claimResultTime ?? ''; | 
|---|
|  |  |  | form.downPaymentAmount = data.downPaymentAmount ?? 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const attachmentIdCard = convertAttAchmentsToForm( | 
|---|
|  |  |  | data.attachments, | 
|---|
|  |  |  | InsuranceClaimAttachmentBusinessTypeEnum.InjuredIdCardImg | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | form.attachmentFrontIdCards = attachmentIdCard[0] ? [attachmentIdCard[0]] : []; | 
|---|
|  |  |  | form.attachmentBackIdCards = attachmentIdCard[1] ? [attachmentIdCard[1]] : []; | 
|---|
|  |  |  | form.attachmentSites = convertAttAchmentsToForm( | 
|---|
|  |  |  | data.attachments, | 
|---|
|  |  |  | InsuranceClaimAttachmentBusinessTypeEnum.InjurySiteImg | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | form.attachmentHandheldIdCards = convertAttAchmentsToForm( | 
|---|
|  |  |  | data.attachments, | 
|---|
|  |  |  | InsuranceClaimAttachmentBusinessTypeEnum.InjuredHandheldIdCardImg | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | form.attachmentAreas = convertAttAchmentsToForm( | 
|---|
|  |  |  | data.attachments, | 
|---|
|  |  |  | InsuranceClaimAttachmentBusinessTypeEnum.InjuredAreaImg | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | form.attachmentCases = convertAttAchmentsToForm( | 
|---|
|  |  |  | data.attachments, | 
|---|
|  |  |  | InsuranceClaimAttachmentBusinessTypeEnum.CasesImg | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | enabled: computed(() => !!form.insuranceOrderId && form.fromRoute === 'InsuranceOrderDetail'), | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { isLoading } = useQuery({ | 
|---|
|  |  |  | queryKey: ['insuranceOrderServices/getInsuranceOrderDetail', _insuranceOrderId], | 
|---|
|  |  |  | queryFn: async () => { | 
|---|
|  |  |  | 
|---|
|  |  |  | onSuccess(data) { | 
|---|
|  |  |  | importInsuranceOrderData(data); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | enabled: computed(() => !!form.insuranceOrderId), | 
|---|
|  |  |  | enabled: computed(() => !!form.insuranceOrderId && form.fromRoute !== 'InsuranceOrderDetail'), | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function importInsuranceOrderData(data: API.InsuranceOrderListOutput) { | 
|---|
|  |  |  | 
|---|
|  |  |  | form.idNumber = data.idNumber; | 
|---|
|  |  |  | form.insuranceBeginTime = data.insuranceBeginTime; | 
|---|
|  |  |  | form.insuranceEndTime = data.insuranceEndTime; | 
|---|
|  |  |  | form.insuredInstitution = data.insuredInstitution; | 
|---|
|  |  |  | form.insuranceOrg = data.insuranceOrg; | 
|---|
|  |  |  | form.insuranceScheme = data.insuranceScheme; | 
|---|
|  |  |  | form.laborContractEnterprise = data.laborContractEnterprise; | 
|---|
|  |  |  | form.enterpriseName = data.enterpriseName; | 
|---|
|  |  |  | form.workEnterprise = data.workEnterprise; | 
|---|
|  |  |  | form.workType = data.workType; | 
|---|
|  |  |  | form.channel = data.channel; | 
|---|
|  |  |  | form.onJobFlag = data.onJobFlag; | 
|---|
|  |  |  | form.gender = data.gender; | 
|---|
|  |  |  | form.age = data.age; | 
|---|
|  |  |  | form.orderNo = data.orderNo; | 
|---|
|  |  |  | form.premiumAmount = data.premiumAmount; | 
|---|
|  |  |  | form.incDecAmount = data.incDecAmount; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | disabledReportedDate, | 
|---|
|  |  |  | queryClaimDetailByOrderId, | 
|---|
|  |  |  | resetForm, | 
|---|
|  |  |  | resetFormWithNotOrder, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|