From 4923681d933b455972166552dfb7538cd18f5808 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期二, 01 四月 2025 18:49:21 +0800
Subject: [PATCH] fix: bug

---
 src/views/Home/Home.vue |  415 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 223 insertions(+), 192 deletions(-)

diff --git a/src/views/Home/Home.vue b/src/views/Home/Home.vue
index 3111cb1..59d56da 100644
--- a/src/views/Home/Home.vue
+++ b/src/views/Home/Home.vue
@@ -17,16 +17,7 @@
           </QueryFilterItem>
           <QueryFilterItem>
             <FieldRadio
-              v-model="extraParamState.onJobFlag"
-              :value-enum="OnJobFlagEnumText"
-              buttonStyle
-              showAllBtn
-              @change="getList()"
-            />
-          </QueryFilterItem>
-          <QueryFilterItem>
-            <FieldRadio
-              v-model="extraParamState.insuranceType"
+              v-model="extraParamState.insurancePeriod"
               :value-enum="insuranceTypeText"
               buttonStyle
               showAllBtn
@@ -34,58 +25,43 @@
             />
           </QueryFilterItem>
           <QueryFilterItem>
+            <FieldRadio
+              v-model="extraParamState.status"
+              :value-enum="InsurancePolicyStatusEnumText"
+              buttonStyle
+              showAllBtn
+              @change="getList()"
+            />
+          </QueryFilterItem>
+          <QueryFilterItem>
             <SearchInput
-              v-model="extraParamState.keyword"
+              v-model="extraParamState.condition"
               style="width: 260px"
-              placeholder="濮撳悕/韬唤璇�/鍗曚綅/淇濆崟鍙风瓑"
+              placeholder="鍗曚綅/淇濆崟鍙�/鍙備繚鏈烘瀯"
               @on-click-search="getList"
             >
             </SearchInput>
           </QueryFilterItem>
         </template>
         <template #btn>
-          <el-button
-            @click="handleDownload()"
-            icon="Download"
-            type="primary"
-            style="margin-right: 10px"
-            link
+          <el-button @click="handleDownload()" type="primary" style="margin-right: 10px" link
             >妯℃澘涓嬭浇</el-button
           >
 
-          <BlFileUpload
-            :limitFileSize="10"
-            accept="xls,xlsx"
-            :showTip="false"
-            :show-file-list="false"
-            :on-success="handleUploadSuccess"
+          <el-button @click="handleUpload()" type="primary" style="margin-right: 10px"
+            >瀵煎叆</el-button
           >
-            <template #default>
-              <el-button icon="Plus" type="primary">瀵煎叆</el-button>
-            </template>
-          </BlFileUpload>
 
-          <el-button
-            @click="handleEnterpriseBatchRefund()"
-            type="primary"
-            style="margin-right: 10px"
-            >鎵归噺鍑忓憳</el-button
-          >
-          <el-button
-            @click="handleExport()"
-            icon="Download"
-            type="primary"
-            style="margin-left: 10px"
-            >瀵煎嚭</el-button
+          <el-button @click="getInsurancePageExport()" type="primary" link>瀵煎嚭淇濆崟鍒楄〃</el-button>
+          <el-button @click="getInsuranceStaffPageExport()" type="primary" link
+            >瀵煎嚭鍦ㄤ繚浜哄憳</el-button
           >
         </template>
       </ProTableQueryFilterBar>
       <ProTableV2
         v-bind="proTableProps"
-        :columns="HomeColumns"
+        :columns="columns"
         :operationBtns="operationBtns"
-        :show-column-check="true"
-        :column-selectable="columnSelectable"
         ref="proTable"
         :table-props="{
           rowStyle: handleRowStyle,
@@ -94,11 +70,8 @@
       >
       </ProTableV2>
     </AppContainer>
-    <UploadMaterialDialog
-      v-bind="dialogProps"
-      @onAddUpdateMaterial="getList(paginationState.pageIndex)"
-    />
-    <BatchDownsizingDialog v-bind="dialogBatchDownsizingProps" />
+    <UploadInsurePersonDialog v-bind="dialogProps" />
+    <UploadStampFileDialog v-bind="dialogStampFileProps" />
   </LoadingLayout>
 </template>
 
@@ -112,27 +85,24 @@
   useTable,
   useFormDialog,
   FieldDatePicker,
-  BlFileUpload,
   defineOperationBtns,
   UploadUserFile,
-  XLSXUtils,
   SearchInput,
   FieldRadio,
+  XLSXUtils,
 } from '@bole-core/components';
 import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
 import { Message, OrderInputType, downloadFileByUrl } from '@bole-core/core';
