<template>
|
<LoadingLayout :loading="state.loading">
|
<AppContainer>
|
<ProTableQueryFilterBar @on-reset="reset">
|
<template #query>
|
<QueryFilterItem>
|
<FieldDatePicker
|
v-model="extraParamState.creationDate"
|
type="daterange"
|
range-separator="~"
|
start-placeholder="起始日期"
|
end-placeholder="结束日期"
|
clearable
|
@change="getList()"
|
tooltipContent="导入日期"
|
></FieldDatePicker>
|
</QueryFilterItem>
|
<QueryFilterItem>
|
<FieldRadio
|
v-model="extraParamState.insurancePeriod"
|
:value-enum="insuranceTypeText"
|
buttonStyle
|
showAllBtn
|
@change="getList()"
|
/>
|
</QueryFilterItem>
|
<QueryFilterItem>
|
<FieldRadio
|
v-model="extraParamState.status"
|
:value-enum="InsurancePolicyStatusEnumText"
|
buttonStyle
|
showAllBtn
|
@change="getList()"
|
/>
|
</QueryFilterItem>
|
<QueryFilterItem>
|
<SearchInput
|
v-model="extraParamState.condition"
|
style="width: 260px"
|
placeholder="单位/保单号/参保机构"
|
@on-click-search="getList"
|
>
|
</SearchInput>
|
</QueryFilterItem>
|
</template>
|
<template #btn>
|
<el-button @click="handleDownload()" type="primary" style="margin-right: 10px" link
|
>模板下载</el-button
|
>
|
|
<el-button @click="handleUpload()" type="primary" style="margin-right: 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="columns"
|
:operationBtns="operationBtns"
|
ref="proTable"
|
:table-props="{
|
rowStyle: handleRowStyle,
|
rowKey: 'id',
|
}"
|
>
|
</ProTableV2>
|
</AppContainer>
|
<UploadInsurePersonDialog v-bind="dialogProps" />
|
<UploadStampFileDialog v-bind="dialogStampFileProps" />
|
</LoadingLayout>
|
</template>
|
|
<script setup lang="ts">
|
import {
|
ProTableQueryFilterBar,
|
ProTableV2,
|
LoadingLayout,
|
AppContainer,
|
QueryFilterItem,
|
useTable,
|
useFormDialog,
|
FieldDatePicker,
|
defineOperationBtns,
|
UploadUserFile,
|
SearchInput,
|
FieldRadio,
|
XLSXUtils,
|
} from '@bole-core/components';
|
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
|
import { Message, OrderInputType, downloadFileByUrl } from '@bole-core/core';
|
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 {
|
InsuranceOrderTempPath,
|
insuranceTypeText,
|
InsurancePolicyStatusEnumText,
|
InsurancePolicyStatusEnum,
|
} from '@/constants';
|
import dayjs from 'dayjs';
|
import _ from 'lodash';
|
|
defineOptions({
|
name: 'Home',
|
});
|
|
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) => handleDownloadInsureFile(role),
|
},
|
extraProps: {
|
hide: (row: API.GetInsurancePageOutput) =>
|
row.status === InsurancePolicyStatusEnum.WaitEffect,
|
},
|
},
|
]).filter(Boolean);
|
|
const BaseState = {
|
loading: true,
|
};
|
|
const state = reactive({ ...BaseState });
|
|
onMounted(async () => {
|
await getList();
|
state.loading = false;
|
});
|
|
const {
|
getDataSource: getList,
|
proTableProps,
|
paginationState,
|
extraParamState,
|
reset,
|
} = useTable(
|
async ({ pageIndex, pageSize }, extraParamState) => {
|
try {
|
let params = createParams(pageIndex, pageSize);
|
let res = await insuranceOrderServices.getInsurancePage(params, {
|
showLoading: !state.loading,
|
});
|
return res;
|
} catch (error) {}
|
},
|
{
|
defaultExtraParams: {
|
orderInput: [{ property: 'id', order: OrderInputType.Desc }],
|
creationDate: [] as unknown as ModelValueType,
|
condition: '',
|
status: '' as any as InsurancePolicyStatusEnum,
|
insurancePeriod: '',
|
},
|
columnsRenderProps: {
|
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),
|
},
|
amount: {
|
type: 'money',
|
formatter: (row: API.GetInsurancePageOutput) =>
|
row.amount == null ? '' : toThousand(row.amount),
|
},
|
},
|
}
|
);
|
|
function createParams(pageIndex: number, pageSize: number) {
|
let params: API.GetInsurancePageInput = {
|
pageModel: {
|
rows: pageSize,
|
page: pageIndex,
|
orderInput: extraParamState.orderInput,
|
},
|
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 { dialogProps, handleAdd, editForm, dialogState } = useFormDialog({
|
onConfirm: checkInrancesSerialNumStatus,
|
defaultFormParams: {
|
serialNum: '',
|
url: [] as UploadUserFile[],
|
},
|
closeAfterConfirm: false,
|
});
|
|
async function checkInrancesSerialNumStatus() {
|
try {
|
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();
|
}
|
} catch (error) {}
|
}
|
|
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 handleUpload() {
|
handleAdd({
|
serialNum: `${dayjs().format('YYYYMMDD')}${_.random(0, 9999).toString().padStart(4, '0')}`,
|
url: [] as UploadUserFile[],
|
});
|
}
|
|
const router = useRouter();
|
|
async function getInsurancePageExport() {
|
try {
|
if (paginationState.total === 0) {
|
Message.warnMessage('没有数据可以导出哦~');
|
return;
|
}
|
let params = createParams(paginationState.pageIndex, paginationState.pageSize);
|
let res = await insuranceOrderServices.getInsurancePageExport(params, {
|
responseType: 'blob',
|
getResponse: true,
|
});
|
if (res) {
|
downloadFile(res.data, `保单导出`, 'xlsx');
|
}
|
} catch (error) {}
|
}
|
|
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 handleDownload() {
|
downloadFileByUrl(InsuranceOrderTempPath, '保单导入模板');
|
}
|
|
function handleRowStyle(data: { row: API.GetInsurancePageOutput }) {
|
if (
|
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',
|
};
|
}
|
}
|
|
const {
|
dialogProps: dialogStampFileProps,
|
handleEdit: handleStampFileEdit,
|
editForm: stampFileForm,
|
} = useFormDialog({
|
onConfirm: uploadInsuranceStampFiles,
|
defaultFormParams: {
|
id: '',
|
url: [] as UploadUserFile[],
|
},
|
});
|
|
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 uploadInsuranceStampFiles() {
|
try {
|
let params: API.UploadInsuranceStampFilesInput = {
|
insurancePolicyId: stampFileForm.id,
|
listFiles: stampFileForm.url?.map((x) => x.path) ?? [],
|
};
|
let res = await insuranceOrderServices.uploadInsuranceStampFiles(params);
|
if (res) {
|
Message.successMessage('上传成功');
|
getList(paginationState.pageIndex);
|
}
|
} catch (error) {}
|
}
|
|
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) {
|
router.push({
|
name: 'BatchChange',
|
params: {
|
id: row.id,
|
},
|
query: {
|
insurerName: row.insurerName ?? '',
|
insureBillNo: row.insureBillNo ?? '',
|
},
|
});
|
}
|
</script>
|