From 12cce14bc30a85bbf96b5b30bb1aff1fc354091a Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期四, 27 三月 2025 15:07:21 +0800
Subject: [PATCH] feat: 接口对接

---
 src/views/Home/BatchChange.vue |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/src/views/Home/BatchChange.vue b/src/views/Home/BatchChange.vue
index b5f5172..fb48b4d 100644
--- a/src/views/Home/BatchChange.vue
+++ b/src/views/Home/BatchChange.vue
@@ -34,6 +34,7 @@
                   :limitFileSize="10"
                   accept="xlsx,xls"
                   :showTip="false"
+                  :on-success="handleUploadAddOrReduce"
                 >
                   <template #default>
                     <el-button type="primary">鍔犲噺浜�</el-button>
@@ -54,6 +55,7 @@
                   :limitFileSize="10"
                   accept="xlsx,xls"
                   :showTip="false"
+                  :on-success="handleUploadReplace"
                 >
                   <template #default>
                     <el-button type="primary">鏇挎崲浜�</el-button>
@@ -108,8 +110,11 @@
   UploadUserFile,
 } from '@bole-core/components';
 import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
-import { downloadFileByUrl, OrderInputType } from '@bole-core/core';
+import * as insureBatchBillServices from '@/services/api/InsureBatchBill';
+import { downloadFileByUrl, Message, OrderInputType } from '@bole-core/core';
 import { InsuranceAddOrReduceTempPath, InsuranceChangeTempPath } from '@/constants';
+import { useRouteView } from '@/hooks';
+import { FormInstance } from 'element-plus';
 
 defineOptions({
   name: 'BatchChange',
@@ -159,6 +164,7 @@
 ];
 
 const route = useRoute();
+const { closeViewPush } = useRouteView();
 const id = route.params.id as string;
 const BaseState = {
   loading: true,
@@ -203,8 +209,50 @@
   }
 );
 
+async function handleUploadAddOrReduce(response: UploadUserFile) {
+  try {
+    let params: API.ImportBatchAddOrSubOrderInput = {
+      url: response.path,
+      insurePolicyId: id,
+    };
+    let res = await insureBatchBillServices.importBatchAddOrSubOrderData(params);
+  } catch (error) {}
+}
+async function handleUploadReplace(response: UploadUserFile) {
+  try {
+    let params: API.ImportBatchAddOrSubOrderInput = {
+      url: response.path,
+      insurePolicyId: id,
+    };
+    let res = await insureBatchBillServices.importBatchUpdateOrderData(params);
+  } catch (error) {}
+}
+
 function handleClear() {}
-function handleSubmit() {}
+
+const formRef = ref<FormInstance>();
+function handleSubmit() {
+  if (!formRef.value) return;
+  formRef.value.validate((valid) => {
+    if (valid) {
+      addOrUpdateInsureBatchBill();
+    } else {
+      return;
+    }
+  });
+}
+
+async function addOrUpdateInsureBatchBill() {
+  try {
+    let params = {};
+    let res = await insureBatchBillServices.addOrUpdateInsureBatchBill(params);
+    if (res) {
+      Message.successMessage('鎻愪氦鎴愬姛');
+      handleBack();
+    }
+  } catch (error) {}
+}
+
 function DownloadAddOrReducePersonTemplate() {
   downloadFileByUrl(InsuranceAddOrReduceTempPath, '鍔犲噺浜烘ā鏉�');
 }
@@ -212,6 +260,12 @@
   downloadFileByUrl(InsuranceChangeTempPath, '鏇挎崲浜烘ā鏉�');
 }
 
+function handleBack() {
+  closeViewPush(route, {
+    name: 'Home',
+  });
+}
+
 onMounted(async () => {
   await getBatchRefundInfoDetail();
   state.loading = false;

--
Gitblit v1.9.1