FilesModal.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 {
  13. visible,
  14. onClose,
  15. onUpload,
  16. data,
  17. uploadProps,
  18. DeleteFile,
  19. downloadFile,
  20. loading,
  21. } = props;
  22. const handleSelect = item => {
  23. // onSelect(item);
  24. // onClose();
  25. };
  26. const columns = [
  27. {
  28. title: '预览',
  29. dataIndex: 'name',
  30. render: (text, item) => {
  31. return <PreviewFile name={item.name} src={item.url} />;
  32. },
  33. },
  34. {
  35. title: '上传时间',
  36. dataIndex: 'c_time',
  37. render: text => {
  38. return text ? moment(text).format('YYYY年MM月DD日 HH:mm:ss') : null;
  39. },
  40. },
  41. {
  42. title: '上传人',
  43. dataIndex: 'CreatorUser',
  44. render: record => record.CName || '',
  45. },
  46. {
  47. title: '操作',
  48. render: record => (
  49. <>
  50. <a
  51. onClick={() => {
  52. downloadFile(record);
  53. }}
  54. >
  55. 查看
  56. </a>
  57. <a
  58. onClick={() => {
  59. confirm({
  60. title: '提醒',
  61. content: '确认删除该文件,删除后无法复原',
  62. okText: '确认',
  63. cancelText: '取消',
  64. onOk() {
  65. DeleteFile(record.id);
  66. },
  67. });
  68. }}
  69. style={{ marginLeft: 10 }}
  70. >
  71. 删除
  72. </a>
  73. </>
  74. ),
  75. },
  76. ];
  77. const onClick = item => {
  78. // onClose();
  79. // onSelect(item);
  80. };
  81. return (
  82. <Modal title="附件列表" width="60%" onCancel={onClose} visible={visible} footer={false}>
  83. <div>
  84. <Upload {...uploadProps}>
  85. <Button type="primary" style={{ marginBottom: 20 }} loading={loading}>
  86. <UploadOutlined /> 上传文件
  87. </Button>
  88. </Upload>
  89. </div>
  90. <Table rowKey="id" columns={columns} dataSource={data} loading={loading} />
  91. </Modal>
  92. );
  93. }
  94. export default FilesModal;