<template>
|
<LoadingLayout>
|
<AppScrollContainer>
|
<ChunkCell title="1">
|
<template #title>
|
<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>
|
<ProFormColItem :span="8">
|
<ProFormItemV2
|
label="期望生效日期:"
|
prop="time"
|
:check-rules="[{ message: '请选择日期' }]"
|
>
|
<ProFormDatePicker
|
v-model="state.form.time"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="请选择日期"
|
:disabled-date="disabledDate"
|
></ProFormDatePicker>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="8">
|
<ProFormItemV2 label="" prop="url" label-width="0">
|
<ProFormUpload
|
v-model:file-url="state.form.addOrReduceUrl"
|
:limit="1"
|
:limitFileSize="10"
|
accept="xlsx"
|
:showTip="false"
|
:on-success="handleUploadAddOrReduce"
|
:disabled="urlDisabled"
|
>
|
<template #default>
|
<el-button type="primary" :disabled="urlDisabled">加减人</el-button>
|
<el-button link type="primary" @click.stop="DownloadAddOrReducePersonTemplate"
|
>下载模板</el-button
|
>
|
</template>
|
</ProFormUpload>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="8">
|
<ProFormItemV2 label="" prop="url" label-width="0">
|
<ProFormUpload
|
v-model:file-url="state.form.replaceUrl"
|
:limit="1"
|
:limitFileSize="10"
|
accept="xlsx"
|
:showTip="false"
|
:on-success="handleUploadReplace"
|
:disabled="urlDisabled"
|
>
|
<template #default>
|
<el-button type="primary" :disabled="urlDisabled">替换人</el-button>
|
<el-button link type="primary" @click.stop="downloadReplacePersonTemplate"
|
>下载模板</el-button
|
>
|
</template>
|
</ProFormUpload>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
</ProForm>
|
</ChunkCell>
|
<ChunkCell title="批改人员详情">
|
<template #titleRight>
|
<el-button type="primary" @click="handleClear">清空数据</el-button>
|
</template>
|
<ProTableV2
|
v-bind="proTableProps"
|
:columns="column"
|
:show-operation-column="false"
|
:auto-height="false"
|
ref="proTable"
|
:tableProps="{
|
maxHeight: '400px',
|
}"
|
>
|
</ProTableV2>
|
<div class="chuck-add-or-edit-actions">
|
<el-button class="chuck-add-or-edit-actions btn" type="primary" @click="handleSubmit"
|
>提交</el-button
|
>
|
</div>
|
</ChunkCell>
|
</AppScrollContainer>
|
</LoadingLayout>
|
</template>
|
|
<script setup lang="ts">
|
import {
|
LoadingLayout,
|
AppScrollContainer,
|
ProForm,
|
ProFormItemV2,
|
ChunkCell,
|
ProFormCol,
|
ProFormColItem,
|
ProFormDatePicker,
|
useTable,
|
ProTableV2,
|
ProFormUpload,
|
UploadUserFile,
|
XLSXUtils,
|
} from '@bole-core/components';
|
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
|
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',
|
});
|
|
const column: API.CustomModuleColumnDto[] = [
|
{
|
id: '1',
|
enCode: 'changeFlag',
|
name: '批改类型',
|
},
|
{
|
id: '2',
|
enCode: 'name',
|
name: '姓名',
|
},
|
{
|
id: '3',
|
enCode: 'idNumber',
|
name: '身份证号',
|
},
|
{
|
id: '4',
|
enCode: 'workType',
|
name: '雇员工种',
|
},
|
{
|
id: '5',
|
enCode: 'gender',
|
name: '性别',
|
},
|
{
|
id: '6',
|
enCode: 'age',
|
name: '年龄',
|
},
|
{
|
id: '7',
|
enCode: 'birthDay',
|
name: '出生日期',
|
},
|
{
|
id: '8',
|
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: '',
|
addOrReduceUrl: [] as UploadUserFile[],
|
replaceUrl: [] as UploadUserFile[],
|
},
|
staffList: [] as any[],
|
};
|
|
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;
|
});
|
|
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: '方案代码',
|
name: '被保险人姓名',
|
certType: '证件类型',
|
idNumber: '证件号码',
|
age: '年龄',
|
phoneNumber: '手机号',
|
workType: '职业/工种',
|
gender: '性别',
|
birthDay: '出生日期',
|
note: '备注',
|
},
|
});
|
})
|
.catch(() => {
|
state.staffList = res.addOrSub;
|
getList();
|
});
|
}
|
state.staffList = res.addOrSub;
|
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: '手机号',
|
workType: '职业/工种',
|
gender: '性别',
|
age: '年龄',
|
birthDay: '出生日期',
|
note: '备注',
|
},
|
});
|
})
|
.catch(() => {
|
state.staffList = res.update;
|
getList();
|
});
|
}
|
state.staffList = res.update;
|
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 getList();
|
state.loading = false;
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
@use '@/style/common.scss' as *;
|
|
.chuck-add-or-edit-actions {
|
&.btn {
|
margin-bottom: 20px;
|
}
|
}
|
</style>
|