import * as React from 'react'; import { Table, Drawer, Button, Pagination, message } from 'kts-xui'; import agent from '../Server'; import { AdvancedSearch, KtsForm } from 'kts-components'; import { Row, Space } from 'kts-components-antd-x4'; import { columnEnum } from '../CommonComponents/ColumnEnum'; import { taskStatusEnum, findLabel } from '../CommonComponents/FiledsEnum'; import moment from 'moment'; /** Props接口 */ interface IProps { onClose: () => void; value: any; } export default class UIComponents extends React.Component { columns = [ { title: '任务单号', dataIndex: columnEnum.任务单号, width: 160, }, { title: '采集方', dataIndex: columnEnum.被核验方, width: 180, ellipsis: true, }, { title: '任务状态', dataIndex: columnEnum.任务状态, width: 100, align: 'center', render: text => { return findLabel(text, taskStatusEnum) } }, { title: '任务截止日期', width: 120, dataIndex: 'taskEndDate', render: (text) => { return text && moment(text).format('YYYY-MM-DD'); } }, { title: '关联单据', width: 180, dataIndex: 'originalDocList', ellipsis: true, render: (text, record) => { if (record.originalDocList?.length > 0) { let originalDocuments = record.originalDocList.reduce((acc, obj) => { acc.push(obj.originalDocument); return acc; }, []) let str = originalDocuments.join('/'); return str } } }, { title: '关联任务单号', width: 180, dataIndex: 'taskRelationList', ellipsis: true, render: (text, record) => { 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, ellipsis: true, dataIndex: columnEnum.创建人, }, { title: '备注', width: 140, dataIndex: columnEnum.备注, ellipsis: true, }, ] constructor(props) { super(props); this.state = { record: this.props.value, selectedRowKeys: [], list: [], pageNum: 1, pageSize: 10, pageMeta: null, params: {}, } } componentDidMount() { if (this.props.value.taskRelationList.length > 0) { let taskUuids = this.props.value.taskRelationList.reduce((acc, obj) => { acc.push(obj.taskUuid); return acc; }, []) this.setState({ selectedRowKeys: taskUuids }) } const params = { pageNum: 1, pageSize: 10000 }; this.getData(params); } getData = async (params) => { params = { ...params, minEffectiveStart: params['minEffectiveStart'] && moment(params['minEffectiveStart']).format('YYYY-MM-DD 00:00:00'), maxEffectiveEnd: params['maxEffectiveEnd'] && moment(params['maxEffectiveEnd']).format('YYYY-MM-DD 23:59:59') } const res: any = await agent.post('/web/verifierTask/queryTaskPage', params, this); if (res.er) { return; } else if (res.res) { this.setState({ pageMeta: res.res.pageMeta, list: res.res.items }); } } onClose = () => { this.props.onClose(); } onRefresh = () => { const params = { ...this.state.params, ...this.state.pageMeta, }; this.getData(params); } onSearch = (data = {}) => { this.setState({ params: data, // selectedRowKeys: [] }); const params = { ...data, ...this.state.pageMeta, pageNum: 1, }; this.getData(params); } onSubmit = async () => { const { selectedRowKeys,record } = this.state; const data = { taskUuid: record.taskUuid, relationTaskUuidList: selectedRowKeys } const res: any = await agent.post('/collector/task/batchLinkTask',data, this); if (res.err) { return false; } else { message.success('操作成功'); this.props.onClose(); } } topExpand = () => { return ( ); } onPageChange = (pageNum, pageSize) => { this.setState({ pageMeta: { ...this.state.pageMeta, pageNum, pageSize } }, () => { this.onRefresh(); }); } render() { const dataSource = this.state.list; const { pageMeta,selectedRowKeys } = this.state const rowSelection = { onChange: (selectedRowKeys: React.Key[]) => { this.setState({ selectedRowKeys: selectedRowKeys }) }, selectedRowKeys }; return ( } width={700} > {/*
{this.topExpand()}
*/} {/* {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} />} */} ); } }