FilesModal.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React, { useEffect, useState, useRef } from 'react';
  2. import { UploadOutlined } from '@ant-design/icons';
  3. import { Form } from '@ant-design/compatible';
  4. import '@ant-design/compatible/assets/index.css';
  5. import { Button, Modal, message, Table, Spin, Tabs, Upload } from 'antd';
  6. const { TabPane } = Tabs;
  7. const { confirm } = Modal;
  8. import moment from 'moment/moment';
  9. import PreviewFile from '@/components/PreviewFile';
  10. // 历史清单
  11. function FilesModal(props) {
  12. const { visible, onClose, onUpload, data, uploadProps, DeleteFile, downloadFile, loading } = props;
  13. const handleSelect = item => {
  14. // onSelect(item);
  15. // onClose();
  16. };
  17. const columns = [
  18. {
  19. title: '预览',
  20. dataIndex: 'name',
  21. render: (text, item) => {
  22. return <PreviewFile name={item.name} src={item.url} />;
  23. },
  24. },
  25. {
  26. title: '上传时间',
  27. dataIndex: 'c_time',
  28. render: text => {
  29. return text ? moment(text).format('YYYY年MM月DD日 HH:mm:ss') : null;
  30. },
  31. },
  32. {
  33. title: '上传人',
  34. dataIndex: 'CreatorUser',
  35. render: record => (record.CName || '')
  36. },
  37. {
  38. title: '操作',
  39. render: record => (
  40. <>
  41. <a onClick={() => { downloadFile(record) }}>
  42. 查看
  43. </a>
  44. <a onClick={() => {
  45. confirm({
  46. title: '提醒',
  47. content: '确认删除该文件,删除后无法复原',
  48. okText: '确认',
  49. cancelText: '取消',
  50. onOk() {
  51. DeleteFile(record.id);
  52. },
  53. });
  54. }} style={{ marginLeft: 10 }}>删除</a>
  55. </>
  56. ),
  57. },
  58. ];
  59. const onClick = item => {
  60. // onClose();
  61. // onSelect(item);
  62. };
  63. return (
  64. <Modal title="附件列表" width="60%" onCancel={onClose} visible={visible} footer={false}>
  65. <div>
  66. <Upload {...uploadProps}>
  67. <Button type="primary" style={{ marginBottom: 20 }} loading={loading}>
  68. <UploadOutlined /> 上传文件
  69. </Button>
  70. </Upload>
  71. </div>
  72. <Table rowKey="id" columns={columns} dataSource={data} loading={loading} />
  73. </Modal>
  74. );
  75. }
  76. export default FilesModal