VideoTableList.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import React from 'react';
  2. import moment from 'moment';
  3. import { Modal, Button } from 'antd';
  4. import { StandardTableList } from '../../../components/AXList';
  5. import AXVideoPlayer from '../../../components/AXVideoPlayer';
  6. import Ellipsis from '../../../components/Ellipsis';
  7. import { resourceQuality } from '../../../utils/utils';
  8. function VideoTableList({
  9. UIParams, dataSource, loading, totalSize, pageSize, pageNo, modalDestroy, currentItem,
  10. onCreateClick, onUpdateClick, onFilterClick, onBatchClick, onModalCreate,
  11. 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: 'name',
  29. }, {
  30. name: '视频编号',
  31. field: 'code',
  32. }],
  33. };
  34. const columns = [{
  35. title: '视频编号',
  36. key: 1,
  37. dataIndex: 'code',
  38. width: '15%',
  39. render: text => (
  40. <Ellipsis tooltip lines={1}>{text}</Ellipsis>
  41. ),
  42. }, {
  43. title: '视频名称',
  44. key: 2,
  45. dataIndex: 'name',
  46. width: '30%',
  47. render: text => (
  48. <Ellipsis tooltip lines={1}>{text}</Ellipsis>
  49. ),
  50. }, {
  51. title: '视频格式',
  52. key: 3,
  53. dataIndex: 'format',
  54. width: '10%',
  55. }, {
  56. title: '质量',
  57. key: 4,
  58. dataIndex: 'quality',
  59. render: text => resourceQuality[text],
  60. width: '10%',
  61. }, {
  62. title: '修改时间',
  63. key: 5,
  64. dataIndex: 'gmtModified',
  65. render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
  66. width: '15%',
  67. }, {
  68. title: '操作',
  69. key: 6,
  70. dataIndex: 'operation',
  71. render: (_, record) => renderActions(record),
  72. width: '20%',
  73. align: 'right',
  74. }];
  75. const renderActions = (item) => {
  76. return (
  77. <div>
  78. <Button
  79. size="small"
  80. type="primary"
  81. className="editBtn"
  82. onClick={() => onUpdateClick(item)}
  83. >编辑
  84. </Button>
  85. <Button
  86. size="small"
  87. type="primary"
  88. className="playBtn"
  89. onClick={() => onModalCreate(item)}
  90. >播放
  91. </Button>
  92. </div>
  93. );
  94. };
  95. return (
  96. <div>
  97. <StandardTableList
  98. columns={columns}
  99. loading={loading}
  100. dataSource={dataSource}
  101. keepUIState={{ ...UIParams }}
  102. header={{ basicSearch, onFilterClick, onCreateClick }}
  103. footer={{ pagination, batchActions, onBatchClick }}
  104. showStatusSelect={false}
  105. />
  106. {!modalDestroy && (
  107. <Modal
  108. title={currentItem.name}
  109. visible
  110. footer={null}
  111. onCancel={onModalDestroy}
  112. maskClosable={false}
  113. width={800}
  114. >
  115. <AXVideoPlayer
  116. width="100%"
  117. height="100%"
  118. url={currentItem.url}
  119. isM3U8={currentItem.format === 'm3u8'}
  120. />
  121. </Modal>
  122. )}
  123. </div>
  124. );
  125. }
  126. export default VideoTableList;