import React, { Component } from 'react'; import st from 'styled-components'; import { connect } from 'dva'; import { Button, Alert, Popover, Input, Select, Modal, notification, Upload, Icon, message } from 'antd'; import { withRouter } from 'dva/router'; import DepartSelect from '../../../../../components/user/DepartSelect'; import { findYIncumbencyPerCount, findOfflineOrOnlinePolicy, saveInsBlbMinusPreservationService, minusBatchRelevancePer, enterpriseInsComInsMinusBatchUploadInsPer, enterpriseInsComInsExportErrInsPer } from '../../../../../services/api'; import columnFun from './columns'; import DelModal from './DelModal'; import tablePage from '../../../../../utils/hoc/tablePage'; import // ExcelButtonOline, {excelButtonHOC} from '../../../../../components/ExcelButtonOline'; import $loading from '../../../../../utils/loading'; const { Option } = Select; @connect(state => ({ global: state.global })) @tablePage() @withRouter export default class Insured extends Component { constructor(props, context) { super(props, context); this.state = { policeys: [{ value: '', comInsId: "", label: "全部", orderId: "", buyMode: 0 // 不区分线上线下 }], //保险列表 quitCount: 0, //离职在保数量 selectedRows: [], //表格中选中的数组 selectedRowKeys: [], importModal: false, // 第一个导入模态框的显示 delModal: false, // 下一个导入模态框 importInfo: {}, //导入后接口返回的数据 }; } componentWillMount() { this.__getQuitCount(); if (this.props.insuranceType !== 'temporary') { this.__getPolicey(); } } componentDidUpdate(prevProps) { // 当项目ID变化时,更新表格数据 if (prevProps.tlkProjectId !== this.props.tlkProjectId) { this.props.form.setFieldsValue({ tlkProjectId: this.props.tlkProjectId || '*****' }); // 传递包含tlkProjectId的参数对象给updateTable方法 this.props.updateTable({ tlkProjectId: this.props.tlkProjectId || '*****', businessType: this.props.insuranceType === 'temporary' ? 1 : 0 }); if (this.props.insuranceType === 'temporary') { this.__getPolicey(); } } } // 获取离职在保人数 __getQuitCount() { findYIncumbencyPerCount().then(res => { this.setState({ quitCount: res.data }); }) } // 获取保单列表下拉菜单 __getPolicey = (cb) => { // 线上线下保单 findOfflineOrOnlinePolicy({ businessType: this.props.insuranceType === 'temporary' ? 1 : 0, tlkProjectId: this.props.tlkProjectId || '*****' }).then(result => { const outlineList = result.data.map(item => { item.value = item.comInsId + '-' + item.orderId + '-' + item.buyMode; //线下 return item; }); this.setState({ policeys: outlineList }, () => { // console.log(this.state.policeys, 'policeys') }); }); } // 表格渲染 __renderTable = () => { const baseColumns = columnFun.call(this); const columns = baseColumns.filter(item => !item.hidden); const { PageTable, isInit } = this.props; if (!isInit) return; return ( { this.setState({ selectedRows, selectedRowKeys }); }, selectedRowKeys: this.state.selectedRowKeys }} dateChange={data => { this.props.getTotal(data.other); }} pagination={{ onChange: (page, pageSize) => { this.setState({ selectedRows: [], //表格中选中的数组 selectedRowKeys: [], }); } }} // scroll={{ x: '1600px' }} /> ); }; render() { const { SearchForm, Form } = this.props; const { getFieldDecorator, setFieldsValue, getFieldValue } = this.props.form; const { importInfo, delModal, importModal } = this.state; return ( { this.state.quitCount > 0 ? 当前有{this.state.quitCount}个已离职人员未退保,请逐单处理,若对应的保单过期了,则会自动将已投保人员变更为未投保状态;
减员:可将已投保人员移出投保单(退保),请先筛选保单,再选择需要减员的人员,点击 减员 按钮,进行操作。} type="warning" showIcon style={{ marginBottom: '15px' }} /> : '' } { values.departId = values.departId.split('-')[0]; const comInsIdvalue = values.comInsId; values.comInsId = comInsIdvalue.split('-')[0]; const orderId = comInsIdvalue.split('-')[1]; const buyMode = comInsIdvalue.split('-')[2]; console.log(values.comInsId,orderId, buyMode), 'values'; this.setState({ comInsId: values.comInsId, orderId, buyMode }); // 重置选中项 this.setState({ selectedRows: [], //表格中选中的数组 selectedRowKeys: [], }); // this.setState({ // params: values //储存参数,供导出使用 // }); return values; }} > {getFieldDecorator('comInsId', { initialValue: '' })( )}
{getFieldDecorator('keyword', { initialValue: '' })( )} {getFieldDecorator('businessType', { initialValue: this.props.insuranceType === 'temporary' ? 1 : 0 })( <> )} { this.props.insuranceType === 'temporary' ? (<> {getFieldDecorator('tlkProjectId', { initialValue: this.props.tlkProjectId || '*****' })( <> )} {getFieldDecorator('comName', { initialValue: '' })( )} ) : ( <> {getFieldDecorator('departId', { initialValue: '' })( )} {getFieldDecorator('isIncumbency', { initialValue: '' })( )} ) }

请选择保单

}>
搜索后可导出 } > {/* 导出筛选结果为excel */} { excelButtonHOC({ disabled: !this.props.clicked, method: 'POST', params: this.props.searchData, apiurl: "/enterprise/ins/com-ins/export-under-warranty-per-list", downloadname: this.props.global.companyInfo.comName + "_已投保人员", children: '导出筛选结果为excel' }, Button) }
{/* 表格 */} {this.__renderTable()} 0 ? false : true }} onOk={() => { this.setState({ importModal: false, delModal: true }); }} onCancel={() => { this.setState({ importModal: false }); }} > 点击下载导入减员模板
减员人员数据: { let canUpload = true; if (!(file.name + '').toLocaleLowerCase().match(/(\.xls)|(\.xlsx)/)) { message.error(`请上传拓展名为.xls或.xlsx的文件!`); canUpload = false; } return canUpload; }} customRequest={({ file }) => { const formData = new FormData(); formData.append('xfile', file); $loading.open('文件导入中,请稍后。。。'); enterpriseInsComInsMinusBatchUploadInsPer(formData, false).then(res => { $loading.close(); // message.success('上传成功'); this.setState({ importInfo: res.data }); this.props.updateTable(); }).catch(ex => { $loading.close(); console.log(ex); }); }} >

支持扩展名:.xls 请下载模板并在模板中完善信息后导入,减员人员需为系统已导入人员。

{ importInfo.errCount && importInfo.errCount > 0 &&

有人员数据无法识别,请下载失败文件查看,调整人员后重新导入
{ const { importBatchId } = this.state.importInfo; enterpriseInsComInsExportErrInsPer({ importBatchId }).then(res => { if (!res) { return; } let url = window.URL.createObjectURL(res.data); let link = document.createElement('a'); link.style.display = 'none'; link.href = url; link.setAttribute( 'download', `导入减员失败文件.xls` ); document.body.appendChild(link); link.click(); // if (!response) { // return; // } // const content = response; // const blob = new Blob([content]); // const fileName = `导入减员失败文件.xls`; // if ("download" in document.createElement("a")) { // // 非IE下载 // const elink = document.createElement("a"); // elink.download = fileName; // elink.style.display = "none"; // elink.href = URL.createObjectURL(blob); // document.body.appendChild(elink); // elink.click(); // URL.revokeObjectURL(elink.href); // 释放URL 对象 // document.body.removeChild(elink); // } else { // // IE10+下载 // navigator.msSaveBlob(blob, fileName); // } }); }}>下载失败文件

}
); } } const Btns = st.div` margin-top: 15px; button { margin-right: 15px; } `; const Container = st.div` padding: 24px; padding-top: 0; `;