picture.jsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React from 'react';
  2. import { Icon, Upload, Modal } from 'antd';
  3. import ImgList from "../../common/imgList";
  4. const PicturesWall = React.createClass({
  5. getInitialState() {
  6. return {
  7. previewVisible: false,
  8. previewImage: '',
  9. fileList: [],
  10. }
  11. },
  12. handleCancel() {
  13. this.setState({ previewVisible: false })
  14. },
  15. handlePreview(file) {
  16. this.setState({
  17. previewImage: file.url || file.thumbUrl,
  18. previewVisible: true,
  19. });
  20. },
  21. handleChange(info) {
  22. let fileList = info.fileList;
  23. this.setState({ fileList });
  24. this.props.fileList(fileList);
  25. },
  26. componentWillReceiveProps(nextProps) {
  27. this.state.fileList = nextProps.pictureUrl;
  28. },
  29. render() {
  30. const { previewVisible, previewImage, fileList } = this.state;
  31. // 预览图标 删除图标
  32. const { showPreview = true, showRemove = true } = this.props
  33. const uploadButton = (
  34. <div>
  35. <Icon type="plus" />
  36. <div className="ant-upload-text">点击上传</div>
  37. </div>
  38. );
  39. return (
  40. <div className="clearfix">
  41. <ImgList
  42. domId={this.props.domId}
  43. uploadConfig={{
  44. action: globalConfig.context + this.props.data.url,
  45. data: { 'sign': this.props.data.sign },
  46. listType: "picture-card",
  47. multiple: true,
  48. showUploadList: { 'showPreviewIcon': showPreview, 'showRemoveIcon': showRemove }
  49. }}
  50. onChange={(infor) => {
  51. this.handleChange(infor)
  52. }}
  53. fileList={fileList}
  54. />
  55. </div>
  56. );
  57. }
  58. });
  59. export default PicturesWall;