1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
| import { Button, Table, Col, Modal, message as Message } from 'antd' import React from 'react' import { PaginationConf } from '../../../../config/antd/PaginationConf' import { Link } from 'react-router-dom' import MessageService from '../../../../service/driverManage/MessageService' export interface IMessageTable { num: string | number creatTime: string driverName: string driverPhoneNum: string receiptType: number receipt: number | string output: number | string banace: number | string } export interface IProps { data: IMessageTable[] page: { current: number pageSize: number total: number } onPagechange?: (page: { current: number; pageSize: number; total: number }) => void getDetail: (param: any) => void onSearch: () => void loading: boolean }
const { confirm } = Modal class MessageListTable extends React.Component<IProps> { public constructor(props: IProps) { super(props) ;(this as any).columns = [ { title: '序号', dataIndex: 'num', align: 'center', }, { title: '发送时间', dataIndex: 'sendTime', align: 'center', }, { title: '发送范围', dataIndex: 'sendScope', align: 'center', }, { title: '消息中心', dataIndex: 'canIntoMessageCenter', align: 'center', }, { title: '标题', dataIndex: 'title', align: 'center', }, { title: '操作人', dataIndex: 'createdBy', align: 'center', }, { title: '创建时间', dataIndex: 'createdTime', align: 'center', }, { title: '发送状态', dataIndex: 'sendStatus', align: 'center', }, { title: '操作', align: 'center', render(row: any) { return ( <div> {row.canCancelSend ? ( <Col> <Button type="primary" onClick={() => { cancel(row) }} > 取消发送 </Button> {new Date(row.sendTime).getTime() - new Date().getTime() > 5 * 60 * 60 * 1000 ? ( <Button type="primary" style={{ marginLeft: '5px' }}> <Link to={`/fast/message/messageUpdate/${row.id}`}>查看</Link> </Button> ) : ( <Button type="primary" style={{ marginLeft: '5px' }}> <Link to={`/fast/message/messageDetail/${row.id}`}>查看</Link> </Button> )} </Col> ) : ( <Button type="primary"> <Link to={`/fast/message/messageDetail/${row.id}`}>查看</Link> </Button> )} </div> ) }, }, ] function cancel(row: any) { const { onSearch } = props if (new Date(row.sendTime).getTime() - new Date().getTime() > 5 * 60 * 60 * 1000) { confirm({ title: '提示', content: '是否确认取消', async onOk() { const { code, message } = await MessageService.messageCancel(row.id) if (code !== 200) { Message.error(message) return } Message.success('取消成功') onSearch() }, onCancel() { return }, }) } else { Modal.info({ title: '提示', content: <div>距离预计发送时间不到5分钟 禁止取消</div>, okText: '关闭', }) } } } public render() { const { data, page, onPagechange, loading } = this.props return ( <section> <Table dataSource={data} loading={loading} // @ts-ignore columns={this.columns} rowKey={'id'} size={'middle'} // scroll={{ x: 2500 }} pagination={{ ...PaginationConf, ...this.props.page, onChange: (toCurrent, pageSize) => { page.current = toCurrent page.pageSize = pageSize as number
if (onPagechange) { onPagechange(page) } }, onShowSizeChange: (current, toPageSize) => { page.current = current page.pageSize = toPageSize
if (onPagechange) { onPagechange(page) } }, showTotal: (total: number) => `共计 ${total} 条`, }} ></Table> </section> ) } }
export { MessageListTable } export default MessageListTable
|