import * as React from 'react'; import { PageHeaderFoot, Button, AutoTableContainer, Table, Pagination, Tag, Radio, MoreMenus, message } from 'kts-xui'; import { AdvancedSearch, KtsForm, WrapperDrop } from 'kts-components'; import AddModal from './UI.DenyModal'; import moment from 'moment'; import { columnEnum } from '../CommonComponents/ColumnEnum'; import { findLabel, invoiceTypeEnum, complianceStatusEnum } from '../CommonComponents/FiledsEnum'; import { withRouter, RouteChildrenProps } from 'react-router-dom'; import agent from '../Server'; import { Space, Dropdown, Menu, Tooltip, Modal } from 'kts-components-antd-x4'; import { DigitalAssetVerification } from '../..'; import { CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; import InvoiceComponent from './UI.InvoiceComponent'; import CollectRecord from './UI.Child.CollectRecord'; import InvoiceModal from './invoiceModal'; // import DIDSelect from './DIDSelect'; import Subrecordlist from './UI.Child.Subrecordlist'; import NoneButton from './UI.NoneConfigBtn'; import PurposeModal from './UI.UsedforModal' const { confirm } = Modal; /** Props接口 */ interface IProps { changeView: (value) => void } class UIComponents extends React.Component { columns = [ { title: '发票类型', width: 120, align: 'center', dataIndex: 'invoiceType', render: (text, record) => { if (text) { return {findLabel(text, invoiceTypeEnum)} } } }, { title: '合规状态', dataIndex: columnEnum['合规状态'], width: 100, ellipsis: true, align: 'center', render: (text, record) => { if (text !== 1) { return } else { return } } }, { title: '销售方', dataIndex: columnEnum['销售方'], width: 200, ellipsis: true, }, { title: '购买方', dataIndex: columnEnum['采购方'], width: 200, ellipsis: true, }, { title: '发票号码', width: 190, dataIndex: 'invoiceNo', }, { title: '发票代码', width: 140, dataIndex: 'invoiceCode', }, { title: '开票日期', width: 130, dataIndex: 'invoiceDate', render: (text) => { return text && moment(text).format('YYYY-MM-DD'); } }, { title: '采集时间', width: 160, dataIndex: columnEnum['采集时间'], ellipsis: true, render: text => { return text && moment(text).format('YYYY-MM-DD HH:mm') } }, { title: '操作', dataIndex: 'invoiceUuid', width: 150, fixed: 'right', render: (text, record) => { const menu = ( { this.onRecheck(text) }}>重验 { this.onViewHistory(text) }}>提交记录 {record.canDelete === 1 && { this.onDelete([text]); }}>删除} ) return {this.showSubmitButton(record)} } }, ]; constructor(props) { super(props); this.state = { pageMeta: null, list: [], params: this.props.location.state || {}, showModal: false, selectedRowKeys: [], denyList: [], invoiceUuid: '', recordModal: false, invoiceModal: false, record: {}, selectParty: {}, config: [], showDid: false, sublistModal: false, loading: false }; } /** * 查看单张发票提交记录 * @param text */ onViewHistory = (text) => { this.setState({ sublistModal: true, invoiceUuid: text }) } closeSubrecord = () => { this.setState({ sublistModal: false, }) } onRecheck = async (text) => { const res: any = await agent.get('/collector/asset/reCheck', { invoiceUuid: text }, this); if (res.err) { return; } else { this.onRefresh(); message.success('操作成功'); } } onView = record => { this.setState({ invoiceModal: true, invoiceUuid: record.invoiceUuid, record }) } // showDid = (id) => { // this.setState({ // showDid: true, // selectedRowKeys: [id] // }) // } //批量提交前检查是否有配置项 beforeSubmit = async idlist => { const configlist = this.state.config; if (configlist.length === 1) { const data = { ...configlist[0], invoiceUuidList: idlist } this.submitBatch(data, configlist[0]); } else { this.setState({ showDid: true }) } } //批量提交 submitBatch = async (data, config) => { if (!this.state.loading) { this.setState({ loading: true }) const res: any = await agent.post('/collector/asset/submitBatch', data, this); this.setState({ loading: false }) if (res.err) { return; } else { //验证通过直接调用提交接口 if (res.res.checkPass) { const list = res.res.invoiceUuidList; const data = { ...config, invoiceUuidList: list }; this.onFinalSubmit(data); } else { //验证部分数据失败,弹框提示 const list = res.res.invoiceUuidList; const total = this.state.selectedRowKeys.length; confirm({ title: '重复提交', content:

您已勾选的{total}行发票数据,有{total - list.length}行已经提交过,无法重复提交,是否提交剩余发票 下载重复发票信息

, onOk: () => { const data = { ...config, invoiceUuidList: list }; this.onFinalSubmit(data); }, }); } } } } //验证通过后提交 onFinalSubmit = async (data) => { const res: any = await agent.post('/collector/asset/submitBatchConfirm', data, this); if (res.err) { return; } else { message.success('操作成功'); } } getSubmitConfig = async () => { const res: any = await agent.get('/collector/asset/getVerifierConfigList', {}, this); if (res.err) { return null; } else { res.res = res.res.map((item, index) => { return { ...item, // id: index } }) this.setState({ config: res.res }) } return res.res } /** * 删除 * @param idlist */ onDelete = async (idlist) => { const res: any = await agent.post('/collector/asset/deleteInvoiceAsset', idlist, this); if (res.err) { return; } else { this.onRefresh(); } } closeVerify = () => { this.setState({ invoiceUuid: '' }) } radioChange = (e) => { this.props.changeView(e.target.value); } topExpand = () => { return ( 发票采集 提交列表 } > ); } /** * 拒绝 * @param keys */ onDenyHandler = (keys: string[]) => { this.setState({ denyList: keys, showModal: true }) } async componentDidMount() { const params = { pageNum: 1, pageSize: 10, ...this.state.params, }; await this.getSubmitConfig(); this.getData(params); } onPageChange = (pageNum, pageSize) => { this.setState({ pageMeta: { ...this.state.pageMeta, pageNum, pageSize } }, () => { this.onRefresh(); }); } onRefresh = () => { const params = { ...this.state.params, ...this.state.pageMeta, }; this.getData(params); } onSearch = (data = {}) => { this.setState({ params: data, }); const params = { ...data, ...this.state.pageMeta, pageNum: 1 }; this.getData(params); } getData = async (params?) => { params = { ...params, minInvoiceDate: params['minInvoiceDate'] && moment(params['minInvoiceDate']).format('YYYY-MM-DD 00:00:00'), maxInvoiceDate: params['maxInvoiceDate'] && moment(params['maxInvoiceDate']).format('YYYY-MM-DD 23:59:59'), minCreateTime: params['minCreateTime'] && moment(params['minCreateTime']).format('YYYY-MM-DD 00:00:00'), maxCreateTime: params['maxCreateTime'] && moment(params['maxCreateTime']).format('YYYY-MM-DD 23:59:59'), } const res: any = await agent.post('/collector/asset/assetInvoicePage', params, this); if (res.err) { return; } else { this.setState({ pageMeta: res.res.pageMeta, list: res.res.items }); } } onDeny = () => { this.setState({ showModal: true, denyList: [...this.state.selectedRowKeys] }) } closeModal = () => { this.setState({ showModal: false, denyList: [] }) } successModal = () => { this.onRefresh(); this.closeModal(); } onExport = async () => { const { params } = this.state; const data = { ...params, minInvoiceDate: params['minInvoiceDate'] && moment(params['minInvoiceDate']).format('YYYY-MM-DD 00:00:00'), maxInvoiceDate: params['maxInvoiceDate'] && moment(params['maxInvoiceDate']).format('YYYY-MM-DD 23:59:59'), minCreateTime: params['minCreateTime'] && moment(params['minCreateTime']).format('YYYY-MM-DD 00:00:00'), maxCreateTime: params['maxCreateTime'] && moment(params['maxCreateTime']).format('YYYY-MM-DD 23:59:59'), }; const res: any = await DigitalAssetVerification.server.post(`${DigitalAssetVerification.prefix_path}/web/verifier/report/exportInvoiceDetail`, data).reqFs(DigitalAssetVerification.server.reqFs.filter(v => v !== DigitalAssetVerification.serviceTools.addContentType)).resFs([]).responseType('blob').end(null);; if (res.err) { return; } else { const blob = res.res.body; let url = URL.createObjectURL(blob); let link = document.createElement('a'); link.style.display = 'none'; link.href = url; link.setAttribute('download', `资产核验商品明细-${moment(new Date()).format('YYYYMMDDHHmmss')}.xls`); link.click(); // link = null; } } onCaijiRefresh = () => { this.onRefresh(); } handleMenuClick = (e) => { if (e.key === 'record') { this.setState({ recordModal: true }) } else if (e.key === 'delete') { this.onDelete(this.state.selectedRowKeys) } } onCloseRecord = () => { this.setState({ recordModal: false }) } closeInvoice = () => { this.setState({ invoiceModal: false }) } // onCloseDid = () => { // this.setState({ // showDid: false, // }) // } // onSuccessDid = () => { // this.setState({ // showDid: false, // selectedRowKeys: [] // }) // } handleDidClick = (e) => { const { config, selectedRowKeys } = this.state; const selectData = { verifierName: config[e.key].verifierName, verifierPartyId: config[e.key].verifierPartyId, collectorPartyId: config[e.key].collectorPartyId, } const data = { ...selectData, invoiceUuidList: selectedRowKeys } this.submitBatch(data, selectData); } //单个提交 showSubmitButton = (record: any) => { const { config } = this.state; //多个配置 if (config.length > 1) { return record.salerName ? 提交 : // const menu = ( // // {config && config.map((item, index) => { // return // {item.verifierName} // // })} // // ); // return } else if (config.length === 1) { //1个配置 if (record.salerName) { return 提交 } else { return } } else { //未设置配置 if (record.salerName) { return 提交 } else { return } } } showBatchSubmitButton = () => { const { config, selectedRowKeys, } = this.state; if (config.length > 1) { return } else if (config.length === 1) { if (selectedRowKeys.length === 0) { return } else { return } } else { return } } render() { const dataSource = this.state.list; const { pageMeta, selectedRowKeys, recordModal, invoiceModal, showDid, sublistModal } = this.state; const rowSelection = { selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRowKeys }); }, getCheckboxProps: (record) => ({ // disabled: record.effectiveStatus !== 1 }), } const menu = ( { this.handleMenuClick(e) }}> 采集记录 批量删除 ); return (
, this.showBatchSubmitButton(), ]} onRefresh={this.onRefresh} >
{pageMeta && `第 ${range[0]}-${range[1]} 条, 共有 ${total} 条`} style={{ padding: '16px 0', flex: 'none', background: 'white', textAlign: 'center' }} total={pageMeta.total} pageSize={pageMeta.pageSize} current={pageMeta.pageNum} showSizeChanger={true} />} { this.state.showModal && } { recordModal && } { invoiceModal && } {/* { showDid && } */} { sublistModal && } ); } } export default withRouter(UIComponents as any)