From 6bde59eb680d1978aad3f7270d7816210c559cfc Mon Sep 17 00:00:00 2001 From: wupengfei <834520024@qq.com> Date: 星期二, 01 四月 2025 19:54:04 +0800 Subject: [PATCH] fix: bug --- src/views/Home/BatchChange.vue | 112 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 83 insertions(+), 29 deletions(-) diff --git a/src/views/Home/BatchChange.vue b/src/views/Home/BatchChange.vue index 2fa1b22..7de55f0 100644 --- a/src/views/Home/BatchChange.vue +++ b/src/views/Home/BatchChange.vue @@ -21,6 +21,7 @@ type="date" value-format="YYYY-MM-DD" placeholder="璇烽�夋嫨鏃ユ湡" + :disabled-date="disabledDate" ></ProFormDatePicker> </ProFormItemV2> </ProFormColItem> @@ -110,6 +111,7 @@ ProTableV2, ProFormUpload, UploadUserFile, + XLSXUtils, } from '@bole-core/components'; import * as insuranceOrderServices from '@/services/api/InsuranceOrder'; import * as insureBatchBillServices from '@/services/api/InsureBatchBill'; @@ -119,6 +121,8 @@ import { FormInstance } from 'element-plus'; import { useQuery, useQueryClient } from '@tanstack/vue-query'; import { paginateList } from '@/utils'; +import dayjs from 'dayjs'; +import _ from 'lodash'; defineOptions({ name: 'BatchChange', @@ -172,6 +176,7 @@ const id = route.params.id as string; const insurerName = route.query.insurerName as string; const insureBillNo = route.query.insureBillNo as string; +const effectEndTime = route.query.effectEndTime as string; const BaseState = { loading: true, form: { @@ -183,6 +188,12 @@ }; const state = reactive({ ...BaseState }); + +const disabledDate = computed(() => { + return (time: Date) => { + return dayjs(time).isBefore(dayjs(), 'day') || dayjs(time).isAfter(dayjs(effectEndTime), 'day'); + }; +}); const urlDisabled = computed(() => { return state.form.addOrReduceUrl.length > 0 || state.form.replaceUrl.length > 0; @@ -207,25 +218,35 @@ url: response.path, insurePolicyId: id, }; - let checkRes = await insureBatchBillServices.importCheckBatchAddOrSubOrderData(params, { - getResponse: true, - responseType: 'blob', - }); - if (checkRes?.data?.size) { + let res = await insureBatchBillServices.importBatchAddOrSubOrderData(params); + if (res?.error.length > 0) { Message.tipMessage('瀛樺湪閿欒鏁版嵁锛屾槸鍚﹀鍑猴紵') .then(() => { - downloadFile(checkRes.data, `閿欒浜哄憳鍚嶅崟`, 'xlsx'); + XLSXUtils.exportToXLSX({ + workbookDataList: res?.error, + fileName: '閿欒浜哄憳鍚嶅崟', + workbookHeaderMap: { + changeFlag: '鎵规敼鏍囧織', + insuranceScheme: '鏂规浠g爜', + name: '琚繚闄╀汉濮撳悕', + certType: '璇佷欢绫诲瀷', + idNumber: '璇佷欢鍙风爜', + age: '骞撮緞', + phoneNumber: '鎵嬫満鍙�', + workType: '鑱屼笟/宸ョ', + gender: '鎬у埆', + birthDay: '鍑虹敓鏃ユ湡', + note: '澶囨敞', + }, + }); }) .catch(() => { - // getList(paginationState.pageIndex); + state.staffList = res.addOrSub; + getList(); }); - } else { - let res = await insureBatchBillServices.importBatchAddOrSubOrderData(params); - if (res?.addOrSub?.length) { - state.staffList = res.addOrSub; - getList(); - } } + state.staffList = res.addOrSub; + getList(); } catch (error) {} } async function handleUploadReplace(response: UploadUserFile) { @@ -234,25 +255,54 @@ url: response.path, insurePolicyId: id, }; - let checkRes = await insureBatchBillServices.importCheckBatchUpdateOrderData(params, { - getResponse: true, - responseType: 'blob', - }); - if (checkRes?.data?.size) { + // let checkRes = await insureBatchBillServices.importCheckBatchUpdateOrderData(params, { + // getResponse: true, + // responseType: 'blob', + // }); + // if (checkRes?.data?.size) { + // Message.tipMessage('瀛樺湪閿欒鏁版嵁锛屾槸鍚﹀鍑猴紵') + // .then(() => { + // downloadFile(checkRes.data, `閿欒浜哄憳鍚嶅崟`, 'xlsx'); + // }) + // .catch(() => { + // // getList(paginationState.pageIndex); + // }); + // } else { + // let res = await insureBatchBillServices.importBatchUpdateOrderData(params); + // if (res?.update?.length) { + // state.staffList = res.update; + // getList(); + // } + // } + let res = await insureBatchBillServices.importBatchUpdateOrderData(params); + if (res?.error.length > 0) { Message.tipMessage('瀛樺湪閿欒鏁版嵁锛屾槸鍚﹀鍑猴紵') .then(() => { - downloadFile(checkRes.data, `閿欒浜哄憳鍚嶅崟`, 'xlsx'); + XLSXUtils.exportToXLSX({ + workbookDataList: res?.error, + fileName: '閿欒浜哄憳鍚嶅崟', + workbookHeaderMap: { + orginName: '鍘熻淇濅汉濮撳悕', + orginIdNumber: '鍘熻淇濅汉璇佷欢鍙风爜', + name: '琚繚闄╀汉濮撳悕', + certType: '璇佷欢绫诲瀷', + idNumber: '璇佷欢鍙风爜', + phoneNumber: '鎵嬫満鍙�', + workType: '鑱屼笟/宸ョ', + gender: '鎬у埆', + age: '骞撮緞', + birthDay: '鍑虹敓鏃ユ湡', + note: '澶囨敞', + }, + }); }) .catch(() => { - // getList(paginationState.pageIndex); + state.staffList = res.update; + getList(); }); - } else { - let res = await insureBatchBillServices.importBatchUpdateOrderData(params); - if (res?.update?.length) { - state.staffList = res.update; - getList(); - } } + state.staffList = res.update; + getList(); } catch (error) {} } @@ -283,12 +333,16 @@ Message.errorMessage('璇峰厛涓婁紶浜哄憳鍚嶅崟'); return; } + let _addInsStaffList = _.uniqBy(state.staffList, 'idNumber'); let params: API.InsureBatchBillInput = { insurancePolicyId: id, effectTime: state.form.time, - addInsStaffList: state.staffList.filter((x) => x.changeFlag.includes('澧炲姞')), - updateInsStaffList: state.staffList.filter((x) => x.changeFlag.includes('鏇挎崲')), - delInsStaffList: state.staffList.filter((x) => x.changeFlag.includes('鍒犻櫎')), + addInsStaffList: _addInsStaffList.filter((x) => x.changeFlag.includes('澧炲姞')), + updateInsStaffList: _.uniqBy( + _addInsStaffList.filter((x) => x.changeFlag.includes('鏇挎崲')), + 'orginIdNumber' + ), + delInsStaffList: _addInsStaffList.filter((x) => x.changeFlag.includes('鍒犻櫎')), }; let res = await insureBatchBillServices.addOrUpdateInsureBatchBill(params); if (res) { -- Gitblit v1.9.1