From 33f3506c93c0b84f6abc165e7d22d2bae1c8fcb1 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期四, 23 十月 2025 22:21:33 +0800
Subject: [PATCH] feat: 接口
---
src/views/Home/BatchChange.vue | 326 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 255 insertions(+), 71 deletions(-)
diff --git a/src/views/Home/BatchChange.vue b/src/views/Home/BatchChange.vue
index 3bda0ec..a32695e 100644
--- a/src/views/Home/BatchChange.vue
+++ b/src/views/Home/BatchChange.vue
@@ -1,10 +1,12 @@
<template>
- <LoadingLayout :loading="state.loading">
+ <LoadingLayout>
<AppScrollContainer>
<ChunkCell title="1">
<template #title>
- <el-text>{{ `淇濆崟鍙凤細${'958585860689'}` }}</el-text>
- <el-text>{{ `鎶曚繚浜猴細${'浜哄姏鏃犲咖'}` }}</el-text>
+ <div class="batch-change-title">
+ <el-text style="margin-right: 20px">{{ `淇濆崟鍙凤細${insureBillNo ?? ''}` }}</el-text>
+ <el-text>{{ `鎶曚繚浜猴細${insurerName ?? ''}` }}</el-text>
+ </div>
</template>
<ProForm :model="state.form" ref="formRef" label-width="120px">
<ProFormCol>
@@ -19,6 +21,7 @@
type="date"
value-format="YYYY-MM-DD"
placeholder="璇烽�夋嫨鏃ユ湡"
+ :disabled-date="disabledDate"
></ProFormDatePicker>
</ProFormItemV2>
</ProFormColItem>
@@ -27,15 +30,17 @@
<ProFormColItem :span="8">
<ProFormItemV2 label="" prop="url" label-width="0">
<ProFormUpload
- v-model:file-url="state.form.url"
+ v-model:file-url="state.form.addOrReduceUrl"
:limit="1"
:limitFileSize="10"
- accept="xlsx,xls"
+ accept="xlsx"
:showTip="false"
+ :on-success="handleUploadAddOrReduce"
+ :disabled="urlDisabled"
>
<template #default>
- <el-button type="primary">鍔犲噺浜�</el-button>
- <el-button link type="primary" @click.stop="handleTemplateDownload"
+ <el-button type="primary" :disabled="urlDisabled">鍔犲噺浜�</el-button>
+ <el-button link type="primary" @click.stop="DownloadAddOrReducePersonTemplate"
>涓嬭浇妯℃澘</el-button
>
</template>
@@ -47,15 +52,17 @@
<ProFormColItem :span="8">
<ProFormItemV2 label="" prop="url" label-width="0">
<ProFormUpload
- v-model:file-url="state.form.url"
+ v-model:file-url="state.form.replaceUrl"
:limit="1"
:limitFileSize="10"
- accept="xlsx,xls"
+ accept="xlsx"
:showTip="false"
+ :on-success="handleUploadReplace"
+ :disabled="urlDisabled"
>
<template #default>
- <el-button type="primary">鏇挎崲浜�</el-button>
- <el-button link type="primary" @click.stop="handleTemplateDownload"
+ <el-button type="primary" :disabled="urlDisabled">鏇挎崲浜�</el-button>
+ <el-button link type="primary" @click.stop="downloadReplacePersonTemplate"
>涓嬭浇妯℃澘</el-button
>
</template>
@@ -81,7 +88,7 @@
>
</ProTableV2>
<div class="chuck-add-or-edit-actions">
- <el-button class="chuck-add-or-edit-actions" type="primary" @click="handleSubmit"
+ <el-button class="chuck-add-or-edit-actions btn" type="primary" @click="handleSubmit"
>鎻愪氦</el-button
>
</div>
@@ -97,25 +104,25 @@
ProForm,
ProFormItemV2,
ChunkCell,
- ProFormText,
- ProTableQueryFilterBar,
- QueryFilterItem,
- SearchInput,
ProFormCol,
ProFormColItem,
ProFormDatePicker,
- ProFormInputNumber,
useTable,
ProTableV2,
- ProFormRadio,
- FieldSelect,
- defineOperationBtns,
- useFormDialog,
ProFormUpload,
UploadUserFile,
+ XLSXUtils,
} from '@bole-core/components';
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
-import { OrderInputType } from '@bole-core/core';
+import * as insureBatchBillServices from '@/services/api/InsureBatchBill';
+import { downloadFile, downloadFileByUrl, Message, OrderInputType } from '@bole-core/core';
+import { InsuranceAddOrReduceTempPath, InsuranceChangeTempPath } from '@/constants';
+import { useRouteView } from '@/hooks';
+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',
@@ -124,7 +131,7 @@
const column: API.CustomModuleColumnDto[] = [
{
id: '1',
- enCode: 'name',
+ enCode: 'changeFlag',
name: '鎵规敼绫诲瀷',
},
{
@@ -134,87 +141,262 @@
},
{
id: '3',
- enCode: 'name',
+ enCode: 'idNumber',
name: '韬唤璇佸彿',
},
{
id: '4',
- enCode: 'idNumber',
- name: '闆囧憳宸ョ',
+ enCode: 'occupationType',
+ name: '鑱屼笟绫诲瀷',
},
{
id: '5',
- enCode: 'idNumber',
- name: '鎬у埆',
+ enCode: 'occupationCode',
+ name: '鑱屼笟鐮佸��',
},
{
id: '6',
- enCode: 'idNumber',
- name: '骞撮緞',
+ enCode: 'workEnterprise',
+ name: '鐢ㄥ伐鍗曚綅',
},
{
id: '7',
- enCode: 'idNumber',
- name: '鍑虹敓鏃ユ湡',
+ enCode: 'workAddress',
+ name: '鐢ㄥ伐鍦扮偣',
},
{
id: '8',
- enCode: 'idNumber',
+ enCode: 'workType',
+ name: '闆囧憳宸ョ',
+ },
+ {
+ id: '9',
+ enCode: 'gender',
+ name: '鎬у埆',
+ },
+ {
+ id: '10',
+ enCode: 'age',
+ name: '骞撮緞',
+ },
+ {
+ id: '11',
+ enCode: 'birthDay',
+ name: '鍑虹敓鏃ユ湡',
+ },
+ {
+ id: '12',
+ enCode: 'phoneNumber',
name: '鎵嬫満鍙风爜',
},
];
const route = useRoute();
+const { closeViewPush } = useRouteView();
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: {
time: '',
- url: [] as UploadUserFile[],
+ addOrReduceUrl: [] as UploadUserFile[],
+ replaceUrl: [] as UploadUserFile[],
},
+ staffList: [] as any[],
};
const state = reactive({ ...BaseState });
-const {
- getDataSource: getBatchRefundInfoDetail,
- proTableProps,
- paginationState,
- extraParamState,
- reset,
-} = useTable(
- async ({ pageIndex, pageSize }, extraParamState) => {
- try {
- let params: API.QueryInsuranceOrderPageInput = {
- pageModel: {
- rows: pageSize,
- page: pageIndex,
- orderInput: extraParamState.orderInput,
- },
- condition: extraParamState.keyWord,
- // insurePolicyOperateHistoryId: id,
- };
- let res = await insuranceOrderServices.getInsuranceOrderPage(params, {
- showLoading: !state.loading,
- });
- return res;
- } catch (error) {}
- },
- {
- defaultExtraParams: {
- keyWord: '',
- orderInput: [{ property: 'id', order: OrderInputType.Asc }],
- },
- columnsRenderProps: {},
- }
-);
+const disabledDate = computed(() => {
+ return (time: Date) => {
+ return dayjs(time).isBefore(dayjs(), 'day') || dayjs(time).isAfter(dayjs(effectEndTime), 'day');
+ };
+});
-function handleClear() {}
-function handleSubmit() {}
-function handleTemplateDownload() {}
+const urlDisabled = computed(() => {
+ return state.form.addOrReduceUrl.length > 0 || state.form.replaceUrl.length > 0;
+});
+
+const { getDataSource: getList, proTableProps } = useTable(({ pageIndex, pageSize }) => {
+ try {
+ return Promise.resolve({
+ pageModel: {
+ rows: pageSize,
+ page: pageIndex,
+ totalCount: state.staffList.length,
+ },
+ data: paginateList(state.staffList, pageIndex, pageSize),
+ });
+ } catch (error) {}
+});
+
+async function handleUploadAddOrReduce(response: UploadUserFile) {
+ try {
+ let params: API.ImportBatchAddOrSubOrderInput = {
+ url: response.path,
+ insurePolicyId: id,
+ };
+ let res = await insureBatchBillServices.importBatchAddOrSubOrderData(params);
+ if (res?.error.length > 0) {
+ Message.tipMessage('瀛樺湪閿欒鏁版嵁锛屾槸鍚﹀鍑猴紵')
+ .then(() => {
+ XLSXUtils.exportToXLSX({
+ workbookDataList: res?.error,
+ fileName: '閿欒浜哄憳鍚嶅崟',
+ workbookHeaderMap: {
+ changeFlag: '鎵规敼鏍囧織',
+ insuranceScheme: '鏂规浠g爜',
+ name: '琚繚闄╀汉濮撳悕',
+ certType: '璇佷欢绫诲瀷',
+ idNumber: '璇佷欢鍙风爜',
+ age: '骞撮緞',
+ phoneNumber: '鎵嬫満鍙�',
+ occupationType: '鑱屼笟绫诲瀷',
+ occupationCode: '鑱屼笟鐮佸��',
+ workEnterprise: '鐢ㄥ伐鍗曚綅',
+ workAddress: '鐢ㄥ伐鍦扮偣',
+ workType: '鑱屼笟/宸ョ',
+ gender: '鎬у埆',
+ birthDay: '鍑虹敓鏃ユ湡',
+ remark: '澶囨敞',
+ },
+ });
+ })
+ .catch(() => {
+ state.staffList = _.uniqBy(res.addOrSub, 'idNumber');
+ getList();
+ });
+ }
+ state.staffList = _.uniqBy(res.addOrSub, 'idNumber');
+ getList();
+ } catch (error) {}
+}
+async function handleUploadReplace(response: UploadUserFile) {
+ try {
+ let params: API.ImportBatchAddOrSubOrderInput = {
+ url: response.path,
+ insurePolicyId: id,
+ };
+ // 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(() => {
+ XLSXUtils.exportToXLSX({
+ workbookDataList: res?.error,
+ fileName: '閿欒浜哄憳鍚嶅崟',
+ workbookHeaderMap: {
+ orginName: '鍘熻淇濅汉濮撳悕',
+ orginIdNumber: '鍘熻淇濅汉璇佷欢鍙风爜',
+ name: '琚繚闄╀汉濮撳悕',
+ certType: '璇佷欢绫诲瀷',
+ idNumber: '璇佷欢鍙风爜',
+ phoneNumber: '鎵嬫満鍙�',
+ occupationType: '鑱屼笟绫诲瀷',
+ occupationCode: '鑱屼笟鐮佸��',
+ workEnterprise: '鐢ㄥ伐鍗曚綅',
+ workAddress: '鐢ㄥ伐鍦扮偣',
+ workType: '鑱屼笟/宸ョ',
+ gender: '鎬у埆',
+ age: '骞撮緞',
+ birthDay: '鍑虹敓鏃ユ湡',
+ remark: '澶囨敞',
+ },
+ });
+ })
+ .catch(() => {
+ state.staffList = _.uniqBy(_.uniqBy(res.update, 'idNumber'), 'orginIdNumber');
+ getList();
+ });
+ }
+ state.staffList = _.uniqBy(_.uniqBy(res.update, 'idNumber'), 'orginIdNumber');
+ getList();
+ } catch (error) {}
+}
+
+function handleClear() {
+ if (!state.staffList.length) {
+ Message.errorMessage('娌℃湁鏁版嵁鍙互娓呴櫎鍝�');
+ return;
+ }
+ state.staffList = [] as any[];
+ getList();
+}
+
+const formRef = ref<FormInstance>();
+function handleSubmit() {
+ if (!formRef.value) return;
+ formRef.value.validate((valid) => {
+ if (valid) {
+ addOrUpdateInsureBatchBill();
+ } else {
+ return;
+ }
+ });
+}
+
+async function addOrUpdateInsureBatchBill() {
+ try {
+ if (state.staffList.length === 0) {
+ Message.errorMessage('璇峰厛涓婁紶浜哄憳鍚嶅崟');
+ return;
+ }
+ let _addInsStaffList = _.uniqBy(state.staffList, 'idNumber');
+ let params: API.InsureBatchBillInput = {
+ insurancePolicyId: id,
+ effectTime: state.form.time,
+ 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) {
+ Message.successMessage('鎻愪氦鎴愬姛');
+ handleBack();
+ }
+ } catch (error) {}
+}
+
+function DownloadAddOrReducePersonTemplate() {
+ downloadFileByUrl(InsuranceAddOrReduceTempPath, '鍔犲噺浜烘ā鏉�');
+}
+function downloadReplacePersonTemplate() {
+ downloadFileByUrl(InsuranceChangeTempPath, '鏇挎崲浜烘ā鏉�');
+}
+
+function handleBack() {
+ closeViewPush(route, {
+ name: 'Home',
+ });
+}
+
+const queryClient = useQueryClient();
onMounted(async () => {
- await getBatchRefundInfoDetail();
+ await getList();
state.loading = false;
});
</script>
@@ -223,6 +405,8 @@
@use '@/style/common.scss' as *;
.chuck-add-or-edit-actions {
- // margin-bottom: 20px;
+ &.btn {
+ margin-bottom: 20px;
+ }
}
</style>
--
Gitblit v1.9.1