-import { HomeColumns } from './constants';
-import UploadMaterialDialog from './components/UploadMaterialDialog.vue';
-import BatchDownsizingDialog from './components/BatchDownsizingDialog.vue';
-import { toThousand, format, downloadFile, setOSSLink } from '@/utils';
-import { omit } from 'lodash';
+import { columns } from './constants';
+import UploadInsurePersonDialog from './components/UploadInsurePersonDialog.vue';
+import UploadStampFileDialog from './components/UploadStampFileDialog.vue';
+import { format, downloadFile, setOSSLink, toThousand, convertApi2FormUrl } from '@/utils';
 import { ModelValueType } from 'element-plus';
-import { useQueryClient } from '@tanstack/vue-query';
 import {
   InsuranceOrderTempPath,
-  JYBInsuranceOrderTempPath,
-  OnJobFlagEnumText,
   insuranceTypeText,
+  InsurancePolicyStatusEnumText,
+  InsurancePolicyStatusEnum,
 } from '@/constants';
 import dayjs from 'dayjs';
 import _ from 'lodash';
@@ -144,21 +114,52 @@
 const operationBtns = defineOperationBtns([
   {
     data: {
+      enCode: 'detailBtn',
+      name: '璇︽儏',
+    },
+    emits: {
+      onClick: (role) => handleDetail(role),
+    },
+  },
+  {
+    data: {
+      enCode: 'batchBtn',
+      name: '鎵规敼',
+    },
+    emits: {
+      onClick: (role) => handleBatch(role),
+    },
+    extraProps: {
+      hide: (row: API.GetInsurancePageOutput) => row.status !== InsurancePolicyStatusEnum.Effecting,
+    },
+  },
+  {
+    data: {
+      enCode: 'uploadStampFileBtn',
+      name: '涓婁紶鐩栫珷鏂囦欢',
+    },
+    emits: {
+      onClick: (role) => handleUploadStampFile(role),
+    },
+    extraProps: {
+      hide: (row: API.GetInsurancePageOutput) =>
+        row.status !== InsurancePolicyStatusEnum.WaitEffect,
+    },
+  },
+  {
+    data: {
       enCode: 'downloadBtn',
       name: '淇濆崟涓嬭浇',
     },
     emits: {
-      onClick: (role) => handleDownloadOrderNo(role),
+      onClick: (role) => handleDownloadInsureFile(role),
     },
     extraProps: {
-      hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
+      hide: (row: API.GetInsurancePageOutput) =>
+        row.status === InsurancePolicyStatusEnum.WaitEffect,
     },
   },
 ]).filter(Boolean);
