resource.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React, { PureComponent } from 'react';
  2. import { Popover } from 'antd';
  3. import SelectModal from '../../../components/SelectModal';
  4. import styles from './resource.less';
  5. import { Codes, ossHost } from '../../../utils/config';
  6. export default class ResourceSelectModal extends PureComponent {
  7. render() {
  8. const { mode, selTableData, modalVisible, onCancel, onOk, onSearch, ...fsTableOpts } = this.props;
  9. const modalProps = {
  10. title: '选择图片',
  11. maskClosable: false,
  12. visible: modalVisible,
  13. onCancel,
  14. onOk,
  15. };
  16. const searchProps = {
  17. searchField: 'name',
  18. searchKeyWord: '',
  19. searchSize: 'default',
  20. searchSelect: true,
  21. searchSelectOptions: [{
  22. value: 'name', name: '图片名称', mode: 'input',
  23. },{
  24. value: 'code', name: '图片编号', mode: 'input',
  25. }],
  26. searchSelectProps: {
  27. defaultValue: 'code',
  28. },
  29. onSearch: (value) => {
  30. onSearch(value);
  31. },
  32. };
  33. const selTableProps = {
  34. operDel: true,
  35. operSort: true,
  36. tableClassName: styles.sTable,
  37. tablePagination: false,
  38. tableDataSource: selTableData,
  39. tableColumns: [{
  40. title: '缩略图',
  41. dataIndex: 'url',
  42. key: 'url',
  43. render: (text, record) => (
  44. <Popover
  45. content={<img alt="" src={`${ossHost}/${record.path}`} width={350} />}
  46. title={record.name}
  47. >
  48. <img alt="" src={`${ossHost}/${record.path}`} width={70} />
  49. </Popover>
  50. ),
  51. },{
  52. title: '图片编号',
  53. dataIndex: 'code',
  54. key: 'code',
  55. },{
  56. title: '图片名称',
  57. dataIndex: 'name',
  58. key: 'name',
  59. }],
  60. };
  61. //待选资源Table属性
  62. const fsTableProps = {
  63. fsTableClassName: styles.fsTable,
  64. fsTableColumns: [{
  65. title: '缩略图',
  66. dataIndex: 'url',
  67. key: 'url',
  68. render: (text, record) => (
  69. <Popover
  70. content={<img alt="" src={`${ossHost}/${record.path}`} width={350} />}
  71. title={record.name}
  72. >
  73. <img alt="" src={`${ossHost}/${record.path}`} width={70} />
  74. </Popover>
  75. ),
  76. },{
  77. title: '图片编号',
  78. dataIndex: 'code',
  79. key: 'code',
  80. },{
  81. title: '图片名称',
  82. dataIndex: 'name',
  83. key: 'name',
  84. }],
  85. ...fsTableOpts,
  86. }
  87. return (
  88. <SelectModal
  89. mode={mode}
  90. { ...searchProps }
  91. { ...selTableProps}
  92. { ...fsTableProps }
  93. { ...modalProps }
  94. />
  95. );
  96. }
  97. }