course.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React, { PureComponent } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { Badge, Popover, Icon } from 'antd';
  4. import SelectModal from '../../../components/SelectModal';
  5. import { Codes } from '../../../utils/config';
  6. export default class CourseSelectModal extends PureComponent {
  7. static propTypes = {
  8. modalVisible: PropTypes.bool.isRequired,
  9. rowKeyName: PropTypes.string.isRequired,
  10. };
  11. render() {
  12. const { modalVisible, onCancel, onOk, onSearch, ...fsTableOpts } = this.props;
  13. const modalProps = {
  14. title: '选择课程',
  15. maskClosable: false,
  16. visible: modalVisible,
  17. onCancel,
  18. onOk,
  19. };
  20. const searchProps = {
  21. searchField: 'name',
  22. searchKeyWord: '',
  23. searchSize: 'default',
  24. searchSelect: true,
  25. searchSelectOptions: [{
  26. value: 'name', name: '课程名称', mode: 'input',
  27. },{
  28. value: 'code', name: '课程编号', mode: 'input',
  29. }],
  30. searchSelectProps: {
  31. defaultValue: 'name',
  32. },
  33. onSearch: (value) => {
  34. onSearch(value);
  35. },
  36. };
  37. //待选资源Table属性
  38. const fsTableProps = {
  39. fsTableColumns: [{
  40. title: '封面图',
  41. dataIndex: 'url',
  42. key: 'url',
  43. render: (text, record) => (
  44. <Popover
  45. content={<img alt="" src={record.coverUrl} width={350} />}
  46. title={record.name}
  47. >
  48. <img alt="" src={record.coverUrl} width={70} />
  49. </Popover>
  50. ),
  51. width: '26%',
  52. },{
  53. title: '课程编号',
  54. dataIndex: 'code',
  55. key: 'code',
  56. width: '27%',
  57. },{
  58. title: '课程名称',
  59. dataIndex: 'name',
  60. key: 'name',
  61. width: '27%',
  62. }],
  63. ...fsTableOpts,
  64. }
  65. return (
  66. <SelectModal
  67. mode="single"
  68. { ...searchProps }
  69. { ...fsTableProps }
  70. { ...modalProps }
  71. />
  72. );
  73. }
  74. }