|  |  |  | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | 
|---|
|  |  |  | type="date" | 
|---|
|  |  |  | value-format="YYYY-MM-DD" | 
|---|
|  |  |  | placeholder="请选择日期" | 
|---|
|  |  |  | :disabled-date="disabledDate" | 
|---|
|  |  |  | ></ProFormDatePicker> | 
|---|
|  |  |  | </ProFormItemV2> | 
|---|
|  |  |  | </ProFormColItem> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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 type="primary" :disabled="urlDisabled">加减人</el-button> | 
|---|
|  |  |  | <el-button link type="primary" @click.stop="DownloadAddOrReducePersonTemplate" | 
|---|
|  |  |  | >下载模板</el-button | 
|---|
|  |  |  | > | 
|---|
|  |  |  | 
|---|
|  |  |  | <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 type="primary" :disabled="urlDisabled">替换人</el-button> | 
|---|
|  |  |  | <el-button link type="primary" @click.stop="downloadReplacePersonTemplate" | 
|---|
|  |  |  | >下载模板</el-button | 
|---|
|  |  |  | > | 
|---|
|  |  |  | 
|---|
|  |  |  | ProTableV2, | 
|---|
|  |  |  | ProFormUpload, | 
|---|
|  |  |  | UploadUserFile, | 
|---|
|  |  |  | XLSXUtils, | 
|---|
|  |  |  | } 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 { 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: 'name', | 
|---|
|  |  |  | enCode: 'changeFlag', | 
|---|
|  |  |  | name: '批改类型', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | id: '3', | 
|---|
|  |  |  | enCode: 'name', | 
|---|
|  |  |  | enCode: 'idNumber', | 
|---|
|  |  |  | name: '身份证号', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | id: '4', | 
|---|
|  |  |  | enCode: 'idNumber', | 
|---|
|  |  |  | enCode: 'workType', | 
|---|
|  |  |  | name: '雇员工种', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | id: '5', | 
|---|
|  |  |  | enCode: 'idNumber', | 
|---|
|  |  |  | enCode: 'gender', | 
|---|
|  |  |  | name: '性别', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | id: '6', | 
|---|
|  |  |  | enCode: 'idNumber', | 
|---|
|  |  |  | enCode: 'age', | 
|---|
|  |  |  | name: '年龄', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | id: '7', | 
|---|
|  |  |  | enCode: 'idNumber', | 
|---|
|  |  |  | enCode: 'birthDay', | 
|---|
|  |  |  | name: '出生日期', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | id: '8', | 
|---|
|  |  |  | enCode: 'idNumber', | 
|---|
|  |  |  | 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() {} | 
|---|
|  |  |  | 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: '出生日期', | 
|---|
|  |  |  | 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: '手机号', | 
|---|
|  |  |  | 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, '加减人模板'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | downloadFileByUrl(InsuranceChangeTempPath, '替换人模板'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function handleBack() { | 
|---|
|  |  |  | closeViewPush(route, { | 
|---|
|  |  |  | name: 'Home', | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const queryClient = useQueryClient(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | onMounted(async () => { | 
|---|
|  |  |  | await getBatchRefundInfoDetail(); | 
|---|
|  |  |  | await getList(); | 
|---|
|  |  |  | state.loading = false; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | </script> | 
|---|