import * as React from 'react'; import { PageHeaderFoot, Button, AutoTableContainer, Table, Pagination, MoreMenus, Modal, message } from 'kts-xui'; import { AdvancedSearch, KtsForm } from 'kts-components'; import moment from 'moment'; import { withRouter, RouteChildrenProps } from 'react-router-dom'; import { taskStatusEnum, findLabel } from '../CommonComponents/FiledsEnum'; import agent from '../Server'; import { DigitalAssetVerification } from '../../'; import { Tooltip, Menu, Space, Dropdown } from 'kts-components-antd-x4'; import ExcelImport from './detail/invoiceImport'; import { ReloadOutlined } from '@ant-design/icons'; import DidModal from './add/DIDSelect'; import ConnectMasterTask from './ConnectMasterTask'; import DenyAction from './UI.DenyAction' /** Props接口 */ interface IProps { } class UIComponents extends React.Component { columns = [ { title: '任务单号', dataIndex: 'taskNo', width: 160, }, { title: '核验方', dataIndex: 'verifierName', width: 200, ellipsis: true, }, { title: '任务状态', dataIndex: 'taskStatus', width: 100, render: (text, record) => { if (text === 6) { return {findLabel(text, taskStatusEnum)} } else { return findLabel(text, taskStatusEnum) } } }, { title: '任务截止日期', width: 130, dataIndex: 'taskEndDate', render: (text) => { return text && moment(text).format('YYYY-MM-DD'); } }, { title: '核验日期范围', width: 200, dataIndex: 'effectiveStart', render: (text, record) => { return text && {moment(text).format('YYYY-MM-DD')}~{moment(record.effectiveEnd).format('YYYY-MM-DD')}; } }, { title: '关联单据', width: 120, dataIndex: 'originalDocList', ellipsis: true, render: (text) => { if (text.length > 0) { let originalDocuments = text.reduce((acc, obj) => { acc.push(obj.originalDocument); return acc; }, []) let str = originalDocuments.join('/'); return str } } }, { title: '关联任务单号', width: 120, dataIndex: 'taskRelationList', ellipsis: true, render: (text) => { if (text.length > 0) { let originalDocuments = text.reduce((acc, obj) => { acc.push(obj.taskNo); return acc; }, []) let str = originalDocuments.join('/'); return str } } }, { title: '创建人', width: 100, dataIndex: 'creator', ellipsis: true, }, { title: '备注', width: 140, dataIndex: 'remark', ellipsis: true, }, { title: '操作', dataIndex: 'taskUuid', fixed: 'right', width: 180, render: (text, record) => { if (record.taskStatus === 2) { //待处理 const menu = ( { this.onConnectTask(record) }}>关联核验任务 { this.checkBeforeSend(record) }}>提交 拒绝完成 ) const menu2 = ( { this.handleMenuClick(e, record.taskUuid) }}> 扫码枪 Excel上传 手工录入 ); //草稿 return { this.onView(text); }}>查看 发票采集 } else if (record.taskStatus === 2) { //待处理 return ( { this.onView(text); }}>查看 ); } else if (record.taskStatus === 3 || record.taskStatus === 4) { //已处理 已截止 return ( { this.onView(text); }}>查看 ); } else if (record.taskStatus === 5) { //提交中 const menu = ( { this.checkBeforeSend(record) }}>提交 ) return ( { this.onView(text); }}>查看 {/* 发票采集 */} ); } else if (record.taskStatus === 6) { //未完成 return ( { this.onView(text); }}>查看 ); } } }, ]; constructor(props) { super(props); this.state = { pageMeta: null, list: [], params: {}, showModal: false, excelModal: false, images: [], preview: false, currImg: 0, didCheck: false, record: {}, loading: false, connectModal: false, selectedRowKeys: [], }; } onConnectTask = (record) => { this.setState({ connectModal: true, record }) } onCloseConnect = () => { this.setState({ connectModal: false, record: null }) this.onRefresh(); } checkBeforeSend = async (record) => { this.setState({ record, loading: true }) const res: any = await DigitalAssetVerification.server.post(`${DigitalAssetVerification.prefix_path}/collector/task/submitTask`, { taskUuid: record.taskUuid, collectorPartyId: record.collectorPartyId, verifierName: record.verifierName, verifierPartyId: record.verifierPartyId, }).resFs([DigitalAssetVerification.serviceTools.repeatCallEnd]).end(this); this.setState({ loading: false }) if (res.err) { message.error('提交失败,网络异常'); return; } else { if (res.res.body.ok) { message.success('操作成功'); this.onRefresh(); } else { Modal.error({ title: '提交失败', content: res.res.body.status.description, okText: '确定', }); } } } send = async (values) => { const res: any = await agent.post('/web/verifiedTask/submitTask', { taskUuid: this.state.record.taskUuid, ...values }, this); this.setState({ loading: false }) if (res.err) { return false; } else { message.success('操作成功'); this.onCloseDid(); this.onRefresh(); } return false; } onCloseDid = () => { this.setState({ didCheck: false }) } handleMenuClick = (e, id) => { this.props.history.push(`${DigitalAssetVerification.rootPath}/task/slaveview/${id}/${e.key}`); } onPreview = async (list: any[]) => { const files = list.reduce((a, b) => { a.push(b.fileUploadName); return a; }, []) const response = await agent.post('/web/verifiedTask/getFileDownloadUrl', { fileNameList: files }, this); const res = response.res; this.setState({ images: res, preview: true, currImg: 0 }) } gotoPrev = () => { this.setState({ currImg: this.state.currImg - 1 }) } gotoNext = () => { this.setState({ currImg: this.state.currImg + 1 }) } onDeleteTask = async (id) => { const res: any = await agent.get('/web/verifiedTask/deleteVerifiedPartyTask', { taskUuid: id }, this); if (res.er) { return; } else if (res.res) { message.success('操作成功'); this.onRefresh(); } } topExpand = () => { return ( ); } componentDidMount() { const params = { pageNum: 1, pageSize: 10 }; 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); } getData = async (params) => { params = { ...params, minInvoiceEffective: params['minInvoiceEffective'] && moment(params['minInvoiceEffective']).format('YYYY-MM-DD'), maxInvoiceEffective: params['maxInvoiceEffective'] && moment(params['maxInvoiceEffective']).format('YYYY-MM-DD') } const res: any = await agent.post('/collector/task/queryTaskPage', params, this); if (res.er) { return; } else if (res.res) { this.setState({ pageMeta: res.res?.pageMeta, list: res.res?.items }); } } onSearch = (data = {}) => { this.setState({ params: data, }); const params = { ...data, ...this.state.pageMeta, pageNum: 1, pageSize: 10 }; this.getData(params); } onView = (id) => { this.props.history.push(`${DigitalAssetVerification.rootPath}/task/slaveview/${id}`); } onExcel = () => { this.setState({ excelModal: true }) } onCloseExcel = () => { this.setState({ excelModal: false }) } setPreview = (preview) => { this.setState({ preview }) } render() { const dataSource = this.state.list; const { pageMeta, excelModal, connectModal, didCheck, record, selectedRowKeys } = this.state; const rowSelection = { selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRowKeys }); }, } return (
, , ]} // onRefresh={this.onRefresh} >
{didCheck === true && } {excelModal && } {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} />} {connectModal && } ); } } export default withRouter(UIComponents as any)