VideoTableList.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import React from 'react';
  2. import moment from 'moment';
  3. import { Modal } from 'antd';
  4. import { StandardTableList } from '../../../components/AXList';
  5. import AXVideoPlayer from '../../../components/AXVideoPlayer';
  6. import Ellipsis from '../../../components/Ellipsis';
  7. import { renderStatus, renderVideoQuality } from '../../../utils/utils';
  8. function VideoTableList({
  9. dataSource, loading, totalSize, pageSize, pageNo, modalDestroy, currentItem,
  10. onCreateClick, onDeleteClick, onUpdateClick, onFilterClick, onBatchClick,
  11. onModalCreate, onModalDestroy,
  12. }) {
  13. const pagination = {
  14. pageNo,
  15. pageSize,
  16. totalSize,
  17. };
  18. const batchActions = [{
  19. key: 'delete',
  20. name: '批量删除',
  21. }, {
  22. key: 'edit',
  23. name: '批量编辑',
  24. }];
  25. const basicSearch = {
  26. keys: [{
  27. name: '视频编号',
  28. field: 'code',
  29. }, {
  30. name: '视频名称',
  31. field: 'name',
  32. }],
  33. };
  34. const columns = [{
  35. title: '视频编号',
  36. key: 1,
  37. dataIndex: 'code',
  38. width: '17%',
  39. }, {
  40. title: '视频名称',
  41. key: 2,
  42. dataIndex: 'name',
  43. width: '30%',
  44. render: text => (
  45. <Ellipsis tooltip lines={1}>{text}</Ellipsis>
  46. ),
  47. }, {
  48. title: '视频格式',
  49. key: 3,
  50. dataIndex: 'format',
  51. width: '10%',
  52. }, {
  53. title: '视频质量',
  54. key: 4,
  55. dataIndex: 'quality',
  56. render: text => renderVideoQuality(text),
  57. width: '10%',
  58. }, {
  59. title: '视频状态',
  60. key: 5,
  61. dataIndex: 'status',
  62. render: text => renderStatus(text),
  63. width: '10%',
  64. }, {
  65. title: '创建时间',
  66. key: 6,
  67. dataIndex: 'gmtModified',
  68. render: text => moment(text).format('YYYY-MM-DD'),
  69. width: '15%',
  70. }, {
  71. title: '操作',
  72. key: 8,
  73. dataIndex: 'operation',
  74. render: (_, record) => <a onClick={() => onModalCreate(record)}>播放</a>,
  75. width: '8%',
  76. align: 'right',
  77. }];
  78. return (
  79. <div>
  80. <StandardTableList
  81. columns={columns}
  82. loading={loading}
  83. dataSource={dataSource}
  84. header={{ basicSearch, onFilterClick, onCreateClick }}
  85. footer={{ pagination, batchActions, onBatchClick }}
  86. />
  87. {!modalDestroy && (
  88. <Modal
  89. title={currentItem.name}
  90. visible
  91. footer={null}
  92. onCancel={onModalDestroy}
  93. maskClosable={false}
  94. width={800}
  95. >
  96. <AXVideoPlayer
  97. width="100%"
  98. height="100%"
  99. url={currentItem.url}
  100. isM3U8={currentItem.format === 'm3u8'}
  101. />
  102. </Modal>
  103. )}
  104. </div>
  105. );
  106. }
  107. export default VideoTableList;