From c88ae82ec2267a77bd19d08ed91f7bf84ad11f87 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 07 七月 2025 18:17:53 +0800
Subject: [PATCH] fix: 江佑保系统健壮性修复

---
 src/hooks/insuranceClaim.ts |   72 ++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/src/hooks/insuranceClaim.ts b/src/hooks/insuranceClaim.ts
index 1f0aaef..47f22ba 100644
--- a/src/hooks/insuranceClaim.ts
+++ b/src/hooks/insuranceClaim.ts
@@ -1,5 +1,6 @@
 import * as insuranceClaimServices from '@/services/api/InsuranceClaim';
 import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
+import { downloadFileByUrl, setOSSLink } from '@/utils';
 import { useQuery, useQueryClient } from '@tanstack/vue-query';
 
 type UseInsuranceOrderMaterialListOptions = {
@@ -29,3 +30,74 @@
     refetch,
   };
 }
+
+type UseInsurancePolicyPayOptions = {
+  id: MaybeRef<string>;
+};
+
+export function useInsurancePolicyPay({ id }: UseInsurancePolicyPayOptions) {
+  const { data: insurancePolicyPayList, isLoading } = useQuery({
+    queryKey: ['insuranceOrderServices/getInsurancePolicyPay', id],
+    queryFn: async () => {
+      return await insuranceOrderServices.getInsurancePolicyPay({
+        id: unref(id),
+      });
+    },
+    placeholderData: () => [] as API.InsurancePolicyPayDto[],
+  });
+
+  return {
+    insurancePolicyPayList,
+    isLoading,
+  };
+}
+
+export function useInsureActions() {
+  const router = useRouter();
+  async function handleGoDownloadInvoice(id: string) {
+    try {
+      await insuranceOrderServices.getInvoiceId({ id: id });
+      router.push({
+        name: 'InsureDownloadInvoice',
+        params: {
+          id: id,
+        },
+      });
+    } catch (error) {}
+  }
+
+  async function handleGoStampFiles(id: string) {
+    try {
+      router.push({
+        name: 'InsurancePolicyStampFiles',
+        params: {
+          id: id,
+        },
+      });
+    } catch (error) {}
+  }
+
+  return {
+    handleGoDownloadInvoice,
+    handleGoStampFiles,
+  };
+}
+
+export function useDownloadPolicyFileId() {
+  async function handleDownload(row: API.InsurancePolicyPayDto) {
+    try {
+      if (row.policyOssUrl) {
+        downloadFileByUrl(setOSSLink(row.policyOssUrl), `淇濆崟_${row.channelOrderNo}`);
+      } else {
+        let res = await insuranceOrderServices.downloadPolicyFileId({ id: row.id });
+        if (res) {
+          window.open(res, '_blank');
+        }
+      }
+    } catch (error) {}
+  }
+
+  return {
+    handleDownload,
+  };
+}

--
Gitblit v1.9.1