-
-const columnSelectable = (row: API.InsuranceOrderListOutput) => {
-  return row.onJobFlag === '澧炲憳';
-};
 
 const BaseState = {
   loading: true,
@@ -181,7 +182,7 @@
   async ({ pageIndex, pageSize }, extraParamState) => {
     try {
       let params = createParams(pageIndex, pageSize);
-      let res = await insuranceOrderServices.getInsuranceOrderPage(params, {
+      let res = await insuranceOrderServices.getInsurancePage(params, {
         showLoading: !state.loading,
       });
       return res;
@@ -189,116 +190,123 @@
   },
   {
     defaultExtraParams: {
-      orderInput: [{ property: 'createTime', order: OrderInputType.Desc }],
+      orderInput: [{ property: 'id', order: OrderInputType.Desc }],
       creationDate: [] as unknown as ModelValueType,
-      keyword: '',
-      onJobFlag: '',
-      insuranceType: '',
+      condition: '',
+      status: '' as any as InsurancePolicyStatusEnum,
+      insurancePeriod: '',
     },
     columnsRenderProps: {
-      createTime: {
-        type: 'date',
-        format: 'YYYY/MM/DD',
+      status: { type: 'enum', valueEnum: InsurancePolicyStatusEnumText },
+      insurancePeriod: { type: 'enum', valueEnum: insuranceTypeText },
+      creationTime: { type: 'date', format: 'YYYY-MM-DD' },
+      effectStartTime: { type: 'date', format: 'YYYY-MM-DD' },
+      effectEndTime: { type: 'date', format: 'YYYY-MM-DD' },
+      sumInsured: {
+        type: 'money',
+        formatter: (row: API.GetInsurancePageOutput) =>
+          row.sumInsured == null ? '' : toThousand(row.sumInsured),
       },
-      insuranceBeginTime: {
-        type: 'date',
-        format: 'YYYY/MM/DD',
-      },
-      insuranceEndTime: {
-        type: 'date',
-        format: 'YYYY/MM/DD',
+      amount: {
+        type: 'money',
+        formatter: (row: API.GetInsurancePageOutput) =>
+          row.amount == null ? '' : toThousand(row.amount),
       },
     },
-    showSummary: true,
-    summaryPropertys: [
-      {
-        property: 'table-operation',
-        valueKey: 'totalAmount',
-        formatter: (v) => `锟�${toThousand(v)}`,
-      },
-    ],
   }
 );
 
 function createParams(pageIndex: number, pageSize: number) {
-  let params: API.QueryInsuranceOrderPageInput = {
+  let params: API.GetInsurancePageInput = {
     pageModel: {
       rows: pageSize,
       page: pageIndex,
       orderInput: extraParamState.orderInput,
     },
-    beginCreationTime: format(extraParamState.creationDate?.[0] ?? '', 'YYYY-MM-DD 00:00:00'),
-    endCreationTime: format(extraParamState.creationDate?.[1] ?? '', 'YYYY-MM-DD 23:59:59'),
-    condition: extraParamState.keyword,
-    onJobFlag: extraParamState.onJobFlag,
-    insuranceType: extraParamState.insuranceType,
+    importStartDateTime: format(extraParamState.creationDate?.[0] ?? '', 'YYYY-MM-DD 00:00:00'),
+    importEndDateTime: format(extraParamState.creationDate?.[1] ?? '', 'YYYY-MM-DD 23:59:59'),
+    condition: extraParamState.condition,
+    insurancePeriod: extraParamState.insurancePeriod,
+    status: extraParamState.status,
   };
   return params;
 }
 
-const queryClient = useQueryClient();
+const { dialogProps, handleAdd, editForm, dialogState } = useFormDialog({
+  onConfirm: checkInrancesSerialNumStatus,
+  defaultFormParams: {
+    serialNum: '',
+    url: [] as UploadUserFile[],
+  },
+  closeAfterConfirm: false,
+});
 
-async function handleUploadSuccess(response: UploadUserFile) {
+async function checkInrancesSerialNumStatus() {
   try {
-    let res = await insuranceOrderServices.importInsuranceOrderData(response.url, {
-      getResponse: true,
-      responseType: 'blob',
-    });
-    if (res?.data?.size) {
-      await Message.tipMessage('瀛樺湪閿欒鏁版嵁锛屾槸鍚﹀鍑猴紵');
-      downloadFile(res.data, `閿欒浜哄憳鍚嶅崟`, 'xlsx');
-      // XLSXUtils.exportToXLSX({
-      //   workbookDataList: res,
-      //   fileName: '閿欒浜哄憳鍚嶅崟',
-      //   workbookHeaderMap: {
-      //     ...omit(Object.fromEntries(HomeColumns.map((x) => [x.enCode, x.name])), [
-      //       'channel',
-      //       'salesmanName',
-      //       'createTime',
-      //     ]),
-      //     erroMsg: '澶囨敞',
-      //   },
-      // });
+    let params: API.APIimportInsStaffToListParams = {
+      serialNum: editForm.serialNum,
+      url: editForm.url?.[0]?.path,
+    };
+    let res = await insuranceOrderServices.checkInrancesSerialNumStatus(params);
+    if (res === InsurancePolicyStatusEnum.Effecting) {
+      await Message.tipMessage('璇ユ壒娆′繚鍗曞凡鐢熸晥锛岃淇敼鎵规鍙峰悗閲嶆柊瀵煎叆');
+    } else if (res === InsurancePolicyStatusEnum.OutTimeEffect) {
+      await Message.tipMessage('璇ユ壒娆′繚鍗曞凡澶辨晥锛岃淇敼鎵规鍙峰悗閲嶆柊瀵煎叆');
+    } else if (res === InsurancePolicyStatusEnum.WaitEffect) {
+      await Message.tipMessage('瀛樺湪鐩稿悓鐨勬壒娆″彿锛屾槸鍚﹁鐩栵紵');
+      importInsStaffToList();
+    } else {
+      importInsStaffToList();
     }
-    queryClient.invalidateQueries({
-      queryKey: ['insuranceOrderServices/getInsuranceOrderListByOrderRelevance'],
-    });
-    getList();
   } catch (error) {}
 }
 
-const { dialogProps, handleAdd } = useFormDialog({
-  defaultFormParams: {
-    id: '',
-    materialName: '',
-    url: [] as UploadUserFile[],
-  },
-});
+async function importInsStaffToList() {
+  try {
+    let params: API.APIimportInsStaffToListParams = {
+      serialNum: editForm.serialNum,
+      url: editForm.url?.[0]?.path,
+    };
+    let res = await insuranceOrderServices.importInsStaffToList(params);
+    if (res.length > 0) {
+      await Message.tipMessage('瀛樺湪閿欒鏁版嵁锛屾槸鍚﹀鍑猴紵');
+      XLSXUtils.exportToXLSX({
+        workbookDataList: res,
+        fileName: '閿欒浜哄憳鍚嶅崟',
+        workbookHeaderMap: {
+          name: '闆囧憳濮撳悕',
+          sex: '鎬у埆',
+          certType: '璇佷欢绫诲瀷',
+          certNo: '璇佷欢鍙风爜',
+          jobName: '闆囧憳宸ョ',
+          useEmploer: '鐢ㄥ伐鍗曚綅',
+          address: '鐢ㄥ伐鍦扮偣',
+          note: '澶囨敞',
+        },
+      });
+    }
+    dialogState.dialogVisible = false;
+    getList(paginationState.pageIndex);
+  } catch (error) {}
+}
 
-function openDialog(row: API.InsuranceOrderListOutput) {
+function handleUpload() {
   handleAdd({
-    id: row.id,
+    serialNum: `${dayjs().format('YYYYMMDD')}${_.random(0, 9999).toString().padStart(4, '0')}`,
+    url: [] as UploadUserFile[],
   });
 }
 
 const router = useRouter();
-function goDetail(row: API.InsuranceOrderListOutput) {
-  router.push({
-    name: 'InsuranceClaimDetail',
-    params: {
-      id: row.id,
-    },
-  });
-}
 
-async function handleExport() {
+async function getInsurancePageExport() {
   try {
     if (paginationState.total === 0) {
       Message.warnMessage('娌℃湁鏁版嵁鍙互瀵煎嚭鍝');
       return;
     }
     let params = createParams(paginationState.pageIndex, paginationState.pageSize);
-    let res = await insuranceOrderServices.exportInsuranceOrderList(params, {
+    let res = await insuranceOrderServices.getInsurancePageExport(params, {
       responseType: 'blob',
       getResponse: true,
     });
@@ -308,14 +316,31 @@
   } catch (error) {}
 }
 
-function handleDownload() {
-  downloadFileByUrl(JYBInsuranceOrderTempPath, '淇濆崟瀵煎叆妯℃澘');
+async function getInsuranceStaffPageExport() {
+  try {
+    if (paginationState.total === 0) {
+      Message.warnMessage('娌℃湁鏁版嵁鍙互瀵煎嚭鍝');
+      return;
+    }
+    let params = createParams(paginationState.pageIndex, paginationState.pageSize);
+    let res = await insuranceOrderServices.getInsuranceStaffPageExport(params, {
+      responseType: 'blob',
+      getResponse: true,
+    });
+    if (res) {
+      downloadFile(res.data, `鍦ㄤ繚浜哄憳瀵煎嚭`, 'xlsx');
+    }
+  } catch (error) {}
 }
 
-function handleRowStyle(data: { row: API.InsuranceOrderListOutput; rowIndex: number }) {
+function handleDownload() {
+  downloadFileByUrl(InsuranceOrderTempPath, '淇濆崟瀵煎叆妯℃澘');
+}
+
+function handleRowStyle(data: { row: API.GetInsurancePageOutput }) {
   if (
-    dayjs(dayjs(data.row?.insuranceEndTime).format('YYYY-MM-DD')).diff(dayjs(), 'day') >= 0 &&
-    dayjs(dayjs(data.row?.insuranceEndTime).format('YYYY-MM-DD')).diff(dayjs(), 'day') < 6
+    dayjs(dayjs(data.row?.effectEndTime).format('YYYY-MM-DD')).diff(dayjs(), 'day') >= 0 &&
+    dayjs(dayjs(data.row?.effectEndTime).format('YYYY-MM-DD')).diff(dayjs(), 'day') < 6
   ) {
     return {
       color: '#ff0000',
@@ -323,72 +348,78 @@
   }
 }
 
-const proTable = ref<InstanceType<typeof ProTableV2>>();
-function handleEnterpriseBatchRefund() {
-  if (proTableProps.value.tableData.length) {
-    const res: API.InsuranceOrderListOutput[] = proTable.value.innerTableRef.getSelectionRows();
-    if (res.length > 0) {
-      const orderNos = _.uniq(res.map((x) => x.orderNo));
-      if (orderNos.length > 1) {
-        Message.errorMessage('瀛樺湪涓嶅悓鐨勪繚鍗曞彿锛屾棤娉曟壒閲忓噺鍛�');
-        return;
-      }
-      handleBatchDownsizing(res);
-    } else {
-      Message.errorMessage('璇峰厛鍕鹃�夊噺鍛樹汉鍛�');
-    }
-  } else {
-    Message.errorMessage('鏆傛棤鏁版嵁');
-  }
-}
-
 const {
-  dialogProps: dialogBatchDownsizingProps,
-  handleAdd: handleBatchDownsizingAdd,
-  editForm: batchDownsizingForm,
+  dialogProps: dialogStampFileProps,
+  handleEdit: handleStampFileEdit,
+  editForm: stampFileForm,
 } = useFormDialog({
-  onConfirm: downsizingInsuranceOrderData,
+  onConfirm: uploadInsuranceStampFiles,
   defaultFormParams: {
-    orderNo: '',
-    checkOrderNo: '',
+    id: '',
     url: [] as UploadUserFile[],
-    downsizingInsuranceList: [] as string[],
   },
 });
 
-function handleBatchDownsizing(res: API.InsuranceOrderListOutput[]) {
-  handleBatchDownsizingAdd({
-    checkOrderNo: res[0]?.orderNo,
-    downsizingInsuranceList: res.map((x) => x.id),
-  });
+async function handleUploadStampFile(row: API.GetInsurancePageOutput) {
+  try {
+    const url = await getInsurancePolicyStampFiles(row.id);
+    handleStampFileEdit({
+      id: row.id,
+      url: url.map((x) => convertApi2FormUrl(x)) ?? [],
+    });
+  } catch (error) {}
 }
 
-async function downsizingInsuranceOrderData() {
+async function uploadInsuranceStampFiles() {
   try {
-    let params: API.DownsizingInsuranceOrderData = {
-      orderNo: batchDownsizingForm.checkOrderNo,
-      downsizingInsuranceList: batchDownsizingForm.downsizingInsuranceList,
-      url: batchDownsizingForm.url?.[0]?.path ?? '',
+    let params: API.UploadInsuranceStampFilesInput = {
+      insurancePolicyId: stampFileForm.id,
+      listFiles: stampFileForm.url?.map((x) => x.path) ?? [],
     };
-    let res = await insuranceOrderServices.downsizingInsuranceOrderDataCheck(params);
+    let res = await insuranceOrderServices.uploadInsuranceStampFiles(params);
     if (res) {
-      let downRes = await insuranceOrderServices.downsizingInsuranceOrderData(params, {
-        getResponse: true,
-        responseType: 'blob',
-      });
-      if (downRes?.data?.size) {
-        await Message.tipMessage('瀛樺湪閿欒鏁版嵁锛屾槸鍚﹀鍑猴紵');
-        downloadFile(downRes.data, `閿欒浜哄憳鍚嶅崟`, 'xlsx');
-      }
-      queryClient.invalidateQueries({
-        queryKey: ['insuranceOrderServices/getInsuranceOrderListByOrderRelevance'],
-      });
+      Message.successMessage('涓婁紶鎴愬姛');
       getList(paginationState.pageIndex);
     }
   } catch (error) {}
 }
 
-function handleDownloadOrderNo(row: API.InsuranceOrderListOutput) {
-  downloadFileByUrl(setOSSLink(row.orderBillFile));
+async function getInsurancePolicyStampFiles(id: string) {
+  try {
+    return await insuranceOrderServices.getInsurancePolicyStampFiles({ id: id });
+  } catch (error) {}
+}
+
+function handleDownloadInsureFile(row: API.GetInsurancePageOutput) {
+  downloadFileByUrl(setOSSLink(row.insureBillUrl));
+}
+
+function handleDetail(row: API.GetInsurancePageOutput) {
+  router.push({
+    name: 'InsuranceOrderDetail',
+    params: {
+      id: row.id,
+    },
+  });
+}
+function handleBatch(row: API.GetInsurancePageOutput) {
+  if (
+    dayjs(row.effectEndTime).isBefore(dayjs()) ||
+    dayjs(row.effectEndTime).isSame(dayjs(), 'day')
+  ) {
+    Message.errorMessage('淇濋櫓浠婂ぉ鍒版湡锛屾棤娉曟壒鏀�');
+    return;
+  }
+  router.push({
+    name: 'BatchChange',
+    params: {
+      id: row.id,
+    },
+    query: {
+      insurerName: row.insurerName ?? '',
+      insureBillNo: row.insureBillNo ?? '',
+      effectEndTime: row.effectEndTime ?? '',
+    },
+  });
 }
 </script>

--
Gitblit v1.9.1